Repository navigation
Keep the whitespace before \\(...\\) math - #908
Merged
Merged
Conversation
markKatex consumed the whitespace before inline math written as `\\(...\\)` and replaced it with the bare marker, so "the paper's :math:`g` parameter" rendered as "paper'sg parameter" (rst `:math:` is converted to `\\(...\\)`). Return the captured whitespace before the marker, as the `$...$` replacement already does; a newline stays a newline, so math at the start of the line after a heading no longer joins the heading. check_links mirrors these placeholders to predict heading anchors, so it keeps the whitespace too: "## Loss \\(L\\) function" is now `loss-katexparse0marker-function`, matching the renderer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l-5ea849 # Conflicts: # kit/preprocessors/mdsvex/index.test.js
mishig25
added a commit
that referenced
this pull request
Nov 9, 2026
Keeps the tests of both sides, and the snapshot now has the space before `:math:` that #908 keeps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
markKatexinkit/preprocessors/mdsvex/index.jsmatched inline math written as\\(...\\)together with the whitespace before it, and replaced both with the bare KaTeX marker. The space disappeared from the rendered page:gparameter" rendered as "paper'sg parameter". rst-style:math:is converted to\\(...\\)byconvert_rst_to_mdx.py, so this affects docstrings as well as page bodies.\\(...\\)was dropped too. Math at the start of the line after a heading was merged into the heading's text.The
$...$replacement in the same function already keeps its surrounding whitespace.Fix
markKatexcaptures the whitespace before\\(and returns it in front of the marker, so a space stays a space and a newline stays a newline.check_links.pymirrors these placeholders to predict heading anchors, so_mark_katex_placeholderskeeps the same whitespace. Otherwise its anchors would no longer match the renderer's. For example,## Loss \\(L\\) functionnow getsloss-katexparse0marker-functionfrom both. Before, both gavelosskatexparse0marker-function.Tests
index.test.js: a space and a newline before\\(...\\)are kept.test_check_links.py: heading anchors with\\(...\\)math, and a\\(...\\)line under a heading no longer joining that heading.page.htmlchanges only inlegacy_function, where "and \(x + y\)" gets its space back. The formatter writes that space as a line break before the<span>.page.mdxis unchanged.cd kit && npm test(15/15) andpytest tests/test_docstring_snapshots.py tests/test_check_links.py(49) pass.Interaction with #905
#905 adds a
mix_embeddingssample totests/data/docstring_snapshots/. That sample has:math:after a space in parameter descriptions, e.g. "timestep :math:t" and "the paper's :math:gparameter". Once both PRs are on main, those spans get their space back too. Whichever of the two PRs merges second must regeneratepage.html:The two PRs edit different functions in
kit/preprocessors/mdsvex/index.js:markKatexhere,renderKatexin #905.🤖 Generated with Claude Code