diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-08-31 13:00:37 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-08-31 13:00:37 -0500 |
commit | 867a13a74030ea1fc0b83208028de700aacc8177 (patch) | |
tree | cbe763d0f131259cf1344e5434651bbfd9d345bf /app/lib/formatter.rb | |
parent | 67bcc0bfd60b7115e16c16179c2ab213b4e585a8 (diff) |
add `nosr` & `sr` bangtags to mark sections of posts that should and should not be read by screenreaders
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r-- | app/lib/formatter.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 499bf90a9..272dc7222 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -221,6 +221,8 @@ class Formatter html = format_bbdown(html) end + html = format_screenreader(html) + html = encode_and_link_urls(html, linkable_accounts, keep_html: %w(text/markdown text/x-bbcode text/x-bbcode+markdown text/html).include?(status.content_type)) html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify] @@ -248,6 +250,10 @@ class Formatter html.html_safe # rubocop:disable Rails/OutputSafety end + def format_screenreader(html) + html.gsub(/\uf333(.*)\uf334/m, '<span aria-hidden="true">\1</span>') + end + def format_console(html) cursor = '<span class="cursor"></span>' "<pre><code>#{html.strip.sub(/<\/p>\Z/, cursor)}</p></code></pre>" |