Do not escape dollar signs delimiting inline math in LaTeX export - #808
Merged
jacebrowning merged 2 commits intoJul 30, 2026
Merged
Conversation
Inline math written as $e=mc^2$ was published as \$e=mc^2\$, because _latex_convert escapes every dollar sign and the publisher only bypassed it for display math ($$...$$). The escaped delimiters break the LaTeX compile. Add _latex_convert_with_inline_math, which splits a line on unescaped dollar signs and converts only the non-math segments, leaving a complete inline math environment untouched. Lines with an unpaired dollar sign, or with an already-escaped \$, keep the previous escaping behaviour. Adds a regression test in test_publisher_latex.py covering both the inline math and the unpaired dollar sign cases.
jacebrowning
approved these changes
Jul 26, 2026
Member
|
@Sanjays2402 thanks, we just need the code to be formatted. |
Contributor
Author
|
Formatted in b6cbfae - black wanted the generator expression in |
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.
Closes #776
Inline math written as
$e=mc^2$is exported as\$e=mc^2\$, which breaks the LaTeX compile._latex_convert()escapes every dollar sign, and the publisher only bypasses it for display math ($$...$$)._latex_convert_with_inline_math()splits a line on unescaped dollar signs and converts only the non-math segments, so a complete inline math environment is left alone. Lines with an unpaired$, or an already-escaped\$, keep the previous escaping behaviour.The added regression test in
test_publisher_latex.pyfails without the fix and passes with it; the rest of the publisher suite is unchanged.