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

content: Handle multiple math blocks in <p> #1156

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rajveermalviya
Copy link
Collaborator

Fixes: #1130

@rajveermalviya rajveermalviya added the maintainer review PR ready for review by Zulip maintainers label Dec 13, 2024
@PIG208
Copy link
Member

PIG208 commented Jan 2, 2025

My test message renders like this:

Screenshot

image

I think this is a result of parsing each span as a MathBlockNode, which is probably fine, but visually looks a bit off with all the borders. Making an alternative design should be out of scope for the fix, though.

// 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;
Copy link
Member

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.

Copy link
Collaborator Author

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'),
]);
Copy link
Member

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.

@PIG208
Copy link
Member

PIG208 commented Jan 2, 2025

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.

@rajveermalviya rajveermalviya force-pushed the pr-multiple-tex-nodes branch 2 times, most recently from 9d222da to f4dde28 Compare January 6, 2025 17:49
@rajveermalviya
Copy link
Collaborator Author

Thanks for the review @PIG208. Pushed a new revision, PTAL.

@rajveermalviya rajveermalviya requested a review from PIG208 January 6, 2025 17:51
Copy link
Member

@PIG208 PIG208 left a 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.

@@ -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```````",
Copy link
Member

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;
Copy link
Member

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));.

Copy link
Collaborator Author

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.

@PIG208 PIG208 added the integration review Added by maintainers when PR may be ready for integration label Jan 8, 2025
@PIG208 PIG208 removed their assignment Jan 8, 2025
@PIG208 PIG208 requested a review from gnprice January 8, 2025 01:59
@PIG208
Copy link
Member

PIG208 commented Jan 8, 2025

Looks good to me! Thanks for the update.

@PIG208 PIG208 removed the maintainer review PR ready for review by Zulip maintainers label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle TeX blocks with blank lines
3 participants