about summary refs log tree commit diff
path: root/app/lib/bangtags.rb
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-08-31 13:00:37 -0500
committermultiple creatures <dev@multiple-creature.party>2019-08-31 13:00:37 -0500
commit867a13a74030ea1fc0b83208028de700aacc8177 (patch)
treecbe763d0f131259cf1344e5434651bbfd9d345bf /app/lib/bangtags.rb
parent67bcc0bfd60b7115e16c16179c2ab213b4e585a8 (diff)
add `nosr` & `sr` bangtags to mark sections of posts that should and should not be read by screenreaders
Diffstat (limited to 'app/lib/bangtags.rb')
-rw-r--r--app/lib/bangtags.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index 10076f074..0e4b81560 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -12,6 +12,7 @@ class Bangtags
 
     @crunch_newlines = false
     @once = false
+    @sroff_open = false
 
     @prefix_ns = {
       'permalink' => ['link'],
@@ -687,6 +688,14 @@ class Bangtags
             keyboard[(keyboard.size * (rand ** 3)).floor].split('').sample
           end
           chunk = chunk.join
+        when 'nosr', 'sroff', 'srskip'
+          next if @sroff_open
+          @sroff_open = true
+          chunk = "\uf333"
+        when 'sr', 'sron', 'srcont'
+          next unless @sroff_open
+          @sroff_open = false
+          chunk = "\uf334"
         when 'admin'
           chunk = nil
           next unless @user.admin?
@@ -911,6 +920,8 @@ class Bangtags
     if text.blank?
       RemoveStatusService.new.call(@status)
     else
+      text.gsub!(/^\uf333\n/m, "\uf333")
+      text.gsub!(/\n\uf334$/m, "\uf334")
       status.text = text
       status.save
       postprocess_after_save
@@ -987,6 +998,8 @@ class Bangtags
         end
       end
     end
+
+    @chunks << "\uf334" if @sroff_open
   end
 
   def postprocess_after_save