{{ message }}
Repository navigation
Conversation
Contributor
|
Website preview ready: https://pr-5451-marktext-website.ransixi.workers.dev Built from |
Jocs
force-pushed
the
feat/muya-tex-math-gfm
branch
from
September 18, 2026 19:33
ea1ee2f to
d794004
Compare
Contributor
|
Build artifacts for PR #5451: Run: https://github.com/marktext/marktext/actions/runs/35437142016
|
) The option does exactly one thing: promote a ```math fence to a math block. That is not "GitLab compatibility" — it is the display half of pandoc's `tex_math_gfm`, and GitHub writes it the same way. Name it after the extension, so the inline half can join it under one switch. The default flips from true to false to match pandoc, where only `tex_math_dollars` ships enabled — including the `?? true` fallbacks in markdownToHtml and the public `renderToStaticHTML`. MarkText already defaulted it off, so this closes a standing disagreement between the two packages rather than opening one; a standalone @muyajs/core consumer that relied on the old default now has to ask for it. Task 3 of #5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`meta.mathStyle` records which syntax a math block was written in, so that the serializer can put it back the way it came. Its non-default value named the wrong vendor: ```` ```math ```` is GitHub's syntax as much as GitLab's, and it is what pandoc's `tex_math_gfm` covers. State-shape change for @muyajs/core: a math block promoted from a ```` ```math ```` fence now carries `mathStyle: 'gfm'`. Nothing persists the value — markdown is the file format, and the fence it round-trips to is unchanged. Task 3 of #5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`` $`e=mc^2`$ `` was silently mis-rendered: the dollar rule claimed the span, the backticks went to KaTeX as part of the formula, and `katex-error` stayed false — nothing reported a problem, it just came out wrong, in the editor and in the export alike. Any document copied from GitHub broke this way. Both tokenizers now recognise it, under `texMathGfm`. The rule goes ahead of the dollar rule in the chunk list, and the marked extension is registered after the dollar one (`Marked.use` unshifts), so in both engines the longer, more specific form is tried first. Opener and closer are mirror images instead of one repeated marker, but both are two characters wide, so the marker arithmetic downstream — the caret offsets, the Tab-past-the-closer hit test, the three render slices — lands correctly without changes. The one place that genuinely needed the closing marker is the clipboard renderer, which reassembled `marker + text + marker`; it now carries an explicit close. With the extension off the span keeps its current reading, as pandoc does: `tex_math_dollars` alone treats `` $`…`$ `` as dollar math whose content happens to contain backticks. Task 3 of #5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Promoting a ```math fence needed `math` as well as the GitLab flag — an accident of the old naming, where `math` read as a master switch. ```` ```math ```` is the display half of `tex_math_gfm` and has nothing to do with the dollar syntax, so it now rides its own extension: turning the dollar forms off no longer takes the fenced form with it. Task 3 of #5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…thGfm (#5446) The preference was named for a vendor and filed under Compatibility, but it switched a markdown extension: ```` ```math ```` blocks, which GitHub writes the same way GitLab does. It now sits with the other pandoc-named toggles under Extensions, links at the pandoc manual like they do, and covers the inline `` $`…`$ `` form as well. The old key is dropped rather than migrated. Before 1.0.0 that is the cheaper trade: the preference loader already deletes keys that leave static/preference.json, so nothing errors, and anyone who had GitLab compatibility on turns the new toggle on once. Task 3 of #5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Task 3 of #5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Jocs
force-pushed
the
feat/muya-tex-math-gfm
branch
from
September 19, 2026 10:20
d794004 to
d10d420
Compare
Member
Author
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.

Task 3 of #5446. Stacked on #5450 (Task 2) — review that one first; this branch targets it, and I will rebase onto
developonce it merges.isGitlabCompatibilityEnabledwas one third of an extensionThe preference was named for a vendor and filed under Compatibility, but it did exactly one thing: promote a
```mathfence to a math block. That is the display half oftex_math_gfm— GitHub's syntax as much as GitLab's — and the inline half was missing entirely.Missing, and worse than missing:
$`e=mc^2`$was silently mis-rendered. The dollar rule claimed the span and handed the backticks to KaTeX as part of the formula:katex-errorwasfalse— nothing reported a problem, it just came out wrong, in the editor and in the export alike. Any document copied from GitHub broke this way.Now
One preference,
texMathGfm, covering both forms, under Preferences → Markdown → Extensions with the other pandoc-named toggles. Default off, as in pandoc, where onlytex_math_dollarsships enabled.The old key is dropped rather than migrated. electron-store keys migrations to app versions, so a prerelease tester who has already run a 0.20.0 build could never receive one — their stored version is already at or past any key we could write. Before 1.0.0 the cheaper trade is to let the setting go: the preference loader already deletes keys that leave
static/preference.json, so nothing errors, and anyone who had GitLab compatibility on turns the new toggle on once.Notes on the implementation
Marker asymmetry.
$`…`$opens and closes with mirror images rather than one repeated marker. Both are two characters wide, so everything downstream that does arithmetic offmarker.length— caret offsets, the Tab-past-the-closer hit test, the three render slices and the preview'sdata-start/data-end— still lands correctly. The one place that genuinely needed the closer is the clipboard renderer, which reassembledmarker + text + markerand would have written$`e=mc^2$`; it now carries an explicit close marker, and there is a test for exactly that round trip.Rule precedence. Both math forms open on
$, and the dollar rule would swallow the gfm span whole. In the editor the gfm rule goes ahead of it in the chunk list; on the marked side the extension is registered after the dollar one, becauseMarked.useunshifts, so the later registration is tried first. marked runs extensions ahead of its built-incodespan, so inline code never gets a chance to claim it either.With the extension off, the span keeps its current reading. That is pandoc's behaviour —
tex_math_dollarsalone does treat$`…`$as dollar math whose content happens to contain backticks — so Gap 2 in the issue is fixed by opting in, not by default. Deliberate, and pinned by a test so it cannot drift silently.Only the single-backtick form is supported (
$`…`$), which is what GitHub documents. Multi-backtick$…$is not.Behaviour changes worth calling out
$`e=mc^2`$with the extension on```mathpromotiontexMathGfmalone — turning dollar math off no longer takes the fenced form with itmeta.mathStyleon such a block'gitlab''gfm'(muya state shape; nothing persists it — markdown is the file format, and the fence is unchanged)isGitlabCompatibilityEnabled: truetexMathGfm: false, including the?? truefallbacks inmarkdownToHtmland the publicrenderToStaticHTMLThat last row changes the default for a standalone
@muyajs/coreconsumer. MarkText already defaulted it off, so this closes a standing disagreement between the two packages rather than opening one.Commits
refactor(muya)— rename the option, flip the default.refactor(muya)—mathStyle: 'gitlab'→'gfm'.feat(muya)— the inline form, in both tokenizers, plustexMathGfmInline.spec.ts.feat(muya)—```mathridestexMathGfmalone.feat(desktop)— the preference swap.docs— the PREFERENCES.md row.Verification
muya 252 files / 1880 tests, CommonMark 0.31 + GFM 0.29 conformance 1347, desktop unit 820 (locale parity included),
lint,typecheck,check-circular, and the muya Playwright math suite (70 passed).🤖 Generated with Claude Code