@wdprlib/decompiler 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @wdprlib/decompiler
2
+
3
+ Decompiler for Wikidot markup.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @wdprlib/decompiler
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { decompile } from "@wdprlib/decompiler";
15
+
16
+ // HTML → Wikidot syntax
17
+ const wikidot = decompile("<p><strong>Hello</strong> world</p>");
18
+ // => "**Hello** world"
19
+ ```
20
+
21
+ ### Step-by-step
22
+
23
+ ```ts
24
+ import { htmlToAst, serialize } from "@wdprlib/decompiler";
25
+
26
+ // 1. HTML → AST
27
+ const tree = htmlToAst("<p>Hello</p>");
28
+
29
+ // 2. Inspect or transform the AST...
30
+
31
+ // 3. AST → Wikidot syntax
32
+ const wikidot = serialize(tree);
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### `decompile(html, options?)`
38
+
39
+ Converts HTML to Wikidot syntax in one call (HTML → AST → serialize).
40
+
41
+ ### `htmlToAst(html, options?)`
42
+
43
+ Converts HTML to a Wikidot AST (`SyntaxTree`). Footnote content is extracted and stored in `tree.footnotes`.
44
+
45
+ ### `serialize(tree, options?)`
46
+
47
+ Converts a Wikidot AST to markup text.
48
+
49
+ ## Limitations
50
+
51
+ - <span style="color: #b01;">**Best-effort conversion**</span>: re-parsing the output should produce structurally equivalent HTML
52
+ - Code block language detection from highlighted HTML is not supported
53
+ - Modules (`[[module ...]]`), includes, iftags, comments are out of scope
54
+
55
+ ## Related Packages
56
+
57
+ - [@wdprlib/ast](https://www.npmjs.com/package/@wdprlib/ast) - AST type definitions
58
+ - [@wdprlib/parser](https://www.npmjs.com/package/@wdprlib/parser) - Wikidot markup parser
59
+ - [@wdprlib/render](https://www.npmjs.com/package/@wdprlib/render) - HTML renderer
60
+ - [@wdprlib/runtime](https://www.npmjs.com/package/@wdprlib/runtime) - Client-side runtime
61
+
62
+ ## License
63
+
64
+ AGPL-3.0 - See [LICENSE](https://github.com/r74tech/wdpr/blob/develop/LICENSE)