fix(desktop): tell the two backslash math preferences apart in the UI (#5481) by Jocs · Pull Request #5485 · marktext/marktext · GitHub
Skip to content

fix(desktop): tell the two backslash math preferences apart in the UI (#5481) - #5485

Merged
Jocs merged 1 commit into
developfrom
fix/backslash-math-preference-labels
Sep 21, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/backslash-math-preference-labels

Conversation

@Jocs

@Jocs Jocs commented Sep 21, 2026

Copy link
Copy Markdown
Member

Follow-up to #5481.

Preferences → Markdown → Extensions shows the two backslash math switches with
the same label. Their strings differ only by backslash count —
"TeX math with \\( and \\[" vs "TeX math with \\\\( and \\\\[" in the JSON —
and vue-i18n's message compiler reads \\ as an escaped backslash and collapses
it to one. Both render as TeX math with \( and \[.

in :  "使用 \\( 和 \\[ 的 TeX 数学公式"     out:  使用 \( 和 \[ 的 TeX 数学公式
in :  "使用 \\\\( 和 \\\\[ 的 TeX 数学公式"  out:  使用 \( 和 \[ 的 TeX 数学公式

Why not just escape it

To display \\( the JSON would need eight backslashes. That is invisible on
review, meaningless to a translator, and the next formatting pass silently
restores this exact symptom. The labels now say it in words instead; the more
link on each switch already points at pandoc's manual for the delimiters
themselves.

before after
texMathSingleBackslash TeX math with \( and \[ TeX math with single-backslash delimiters
texMathDoubleBackslash TeX math with \\( and \\[ TeX math with double-backslash delimiters

All eleven locales updated. The long preferences.search.items strings are
untouched — they name the pandoc extension and have no backslashes to lose.

The check

Values in these files are plain labels, never templates that need escaping, so
locale-validation.spec.ts now rejects a backslash anywhere in a translated
value. It covers en.json, which the comparison checks around it deliberately
skip — the first version of the check did not, and passed while the bug was
still there.

Test plan

  • pnpm run test:unit — locale-validation.spec.ts at 46 cases
  • pnpm run lint and pnpm run typecheck
  • Rendered both labels through the app's own safeMessageCompiler to
    confirm they now differ
  • Positive control: reintroducing a backslash in en.json fails the new
    check and names the offending key

🤖 Generated with Claude Code

…#5481)

Their labels differed only by backslash count — "TeX math with \( and \[" vs
"TeX math with \\( and \\[" — and vue-i18n's message compiler reads `\\` as an
escaped backslash and collapses it to one. Both rendered as "TeX math with \(
and \[", so Preferences → Markdown → Extensions showed two identical switches.

Getting the escaping right would take eight backslashes in the JSON to display
two: invisible on review, and the next translator or formatting pass silently
breaks it back to this exact symptom. The labels now say it in words instead.
The `more` link on each switch already points at pandoc's manual for the
delimiters themselves.

A locale check enforces the rule: values here are plain labels, never templates
that need escaping, so none of them may contain a backslash. It covers en.json
too, which the comparison checks around it deliberately skip.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5485:

Run: https://github.com/marktext/marktext/actions/runs/35587596889

Artifact Size Link
marktext-macos-x64 297.9 MB Download
marktext-windows-arm64 279.5 MB Download
marktext-macos-arm64 287.5 MB Download
marktext-linux 638.5 MB Download
marktext-windows-x64 287.7 MB Download

@Jocs
Jocs merged commit 7d862bf into develop Sep 21, 2026
11 checks passed
@Jocs
Jocs deleted the fix/backslash-math-preference-labels branch September 21, 2026 13:48
Wangqkoe pushed a commit to Wangqkoe/marktext that referenced this pull request Oct 21, 2026
…marktext#5481) (marktext#5485)

Their labels differed only by backslash count — "TeX math with \( and \[" vs
"TeX math with \\( and \\[" — and vue-i18n's message compiler reads `\\` as an
escaped backslash and collapses it to one. Both rendered as "TeX math with \(
and \[", so Preferences → Markdown → Extensions showed two identical switches.

Getting the escaping right would take eight backslashes in the JSON to display
two: invisible on review, and the next translator or formatting pass silently
breaks it back to this exact symptom. The labels now say it in words instead.
The `more` link on each switch already points at pandoc's manual for the
delimiters themselves.

A locale check enforces the rule: values here are plain labels, never templates
that need escaping, so none of them may contain a backslash. It covers en.json
too, which the comparison checks around it deliberately skip.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 7d862bf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant