diff options
author | multiple creatures <dev@multiple-creature.party> | 2020-02-19 12:08:22 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2020-02-19 12:08:22 -0600 |
commit | 4c6025496617eef1551faa065dd45336b9b116fa (patch) | |
tree | b4127dcb52c193d4c46e66d867ddc27cb0d24b56 /app | |
parent | 0141cf4eaf9974e96aaad535cc5c24dee88e4d83 (diff) |
fix `bangtags:on`, `bangtags:skip`
Diffstat (limited to 'app')
-rw-r--r-- | app/lib/bangtags.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb index ae9e938c7..2fb1324a9 100644 --- a/app/lib/bangtags.rb +++ b/app/lib/bangtags.rb @@ -96,21 +96,26 @@ class Bangtags return unless !@vars['_bangtags:disable'] && status.text&.present? && status.text&.include?('#!') status.text.gsub!('#!!', "#\ufdd6!") + @vars.delete('_bangtags:skip') if @vars['_bangtags:skip'] status.text.split(/(#!(?:.*:!#|{.*?}|[^\s#]+))/).each do |chunk| 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 + + chunk.gsub("#\ufdd6!", '#!') + @chunks << chunk elsif chunk.starts_with?('#!') orig_chunk = chunk chunk.sub!(/(\\:)?+:+?!#\Z/, '\1') chunk.sub!(/{(.*)}\Z/, '\1') - if @vars['_bangtags:off'] - if chunk.in?('#!bangtags:on', '#!bangtags:enable') - @vars.delete('_bangtags:off') - next - end elsif @vore_stack.last != '_comment' cmd = chunk[2..-1].strip next if cmd.blank? @@ -153,7 +158,10 @@ class Bangtags when 'off', 'disable' @vars['_bangtags:off'] = true next - when 'break', 'skip' + when 'skip' + @vars['_bangtags:skip'] = true + next + when 'break' break end @@ -1290,6 +1298,7 @@ class Bangtags @chunks << chunk unless chunk.nil? end + @vars.delete('_bangtags:skip') if @vars['_bangtags:skip'] @vars.transform_values! { |v| v.rstrip if v.is_a?(String) } postprocess_before_save |