Repository navigation
fix: keep latex script markers - #303
Merged
Merged
Conversation
RivoLink
force-pushed
the
fix/latex-script-fallback
branch
2 times, most recently
from
September 28, 2026 08:39
c8c3b9a to
34e7339
Compare
RivoLink
force-pushed
the
fix/latex-script-fallback
branch
from
September 28, 2026 09:09
34e7339 to
914fe54
Compare
|
Warning The head commit isn't GPG-signed. |
RivoLink
force-pushed
the
fix/latex-script-fallback
branch
from
September 28, 2026 09:54
914fe54 to
34e832e
Compare
RivoLink
reviewed
Sep 28, 2026
RivoLink
left a comment
Owner
There was a problem hiding this comment.
Hi,
Thank you so much for this PR!
I just made some minor optimizations and signed the commit.
RivoLink
approved these changes
Sep 28, 2026
Contributor
Author
|
Thank you for your better design!! |
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.
convert_scriptmaps the body of^{...}/_{...}to Unicode superscript or subscript characters. When at least one character has no such form —π,∞,ε, or a nested script — it falls back to({group}), and the^/_itself is dropped along the way. The exponent then reads as multiplication and an integral bound reads as function application, so the rendering says something different from the source rather than merely looking plainer.Keeping the marker in the fallback is enough to remove the ambiguity:
e^{i\pi}renders ase^(iπ)instead ofe(iπ). The conversion rule itself is unchanged, so anything that already had a Unicode form still gets it —n^2,A^T,M^{-1},x_{max},n^{abc}and∑ᵢ₌₁ⁿare untouched.Reproduce
leaf --inline=plain --width 50 repro.mdBefore:
After:
Both formulas are already in the repository:
demo/sources/demo-latex-render.mdshows the Euler–Poisson integral, andTESTING.mdshows Euler's identity and the Basel problem. All three render without their markers onmain.Testing
superscript_fallback_keeps_caret,subscript_fallback_keeps_underscoreandnested_script_fallback_keeps_both_markers; all three fail onmainand pass with this change.convertible_scripts_stay_unicodeguards the paths that already worked and passes on both.cargo test(504 passed),cargo clippy --all-targets --all-features -- -D warnings,cargo fmt --check,cargo build --release.*.mdin this repo at 11 widths (20–160) in both inline modes with the old and the new binary: 418 comparisons, identical exceptdemo/sources/demo-latex-render.mdandTESTING.md, where the only difference is the restored^shown above.\frac,\sqrt,\binom,\begin{cases}, table cells, and scripts nested in scripts (n^{a_{\varepsilon}}→n^(a_(ε)),2^{2^{2^n}}→2^(2^(2ⁿ))) — plus degenerate groups such asn^{ },n^{S}and non-Latin content. Nothing renders worse than before.Two rough edges are left as they are, since both read correctly and predate this change: a single-character fallback still gets parentheses (
n^{\varepsilon}→n^(ε)), and\left(...\right)inside an exponent yields a doubled pair (n^((1−ε))). Happy to tighten either in a follow-up if that is worth doing.🤖 Generated with Claude Code