Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2529 - Fix the chat regression #2533

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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