@dogsbay/format-asciidoc 0.2.0-beta.48

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.
Files changed (54) hide show
  1. package/README.md +40 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +239 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/detect.d.ts +42 -0
  7. package/dist/detect.d.ts.map +1 -0
  8. package/dist/detect.js +56 -0
  9. package/dist/detect.js.map +1 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +9 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/inline-walker.d.ts +17 -0
  15. package/dist/inline-walker.d.ts.map +1 -0
  16. package/dist/inline-walker.js +167 -0
  17. package/dist/inline-walker.js.map +1 -0
  18. package/dist/loaders/antora.d.ts +3 -0
  19. package/dist/loaders/antora.d.ts.map +1 -0
  20. package/dist/loaders/antora.js +254 -0
  21. package/dist/loaders/antora.js.map +1 -0
  22. package/dist/loaders/asciibinder.d.ts +3 -0
  23. package/dist/loaders/asciibinder.d.ts.map +1 -0
  24. package/dist/loaders/asciibinder.js +206 -0
  25. package/dist/loaders/asciibinder.js.map +1 -0
  26. package/dist/loaders/master-adoc.d.ts +3 -0
  27. package/dist/loaders/master-adoc.d.ts.map +1 -0
  28. package/dist/loaders/master-adoc.js +168 -0
  29. package/dist/loaders/master-adoc.js.map +1 -0
  30. package/dist/loaders/plain.d.ts +3 -0
  31. package/dist/loaders/plain.d.ts.map +1 -0
  32. package/dist/loaders/plain.js +61 -0
  33. package/dist/loaders/plain.js.map +1 -0
  34. package/dist/loaders/types.d.ts +88 -0
  35. package/dist/loaders/types.d.ts.map +1 -0
  36. package/dist/loaders/types.js +2 -0
  37. package/dist/loaders/types.js.map +1 -0
  38. package/dist/loaders/util.d.ts +15 -0
  39. package/dist/loaders/util.d.ts.map +1 -0
  40. package/dist/loaders/util.js +49 -0
  41. package/dist/loaders/util.js.map +1 -0
  42. package/dist/parse.d.ts +110 -0
  43. package/dist/parse.d.ts.map +1 -0
  44. package/dist/parse.js +116 -0
  45. package/dist/parse.js.map +1 -0
  46. package/dist/tree.d.ts +2 -0
  47. package/dist/tree.d.ts.map +1 -0
  48. package/dist/tree.js +2 -0
  49. package/dist/tree.js.map +1 -0
  50. package/dist/walker.d.ts +8 -0
  51. package/dist/walker.d.ts.map +1 -0
  52. package/dist/walker.js +193 -0
  53. package/dist/walker.js.map +1 -0
  54. package/package.json +53 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"master-adoc.js","sourceRoot":"","sources":["../../src/loaders/master-adoc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQvE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,SAAS,eAAe,CACtB,GAAW,EACX,MAAgB,EAAE;IAElB,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YACxC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;A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,CAAC,CAAC;gBACL,CAAC;gBACD,WAAW,CAAC,IAAI,CAAC;oBACf,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACnC,IAAI,EAAE,GAAG,UAAU,IAAI,IAAI,EAAE;iBAC9B,CAAC,CAAC;YACL,CAAC;YAED,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;QAC/D,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACvC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IACnC,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CorpusLoader } from "./types.js";
2
+ export declare const plainLoader: CorpusLoader;
3
+ //# sourceMappingURL=plain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plain.d.ts","sourceRoot":"","sources":["../../src/loaders/plain.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAwC,MAAM,YAAY,CAAC;AAqBrF,eAAO,MAAM,WAAW,EAAE,YAmCzB,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Plain corpus loader — walks every `.adoc` under the source dir
3
+ * and treats directory structure as nav. The MVP / default loader;
4
+ * also the fallback when no topology marker is present.
5
+ *
6
+ * Lineage: this logic used to live inline in `cli.ts` (Phase 8a).
7
+ * Phase 9a extracted it behind the CorpusLoader contract so other
8
+ * loaders (master-adoc, asciibinder, antora) can sit alongside it.
9
+ */
10
+ import { existsSync, readdirSync, statSync } from "node:fs";
11
+ import { basename, join, relative } from "node:path";
12
+ import { buildNavFromDirectoryMirror, prettifyName } from "./util.js";
13
+ function walkAdocFiles(dir, root, out = []) {
14
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
15
+ const full = join(dir, entry.name);
16
+ if (entry.isDirectory()) {
17
+ walkAdocFiles(full, root, out);
18
+ }
19
+ else if (entry.name.endsWith(".adoc")) {
20
+ const rel = relative(root, full).replace(/\\/g, "/");
21
+ const slug = rel.replace(/\.adoc$/, "");
22
+ out.push({ filePath: full, slug });
23
+ }
24
+ }
25
+ return out;
26
+ }
27
+ export const plainLoader = {
28
+ name: "plain",
29
+ detect(sourceDir) {
30
+ if (!existsSync(sourceDir))
31
+ return false;
32
+ try {
33
+ const st = statSync(sourceDir);
34
+ if (!st.isDirectory())
35
+ return false;
36
+ const entries = readdirSync(sourceDir, { recursive: true });
37
+ return entries.some((e) => e.endsWith(".adoc"));
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ },
43
+ async load(sourceDir, opts) {
44
+ if (!existsSync(sourceDir)) {
45
+ throw new Error(`Source directory not found: ${sourceDir}`);
46
+ }
47
+ const st = statSync(sourceDir);
48
+ if (!st.isDirectory()) {
49
+ throw new Error(`Source must be a directory: ${sourceDir}`);
50
+ }
51
+ const hrefPrefix = opts.hrefPrefix ?? "";
52
+ const files = walkAdocFiles(sourceDir, sourceDir);
53
+ const pages = files.map((f) => ({
54
+ filePath: f.filePath,
55
+ slug: f.slug,
56
+ }));
57
+ const nav = buildNavFromDirectoryMirror(pages.map((p) => ({ slug: p.slug, title: prettifyName(basename(p.slug)) })), hrefPrefix);
58
+ return { pages, nav };
59
+ },
60
+ };
61
+ //# sourceMappingURL=plain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plain.js","sourceRoot":"","sources":["../../src/loaders/plain.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtE,SAAS,aAAa,CACpB,GAAW,EACX,IAAY,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AC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,IAAgB;QAC5C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAClD,MAAM,KAAK,GAAiB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5C,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,IAAI,EAAE,CAAC,CAAC,IAAI;SACb,CAAC,CAAC,CAAC;QACJ,MAAM,GAAG,GAAG,2BAA2B,CACrC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAC3E,UAAU,CACX,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IACxB,CAAC;CACF,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * CorpusLoader contract — Phase 9a.
3
+ *
4
+ * AsciiDoc corpora come in distinct topology shapes:
5
+ *
6
+ * - **plain** (Phase 9a) — flat .adoc walk; directory mirrors nav.
7
+ * - **master-adoc** (Phase 9a) — AAP convention: each `master.adoc`
8
+ * is a title; its include:: chain
9
+ * defines the module ordering.
10
+ * - **asciibinder** (Phase 9b) — `_topic_maps/_topic_map.yml` +
11
+ * distros (OpenShift).
12
+ * - **antora** (Phase 9c) — `antora-playbook.yml` + per-component
13
+ * `antora.yml` (version axis maps to
14
+ * Dogsbay's version axis).
15
+ *
16
+ * Each loader is a thin enumerator: discover the corpus, decide which
17
+ * .adoc files become pages, propose a nav. Loaders do NOT parse —
18
+ * `cli.ts` runs `parseAsciidocToTree` on each `PageSource.filePath`.
19
+ * Keeping the split clean means loaders can be tested in isolation
20
+ * against their topology fixtures without depending on the full
21
+ * markdown-it pipeline.
22
+ *
23
+ * See plans/asciidoc-corpus-loaders.md for the four-loader rollout
24
+ * + axis-translation bridge spec.
25
+ */
26
+ import type { NavItem } from "@dogsbay/types";
27
+ export interface PageSource {
28
+ /** Absolute filesystem path to the .adoc file. */
29
+ filePath: string;
30
+ /**
31
+ * URL slug for this page (e.g. `"guides/install"`). The cli's
32
+ * caller is free to prepend its own hrefPrefix when emitting.
33
+ */
34
+ slug: string;
35
+ /**
36
+ * AsciiDoc `:leveloffset:` adjustment if the loader's topology
37
+ * implies one (master.adoc includes carry `leveloffset=+1`, etc.).
38
+ * Engine handles the actual offset; loader just declares it.
39
+ */
40
+ leveloffset?: number;
41
+ /**
42
+ * Per-page attribute context contributed by the loader's topology
43
+ * (AAP `_attributes/attributes.adoc`, Antora component attributes,
44
+ * AsciiBinder distro filters). Merged onto the global attributes
45
+ * passed to the engine + Minja.
46
+ */
47
+ attributes?: Record<string, unknown>;
48
+ }
49
+ export interface LoaderOpts {
50
+ /**
51
+ * URL prefix to apply when building nav hrefs. The CLI fills this
52
+ * in from the consumer site's section mount; loaders just append
53
+ * `/<slug>` after.
54
+ */
55
+ hrefPrefix?: string;
56
+ }
57
+ export interface LoaderResult {
58
+ pages: PageSource[];
59
+ nav: NavItem[];
60
+ /**
61
+ * Optional list of distro names declared by the corpus (AsciiBinder
62
+ * `_distro_map.yml` or topic-level `Distros:` aggregation). Surfaced
63
+ * for forward-compatibility with distro-axis emission per the
64
+ * "axis translation" bridge spec in plans/asciidoc-corpus-loaders.md.
65
+ * Today's callers don't consume it; the data is informational only.
66
+ */
67
+ distros?: string[];
68
+ }
69
+ export interface CorpusLoader {
70
+ /** Identifier surfaced via the CLI's `--loader <name>` override. */
71
+ name: "plain" | "asciibinder" | "master-adoc" | "antora";
72
+ /**
73
+ * Heuristic detection: does this directory look like this corpus
74
+ * shape? Detection is best-effort; the CLI's `--loader` override
75
+ * always wins. detect() must NOT throw — return false on any
76
+ * unexpected state.
77
+ */
78
+ detect(sourceDir: string): boolean;
79
+ /**
80
+ * Enumerate pages + build nav. Loaders may walk the filesystem,
81
+ * read topology files (`master.adoc`, `_topic_map.yml`,
82
+ * `antora.yml`), and resolve includes. They MUST NOT parse the
83
+ * `.adoc` body — that's `cli.ts`'s job, per the separation in
84
+ * the plan.
85
+ */
86
+ load(sourceDir: string, opts: LoaderOpts): Promise<LoaderResult>;
87
+ }
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/loaders/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,GAAG,EAAE,OAAO,EAAE,CAAC;IACf;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,aAAa,GAAG,QAAQ,CAAC;IACzD;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAClE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/loaders/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { NavItem } from "@dogsbay/types";
2
+ export declare function prettifyName(slug: string): string;
3
+ /**
4
+ * Compose a nav tree that mirrors an on-disk directory layout from
5
+ * a flat list of `{ slug, title }` pages. Subdirectories become
6
+ * NavItem groups; leaves are `{ label, href: <hrefPrefix>/<slug> }`.
7
+ *
8
+ * Shared between the plain loader and (with topology overlay) the
9
+ * master-adoc loader's per-title grouping.
10
+ */
11
+ export declare function buildNavFromDirectoryMirror(pages: {
12
+ slug: string;
13
+ title: string;
14
+ }[], hrefPrefix: string): NavItem[];
15
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/loaders/util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,EACxC,UAAU,EAAE,MAAM,GACjB,OAAO,EAAE,CA6BX"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Shared utilities for the corpus loaders.
3
+ */
4
+ import { basename, dirname } from "node:path";
5
+ export function prettifyName(slug) {
6
+ return slug
7
+ .split(/[-_]/)
8
+ .filter(Boolean)
9
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
10
+ .join(" ");
11
+ }
12
+ /**
13
+ * Compose a nav tree that mirrors an on-disk directory layout from
14
+ * a flat list of `{ slug, title }` pages. Subdirectories become
15
+ * NavItem groups; leaves are `{ label, href: <hrefPrefix>/<slug> }`.
16
+ *
17
+ * Shared between the plain loader and (with topology overlay) the
18
+ * master-adoc loader's per-title grouping.
19
+ */
20
+ export function buildNavFromDirectoryMirror(pages, hrefPrefix) {
21
+ const groups = new Map();
22
+ groups.set("", []);
23
+ for (const page of pages) {
24
+ const dir = dirname(page.slug);
25
+ const key = dir === "." ? "" : dir;
26
+ if (!groups.has(key))
27
+ groups.set(key, []);
28
+ groups.get(key).push({
29
+ label: page.title,
30
+ href: `${hrefPrefix}/${page.slug}`,
31
+ });
32
+ }
33
+ // Wrap each non-root directory as a group under its parent —
34
+ // deepest-first so child groups exist when parents wrap them.
35
+ const sortedKeys = [...groups.keys()].sort((a, b) => b.split("/").length - a.split("/").length);
36
+ for (const key of sortedKeys) {
37
+ if (key === "")
38
+ continue;
39
+ const parent = dirname(key) === "." ? "" : dirname(key);
40
+ if (!groups.has(parent))
41
+ groups.set(parent, []);
42
+ groups.get(parent).push({
43
+ label: prettifyName(basename(key)),
44
+ children: groups.get(key),
45
+ });
46
+ }
47
+ return groups.get("");
48
+ }
49
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/loaders/util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,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CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CACpD,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,GAAG,KAAK,EAAE;YAAE,SAAS;QACzB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,IAAI,CAAC;YACvB,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAClC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;SAC3B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * AsciiDoc → TreeNode pipeline.
3
+ *
4
+ * Three composable stages, each independently testable:
5
+ *
6
+ * 1. @dogsbay/adoc2md-modular — AsciiDoc → Markdown-with-Minja-directives.
7
+ * Pure syntactic translation. The engine emits `{{ name }}` for
8
+ * attribute refs, `{% if name %}` for conditionals, `{% include %}`
9
+ * for include::, `{% set name = "value" %}` for in-doc :name: entries.
10
+ * 2. @dogsbay/minja — resolve directives against the
11
+ * attribute context. undefinedBehavior: "preserve" lets unresolved
12
+ * attrs / conditionals survive into the markdown so a downstream
13
+ * pass can finish the job.
14
+ * 3. markdown-it + walker — Markdown → Token[] → TreeNode[].
15
+ * Each format-X package owns its own walker per the convention
16
+ * (see plans/format-asciidoc-import.md Phase 6).
17
+ *
18
+ * Notably we do NOT register markdown-it-attrs here. The engine emits
19
+ * `{id="…"}` after headings (from AsciiDoc `[id="…"]` block anchors)
20
+ * and md-attrs would consume those — but it would also consume any
21
+ * trailing `{% endif %}` / `{{ var }}` at the end of a paragraph as a
22
+ * malformed attribute block, dropping the directive and breaking the
23
+ * build-time preprocessor pass. md2md sidestepped this by fully
24
+ * resolving Nunjucks at convert time (single-pass), so no directives
25
+ * survived to collide. We support a two-pass model (migrate-asciidoc
26
+ * preserves directives so the build-time preprocessor can substitute
27
+ * later from config), which means the directives ARE present when
28
+ * markdown-it tokenises. So we leave md-attrs out of this stage and
29
+ * let `extractHeadings` (cli.ts) parse `{id="…"}` / `{#anchor}`
30
+ * trailers out of heading text manually — a localised concern that
31
+ * doesn't risk eating directives in paragraph content. md-attrs runs
32
+ * at Astro render time, after the preprocessor has resolved
33
+ * directives, where the collision can't happen.
34
+ *
35
+ * See plans/format-asciidoc-import.md for the full architecture rationale.
36
+ */
37
+ import type MarkdownIt from "markdown-it";
38
+ import type { TreeNode } from "@dogsbay/types";
39
+ export interface ParseAsciidocOptions {
40
+ /**
41
+ * Filesystem path of the source `.adoc` file. Used as the base for
42
+ * `include::` directive resolution (both at AsciiDoc convert time
43
+ * via adoc2md-modular's `basePath` AND at Minja resolution time
44
+ * for the same directive after conversion). Optional; without it
45
+ * includes won't resolve, but unresolved `{% include %}` directives
46
+ * are preserved as text per Minja's `undefinedBehavior: "preserve"`.
47
+ */
48
+ filePath?: string;
49
+ /**
50
+ * AsciiDoc attribute values. Surfaces in two places:
51
+ * - `adoc2md-modular`'s `attributes` option (mostly a no-op today —
52
+ * the engine emits `{{ name }}` for everything anyway).
53
+ * - Minja's render context — this is where the actual substitution
54
+ * happens. Any `{{ name }}` whose `name` is in this map gets
55
+ * resolved; the rest are preserved.
56
+ */
57
+ attributes?: Record<string, unknown>;
58
+ /**
59
+ * Caller-supplied env values merged into the markdown-it env object.
60
+ * Available to plugins; format-asciidoc itself doesn't read from env.
61
+ */
62
+ envOverrides?: Record<string, unknown>;
63
+ }
64
+ /**
65
+ * Parse an AsciiDoc source string into TreeNode[].
66
+ *
67
+ * Async because Minja's renderer is async (handles I/O for includes
68
+ * and supports timeout enforcement).
69
+ *
70
+ * Mirrors `parseToTree` from `format-mkdocs` in shape: takes a
71
+ * markdown-it instance + source, returns `{ tree, env }`.
72
+ */
73
+ export declare function parseAsciidocToTree(md: MarkdownIt, src: string, opts?: ParseAsciidocOptions): Promise<{
74
+ tree: TreeNode[];
75
+ env: Record<string, unknown>;
76
+ /**
77
+ * Raw engine output — `asciidocToMarkdown(src)` — before any
78
+ * Minja evaluation, before markdown-it tokenisation. The most
79
+ * faithful possible markdown rendition of the AsciiDoc source:
80
+ *
81
+ * - `{% set %}` directives intact (build-time preprocessor
82
+ * evaluates them when it has the attribute context).
83
+ * - `{% include %}` directives intact (not inlined here —
84
+ * build-time preprocessor handles inclusion against the
85
+ * resolved attribute context).
86
+ * - `{%- if %}` directives with whitespace-control intact
87
+ * (`-` stripping fires at *resolution* time, not parse
88
+ * time; preserving it keeps the migrated file rendering
89
+ * identically to the original `.adoc` once a real build
90
+ * resolves the conditionals).
91
+ * - `{{ var }}` references intact, regardless of whether
92
+ * `opts.attributes` supplied a value.
93
+ *
94
+ * Surfaced for `migrate-asciidoc`'s benefit: writing this to disk
95
+ * preserves the line structure of the original `.adoc` (each
96
+ * `ifdef`/`endif` block on its own line, blank lines between
97
+ * major blocks). Running Minja at migrate time would collapse
98
+ * lines (`-` trim fuses adjacent lines), consume `{% set %}`
99
+ * metadata, and inline `{% include %}` content — all undesirable
100
+ * for editable source.
101
+ *
102
+ * The `tree` field is the post-Minja-preserve, fully-parsed
103
+ * TreeNode shape — that's what the runtime path (format-astro
104
+ * emit, direct `from: asciidoc` builds) consumes. The two
105
+ * fields exist for two different downstream consumers; they're
106
+ * NOT derived from each other.
107
+ */
108
+ intermediateMd: string;
109
+ }>;
110
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,UAAU,EACd,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC;IACT,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CAgED"}
package/dist/parse.js ADDED
@@ -0,0 +1,116 @@
1
+ import { dirname } from "node:path";
2
+ import { asciidocToMarkdown } from "@dogsbay/adoc2md-modular";
3
+ import { render as minjaRender, FileSystemLoader } from "@dogsbay/minja";
4
+ import { tokensToTree } from "./walker.js";
5
+ /**
6
+ * Parse an AsciiDoc source string into TreeNode[].
7
+ *
8
+ * Async because Minja's renderer is async (handles I/O for includes
9
+ * and supports timeout enforcement).
10
+ *
11
+ * Mirrors `parseToTree` from `format-mkdocs` in shape: takes a
12
+ * markdown-it instance + source, returns `{ tree, env }`.
13
+ */
14
+ export async function parseAsciidocToTree(md, src, opts = {}) {
15
+ // Stage 1 — AsciiDoc → Markdown-with-Minja-directives.
16
+ const intermediateMd = asciidocToMarkdown(src, {
17
+ attributes: opts.attributes,
18
+ basePath: opts.filePath,
19
+ });
20
+ // Stage 2 — resolve Minja directives. Preserve mode means unresolved
21
+ // refs survive as literal `{{ name }}` / `{% if … %}` text in the
22
+ // output. That text passes through markdown-it as part of the
23
+ // surrounding paragraph; the consumer can re-render with a richer
24
+ // context later if needed.
25
+ //
26
+ // basePath is the file's DIRECTORY (not the file itself) so
27
+ // Minja's FileSystemLoader can join relative `{% include %}`
28
+ // targets correctly. Earlier passes used `opts.filePath` directly,
29
+ // which produced ENOTDIR errors trying to treat the .adoc file as
30
+ // a directory.
31
+ //
32
+ // We wrap the render call in try/catch so that a Minja parse
33
+ // error (e.g. hyphenated identifiers in `{% if product-version %}`,
34
+ // which Minja's expression grammar doesn't accept) doesn't abort
35
+ // the entire import. Fall back to the engine output unchanged —
36
+ // every surviving directive lives on as literal text in the
37
+ // markdown, matching `preserve` mode's intent for whole-block
38
+ // failures the same way it handles single-variable failures. We
39
+ // log a warning so the user knows why some directives didn't
40
+ // resolve.
41
+ const basePath = opts.filePath ? dirname(opts.filePath) : "";
42
+ let resolvedMd;
43
+ try {
44
+ resolvedMd = await minjaRender(intermediateMd, {
45
+ context: opts.attributes ?? {},
46
+ undefinedBehavior: "preserve",
47
+ hyphenToUnderscore: true,
48
+ basePath,
49
+ loader: new FileSystemLoader(),
50
+ });
51
+ }
52
+ catch (err) {
53
+ const msg = err instanceof Error ? err.message : String(err);
54
+ const where = opts.filePath ? ` in ${opts.filePath}` : "";
55
+ console.warn(`asciidoc parse: Minja render failed${where}, preserving raw directives (${msg})`);
56
+ resolvedMd = intermediateMd;
57
+ }
58
+ // Stage 3 — markdown-it parse + walker.
59
+ const env = { ...(opts.envOverrides ?? {}) };
60
+ const tokens = md.parse(resolvedMd, env);
61
+ const tree = flattenProseWrappers(tokensToTree(tokens));
62
+ // `intermediateMd` is the RAW engine output — pre-Minja,
63
+ // pre-markdown-it. The faithful AsciiDoc → markdown
64
+ // translation. migrate-asciidoc writes this to disk so all
65
+ // `{% set %}` / `{% include %}` / `{%- if %}` directives
66
+ // survive verbatim for the build-time preprocessor to handle.
67
+ // (Returning `resolvedMd` here would consume `{% set %}` lines,
68
+ // inline `{% include %}` content, and fuse lines via `{%-`
69
+ // whitespace control — all wrong for editable migrated source.)
70
+ // The `tree` is parsed from the Minja-resolved form (`resolvedMd`)
71
+ // for accurate runtime rendering when used directly via
72
+ // `from: asciidoc` — a separate consumer with separate needs.
73
+ return { tree, env, intermediateMd };
74
+ }
75
+ /**
76
+ * Normalise the walker's "wrapped" shape into the "flat" shape that
77
+ * every other TreeNode consumer expects.
78
+ *
79
+ * The format-mkdocs walker (which we inherit) wraps inline content
80
+ * of heading / paragraph / list-item / dt / dd nodes in a single
81
+ * `{type:"prose", inline: [...]}` child instead of attaching
82
+ * `inline` directly to the parent. format-dogsbay-md's serializer
83
+ * and most downstream consumers read `node.inline`; lifting the
84
+ * inline up here means every consumer sees a single canonical shape
85
+ * and we don't have to thread cross-shape tolerance through every
86
+ * call site.
87
+ *
88
+ * Recursive — handles nested blocks (e.g. list_item containing a
89
+ * paragraph).
90
+ */
91
+ function flattenProseWrappers(nodes) {
92
+ const FLATTENABLE = new Set([
93
+ "heading",
94
+ "paragraph",
95
+ "list_item",
96
+ "dt",
97
+ "dd",
98
+ ]);
99
+ return nodes.map((node) => {
100
+ let out = node;
101
+ if (FLATTENABLE.has(node.type) &&
102
+ Array.isArray(node.children) &&
103
+ node.children.length === 1 &&
104
+ node.children[0].type === "prose" &&
105
+ Array.isArray(node.children[0].inline)) {
106
+ const prose = node.children[0];
107
+ out = { ...node, inline: prose.inline };
108
+ delete out.children;
109
+ }
110
+ else if (Array.isArray(node.children)) {
111
+ out = { ...node, children: flattenProseWrappers(node.children) };
112
+ }
113
+ return out;
114
+ });
115
+ }
116
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,OAAO,EAA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AC,QAAQ,CAAC,MAAM,KAAK,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAc,CAAC,IAAI,KAAK,OAAO;YAC/C,KAAK,CAAC,OAAO,CAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAc,CAAC,MAAM,CAAC,EACpD,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAa,CAAC;YAC3C,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAA4B,EAAE,CAAC;YAC9D,OAAQ,GAA8B,CAAC,QAAQ,CAAC;QAClD,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC,QAAsB,CAAC,EAAE,CAAC;QACjF,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/tree.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export type { TreeNode } from "@dogsbay/types";
2
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/tree.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type Token from "markdown-it/lib/token.mjs";
2
+ import type { TreeNode } from "./tree.js";
3
+ /**
4
+ * Convert a markdown-it token stream into a TreeNode[].
5
+ * Handles open/close token pairs by recursively collecting children.
6
+ */
7
+ export declare function tokensToTree(tokens: Token[]): TreeNode[];
8
+ //# sourceMappingURL=walker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walker.d.ts","sourceRoot":"","sources":["../src/walker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG1C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAkCxD"}