Skip to content

feat: Add LaTeX and markdown extensions - #9

Open
Fuyeors wants to merge 2 commits into
mainfrom
feat/latex-plugin
Open

feat: Add LaTeX and markdown extensions#9
Fuyeors wants to merge 2 commits into
mainfrom
feat/latex-plugin

Conversation

@Fuyeors

@Fuyeors Fuyeors commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

Extend the existing LaTeX parser work with five Interactify-compatible Markdown extensions:

  • Add Twemoji AST transformation for Unicode emoji while preserving code spans and code blocks.
  • Add highlight.js-compatible fenced-code output, including language alias normalization for JavaScript, TypeScript, FFM, FON, FER, and other common aliases.
  • Add Mermaid and ABC fenced-code placeholders for asynchronous frontend rendering.
  • Add fenced and inline SMILES placeholders, including the FFM syntax #[smiles = SMILES_CODE].
  • Add a lazy AST traversal utility and a combined extensionsPlugin so the default FFM parser performs one post-parse extension pass.

The existing latexPlugin remains available independently. createFuyeorMarkdownParser() enables LaTeX and the five new extensions by default, while individual plugins remain publicly exportable for opt-in parser configurations.

Rendering contract

The implementation follows the existing Interactify asynchronous processor contract:

  • Emoji: <img class="emoji" draggable="false" alt="..." src="..."/>
  • Mermaid: <div class="language-mermaid">...</div>
  • ABC: <div class="language-abc">...</div>
  • Fenced SMILES: one <div class="language-smiles smiles-block" data-smiles="..."></div> per non-empty line
  • Inline SMILES: <span class="language-smiles smiles-inline" data-smiles="..."></span>
  • Highlightable code: pre.hljs.language-${lang}[data-language="${lang}"]

All user-controlled content inserted into HTML attributes or text placeholders is escaped.

Validation

Check Result
TypeScript typecheck Pass
Parser unit tests 21/21 pass
FFM regression tests 10 pass, 458 skipped by existing filters
Prettier check Pass
git diff --check Pass

Performance

Five-run local benchmarks with identical Node/Vitest settings showed that plain text without extension markers changed from a median of 2.185 ms to 2.204 ms per iteration (+0.9%) after the lazy single-pass optimization. New extension paths are measured separately because the baseline parser emitted ordinary text/code rather than the requested structured placeholders. Temporary benchmark files were not included in the commit.

Package size

Compared with the existing LaTeX branch using npm pack, the tarball increased from 36,278 B to 40,154 B (+3,876 B, +10.7%), while unpacked size increased from 212,359 B to 226,779 B (+14,420 B, +6.8%). The increase is source-only and includes the five extension modules, AST traversal helper, and regression tests; no runtime dependency was added.

@Fuyeors Fuyeors changed the title feat: Add LaTeX parser plugin feat: Add LaTeX and markdown extensions Aug 25, 2026
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