{{ message }}
Repository navigation
feat: add setting to disable inline math ($...$) parsing - #4231
Closed
briannnelson wants to merge 1 commit into
Closed
briannnelson wants to merge 1 commit into
briannnelson wants to merge 1 commit into
Conversation
Adds an opt-in preference `inlineMath` (default: true) that lets users turn off inline math parsing so dollar signs in regular prose (e.g. "$5 and $10") render as literal characters instead of broken LaTeX. Block math ($$...$$) is unaffected. - Split the shared `math` parser flag into `math` (block) + `inlineMath` (inline), with `inlineMath !== false` guard for backward compat - Gate `inline_math` token in the WYSIWYG tokenizer (parser/index.js) - Gate inline math in the marked InlineLexer (export/copy path) - Wire the new preference through Pinia store, schema, static defaults, editor.vue (storeToRefs + watch + onMounted options), and the Markdown preferences UI (Extensions section) - Add i18n strings to all 9 supported locales Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Member
Author
@Jocs $ is a workaround that pollutes the source file, doesn't survive copy/paste, and requires the user to think about math syntax in documents that have no math. The setting removes the friction at its root. |
Member
|
If inline math can be controlled via settings, shouldn't block math also be? My thinking is that math is not supported by GFM and CommonMark Spec, so it should be configurable. Should block math and inline math use a single configuration item, or be configured separately? |
Member
|
@claude review this PR |
8 of 11 tasks
niyo-oyin
added a commit
to niyo-oyin/marktext-ja
that referenced
this pull request
Aug 13, 2026
Port of upstream PR marktext#5004 (follow-up to marktext#4231, related to marktext#2002). Adds a default-on 'Inline math' preference under Preferences -> Markdown -> Extensions. When disabled, single-dollar expressions stay literal text — currency-heavy prose like $13B is no longer swallowed into KaTeX — while double-dollar display math keeps rendering. The option threads through every parse/render entry point: live editing, markdown import, clipboard HTML, TOC text, and static HTML/export. Deviations from the upstream PR: the schema.json hunk is re-applied on top of this fork's separator fixes (e197fb8), and the ja / zh-CN / zh-TW locale strings are translated instead of the English placeholders. Round-trip serialization (marktext#4934 concern) verified: muya spec suites including roundTrip.spec pass, and the PR's own test pins getMarkdown() identity with inlineMath disabled.
This was referenced Sep 18, 2026
Jocs
added a commit
that referenced
this pull request
Sep 19, 2026
…5446) (#5450) `math` was a half-finished master switch: it gated only the marked path (import, HTML export, clipboard), the live editor ignored it entirely, and MarkText never set it — no schema entry, no UI, no setOptions call. So the option that was supposed to control dollar math could not turn it off, and where it did apply it made the editor disagree with its export. It is now `texMathDollars`, named after the pandoc extension it implements, with the live-editor gate it never had and a preference under Preferences → Markdown → Extensions beside the other pandoc-named toggles. Default on, as in pandoc's own `markdown` dialect. It covers `$…$` and `$$…$$` together, because that is the granularity pandoc gives the extension — the question #4231 stalled on, answered by adopting an existing definition rather than inventing one. This is also the switch #2002, #4231 and #5243 asked for, the last of them patching app.asar to get it. With the option off the syntax is neither read nor offered: the inline and begin rules skip it, `$$` + Enter stays a paragraph, and the menus that list blocks — quick insert, the front menu's Turn Into, and the desktop Paragraph menu — drop Math Block. `canInsertLabel` is the single rule behind that, consulted by those menus and by the builder every insertion path funnels through, so the ⌥⌘M shortcut cannot slip past a list it never reads. Task 2 of #5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Wangqkoe
pushed a commit
to Wangqkoe/marktext
that referenced
this pull request
Oct 21, 2026
…arktext#5446) (marktext#5450) `math` was a half-finished master switch: it gated only the marked path (import, HTML export, clipboard), the live editor ignored it entirely, and MarkText never set it — no schema entry, no UI, no setOptions call. So the option that was supposed to control dollar math could not turn it off, and where it did apply it made the editor disagree with its export. It is now `texMathDollars`, named after the pandoc extension it implements, with the live-editor gate it never had and a preference under Preferences → Markdown → Extensions beside the other pandoc-named toggles. Default on, as in pandoc's own `markdown` dialect. It covers `$…$` and `$$…$$` together, because that is the granularity pandoc gives the extension — the question marktext#4231 stalled on, answered by adopting an existing definition rather than inventing one. This is also the switch marktext#2002, marktext#4231 and marktext#5243 asked for, the last of them patching app.asar to get it. With the option off the syntax is neither read nor offered: the inline and begin rules skip it, `$$` + Enter stays a paragraph, and the menus that list blocks — quick insert, the front menu's Turn Into, and the desktop Paragraph menu — drop Math Block. `canInsertLabel` is the single rule behind that, consulted by those menus and by the builder every insertion path funnels through, so the ⌥⌘M shortcut cannot slip past a list it never reads. Task 2 of marktext#5446. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 3e9e91c)
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 #2002
Summary
$...$is treated as literal text — dollar signs in prose like$5 and $10no longer trigger broken LaTeX rendering$$...$$) is unaffected regardless of the settingProblem
Users writing documents with currency or other dollar signs frequently get unexpected KaTeX render errors because
$5 and $10is parsed as inline math syntax. There was no way to opt out of inline math without also losing block math.Implementation
Parser layer (
src/muya/lib/):inlineMathoption (defaulttrue) separate from the existingmathflag (which gates block math)inline_mathtoken in the WYSIWYG tokenizer (parser/index.js) viainlineMath !== falseInlineLexer(parser/marked/inlineLexer.js) — used for export and copy/paste — with the same guard for backward compat with old configs that lack the keymultiplemath) in the block lexer is unchangedPreferences system:
src/renderer/src/store/preferences.js— Pinia state defaultinlineMath: truestatic/preference.json— static defaultsrc/main/preferences/schema.json— JSON schema entryEditor wiring (
src/renderer/src/components/editorWithTabs/editor.vue):storeToRefs, passed inonMountedoptions, and watched withneedRender: trueso toggling re-renders all blocks immediately (no restart needed)Settings UI (
src/renderer/src/prefComponents/markdown/index.vue):<bool>toggle in the Extensions compound, after Footnotei18n: Added
"inlineMath"keys to all 9 supported locale files (English placeholder for non-English locales — translations welcome).Test plan
$E = mc^2$renders as KaTeX inline math$E = mc^2$renders as literal$E = mc^2$;$5 and $10renders as plain text$$E = mc^2$$renders as KaTeX block regardless of settingpnpm run test:unitpasses🤖 Generated with Claude Code