@dogsbay/format-dogsbay-md 0.2.0-beta.11 → 0.2.0-beta.111

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 (88) hide show
  1. package/dist/attributes.d.ts +16 -1
  2. package/dist/attributes.d.ts.map +1 -1
  3. package/dist/attributes.js +14 -2
  4. package/dist/attributes.js.map +1 -1
  5. package/dist/browser.d.ts +22 -0
  6. package/dist/browser.d.ts.map +1 -0
  7. package/dist/browser.js +21 -0
  8. package/dist/browser.js.map +1 -0
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +206 -27
  11. package/dist/cli.js.map +1 -1
  12. package/dist/code-regions.d.ts +89 -0
  13. package/dist/code-regions.d.ts.map +1 -0
  14. package/dist/code-regions.js +215 -0
  15. package/dist/code-regions.js.map +1 -0
  16. package/dist/directive-guard.d.ts +11 -0
  17. package/dist/directive-guard.d.ts.map +1 -0
  18. package/dist/directive-guard.js +16 -0
  19. package/dist/directive-guard.js.map +1 -0
  20. package/dist/directive-preserve.d.ts +66 -0
  21. package/dist/directive-preserve.d.ts.map +1 -0
  22. package/dist/directive-preserve.js +410 -0
  23. package/dist/directive-preserve.js.map +1 -0
  24. package/dist/directives.js +23 -1
  25. package/dist/directives.js.map +1 -1
  26. package/dist/escape.d.ts +46 -3
  27. package/dist/escape.d.ts.map +1 -1
  28. package/dist/escape.js +83 -26
  29. package/dist/escape.js.map +1 -1
  30. package/dist/frontmatter.d.ts +12 -0
  31. package/dist/frontmatter.d.ts.map +1 -0
  32. package/dist/frontmatter.js +67 -0
  33. package/dist/frontmatter.js.map +1 -0
  34. package/dist/headings.d.ts +50 -0
  35. package/dist/headings.d.ts.map +1 -0
  36. package/dist/headings.js +116 -0
  37. package/dist/headings.js.map +1 -0
  38. package/dist/index.d.ts +7 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +6 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/inline.d.ts +0 -3
  43. package/dist/inline.d.ts.map +1 -1
  44. package/dist/inline.js +221 -7
  45. package/dist/inline.js.map +1 -1
  46. package/dist/minja-mask.d.ts +64 -0
  47. package/dist/minja-mask.d.ts.map +1 -0
  48. package/dist/minja-mask.js +128 -0
  49. package/dist/minja-mask.js.map +1 -0
  50. package/dist/nav-file.d.ts +26 -3
  51. package/dist/nav-file.d.ts.map +1 -1
  52. package/dist/nav-file.js +84 -12
  53. package/dist/nav-file.js.map +1 -1
  54. package/dist/nav.d.ts +7 -0
  55. package/dist/nav.d.ts.map +1 -1
  56. package/dist/nav.js +14 -2
  57. package/dist/nav.js.map +1 -1
  58. package/dist/parse.d.ts +12 -1
  59. package/dist/parse.d.ts.map +1 -1
  60. package/dist/parse.js +428 -14
  61. package/dist/parse.js.map +1 -1
  62. package/dist/plugin-containers.d.ts +1 -1
  63. package/dist/plugin-containers.d.ts.map +1 -1
  64. package/dist/plugin-containers.js +22 -1
  65. package/dist/plugin-containers.js.map +1 -1
  66. package/dist/plugin-math.d.ts +23 -0
  67. package/dist/plugin-math.d.ts.map +1 -0
  68. package/dist/plugin-math.js +91 -0
  69. package/dist/plugin-math.js.map +1 -0
  70. package/dist/renderers/diagrams.d.ts +25 -0
  71. package/dist/renderers/diagrams.d.ts.map +1 -0
  72. package/dist/renderers/diagrams.js +71 -0
  73. package/dist/renderers/diagrams.js.map +1 -0
  74. package/dist/renderers/mermaid.d.ts +24 -0
  75. package/dist/renderers/mermaid.d.ts.map +1 -0
  76. package/dist/renderers/mermaid.js +135 -0
  77. package/dist/renderers/mermaid.js.map +1 -0
  78. package/dist/serialize.d.ts +1 -1
  79. package/dist/serialize.d.ts.map +1 -1
  80. package/dist/serialize.js +352 -37
  81. package/dist/serialize.js.map +1 -1
  82. package/dist/types.d.ts.map +1 -1
  83. package/dist/types.js +18 -1
  84. package/dist/types.js.map +1 -1
  85. package/dist/yaml.d.ts.map +1 -1
  86. package/dist/yaml.js +6 -0
  87. package/dist/yaml.js.map +1 -1
  88. package/package.json +20 -11
