A blazingly fast library for Wikitext that has a syntax highlighter and editor written in Rust and TypeScript.
- Supports all wikitext syntax.
- SIMD-accelerated tokenization via Rust.
- Configurable protocols, redirect keywords, extension tags, etc.
- Semantic CSS classes via
getDefaultStyles().
npm i wikistxrStatic, full-pass syntax highlighting
- Tokenizes input in one pass.
- Renders to HTML strings.
import { WikitextHighlighter } from "wikistxr";
const highlighter = new WikitextHighlighter();
const html = highlighter.highlight(wikitextString);Incremental, live editing with DOM patching
- Caches tokenizer state and tokens per line.
- Handles cursor persistence and DOM synchronization.
import { WikitextEditor } from "wikistxr";
const editor = new WikitextEditor();
editor.attach(editableDiv);
editor.update(wikitextString);Both classes accept the same options:
const config = {
urlProtocols: "http|https|mailto",
redirectKeywords: ["REDIRECT", "WEITERLEITUNG"],
extensionTags: ["nowiki", "ref", "gallery"],
contentPreservingTags: ["nowiki", "pre"],
};
const highlighter = new WikitextHighlighter(config);To apply default styles:
const styles = WikitextHighlighter.getDefaultStyles();# Build Rust core and TypeScript bundles
bun run build
# Run development demo
bun run dev