diff options
author | multiple creatures <dev@multiple-creature.party> | 2020-02-19 13:51:45 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2020-02-19 13:51:45 -0600 |
commit | e01547e20dab42db5377d324fe1ad3874a79ca25 (patch) | |
tree | 97cc6c94fe8290f0db1c1e7b204276a5f4ce3bfd | |
parent | 38ecbd30ec388354e4c5d6baa68a1b185ec25dcf (diff) |
fix `bangtags:on`, `bangtags:skip` - attempt 2
-rw-r--r-- | app/lib/bangtags.rb | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb index 4a5adcaad..22effa3cc 100644 --- a/app/lib/bangtags.rb +++ b/app/lib/bangtags.rb @@ -102,21 +102,32 @@ class Bangtags if @vore_stack.last == '_draft' || (@chunks.present? && status.draft?) chunk.gsub("#\ufdd6!", '#!') @chunks << chunk - elsif @vars['_bangtags:off'] || @vars['_bangtags:skip'] - if chunk.in?(['#!bangtags:on', '#!bangtags:enable']) - @vars.delete('_bangtags:off') - @vars.delete('_bangtags:skip') - next - end + next + end - chunk.gsub("#\ufdd6!", '#!') - @chunks << chunk - elsif chunk.starts_with?('#!') + if chunk.starts_with?('#!') orig_chunk = chunk chunk.sub!(/(\\:)?+:+?!#\Z/, '\1') chunk.sub!(/{(.*)}\Z/, '\1') + chunk.strip! - if @vore_stack.last != '_comment' + if @vore_stack.last == '_comment' + if chunk.in?(['#!comment:end', '#!comment:stop', '#!comment:endall', '#!comment:stopall']) + @vore_stack.pop + @component_stack.pop + end + + next + elsif @vars['_bangtags:off'] || @vars['_bangtags:skip'] + if chunk.in?(['#!bangtags:on', '#!bangtags:enable']) + @vars.delete('_bangtags:off') + @vars.delete('_bangtags:skip') + next + end + + @chunks << orig_chunk.gsub("#\ufdd6!", '#!') + next + else cmd = chunk[2..-1].strip next if cmd.blank? @@ -132,12 +143,6 @@ class Bangtags @aliases.each_key do |old_cmd| cmd = @aliases[old_cmd] + cmd.drop(old_cmd.length) if cmd.take(old_cmd.length) == old_cmd end - elsif chunk.in?(['#!comment:end', '#!comment:stop', '#!comment:endall', '#!comment:stopall']) - @vore_stack.pop - @component_stack.pop - next - else - next end next if cmd[0].nil? @@ -149,7 +154,6 @@ class Bangtags end case cmd[0].downcase - when 'bangtags' chunk = nil next if cmd[1].nil? |