about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/lib/bangtags.rb21
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