Skip to content

Commit

Permalink
Fix custom emojis and hashtags being formatted with Markdown
Browse files Browse the repository at this point in the history
Prevents custom emojis and hashtags from being underlined and therefore broken.

Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com>
  • Loading branch information
Plastikmensch committed Nov 25, 2024
1 parent 4eb8323 commit 518a76a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/lib/advanced_text_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def rewrite
private

def format_markdown(html)
# Force escape usernames in mentions before formatting
html = markdown_formatter.render(html.gsub(Account::MENTION_RE) { |re| re.gsub('_', '\\_') })
# Force escape underscores in mentions, custom emojis and hashtags before formatting
html = html.gsub(/#{Account::MENTION_RE}|#{CustomEmoji::SCAN_RE}|#{Tag::HASHTAG_RE}/o) { |re| re.gsub('_', '\\_') }
html = markdown_formatter.render(html)
html.delete("\r").delete("\n")
end

Expand Down

0 comments on commit 518a76a

Please sign in to comment.