From ba45644591b7626e2acffd6f21de6988456a008b Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 26 Jul 2020 07:50:18 -0500 Subject: [Bug, Command Tags] Match multi-line blocks non-greedily --- app/lib/command_tag/processor.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/lib/command_tag/processor.rb') 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 -- cgit