@@ -8,12 +8,27 @@
8
8
  export interface RenderedAttrs {
9
9
  id?: string;
10
10
  classes?: string[];
11
- props?: Record<string, string | number | boolean | undefined>;
11
+ /**
12
+ * Props captured from `TreeNode.props`. Primitive values (string,
13
+ * number, boolean) round-trip through inline `{key="value"}` form.
14
+ * Arrays / plain objects are preserved here too — `renderAttrs`
15
+ * skips them (inline form can't represent them) but the
16
+ * directive renderer's `shouldUseYaml` branch picks them up and
17
+ * routes the directive to YAML body form, where complex values
18
+ * survive intact.
19
+ */
20
+ props?: Record<string, unknown>;
12
21
  }
13
22
  /**
14
23
  * Render an attribute block.
15
24
  * Returns `{ #id .a .b key="value" }` or "" if no attrs.
16
25
  * Leading space included so callers can append directly to content.
26
+ *
27
+ * Inline form can only carry primitive values. Arrays / objects in
28
+ * `props` are silently skipped here — the caller is expected to have
29
+ * already routed those to YAML body form (see `shouldUseYaml` in
30
+ * directives.ts). If a non-primitive does reach this point, dropping
31
+ * it is the safest fallback (there's no inline syntax for it).
17
32
  */
18
33
  export declare function renderAttrs(attrs: RenderedAttrs): string;
19
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC/D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CA0BxD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC1C,WAAW,GAAE,MAAM,EAAO,GACzB,aAAa,CA8Bf"}
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CA6BxD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC1C,WAAW,GAAE,MAAM,EAAO,GACzB,aAAa,CAiCf"}
@@ -9,6 +9,12 @@
9
9
  * Render an attribute block.
10
10
  * Returns `{ #id .a .b key="value" }` or "" if no attrs.
11
11
  * Leading space included so callers can append directly to content.
12
+ *
13
+ * Inline form can only carry primitive values. Arrays / objects in
14
+ * `props` are silently skipped here — the caller is expected to have
15
+ * already routed those to YAML body form (see `shouldUseYaml` in
16
+ * directives.ts). If a non-primitive does reach this point, dropping
17
+ * it is the safest fallback (there's no inline syntax for it).
12
18
  */
13
19
  export function renderAttrs(attrs) {
14
20
  const parts = [];
@@ -29,6 +35,10 @@ export function renderAttrs(attrs) {
29
35
  parts.push(key);
30
36
  continue;
31
37
  }
38
+ // Skip arrays / plain objects — inline form can't represent
39
+ // them. They survive via the YAML body branch upstream.
40
+ if (typeof value === "object")
41
+ continue;
32
42
  parts.push(`${key}=${escapeAttrValue(String(value))}`);
33
43
  }
34
44
  }
@@ -71,8 +81,10 @@ export function splitProps(props, excludeKeys = []) {
71
81
  }
72
82
  if (value === null || value === undefined)
73
83
  continue;
74
- if (typeof value === "object")
75
- continue; // skip nested structures
84
+ // Pass arrays / objects through. Inline-form rendering will skip
85
+ // them (`renderAttrs`); YAML-body rendering preserves them
86
+ // (`attrsToYaml`). The `shouldUseYaml` heuristic in directives.ts
87
+ // detects their presence and routes the directive accordingly.
76
88
  cleanProps[key] = value;
77
89
  }
