diff --git a/.gitignore b/.gitignore index 9d68ddd..7400b34 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ test_project/subdir1/file2.rb test_project/subdir1/file3.rb test_project/subdir2/file4.rb test_project/subdir2/file5.rb +test_project/TODO.md diff --git a/lib/todo_marker.rb b/lib/todo_marker.rb index 13214de..901b53c 100644 --- a/lib/todo_marker.rb +++ b/lib/todo_marker.rb @@ -6,13 +6,10 @@ require 'find' module TodoMarker TODO_REGEX = /# !!TODO!!(?: style: (\w+))? "(.*?)"/ - STYLE_REGEX = /`style: (\w+?)` (.*?)`/ STYLES = { 'title' => '## %s', 'title1' => '# %s', - 'sublist' => ' - %s', - 'super-text' => '%s', - 'sub-text' => '%s' + 'sublist' => ' - %s' }.freeze def self.generate_todo_md(directory) @@ -25,7 +22,6 @@ module TodoMarker next unless line.match(TODO_REGEX) style, message = line.match(TODO_REGEX).captures - message = parse_styles(message) todos << { style:, message:, @@ -38,25 +34,13 @@ module TodoMarker create_todo_file(directory, todos) end - def self.parse_styles(message) - while message.match?(STYLE_REGEX) - message.gsub!(STYLE_REGEX) do - style, text = Regexp.last_match.captures - STYLES[style] % text - end - end - message - end - def self.create_todo_file(directory, todos) File.open(File.join(directory, 'TODO.md'), 'w') do |file| file.puts "# TODO List\n\n" - previous_style = nil todos.each do |todo| formatted_message = format_message(todo[:style], todo[:message]) file.puts formatted_message - file.puts " (#{todo[:file]}:#{todo[:line]})" if todo[:style] != 'sublist' && todo[:style].nil? - previous_style = todo[:style] + file.puts " (#{todo[:file]}:#{todo[:line]})" if todo[:style].nil? end end end