-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
#2356 - Fix the chat markdown bug related to a line-break #2361
Conversation
.replace(/<br>\n(\s*)(\d+\.|-)/g, '\n\n$1$2') // [1] custom-handling the case where <br> is directly followed by the start of ordered/unordered lists | ||
.replace(/(\d+\.|-)(\s.+)\n<br>/g, '$1$2\n\n') // [2] this is a custom-logic added so that the end of ordered/un-ordered lists are correctly detected by markedjs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As inline-commented in the same file, markedjs
with gfm
style has a default behaviour where it collapses multiple consecutive line-breaks into one which is not what we want for the app. [1]
and [2]
here are the custom logics added to work around this. But [2] here didn't capture an edge-case where the last-child of a list ends with <code>
element.
(The reason for this edge case is that, we split the whole text by markdown code elements first before applying these [1]
and [2]
because no content wrapped within <code>...</code>
should be converted. eg. we already made a fix before for a bug where something like a<=b within <code>
element looks incorrect.)
So added a fix in L51
below to take this into account.
group-income
|
Project |
group-income
|
Branch Review |
sebin/task/#2356-markdown-linebreak-bug
|
Run status |
|
Run duration | 09m 27s |
Commit |
|
Committer | Sebin Song |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
10
|
|
0
|
|
111
|
View all changes introduced in this branch ↗︎ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @SebinSong! 👏
closes #2356
Screenshot for the fix.
![](https://private-user-images.githubusercontent.com/17641213/369719792-58edd991-517f-41ec-955a-ce41784ac268.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjkyNjUsIm5iZiI6MTczOTQyODk2NSwicGF0aCI6Ii8xNzY0MTIxMy8zNjk3MTk3OTItNThlZGQ5OTEtNTE3Zi00MWVjLTk1NWEtY2U0MTc4NGFjMjY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDA2NDI0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM2ZjFiNTMxOGRiZDU4ZDk4ODliMTAxNTQ1MDBhZjgwMWEwM2JmOWNkOGUwYWUzNGJjYTAxZDNhYjZiZTM0MjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.cPoHGuPcSOU3NZK8ZJ5wmr3t9gjU44FnaQ-g6GrSqkw)