@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.
@@ -0,0 +1,46 @@
1
+ /** Options for {@link decompile} and {@link htmlToAst}. */
2
+ interface DecompileOptions {
3
+ /** Whether to restore footnotes inline (default: `true`). */
4
+ inlineFootnotes?: boolean;
5
+ }
6
+ /** Options for {@link serialize}. */
7
+ interface SerializeOptions {
8
+ /** Newline character(s) to use (default: `"\n"`). */
9
+ newline?: string;
10
+ }
11
+ import { SyntaxTree } from "@wdprlib/ast";
12
+ /**
13
+ * Convert an HTML string into a Wikidot AST ({@link SyntaxTree}).
14
+ *
15
+ * The returned tree includes a `footnotes` array when footnote content is
16
+ * detected in the HTML.
17
+ *
18
+ * @param html - The HTML string to parse
19
+ * @param options - Decompilation options
20
+ * @returns The resulting syntax tree
21
+ */
22
+ declare function htmlToAst(html: string, options?: DecompileOptions): SyntaxTree;
23
+ import { SyntaxTree as SyntaxTree2 } from "@wdprlib/ast";
24
+ /**
25
+ * Serialize a Wikidot AST ({@link SyntaxTree}) into Wikidot markup text.
26
+ *
27
+ * Trailing blank lines are collapsed, and the output always ends with
28
+ * a single newline.
29
+ *
30
+ * @param tree - The syntax tree to serialize
31
+ * @param options - Serialization options (e.g. newline style)
32
+ * @returns Wikidot markup string
33
+ */
34
+ declare function serialize(tree: SyntaxTree2, options?: SerializeOptions): string;
35
+ /**
36
+ * Decompile HTML into Wikidot syntax.
37
+ *
38
+ * Combines {@link htmlToAst} and {@link serialize} into a single call:
39
+ * HTML → AST → Wikidot markup.
40
+ *
41
+ * @param html - The HTML string to decompile
42
+ * @param options - Decompilation options
43
+ * @returns Wikidot syntax string
44
+ */
45
+ declare function decompile(html: string, options?: DecompileOptions): string;
46
+ export { serialize, htmlToAst, decompile, SerializeOptions, DecompileOptions };
@@ -0,0 +1,46 @@
1
+ /** Options for {@link decompile} and {@link htmlToAst}. */
2
+ interface DecompileOptions {
3
+ /** Whether to restore footnotes inline (default: `true`). */
4
+ inlineFootnotes?: boolean;
5
+ }
6
+ /** Options for {@link serialize}. */
7
+ interface SerializeOptions {
8
+ /** Newline character(s) to use (default: `"\n"`). */
9
+ newline?: string;
10
+ }
11
+ import { SyntaxTree } from "@wdprlib/ast";
12
+ /**
13
+ * Convert an HTML string into a Wikidot AST ({@link SyntaxTree}).
14
+ *
15
+ * The returned tree includes a `footnotes` array when footnote content is
16
+ * detected in the HTML.
17
+ *
18
+ * @param html - The HTML string to parse
19
+ * @param options - Decompilation options
20
+ * @returns The resulting syntax tree
21
+ */
22
+ declare function htmlToAst(html: string, options?: DecompileOptions): SyntaxTree;
23
+ import { SyntaxTree as SyntaxTree2 } from "@wdprlib/ast";
24
+ /**
25
+ * Serialize a Wikidot AST ({@link SyntaxTree}) into Wikidot markup text.
26
+ *
27
+ * Trailing blank lines are collapsed, and the output always ends with
28
+ * a single newline.
29
+ *
30
+ * @param tree - The syntax tree to serialize
31
+ * @param options - Serialization options (e.g. newline style)
32
+ * @returns Wikidot markup string
33
+ */
34
+ declare function serialize(tree: SyntaxTree2, options?: SerializeOptions): string;
35
+ /**
36
+ * Decompile HTML into Wikidot syntax.
37
+ *
38
+ * Combines {@link htmlToAst} and {@link serialize} into a single call:
39
+ * HTML → AST → Wikidot markup.
40
+ *
41
+ * @param html - The HTML string to decompile
42
+ * @param options - Decompilation options
43
+ * @returns Wikidot syntax string
44
+ */
45
+ declare function decompile(html: string, options?: DecompileOptions): string;
46
+ export { serialize, htmlToAst, decompile, SerializeOptions, DecompileOptions };