Skip to content

Commit

Permalink
#2529 - Fix the chat regression (#2533)
Browse files Browse the repository at this point in the history
* fix the extra br tag issues

* better comment
  • Loading branch information
SebinSong authored Jan 22, 2025
1 parent 80397f4 commit fe77c20
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/views/utils/markdown-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export function renderMarkdown (str: string): any {
converted = converted.replace(/<([a-z]+)>\n/g, '<$1>')
.replace(/\n<\/([a-z]+)>/g, '</$1>')

// STEP 4. Sanitize some <br/>s that directly precedes/follows <ul>, <ol>, <blockquote> elements.
// - These are block elements by themselves, meaning they naturally carry one line-breaks at the start/end the tag(s).
// So remove 1 direct sibling <br>s. (reference issue: https://github.com/okTurtles/group-income/issues/2529)
converted = converted.replace(/<br\/>\s*?(<ul>|<ol>|<blockquote>)/g, '$1')
.replace(/(<\/ul>|<\/ol>|<\/blockquote>)\s*?<br\/>/g, '$1')
return converted
}

Expand Down

0 comments on commit fe77c20

Please sign in to comment.