diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-07-26 07:50:18 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:16 -0500 |
commit | ba45644591b7626e2acffd6f21de6988456a008b (patch) | |
tree | b88bd14e586f7f86d103a8ca30e192a1200871d9 | |
parent | a72e63329495228659f01d1fd254e954268afb69 (diff) |
[Bug, Command Tags] Match multi-line blocks non-greedily
-rw-r--r-- | app/lib/command_tag/processor.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/lib/command_tag/processor.rb b/app/lib/command_tag/processor.rb index 79b24eec3..e9b8f5c05 100644 --- a/app/lib/command_tag/processor.rb +++ b/app/lib/command_tag/processor.rb @@ -15,8 +15,8 @@ class CommandTag::Processor include ImgProxyHelper include CommandTag::Commands - STATEMENT_RE = /^\s*#!\s*([^\n]+ (?:start|begin|do)$.*)\n\s*#!\s*(?:end|stop|done)\s*$|^\s*#!\s*(.*?)\s*$/im.freeze - STATEMENT_STRIP_RE = /^\s*#!\s*(?:[^\n]+ (?:start|begin|do)$.*)\n\s*#!\s*(?:end|stop|done)\s*$\n?|^\s*#!\s*(?:.*?)\s*$\n?/im.freeze + STATEMENT_RE = /^\s*#!\s*([^\n]+ (?:start|begin|do)$.*?)\n\s*#!\s*(?:end|stop|done)\s*$|^\s*#!\s*(.*?)\s*$/im.freeze + STATEMENT_STRIP_RE = /^\s*#!\s*(?:[^\n]+ (?:start|begin|do)$.*?)\n\s*#!\s*(?:end|stop|done)\s*$\n?|^\s*#!\s*(?:.*?)\s*$\n?/im.freeze TEMPLATE_RE = /%%\s*(.*?)\s*%%/.freeze ESCAPE_MAP = { '\n' => "\n", @@ -117,7 +117,7 @@ class CommandTag::Processor @text.scan(STATEMENT_RE).flatten.compact.each do |statement| next if statement.blank? - statement = statement.scan(/'([^']*)'|"([^"]*)"|(\S+)|\s+(?:start|begin|do)\s*$[\r\n]+(.*)/im).flatten.compact + statement = statement.scan(/'([^']*)'|"([^"]*)"|(\S+)|\s+(?:start|begin|do)\s*$\n+(.*)/im).flatten.compact statement[0] = statement[0].strip.tr(':.\- ', '_').gsub(/__+/, '_').downcase statement[-1].rstrip! if statement.count > 1 |