-
Notifications
You must be signed in to change notification settings - Fork 235
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
content: Handle multiple math blocks in <p>
#1156
base: main
Are you sure you want to change the base?
Conversation
My test message renders like this: I think this is a result of parsing each |
lib/model/content.dart
Outdated
// it seems like a glitch in the server's Markdown processing, | ||
// so hopefully there just aren't any further such glitches. | ||
if (child case dom.Element(localName: 'br')) continue; | ||
if (child case dom.Text(text: '\n' || '\n\n')) continue; |
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.
Looks like this no longer checks if the <br>\n
is at the end. Would it be unexpected to have them appear in the middle?
\n\n
on the other hand, appear to be somehow separate from the quirk commented here.
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.
Separated the handling of both these cases.
'<span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></span></p>', [ | ||
MathBlockNode(texSource: 'a'), | ||
MathBlockNode(texSource: 'b'), | ||
]); |
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.
Let's also have a test with multiple math blocks in a quote.
Thanks for the PR! Apparently I've missed this one as it has been sitting for some time. Overall this works fine for me. Left some comments. |
9d222da
to
f4dde28
Compare
Thanks for the review @PIG208. Pushed a new revision, PTAL. |
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.
Looks good to me! Left some small comments.
test/model/content_test.dart
Outdated
@@ -522,6 +539,26 @@ class ContentExample { | |||
'<br>\n</p>\n</blockquote>', | |||
[QuotationNode([MathBlockNode(texSource: r'\lambda')])]); | |||
|
|||
static const mathBlocksMultipleInQuote = ContentExample( | |||
'math blocks, multiple in quote', | |||
"````quote\n```math\na\n\nb```````", |
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.
Need a \n
between ``` and ````
"````quote\n```math\na\n\nb```\n````"
// each node is interleaved by '\n\n'. Whitespaces are ignored in HTML | ||
// on web but each node has `display: block`, which renders each node | ||
// on a newline. So do the same here. | ||
if (child case dom.Text(text: '\n\n')) continue; |
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.
I can see how the first sentence is relevant. Regarding "do the same here", continue
itself does not seem to address the part about rendering each node with display: block
, as that is more relevant to blocks.add(MathBlockNode(texSource: texSource, debugHtmlNode: debugHtmlNode));
.
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.
Added more info about how it tries to replicate web behavior.
f4dde28
to
5f0bfa1
Compare
Looks good to me! Thanks for the update. |
Fixes: #1130