Skip to content

Commit

Permalink
Accept: Allow multiple annotations of same type
Browse files Browse the repository at this point in the history
Before this patch, when there are annotations of the same type, the
greedy matching matches all of them:

a {++ b ++} c {++ d ++} e
-> a b ++} c {++ d e

Solution: Make matching non-greedy (`*?`).
  • Loading branch information
teoric committed Aug 26, 2015
1 parent 7809963 commit 81fdb23
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Support/bin/accept_critic.rb
Expand Up @@ -22,17 +22,17 @@ class AcceptCritic

def accept_all(file_path)
self.file_data(file_path) do |data|
data.gsub!(/\{\+\+(.*)\+\+\}/, "\\1") # Add all
data.gsub!(/\{\-\-(.*)\-\-\}/, '') # Delete all
data.gsub!(/\{\~\~(.*)~>(.*)\~\~\}/, "\\2") # Accept substitutions
data.gsub!(/\{\+\+(.*?)\+\+\}/, "\\1") # Add all
data.gsub!(/\{\-\-(.*?)\-\-\}/, '') # Delete all
data.gsub!(/\{\~\~(.*?)~>(.*?)\~\~\}/, "\\2") # Accept substitutions
end
end

def reject_all(file_path)
self.file_data(file_path) do |data|
data.gsub!(/\{\+\+(.*)\+\+\}/, '') # No Adds
data.gsub!(/\{\-\-(.*)\-\-\}/, "\\1") # Undo Deletes
data.gsub!(/\{\~\~(.*)~>(.*)\~\~\}/, "\\1") # Reject substitutions
data.gsub!(/\{\+\+(.*?)\+\+\}/, '') # No Adds
data.gsub!(/\{\-\-(.*?)\-\-\}/, "\\1") # Undo Deletes
data.gsub!(/\{\~\~(.*?)~>(.*?)\~\~\}/, "\\1") # Reject substitutions
end
end

Expand All @@ -43,8 +43,8 @@ def file_data(file_path)

yield data

data.gsub!(/\{\=\=(.*)\=\=\}/, "\\1") # Unhighlight
data.gsub!(/\{\>\>(.*)\<\<\}/, '') # Lose comments
data.gsub!(/\{\=\=(.*?)\=\=\}/, "\\1") # Unhighlight
data.gsub!(/\{\>\>(.*?)\<\<\}/, '') # Lose comments

puts data
end
Expand Down

0 comments on commit 81fdb23

Please sign in to comment.