78
90
  if (Object.keys(cleanProps).length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAoB;IAC9C,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;QACb,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,GAAG;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACvD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK;gBAAE,SAAS;YACvE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAChB,SAAS;YACX,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,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K,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC;YAClB,SAAS;QACX,CAAC;QAED,IAAI,CAAC,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,WAAW,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC1E,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACpD,SAAS;QACX,CAAC;QAED,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QACpD,iEAAiE;QACjE,2DAA2D;QAC3D,kEAAkE;QAClE,+DAA+D;QAC/D,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Browser-safe entry point — the pure TreeNode round-trip and text
3
+ * helpers, with NO `node:fs` in the module graph.
4
+ *
5
+ * The main barrel (`.`) re-exports nav / nav-file / mermaid, which
6
+ * import `node:fs` at module load and so break browser/extension
7
+ * bundling. Consumers that only need parse/serialize (the editing
8
+ * engine, extension contexts) import from `@dogsbay/format-dogsbay-md/browser`
9
+ * instead. `parse.ts` and `serialize.ts` transit only browser-safe deps
10
+ * (markdown-it, js-yaml). Frontmatter is split by the local `frontmatter.ts`
11
+ * (js-yaml only) rather than gray-matter, whose entry `require('fs')`s at
12
+ * module load and would drag `node:fs` back into this graph.
13
+ */
14
+ export { dogsbayMdToTree, parseInline, type ParseResult, type ParseOptions } from "./parse.js";
15
+ export { treeToDogsbayMd, nodeToDogsbayMd } from "./serialize.js";
16
+ export type { SerializeOptions } from "./types.js";
17
+ export { inlineToDogsbayMd } from "./inline.js";
18
+ export { transformCodeRegions, transformProseLines, transformProseSegments, fenceOpenBefore, createFenceTracker, } from "./code-regions.js";
19
+ export { maskMinjaInCode, unmaskMinjaInCode, maskAllMinjaOpeners, isMinjaProcessedFence, stripInlineMinjaMarkers, stripFenceMinjaMarkers } from "./minja-mask.js";
20
+ export { extractHeadings, slugifyHeadingText, type HeadingInfo } from "./headings.js";
21
+ export { splitFrontmatter, type Frontmatter } from "./frontmatter.js";
22
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAClK,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Browser-safe entry point — the pure TreeNode round-trip and text
3
+ * helpers, with NO `node:fs` in the module graph.
4
+ *
5
+ * The main barrel (`.`) re-exports nav / nav-file / mermaid, which
6
+ * import `node:fs` at module load and so break browser/extension
7
+ * bundling. Consumers that only need parse/serialize (the editing
8
+ * engine, extension contexts) import from `@dogsbay/format-dogsbay-md/browser`
9
+ * instead. `parse.ts` and `serialize.ts` transit only browser-safe deps
10
+ * (markdown-it, js-yaml). Frontmatter is split by the local `frontmatter.ts`
11
+ * (js-yaml only) rather than gray-matter, whose entry `require('fs')`s at
12
+ * module load and would drag `node:fs` back into this graph.
13
+ */
14
+ export { dogsbayMdToTree, parseInline } from "./parse.js";
15
+ export { treeToDogsbayMd, nodeToDogsbayMd } from "./serialize.js";
16
+ export { inlineToDogsbayMd } from "./inline.js";
17
+ export { transformCodeRegions, transformProseLines, transformProseSegments, fenceOpenBefore, createFenceTracker, } from "./code-regions.js";
18
+ export { maskMinjaInCode, unmaskMinjaInCode, maskAllMinjaOpeners, isMinjaProcessedFence, stripInlineMinjaMarkers, stripFenceMinjaMarkers } from "./minja-mask.js";
19
+ export { extractHeadings, slugifyHeadingText } from "./headings.js";
20
+ export { splitFrontmatter } from "./frontmatter.js";
21
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,eAAe,EAAE,WAAW,EAAuC,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAClK,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAoB,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC"}
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAgC,MAAM,gBAAgB,CAAC;AA2HjF,eAAO,MAAM,MAAM,EAAE,YAcpB,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAA8C,MAAM,gBAAgB,CAAC;AA6U/F,eAAO,MAAM,MAAM,EAAE,YAiBpB,CAAC"}
package/dist/cli.js CHANGED
@@ -4,11 +4,14 @@
4
4
  * Reads a directory of .md files, parses each via dogsbayMdToTree, builds nav
5
5
  * from directory structure + frontmatter, returns ExportPage[] + NavItem[].
6
6
  */
7
- import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
8
- import { join, relative, basename } from "node:path";
7
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
8
+ import { join, relative, basename, dirname } from "node:path";
9
+ import { extractHeadings } from "./headings.js";
9
10
  import { parseMeta } from "@dogsbay/types";
10
11
  import { dogsbayMdToTree } from "./parse.js";
12
+ import { treeToDogsbayMd } from "./serialize.js";
11
13
  import { buildNavFromDirectory } from "./nav.js";
14
+ import { renderDiagrams } from "./renderers/diagrams.js";
12
15
  /**
13
16
  * Detect whether a directory contains a Dogsbay MD source tree.
14
17
  *
@@ -30,15 +33,75 @@ function detectDogsbayMdSource(path) {
30
33
  return false;
31
34
  }
32
35
  }
36
+ /**
37
+ * Conventional content-asset roots, in probe order. Mounted under their own
38
+ * name so an author's `/images/logo.png` resolves, and excluded from the page
39
+ * walk so their contents are assets rather than also being pages.
40
+ */
41
+ const ASSET_ROOTS = ["images", "assets", "_assets"];
42
+ /**
43
+ * Does this directory hold any markdown, at any depth?
44
+ *
45
+ * Distinguishes a media-only asset root (skip it: its files are assets, and a
46
+ * stray .md would become both a page and a raw copy in public/) from a docs
47
+ * SECTION that merely shares the name (walk it: those are pages).
48
+ */
49
+ function containsMarkdown(dir) {
50
+ let entries;
51
+ try {
52
+ entries = readdirSync(dir, { withFileTypes: true });
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ for (const e of entries) {
58
+ if (e.isDirectory()) {
59
+ if (containsMarkdown(join(dir, e.name)))
60
+ return true;
61
+ }
62
+ else if (e.name.endsWith(".md")) {
63
+ return true;
64
+ }
65
+ }
66
+ return false;
67
+ }
33
68
  function walkMdFiles(dir, root, out = []) {
34
69
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
70
+ // `_`-prefixed files/dirs are include targets (fragments), not routable
71
+ // pages — the standard Jekyll/Docusaurus convention. The build-time Minja
72
+ // preprocessor `{% include %}`s them into pages; they get no route of their
73
+ // own. (e.g. structural Docusaurus import writes `_includes/**` fragments.)
74
+ if (entry.name.startsWith("_"))
75
+ continue;
76
+ // A conventional asset root carrying only media is not a page tree, and
77
+ // leaving it in the walk would make a stray .md there BOTH a routable
78
+ // page and a file copied verbatim into public/.
79
+ //
80
+ // But `images/` is also a perfectly ordinary section name. Skipping it
81
+ // unconditionally silently dropped every page under it — "Imported 1
82
+ // pages" where there were 2, no warning. So skip only a root that
83
+ // carries NO markdown at all, and only at the content root.
84
+ if (dir === root &&
85
+ ASSET_ROOTS.includes(entry.name) &&
86
+ !containsMarkdown(join(dir, entry.name))) {
87
+ continue;
88
+ }
35
89
  const full = join(dir, entry.name);
36
90
  if (entry.isDirectory()) {
37
91
  walkMdFiles(full, root, out);
38
92
  }
39
93
  else if (entry.name.endsWith(".md")) {
40
94
  const rel = relative(root, full).replace(/\\/g, "/");
41
- const slug = rel.replace(/\.md$/, "");
95
+ let slug = rel.replace(/\.md$/, "");
96
+ // A `<dir>/index.md` page is the directory's landing page: its slug
97
+ // is the directory, not `<dir>/index`. This MUST match how the nav
98
+ // layer normalizes the same file (nav-file.ts `fileToHref` strips
99
+ // `/index`), or `routablesFrom: nav`'s `filterPagesToNav` drops the
100
+ // page and the section landing 404s. The bare root `index.md` keeps
101
+ // slug `index` — format-astro's root-home + `.md`-mirror special-case
102
+ // keys off `slug === "index"`. See plans/dir-index-slug-nav-drop.md.
103
+ if (slug.endsWith("/index"))
104
+ slug = slug.slice(0, -"/index".length);
42
105
  out.push({ filePath: full, slug });
43
106
  }
44
107
  }
@@ -61,26 +124,31 @@ async function importDogsbayMd(source, opts) {
61
124
  const taxonomyNames = Array.isArray(opts.taxonomyNames)
62
125
  ? opts.taxonomyNames
63
126
  : undefined;
127
+ // Pre-parse pass — opt-out via `diagrams: false`. When enabled
128
+ // (default), `code` fences with `lang: mermaid` get transformed
129
+ // to `diagram` nodes with pre-rendered SVG. Fail-open: if mmdc
130
+ // (mermaid-cli) isn't installed the code block is left as-is and
131
+ // a one-line warning is printed. See plans/mermaid-dogsbay-md.md.
132
+ const diagramsOn = opts.diagrams !== false;
64
133
  for (const { filePath, slug } of files) {
65
134
  const content = readFileSync(filePath, "utf-8");
66
135
  const { tree, frontmatter } = dogsbayMdToTree(content);
136
+ if (diagramsOn) {
137
+ await renderDiagrams(tree);
138
+ }
67
139
  const title = String(frontmatter.title
68
140
  ?? prettifyName(basename(slug)));
69
- // Extract heading metadata for TOC
70
- const headings = [];
71
- for (const node of tree) {
72
- if (node.type === "heading" && node.inline) {
73
- const text = node.inline
74
- .map((n) => (n.type === "text" ? n.text : ""))
75
- .join("")
76
- .trim();
77
- headings.push({
78
- depth: node.props?.level ?? 1,
79
- slug: node.props?.slug ?? slugify(text),
80
- text,
81
- });
82
- }
83
- }
141
+ // Extract heading metadata for TOC AND backfill `node.props.slug`
142
+ // so format-astro's headingToAstro emits a matching `id` on the
143
+ // rendered `<h2>` / `<h3>`. Without this, the TOC's
144
+ // `<a href="#quick-start">` had nothing to scroll to — the
145
+ // heading was emitted without an id because the tree didn't
146
+ // carry the slug. Mirrors format-mkdocs/src/loader.ts:312.
147
+ //
148
+ // Duplicate slugs get `-1`, `-2` suffixes so two `## Foo`
149
+ // headings on the same page produce distinct anchors. Same
150
+ // collision-handling shape as MkDocs.
151
+ const headings = extractHeadings(tree);
84
152
  const redirect = frontmatter.redirect;
85
153
  const meta = parseMeta(frontmatter, { slug, taxonomyNames });
86
154
  pages.push({
@@ -95,8 +163,42 @@ async function importDogsbayMd(source, opts) {
95
163
  }
96
164
  const navFilePath = opts.nav || undefined;
97
165
  const hrefPrefix = typeof opts.hrefPrefix === "string" ? opts.hrefPrefix : undefined;
98
- const nav = buildNavFromDirectory(source, { navFilePath, hrefPrefix });
99
- return { pages, nav };
166
+ // `--strict` at the CLI layer maps to "fail" here. `loadNavFile`
167
+ // already throws on the first miss in fail mode; the build
168
+ // surfaces the throw as a fatal error and exits non-zero.
169
+ // See plans/site-build-strict.md.
170
+ const missingNavTargets = opts.missingNavTargets === "fail"
171
+ ? "fail"
172
+ : undefined;
173
+ const nav = buildNavFromDirectory(source, {
174
+ navFilePath,
175
+ hrefPrefix,
176
+ missingFile: missingNavTargets,
177
+ });
178
+ // Declare where this corpus's media lives, so an exporter copies the FILES
179
+ // that the `_assets/…` references in the pages point at.
180
+ //
181
+ // Without this the reference survives the conversion and the file does not,
182
+ // which looks exactly like success: the page count, the retention score and
183
+ // a clean exit are all unaffected while every image 404s. `dogsbay site
184
+ // build` has its own asset pass, so this was invisible there and only bit
185
+ // `convert` — an OpenShift vault shipped with 294 dead image references.
186
+ // Conventional asset roots, in probe order. `_assets` is what every
187
+ // importer rewrites its refs to and stays the documented convention
188
+ // (docs/images.md). Hand-authored content is not written by an
189
+ // importer, though: someone starting a site types `/images/logo.png`,
190
+ // which silently resolved nowhere because only `_assets` was probed.
191
+ //
192
+ // Each root that exists mounts under its OWN name, so the reference the
193
+ // author wrote is the path the file lands at. Recognising several costs
194
+ // nothing: an absent directory is simply not mounted.
195
+ const assetMounts = [];
196
+ for (const root of ASSET_ROOTS) {
197
+ const dir = join(source, root);
198
+ if (existsSync(dir))
199
+ assetMounts.push({ dir, root });
200
+ }
201
+ return assetMounts.length ? { pages, nav, assetMounts } : { pages, nav };
100
202
  }
101
203
  function prettifyName(slug) {
102
204
  return slug
@@ -104,17 +206,91 @@ function prettifyName(slug) {
104
206
  .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
105
207
  .join(" ");
106
208
  }
107
- function slugify(text) {
108
- return text
109
- .toLowerCase()
110
- .replace(/[^\w\s-]/g, "")
111
- .trim()
112
- .replace(/\s+/g, "-");
209
+ /**
210
+ * Export ExportPage[] + nav to a directory of Dogsbay-MD files.
211
+ *
212
+ * Each page's tree is serialized via `treeToDogsbayMd` (which preserves any
213
+ * Minja directives via `escapePreservingMinja`) and written to `<output>/<slug>.md`.
214
+ *
215
+ * Fragment pages (`page.fragment`) are include targets, not routable pages:
216
+ * written with NO frontmatter, NO title, and excluded from nav — their identity
217
+ * is the include path. Mirrors migrate-asciidoc's fragment convention so the
218
+ * build-time Minja preprocessor can `{% include %}` them.
219
+ */
220
+ /** Media files worth carrying into `_assets` from a media-only mount. */
221
+ const MEDIA_EXTS = new Set([
222
+ ".png", ".jpg", ".jpeg", ".gif", ".webp", ".avif",
223
+ ".svg", ".ico", ".pdf", ".mp4", ".webm",
224
+ ]);
225
+ /** Recursively copy only media files, preserving relative structure. */
226
+ function copyMediaTree(srcDir, destDir) {
227
+ for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
228
+ const full = join(srcDir, entry.name);
229
+ if (entry.isDirectory()) {
230
+ copyMediaTree(full, join(destDir, entry.name));
231
+ continue;
232
+ }
233
+ const dot = entry.name.lastIndexOf(".");
234
+ if (dot === -1 || !MEDIA_EXTS.has(entry.name.slice(dot).toLowerCase()))
235
+ continue;
236
+ mkdirSync(destDir, { recursive: true });
237
+ cpSync(full, join(destDir, entry.name));
238
+ }
239
+ }
240
+ async function exportDogsbayMd(pages, nav, output, opts) {
241
+ mkdirSync(output, { recursive: true });
242
+ // Copy mounted asset dirs (e.g. Docusaurus `static/`) into `content/_assets/`,
243
+ // the Dogsbay standard (docs/images.md). Preserves internal structure
244
+ // (static/img/x → <output>/_assets/img/x) so the parser's rewritten
245
+ // `/_assets/img/x` refs resolve, and a later `site build`'s asset pass copies
246
+ // `content/_assets/**` through to `/_assets/**`. A mount may target an
247
+ // `_assets` subdir (`into`) and restrict itself to media files (`mediaOnly`) —
248
+ // used for docs-co-located images where the mount dir IS the docs tree.
249
+ if (Array.isArray(opts.assetMounts)) {
250
+ for (const mount of opts.assetMounts) {
251
+ if (!existsSync(mount.dir))
252
+ continue;
253
+ // Per-mount root: `_assets` for an imported corpus, `images`/`assets`
254
+ // for hand-authored content. A hardcoded root would copy the file
255
+ // where the reference does not point.
256
+ const assetsRoot = join(output, mount.root ?? "_assets");
257
+ const dest = mount.into ? join(assetsRoot, mount.into) : assetsRoot;
258
+ if (mount.mediaOnly) {
259
+ copyMediaTree(mount.dir, dest);
260
+ continue;
261
+ }
262
+ const skip = new Set(mount.exclude ?? []);
263
+ cpSync(mount.dir, dest, {
264
+ recursive: true,
265
+ ...(skip.size === 0 ? {} : {
266
+ // Relative to the mount, so an exclusion cannot be accidentally
267
+ // satisfied by a directory name somewhere above it on disk.
268
+ filter: (src) => {
269
+ const rel = relative(mount.dir, src);
270
+ return rel === "" || !rel.split(/[\\/]/).some((seg) => skip.has(seg));
271
+ },
272
+ }),
273
+ });
274
+ }
275
+ }
276
+ for (const page of pages) {
277
+ const slug = page.slug || "index";
278
+ const outPath = join(output, `${slug}.md`);
279
+ mkdirSync(dirname(outPath), { recursive: true });
280
+ const frontmatter = page.fragment || !page.title
281
+ ? undefined
282
+ : { title: page.title, ...(page.redirect ? { redirect: page.redirect } : {}) };
283
+ const md = treeToDogsbayMd(page.tree, frontmatter ? { frontmatter } : undefined);
284
+ writeFileSync(outPath, md.endsWith("\n") ? md : md + "\n", "utf-8");
285
+ }
286
+ // Nav as nav.json at the content root (the dogsbay-md importer + runtime
287
+ // loader both prefer nav.json). Fragments never appear here.
288
+ writeFileSync(join(output, "nav.json"), JSON.stringify(nav, null, 2) + "\n", "utf-8");
113
289
  }
114
290
  export const plugin = {
115
291
  name: "dogsbay-md",
116
292
  canImport: true,
117
- canExport: false,
293
+ canExport: true,
118
294
  detectSource: detectDogsbayMdSource,
119
295
  importOptions: [
120
296
  {
@@ -125,5 +301,8 @@ export const plugin = {
125
301
  async import(source, opts) {
126
302
  return importDogsbayMd(source, opts);
127
303
  },
304
+ async export(pages, nav, output, opts) {
305
+ return exportDogsbayMd(pages, nav, output, opts);
306
+ },
128
307
  };
129
308
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,IAAY;IACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE;YAAE,OAAO,KAAK,CAAC;QACpC,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAa,CAAC;QACnE,OAAO,OAAO,CAAC,IAAI,CAAC,CA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,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACjF,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,yEAAyE;IACzE,6DAA6D;IAC7D,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAiB;IAClC,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,qBAAqB;IACnC,aAAa,EAAE;QACb;YACE,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,2IAA2I;SACzJ;KACF;IACD,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,IAA6B;QACxD,OAAO,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI;QACnC,OAAO,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;CACF,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Code-region walker — THE fence grammar shared by every tool that must
3
+ * treat code specially: the build preprocessor masks Minja openers
4
+ * inside code so template examples never evaluate, the workspace
5
+ * indexer blanks code so `{% include %}` examples never count as real
6
+ * includes, and the refactor commands edit only prose so code samples
7
+ * are never rewritten. One implementation, so none of them can drift.
8
+ *
9
+ * Fence rules (CommonMark): a fence opens with ``` or ~~~ (3+ chars,
10
+ * info string allowed) and closes only on a line of the SAME character
11
+ * with AT LEAST the opener's length and nothing but whitespace after —
12
+ * the serializer emits escalated fences (```` around content containing
13
+ * ```), so honoring the length rule is load-bearing. Fence-looking
14
+ * lines inside an open fence that don't close it are code content.
15
+ */
16
+ type LineKind = "prose" | "fence" | "code";
17
+ /** Context passed to a code transform: which fence the line belongs to. */
18
+ export interface CodeRegionContext {
19
+ /**
20
+ * Fence info string (e.g. `yaml {minja}`). For inline code spans:
21
+ * the markdown-it-attrs group immediately following the closing
22
+ * backticks when present (e.g. `{minja}` for `` `x`{minja} ``),
23
+ * empty otherwise — so `isMinjaProcessedFence` grades fences and
24
+ * marked inline spans with the same predicate.
25
+ */
26
+ fenceInfo: string;
27
+ }
28
+ /**
29
+ * Transform CODE content: every line inside a fence, and the inner
30
+ * content of inline code spans on prose lines (backticks kept). Fence
31
+ * marker lines themselves are untouched.
32
+ *
33
+ * `transformInlineAttrs` (optional) rewrites the attr group of an
34
+ * inline span at re-emission — return `""` to drop it. Only inline
35
+ * spans see it; fence info strings are never routed through it.
36
+ */
37
+ /**
38
+ * Line-by-line fence tracker on THE shared grammar — for tools that must
39
+ * walk a document themselves (the remote-include inliner) instead of
40
+ * transforming regions. A locally re-implemented open/close regex pair
41
+ * drifted immediately: it missed the deflist-hosted `: ```` opener the
42
+ * shared grammar just gained, took the indented closer for an opener,
43
+ * and re-created the exact phantom-fence inversion it was fixing
44
+ * (issue #039 review).
45
+ *
46
+ * step(line) returns what the line IS: "fence" (an opener or closer),
47
+ * "code" (content of an open fence), or "prose". open() reports the
48
+ * state AFTER the last step, so an opener steps "fence" with
49
+ * open()===true and its closer steps "fence" with open()===false.
50
+ */
51
+ export declare function createFenceTracker(): {
52
+ step(line: string): LineKind;
53
+ open(): boolean;
54
+ };
55
+ /**
56
+ * Transform only fence OPENING lines' info strings, on the same shared
57
+ * grammar — a fence-looking line inside an open fence is code content
58
+ * and is never touched. Used to strip the spent `{minja}` marker after
59
+ * the terminal Minja render (a fence marker that survives into the
60
+ * mirror leaks into serializers that round-trip fence info verbatim —
61
+ * the Obsidian vault showed literal ```` ```yaml {minja} ````).
62
+ */
63
+ export declare function transformFenceInfo(source: string, transform: (info: string) => string): string;
64
+ export declare function transformCodeRegions(source: string, transform: (codeText: string, ctx: CodeRegionContext) => string, transformInlineAttrs?: (attrs: string) => string): string;
65
+ /**
66
+ * The inverse walk: transform PROSE lines (outside fences), leaving
67
+ * fenced content and the fence lines untouched. Used by refactor
68
+ * commands that rewrite markdown structure line-wise (heading shifts,
69
+ * section splits) — a `# heading` inside a code example must never be
70
+ * treated as structure.
71
+ */
72
+ export declare function transformProseLines(source: string, transform: (line: string, lineIndex: number) => string): string;
73
+ /**
74
+ * Transform PROSE TEXT SEGMENTS: prose lines with their inline code
75
+ * spans protected (the transform sees only the non-code stretches of
76
+ * each prose line). This is the write-side counterpart of
77
+ * transformCodeRegions — refactor commands rewrite references through
78
+ * it so `[x](old.md)` or `{{ key }}` inside examples survive verbatim.
79
+ */
80
+ export declare function transformProseSegments(source: string, transform: (proseText: string) => string): string;
81
+ /**
82
+ * Fence state BEFORE each line: `openBefore[i]` is true when line i
83
+ * starts inside an unclosed fence. One extra trailing entry gives the
84
+ * state after the last line. Lets line-range refactors check "does
85
+ * this range start or end mid-fence" with the same grammar.
86
+ */
87
+ export declare function fenceOpenBefore(source: string): boolean[];
88
+ export {};
89
+ //# sourceMappingURL=code-regions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-regions.d.ts","sourceRoot":"","sources":["../src/code-regions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgBH,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AA6D3C,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B,IAAI,IAAI,OAAO,CAAC;CACjB,CAMA;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAClC,MAAM,CAuBR;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,KAAK,MAAM,EAC/D,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAC/C,MAAM,CAyBR;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GACrD,MAAM,CAMR;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GACvC,MAAM,CAmBR;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CASzD"}