{{ message }}
Repository navigation
feat: support ==highlight== markdown syntax (#2552) - #5647
Merged
Merged
Conversation
Add an off-by-default `highlightSyntax` preference that renders `==text==` as highlighted text in the editor and as `<mark>` in the HTML / PDF / print and copy-as-HTML export paths. The existing `<mark>` handling and the Highlight button/menu (which keep writing `<mark>`) are unchanged; the syntax only activates on manual input or paste. - muya: new `mark` inline rule/token gated by `highlightSyntax`, rendered through the shared del/em/strong factory; format toggle/clear, TOC plain text and markdown round-trip cover the new token. - export: new marked `mark` inline extension wired into getHighlightHtml, getClipBoardHtml and renderToStaticHTML. - desktop: `highlightSyntax` preference (schema / store / Preferences UI, default false) plus all 12 locales and the markdown syntax doc.
Contributor
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The preference does not survive restart, and export and formatting operations can discard trailing backslashes.
Review effort: Balanced
Findings: 4
Open (4)
What changed in this PR
Adds opt-in ==highlight== support to MarkText’s editor and HTML-based output, addressing interoperability requested in #2552.
Changes:
- Adds highlight parsing, rendering, formatting integration, and export support.
- Adds a disabled-by-default preference with localized labels.
- Adds regression tests and user documentation.
| File | Description |
|---|---|
| packages/website/content/docs/end-user/MARKDOWN_SYNTAX.md | Documents highlight syntax and opt-in behavior. |
| packages/muya/src/utils/marked/types.ts | Types the export option. |
| packages/muya/src/utils/marked/options.ts | Defaults highlight export off. |
| packages/muya/src/utils/marked/getHighlightHtml.ts | Enables highlight HTML export. |
| packages/muya/src/utils/marked/getClipboardHtml.ts | Enables highlight clipboard output. |
| packages/muya/src/utils/marked/extensions/mark.ts | Adds the Marked highlight extension. |
| packages/muya/src/types.ts | Exposes the Muya option. |
| packages/muya/src/state/renderToStaticHTML.ts | Forwards the static export option. |
| packages/muya/src/state/markdownToHtml.ts | Forwards the editor export option. |
| packages/muya/src/state/getTOC.ts | Includes highlighting in heading text parsing. |
| packages/muya/src/state/__tests__/texMathDollarsToggle.spec.ts | Updates tokenizer options. |
| packages/muya/src/state/__tests__/renderToStaticHTML.spec.ts | Tests highlight export toggling. |
| packages/muya/src/state/__tests__/referenceLink.spec.ts | Updates tokenizer options. |
| packages/muya/src/inlineRenderer/types.ts | Defines highlight tokens and options. |
| packages/muya/src/inlineRenderer/rules.ts | Adds the highlight matching rule. |
| packages/muya/src/inlineRenderer/renderer/mark.ts | Renders highlight tokens. |
| packages/muya/src/inlineRenderer/renderer/index.ts | Registers the highlight renderer. |
| packages/muya/src/inlineRenderer/renderer/delEmStrongFactory.ts | Supports mark wrappers. |
| packages/muya/src/inlineRenderer/lexer.ts | Integrates highlight token handling. |
| packages/muya/src/inlineRenderer/__tests__/texMathSingleBackslash.spec.ts | Updates tokenizer options. |
| packages/muya/src/inlineRenderer/__tests__/texMathGfmInline.spec.ts | Updates tokenizer options. |
| packages/muya/src/inlineRenderer/__tests__/texMathDoubleBackslash.spec.ts | Updates tokenizer options. |
| packages/muya/src/inlineRenderer/__tests__/markSyntax.spec.ts | Tests highlight parsing and exports. |
| packages/muya/src/inlineRenderer/__tests__/linkDestination.spec.ts | Updates tokenizer options. |
| packages/muya/src/inlineRenderer/__tests__/emphasisDelimiterRuns.spec.ts | Updates tokenizer options. |
| packages/muya/src/config/index.ts | Registers mark formatting and defaults. |
| packages/muya/src/clipboard/copyData.ts | Passes highlighting to clipboard conversion. |
| packages/muya/src/block/base/format.ts | Handles highlight removal and offsets. |
| packages/muya/src/block/base/__tests__/formatToggle.spec.ts | Tests highlight removal. |
| packages/muya/src/__tests__/setOptions.spec.ts | Tests live highlight toggling. |
| packages/desktop/static/locales/zh-TW.json | Adds Traditional Chinese labels. |
| packages/desktop/static/locales/zh-CN.json | Adds Simplified Chinese labels. |
| packages/desktop/static/locales/tr.json | Adds Turkish labels. |
| packages/desktop/static/locales/ru.json | Adds Russian labels. |
| packages/desktop/static/locales/pt.json | Adds Portuguese labels. |
| packages/desktop/static/locales/nl.json | Adds Dutch labels. |
| packages/desktop/static/locales/ko.json | Adds Korean labels. |
| packages/desktop/static/locales/ja.json | Adds Japanese labels. |
| packages/desktop/static/locales/fr.json | Adds French labels. |
| packages/desktop/static/locales/es.json | Adds Spanish labels. |
| packages/desktop/static/locales/en.json | Adds English labels. |
| packages/desktop/static/locales/de.json | Adds German labels. |
| packages/desktop/src/shared/types/preferences.ts | Types the shared preference. |
| packages/desktop/src/renderer/src/store/preferences.ts | Adds renderer preference state. |
| packages/desktop/src/renderer/src/prefComponents/markdown/index.vue | Adds the preference toggle. |
| packages/desktop/src/renderer/src/components/editorWithTabs/editor.vue | Applies initial and live settings. |
| packages/desktop/src/main/preferences/schema.json | Defines preference validation and default. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Add highlightSyntax to the shipped default preference.json (the source that migrates new keys into existing user settings), the Preferences reference table and the muya feature list.
Jocs
force-pushed
the
feat/highlight-syntax-2552
branch
from
October 7, 2026 13:19
803cb57 to
0ce102e
Compare
The `==text==` rule keeps the escaped run before the closing marker in `token.backlash`, outside `children`. Formatting dropped it: `clearFormat` spliced only the children and `rebuildWrapperToken` reproduced just marker + children + marker, so toggling Highlight off or formatting anything else in the block deleted the literal backslashes. Both now re-emit `backlash` (this also fixes the same latent loss for strong/em/del). The marked extension is aligned with the editor too: it rejects odd backslash runs (where the editor keeps the span literal) and feeds the run through the inline lexer so `\\` renders as the single backslash the editor shows.
Contributor
|
Build artifacts for PR #5647: Run: https://github.com/marktext/marktext/actions/runs/37631386652 |
Wangqkoe
pushed a commit
to Wangqkoe/marktext
that referenced
this pull request
Oct 24, 2026
…#5647) Picked with the highlightSyntax switch off by default, as upstream ships it. Local changes to the pick: - Restores the two outline spots removed when the outline inline-markdown port (80f49274) dropped highlight code: getTOC passes highlightSyntax to the tokenizer, and tokensToInlineHtml renders mark tokens. Adds back upstream's outline test and a test that == stays literal while off. - The desktop watcher uses applyOutlineAffectingOption, so toggling the switch refreshes the outline like the other syntax options. - Leaves out the softNewlineAsSpace option the upstream commit carried (not picked), and the nl/ru locales this fork does not ship. - Keeps the local Japanese strings and preference table, adding only the new highlightSyntax entries; a local tokenizer test gets the new option. (cherry picked from commit b317901) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 #2552
Summary
Implements
==highlight==, the non-standard markdown extension used by Obsidian / Typora / Logseq / Joplin, in both the editor and the export paths.Adds an off-by-default Preferences → Markdown → Extensions → Highlight (==text==) toggle. When enabled,
==text==renders as<mark>in the WYSIWYG editor and in the HTML / PDF / print / "Copy as HTML" output. When disabled (the default),==keeps reading as literal text, so existing documents are unaffected.The existing
<mark>handling is unchanged, and the Highlight button / menu / shortcut keep inserting<mark>; the new syntax only activates on manual input or paste.Type of change
Test plan
packages/muya/src/inlineRenderer/__tests__/markSyntax.spec.ts— editor lexer plus export (getHighlightHtml/getClipBoardHtml)packages/muya/src/block/base/__tests__/formatToggle.spec.ts— togglingformat('mark')off an==…==runpackages/muya/src/__tests__/setOptions.spec.ts— livehighlightSyntaxtoggle re-renders<mark>packages/muya/src/state/__tests__/renderToStaticHTML.spec.ts— option on/offpnpm -C packages/muya test(278 files / 2389 tests),test:spec(CommonMark + GFM),lint,check-circular,lint:typespnpm run lint(0 errors) andpnpm run typecheckNotes for reviewers [optional]
markextension exists only on themarkdownreader (notgfm), so enabling it would require switching readers. Verified with pandoc 3.12.==is not included.mark(nothighlight) so it maps onto the existing Highlight format/menu state without changing the menu id → format map.==is not added to auto-pairing or the backslash-escape set.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.