@wdprlib/decompiler
v1.0.1
Published
HTML to Wikidot markup decompiler
Readme
@wdprlib/decompiler
Decompiler for Wikidot markup.
Installation
bun add @wdprlib/decompilerUsage
import { decompile } from "@wdprlib/decompiler";
// HTML → Wikidot syntax
const wikidot = decompile("<p><strong>Hello</strong> world</p>");
// => "**Hello** world"Step-by-step
import { htmlToAst, serialize } from "@wdprlib/decompiler";
// 1. HTML → AST
const tree = htmlToAst("<p>Hello</p>");
// 2. Inspect or transform the AST...
// 3. AST → Wikidot syntax
const wikidot = serialize(tree);API
decompile(html, options?)
Converts HTML to Wikidot syntax in one call (HTML → AST → serialize).
htmlToAst(html, options?)
Converts HTML to a Wikidot AST (SyntaxTree). Footnote content is extracted and stored in tree.footnotes.
serialize(tree, options?)
Converts a Wikidot AST to markup text.
Limitations
- Best-effort conversion: re-parsing the output should produce structurally equivalent HTML
- Code block language detection from highlighted HTML is not supported
- Modules (
[[module ...]]), includes, iftags, comments are out of scope
Related Packages
- @wdprlib/ast - AST type definitions
- @wdprlib/parser - Wikidot markup parser
- @wdprlib/render - HTML renderer
- @wdprlib/runtime - Client-side runtime
License
AGPL-3.0 - See LICENSE
