FluxMarkdown extends the core markdown-it parser with a carefully chosen set of plugins that cover common real-world Markdown dialects — GitHub Flavored Markdown, Obsidian, Pandoc exports, and more. Because FluxMarkdown is a passive viewer rather than an editor, the selection principle is to maximize compatibility with content written in other tools, not to introduce syntax that only works here.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/xykong/flux-markdown/llms.txt
Use this file to discover all available pages before exploring further.
Plugins
markdown-it — core parser
markdown-it — core parser
buildMd() inside src/index.ts with:html: true setting allows documents that embed raw HTML (common in GitHub READMEs) to render correctly inside the WebView.@iktakahiro/markdown-it-katex — math
@iktakahiro/markdown-it-katex — math
$E=mc^2$); display math uses double dollar signs ($$\int_0^\infty$$).$ or $$ pattern. Documents without math pay no loading cost.markdown-it-anchor — heading anchors
markdown-it-anchor — heading anchors
id attributes to every heading so that in-page links like [see overview](#overview) work correctly.The plugin is configured with a custom slugify function that handles CJK characters and mixed Latin/Chinese headings:src/index.ts → findElementByAnchor.markdown-it-emoji — emoji shortcodes
markdown-it-emoji — emoji shortcodes
:emoji_name: shortcodes to Unicode characters.enableEmoji render option is true (the default).markdown-it-footnote — footnotes
markdown-it-footnote — footnotes
[^label] footnote references and definitions.markdown-it-github-alerts — callout blocks
markdown-it-github-alerts — callout blocks
> [!TYPE] alert syntax into styled callout blocks.NOTE, TIP, IMPORTANT, WARNING, CAUTION.markdown-it-mark — highlight
markdown-it-mark — highlight
==text== in <mark> elements for highlighted text.markdown-it-sub — subscript
markdown-it-sub — subscript
H~2~O subscript syntax.markdown-it-sup — superscript
markdown-it-sup — superscript
x^2^ superscript syntax.markdown-it-task-lists — task lists
markdown-it-task-lists — task lists
- [ ] and - [x] list items as checkboxes.Rendering pipeline
The full pipeline runs insidewindow.renderMarkdown in src/index.ts. Steps execute in this order:
YAML frontmatter extraction
extractFrontMatter(text) splits the input at the --- delimiter. If a frontmatter block is present, it is parsed with js-yaml and rendered as an HTML table (<table class="yaml-frontmatter">). The body text is passed to the next stage.Feature flag evaluation
enableEmoji and enableKatex options passed by Swift. If a previously-enabled plugin needs to be disabled, rebuildMd() creates a fresh instance.Outline extraction
extractOutline(md, body) parses the body text with markdown-it to extract heading tokens and builds a tree structure for the TOC panel.markdown-it render
md.render(body, { baseUrl }) converts the Markdown body to an HTML string. The custom image rule resolves relative paths to local-md:// URLs. The renderToken override injects data-source-line attributes for source-line tracking.Mermaid block extraction
code.language-mermaid blocks are replaced with <div class="mermaid"> placeholder elements. The raw diagram source is preserved as text content.DOM update
#markdown-preview via innerHTML. RTL detection runs immediately after.Diff annotation (optional)
prevContent was provided, computeLineDiff produces a line-level diff and DiffAnimator.annotateRenderDOM annotates changed DOM nodes with CSS classes for animated highlighting.Mermaid rendering
.mermaid placeholder is processed: preprocessMermaidNewlines runs first, then mermaid.render() produces an SVG string that replaces the placeholder content.Mermaid newline preprocessing
Mermaid v11 does not convert\n escape sequences to line breaks inside unquoted node labels. The preprocessMermaidNewlines function in src/index.ts normalizes diagram source before passing it to mermaid.render().
It handles three cases:
test/mermaid-newline.test.ts.
GitHub Markdown CSS
Thegithub-markdown-css package provides the base styling that makes rendered output look like GitHub’s Markdown preview. It is imported at the top of src/index.ts:
markdown-body class that activates these styles. Dark mode is handled by setting data-theme="dark" on <html> — the CSS package responds to this attribute.
Additional style overrides live in src/styles/ and cover highlight.js themes, the TOC panel, search UI, callout blocks, print layout, and diff animations.
Extending the renderer: adding a plugin
To add a new markdown-it plugin:Write a test first
test/your-plugin.test.ts and add a test that verifies the expected HTML output. See test/extended-syntax.test.ts and test/github-alerts.test.ts for examples.Import and register in src/index.ts
instance.use(yourPlugin) inside buildMd():