cudoc-remark 0.4.0 → 0.6.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.
Files changed (69) hide show
  1. package/README.md +5 -3
  2. package/dist/capture.d.ts +23 -2
  3. package/dist/capture.d.ts.map +1 -1
  4. package/dist/capture.js +55 -3
  5. package/dist/capture.js.map +1 -1
  6. package/dist/embed.d.ts +37 -3
  7. package/dist/embed.d.ts.map +1 -1
  8. package/dist/embed.js +101 -69
  9. package/dist/embed.js.map +1 -1
  10. package/dist/host-plugins.d.ts +7 -2
  11. package/dist/host-plugins.d.ts.map +1 -1
  12. package/dist/host-plugins.js +49 -6
  13. package/dist/host-plugins.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/loader.d.ts +56 -0
  19. package/dist/loader.d.ts.map +1 -0
  20. package/dist/loader.js +69 -0
  21. package/dist/loader.js.map +1 -0
  22. package/dist/options.d.ts +5 -2
  23. package/dist/options.d.ts.map +1 -1
  24. package/dist/options.js +8 -1
  25. package/dist/options.js.map +1 -1
  26. package/dist/prepare.d.ts.map +1 -1
  27. package/dist/prepare.js +13 -2
  28. package/dist/prepare.js.map +1 -1
  29. package/dist/transforms/table-cell-list/index.d.ts +1 -1
  30. package/dist/transforms/table-cell-list/index.d.ts.map +1 -1
  31. package/dist/transforms/table-cell-list/index.js +3 -2
  32. package/dist/transforms/table-cell-list/index.js.map +1 -1
  33. package/dist/transforms/table-column-layout/index.d.ts +1 -1
  34. package/dist/transforms/table-column-layout/index.d.ts.map +1 -1
  35. package/dist/transforms/table-column-layout/index.js +3 -2
  36. package/dist/transforms/table-column-layout/index.js.map +1 -1
  37. package/package.json +13 -16
  38. package/dist/runtime.d.ts +0 -11
  39. package/dist/runtime.d.ts.map +0 -1
  40. package/dist/runtime.js +0 -12
  41. package/dist/runtime.js.map +0 -1
  42. package/dist/transforms/table-cell-list/build-table-cell-children.d.ts +0 -2
  43. package/dist/transforms/table-cell-list/build-table-cell-children.d.ts.map +0 -1
  44. package/dist/transforms/table-cell-list/build-table-cell-children.js +0 -3
  45. package/dist/transforms/table-cell-list/build-table-cell-children.js.map +0 -1
  46. package/dist/transforms/table-cell-list/elements.d.ts +0 -2
  47. package/dist/transforms/table-cell-list/elements.d.ts.map +0 -1
  48. package/dist/transforms/table-cell-list/elements.js +0 -3
  49. package/dist/transforms/table-cell-list/elements.js.map +0 -1
  50. package/dist/transforms/table-cell-list/nodes.d.ts +0 -2
  51. package/dist/transforms/table-cell-list/nodes.d.ts.map +0 -1
  52. package/dist/transforms/table-cell-list/nodes.js +0 -3
  53. package/dist/transforms/table-cell-list/nodes.js.map +0 -1
  54. package/dist/transforms/table-cell-list/parse-inline-markdown.d.ts +0 -2
  55. package/dist/transforms/table-cell-list/parse-inline-markdown.d.ts.map +0 -1
  56. package/dist/transforms/table-cell-list/parse-inline-markdown.js +0 -3
  57. package/dist/transforms/table-cell-list/parse-inline-markdown.js.map +0 -1
  58. package/dist/transforms/table-cell-list/parse-table-cell-list.d.ts +0 -2
  59. package/dist/transforms/table-cell-list/parse-table-cell-list.d.ts.map +0 -1
  60. package/dist/transforms/table-cell-list/parse-table-cell-list.js +0 -3
  61. package/dist/transforms/table-cell-list/parse-table-cell-list.js.map +0 -1
  62. package/dist/transforms/table-column-layout/create-table.d.ts +0 -2
  63. package/dist/transforms/table-column-layout/create-table.d.ts.map +0 -1
  64. package/dist/transforms/table-column-layout/create-table.js +0 -3
  65. package/dist/transforms/table-column-layout/create-table.js.map +0 -1
  66. package/dist/transforms/table-column-layout/split-cell.d.ts +0 -2
  67. package/dist/transforms/table-column-layout/split-cell.d.ts.map +0 -1
  68. package/dist/transforms/table-column-layout/split-cell.js +0 -3
  69. package/dist/transforms/table-column-layout/split-cell.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # cudoc-remark
2
2
 
3
+ > **Most sites do not set this package up themselves.** On Docusaurus and Nextra it sits under the adapter: install it beside `cudoc-docusaurus` or `cudoc-nextra` and take only its embed plugin, library loader and compiler capture from it, as the [Docusaurus](https://github.com/cudoment/cudoc/tree/main/docs/docusaurus.md) and [Nextra](https://github.com/cudoment/cudoc/tree/main/docs/nextra.md) guides show. Configure it directly in two cases only: a Next.js site on `@next/mdx`, which has no adapter ([Next.js guide](https://github.com/cudoment/cudoc/tree/main/docs/next.md)), and a remark or MDX pipeline you assemble yourself. Otherwise start from [your site generator](https://github.com/cudoment/cudoc#pick-your-site-generator).
4
+
3
5
  Connect cudoc Markdown syntax and prepared document embeds to a remark/MDX pipeline.
4
6
 
5
- This separate package is a pipeline adapter, not a second implementation of cudoc's rules. Shared document semantics live in `@cudoment/cudoc`. Use it directly with Next.js/remark; Docusaurus and Nextra adapters already depend on it. VitePress and Eleventy share `cudoc-markdown-it`, and HTML uses its own adapter; none of them need this plugin.
7
+ This separate package is a pipeline adapter, not a second implementation of cudoc's rules. Shared document semantics live in `@cudoment/cudoc`. VitePress and Eleventy share `cudoc-markdown-it`, and HTML uses its own adapter; none of them need this plugin.
6
8
 
7
9
  ESM · Node.js 20+
8
10
 
@@ -17,13 +19,13 @@ import cudoc from "cudoc-remark"
17
19
  const remarkPlugins = [remarkGfm, [cudoc, { host: "next", syntax: {} }]]
18
20
  ```
19
21
 
20
- Default settings produce component-free output in both `.md` and `.mdx`; `syntax: {}` makes the defaults explicit. Let the host detect the document format. For Next.js Turbopack, use package-name plugin strings and JSON options as shown in the guide. `cudoc-remark/embed` inserts its runtime automatically after collection and preparation.
22
+ Default settings produce component-free output in both `.md` and `.mdx`; `syntax: {}` makes the defaults explicit. Let the host detect the document format. For Next.js Turbopack, use package-name plugin strings and JSON options as shown in the guide. After collection and preparation, `cudoc-remark/embed` splices each prepared embed into the page as it compiles, so embedded components render through the host's own component mapping; `cudoc-remark/loader` keeps a recollection visible to the dev server and the build cache.
21
23
 
22
24
  Choose `host`, `cudoc` or `both` independently for `headingAnchor`, `badge`, `tableCellList`, `callout` and `link`. The representative callout is `> [!NOTE] Title`. Authors do not register cudoc React components in the recommended setup. Syntax-only rendering needs no stored JSON; cross-document embedding requires document collection.
23
25
 
24
26
  - [Usage guide](https://github.com/cudoment/cudoc/tree/main/docs/next.md) · [한국어 가이드](https://github.com/cudoment/cudoc/tree/main/docs/next.ko.md)
25
27
  - [Markdown syntax](https://github.com/cudoment/cudoc/tree/main/docs/syntax.md)
26
28
  - [Embedding](https://github.com/cudoment/cudoc/tree/main/docs/embedding.md)
27
- - [Standalone HTML alongside a host](https://github.com/cudoment/cudoc/tree/main/docs/html.md#export-alongside-an-existing-site)
29
+ - [Standalone HTML alongside a host](https://github.com/cudoment/cudoc/tree/main/docs/export.md#export-alongside-an-existing-site)
28
30
  - [API reference](https://github.com/cudoment/cudoc/tree/main/docs/api-reference/README.md)
29
31
  - [Runnable examples](https://github.com/cudoment/cudoc/tree/main/examples/README.md)
package/dist/capture.d.ts CHANGED
@@ -1,8 +1,29 @@
1
1
  import type { Root } from "mdast";
2
2
  import type { Plugin } from "unified";
3
3
  import type { CompiledDocument } from "@cudoment/cudoc/markdown";
4
- /** Capture remark's final tree at the start of rehype, after native host plugins. */
5
- export declare function createCompilerCapture(): {
4
+ export type CompilerCaptureOptions = {
5
+ /**
6
+ * Path prefixes the host resolves by itself, each with the prefix an image
7
+ * is recorded under instead. Docusaurus reads `@site/static/img/logo.png`
8
+ * from the site directory and serves it at `/img/logo.png`, an address the
9
+ * check and the export resolve through their asset directories, so a
10
+ * Docusaurus collector passes `{ "@site/static/": "/" }`. The longest
11
+ * matching prefix wins; the host's own page is not changed. Only images
12
+ * are recorded this way: a link keeps the path it was written with.
13
+ */
14
+ aliases?: Record<string, string>;
15
+ };
16
+ /**
17
+ * Capture remark's final tree at the start of rehype, after native host plugins.
18
+ *
19
+ * `capture.remark` also notes every Markdown image as it stands then. A host
20
+ * plugin that runs later may turn one into a component of its own, as
21
+ * Docusaurus turns each into an `<img>` requiring the file; it rewrites the
22
+ * node in place, so the note still finds it, and the captured component keeps
23
+ * the image as `data.cudocImage` for everything that renders the stored tree
24
+ * without the host.
25
+ */
26
+ export declare function createCompilerCapture(options?: CompilerCaptureOptions): {
6
27
  remark: Plugin<[], Root>;
7
28
  rehype: Plugin;
8
29
  read(): CompiledDocument;
@@ -1 +1 @@
1
- {"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAEhE,qFAAqF;AACrF,wBAAgB,qBAAqB;;;YAyBzB,gBAAgB;EAQ3B"}
1
+ {"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,IAAI,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAMrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAGhE,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B;;;YAwE9D,gBAAgB;EAQ3B"}
package/dist/capture.js CHANGED
@@ -1,16 +1,67 @@
1
- import { lowerNativeElements } from "@cudoment/cudoc/document";
2
- /** Capture remark's final tree at the start of rehype, after native host plugins. */
3
- export function createCompilerCapture() {
1
+ import { visit } from "unist-util-visit";
2
+ import { lowerNativeElements, } from "@cudoment/cudoc/document";
3
+ import { importedNames, importedNamesFromSource } from "@cudoment/cudoc/mdx";
4
+ /**
5
+ * Capture remark's final tree at the start of rehype, after native host plugins.
6
+ *
7
+ * `capture.remark` also notes every Markdown image as it stands then. A host
8
+ * plugin that runs later may turn one into a component of its own, as
9
+ * Docusaurus turns each into an `<img>` requiring the file; it rewrites the
10
+ * node in place, so the note still finds it, and the captured component keeps
11
+ * the image as `data.cudocImage` for everything that renders the stored tree
12
+ * without the host.
13
+ */
14
+ export function createCompilerCapture(options = {}) {
15
+ const given = options.aliases === undefined ? {} : options.aliases;
16
+ if (typeof given !== "object" ||
17
+ given === null ||
18
+ Array.isArray(given) ||
19
+ Object.entries(given).some(([prefix, value]) => !prefix || typeof value !== "string"))
20
+ throw new TypeError("cudoc: capture aliases must map path prefixes to strings");
21
+ const aliases = Object.entries(given).sort(([a], [b]) => b.length - a.length);
22
+ const portable = (url) => {
23
+ const alias = aliases.find(([prefix]) => url.startsWith(prefix));
24
+ return alias ? `${alias[1]}${url.slice(alias[0].length)}` : url;
25
+ };
4
26
  let current;
5
27
  let result;
28
+ const images = new Map();
6
29
  const remark = () => (tree) => {
7
30
  current = tree;
31
+ images.clear();
32
+ visit(tree, "image", (node) => {
33
+ images.set(node, {
34
+ url: portable(node.url),
35
+ alt: node.alt ?? null,
36
+ title: node.title ?? null,
37
+ });
38
+ });
8
39
  };
9
40
  const rehype = () => (_tree, file) => {
10
41
  if (!current)
11
42
  throw new Error("cudoc: install capture.remark before capture.rehype");
43
+ for (const [node, image] of images) {
44
+ const replaced = node;
45
+ if (replaced.type !== "image")
46
+ replaced.data = { ...replaced.data, cudocImage: image };
47
+ }
12
48
  const tree = structuredClone(current);
49
+ // An image the host kept is recorded under the same address.
50
+ if (aliases.length)
51
+ visit(tree, "image", (node) => {
52
+ node.url = portable(node.url);
53
+ });
13
54
  lowerNativeElements(tree);
55
+ // A host may have hoisted the ESM out of the tree already, so the source
56
+ // is read as well; the two agree when both are present.
57
+ const imports = [
58
+ ...new Set([
59
+ ...importedNames(tree),
60
+ ...(file.extname === ".mdx"
61
+ ? importedNamesFromSource(String(file.value))
62
+ : []),
63
+ ]),
64
+ ];
14
65
  tree.children = tree.children.filter((n) => !["yaml", "mdxjsEsm"].includes(n.type));
15
66
  result = {
16
67
  tree,
@@ -18,6 +69,7 @@ export function createCompilerCapture() {
18
69
  file.data.frontmatter ??
19
70
  {}),
20
71
  diagnostics: [],
72
+ ...(imports.length ? { imports } : {}),
21
73
  };
22
74
  };
23
75
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"capture.js","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAG9D,qFAAqF;AACrF,MAAM,UAAU,qBAAqB;IACnC,IAAI,OAAyB,CAAA;IAC7B,IAAI,MAAoC,CAAA;IACxC,MAAM,MAAM,GAAqB,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9C,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC,CAAA;IACD,MAAM,MAAM,GAAW,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3C,IAAI,CAAC,OAAO;YACV,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;QACxE,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;QACrC,mBAAmB,CAAC,IAAI,CAAC,CAAA;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAClC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAC9C,CAAA;QACD,MAAM,GAAG;YACP,IAAI;YACJ,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW;gBACjC,IAAI,CAAC,IAAI,CAAC,WAAW;gBACrB,EAAE,CAA4B;YAChC,WAAW,EAAE,EAAE;SAChB,CAAA;IACH,CAAC,CAAA;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CAAC;KACF,CAAA;AACH,CAAC"}
package/dist/embed.d.ts CHANGED
@@ -1,9 +1,43 @@
1
+ /**
2
+ * Prepared embeds, spliced into the document as it compiles.
3
+ *
4
+ * `prepareEmbeds` has already resolved every fence into an mdast block: the
5
+ * selected sections, replacements applied, ids and links rebased, nested
6
+ * embeds expanded, all produced by the host's own compiler. This plugin puts
7
+ * those nodes where the fence was, so the rest of the host's pipeline — its
8
+ * remaining remark plugins, remark-rehype, the component mapping — treats
9
+ * them exactly like the document's own content. A component in an embedded
10
+ * section renders through the host's components; a code block reaches the
11
+ * host's highlighter; nothing is turned into an HTML string first.
12
+ *
13
+ * The stored blocks carry no `estree`: the AST export strips it, because it
14
+ * is compiler state rather than content. The expression text is kept, so the
15
+ * estree is parsed again here for every expression node the block contains.
16
+ */
1
17
  import type { Root } from "mdast";
2
18
  import type { Plugin } from "unified";
3
- /** Render persisted embeds inside the current host compilation. */
4
- declare const embed: Plugin<[{
19
+ import type { DocumentNode } from "@cudoment/cudoc/document";
20
+ import { type SourceRoot } from "@cudoment/cudoc/node/roots";
21
+ export type EmbedPluginOptions = {
22
+ /** The prepared library. Defaults to `.cudoc/documents`. */
5
23
  outDir?: string;
24
+ /** One root at the top of the library. Defaults to `docs` when `roots` is absent. */
6
25
  sourceRoot?: string;
7
- }?], Root>;
26
+ /** The roots collection used, so a file maps to the same id here. */
27
+ roots?: SourceRoot[];
28
+ };
29
+ /**
30
+ * Gives every expression node in a stored block the estree the MDX compiler
31
+ * needs, from the expression text the export preserved.
32
+ *
33
+ * A JSX attribute value expression is parsed as an expression; a spread
34
+ * attribute as the object `{...value}` the MDX parser itself builds; a flow or
35
+ * text expression as an expression, or as an empty program when it holds only
36
+ * a comment. Anything that does not parse names the document and the text, so
37
+ * a block that compiled at collection but not here is not a silent failure.
38
+ */
39
+ export declare function restoreExpressions(node: DocumentNode, documentId: string): void;
40
+ /** Splice prepared embeds into the current host compilation. */
41
+ declare const embed: Plugin<[EmbedPluginOptions?], Root>;
8
42
  export default embed;
9
43
  //# sourceMappingURL=embed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AASrC,mEAAmE;AACnE,QAAA,MAAM,KAAK,EAAE,MAAM,CAAC,CAAC;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EAAE,IAAI,CA6ElE,CAAA;AACH,eAAe,KAAK,CAAA"}
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAI5D,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAA;AAInC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,KAAK,CAAC,EAAE,UAAU,EAAE,CAAA;CACrB,CAAA;AAcD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,YAAY,EAClB,UAAU,EAAE,MAAM,GACjB,IAAI,CA8CN;AAED,gEAAgE;AAChE,QAAA,MAAM,KAAK,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC,EAAE,IAAI,CA6B5C,CAAA;AACH,eAAe,KAAK,CAAA"}
package/dist/embed.js CHANGED
@@ -1,74 +1,106 @@
1
- import path from "node:path";
2
- import { parse } from "acorn";
3
- import { readPreparedEmbeds, embedKey, } from "@cudoment/cudoc/node/prepare-embeds";
4
- /** Render persisted embeds inside the current host compilation. */
5
- const embed = (options = {}) => (tree, file) => {
6
- let prepared;
7
- let index = 0;
8
- let usesEmbeds = false;
9
- // One import per document makes the generated data a real bundler dependency.
10
- // Rebuilding sources updates embeds.json even when the Markdown page is cached.
11
- let relativeData = path
12
- .relative(path.dirname(file.path), path.resolve(options.outDir ?? ".cudoc/documents", "embeds.json"))
13
- .split(path.sep)
14
- .join("/");
15
- if (!relativeData.startsWith("."))
16
- relativeData = `./${relativeData}`;
17
- const documentId = path
18
- .relative(path.resolve(options.sourceRoot ?? "docs"), file.path)
19
- .split(path.sep)
20
- .join("/")
21
- .replace(/\.mdx?$/i, "");
22
- const expand = (node) => {
23
- if (!node.children)
24
- return;
25
- node.children = node.children.flatMap((child) => {
26
- if (child.type === "code" && child.lang === "cudoc-embed") {
27
- prepared ??= readPreparedEmbeds(options.outDir ?? ".cudoc/documents", documentId, String(file.value));
28
- const result = prepared.blocks[embedKey(documentId, child.value, ++index)];
29
- if (!result)
30
- throw new Error(`cudoc: prepared embed missing in ${documentId}; recollect documents`);
31
- usesEmbeds = true;
32
- const expression = `_cudocData.blocks[${JSON.stringify(embedKey(documentId, child.value, index))}]`;
33
- return [
34
- {
35
- type: "mdxJsxFlowElement",
36
- name: "_CudocEmbed",
37
- attributes: [
38
- {
39
- type: "mdxJsxAttribute",
40
- name: "tree",
41
- value: {
42
- type: "mdxJsxAttributeValueExpression",
43
- value: expression,
44
- data: {
45
- estree: parse(expression, {
46
- ecmaVersion: "latest",
47
- sourceType: "module",
48
- }),
49
- },
50
- },
51
- },
52
- ],
53
- children: [],
54
- },
55
- ];
1
+ /**
2
+ * Prepared embeds, spliced into the document as it compiles.
3
+ *
4
+ * `prepareEmbeds` has already resolved every fence into an mdast block: the
5
+ * selected sections, replacements applied, ids and links rebased, nested
6
+ * embeds expanded, all produced by the host's own compiler. This plugin puts
7
+ * those nodes where the fence was, so the rest of the host's pipeline — its
8
+ * remaining remark plugins, remark-rehype, the component mapping — treats
9
+ * them exactly like the document's own content. A component in an embedded
10
+ * section renders through the host's components; a code block reaches the
11
+ * host's highlighter; nothing is turned into an HTML string first.
12
+ *
13
+ * The stored blocks carry no `estree`: the AST export strips it, because it
14
+ * is compiler state rather than content. The expression text is kept, so the
15
+ * estree is parsed again here for every expression node the block contains.
16
+ */
17
+ import { Parser } from "acorn";
18
+ import jsx from "acorn-jsx";
19
+ // The roots module alone: a host loads its configuration, and this plugin
20
+ // with it, in a runtime that cannot import the compiler stack behind
21
+ // `node/library`.
22
+ import { documentIdOf, resolveRoots, } from "@cudoment/cudoc/node/roots";
23
+ import { expandPreparedEmbeds } from "@cudoment/cudoc/node/prepare-embeds";
24
+ import { stripLibraryMarker } from "./loader.js";
25
+ const parser = Parser.extend(jsx());
26
+ const parse = (source) => parser.parse(source, {
27
+ ecmaVersion: "latest",
28
+ sourceType: "module",
29
+ locations: false,
30
+ });
31
+ /** A program holding only comments, which is what a commented-out expression compiles to. */
32
+ const commentOnly = (value) => value.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, "").trim() === "";
33
+ /**
34
+ * Gives every expression node in a stored block the estree the MDX compiler
35
+ * needs, from the expression text the export preserved.
36
+ *
37
+ * A JSX attribute value expression is parsed as an expression; a spread
38
+ * attribute as the object `{...value}` the MDX parser itself builds; a flow or
39
+ * text expression as an expression, or as an empty program when it holds only
40
+ * a comment. Anything that does not parse names the document and the text, so
41
+ * a block that compiled at collection but not here is not a silent failure.
42
+ */
43
+ export function restoreExpressions(node, documentId) {
44
+ const estreeFor = (value, wrap) => {
45
+ try {
46
+ return parse(wrap(value));
47
+ }
48
+ catch (cause) {
49
+ if (commentOnly(value))
50
+ return { type: "Program", body: [], sourceType: "module", comments: [] };
51
+ throw new Error(`cudoc: embedded expression in ${documentId} does not parse: {${value}}`, { cause });
52
+ }
53
+ };
54
+ const visit = (current) => {
55
+ if ((current.type === "mdxFlowExpression" ||
56
+ current.type === "mdxTextExpression") &&
57
+ typeof current.value === "string")
58
+ current.data = {
59
+ ...current.data,
60
+ estree: estreeFor(current.value, (v) => `(${v})`),
61
+ };
62
+ if (Array.isArray(current.attributes))
63
+ for (const attribute of current.attributes) {
64
+ if (attribute.type === "mdxJsxExpressionAttribute") {
65
+ attribute.data = {
66
+ ...attribute.data,
67
+ estree: estreeFor(String(attribute.value), (v) => `({${v}})`),
68
+ };
69
+ continue;
70
+ }
71
+ const value = attribute.value;
72
+ if (value &&
73
+ typeof value === "object" &&
74
+ value.type === "mdxJsxAttributeValueExpression")
75
+ value.data = {
76
+ ...value.data,
77
+ estree: estreeFor(String(value.value), (v) => `(${v})`),
78
+ };
56
79
  }
57
- expand(child);
58
- return [child];
59
- });
80
+ current.children?.forEach(visit);
60
81
  };
61
- expand(tree);
62
- if (usesEmbeds) {
63
- const value = `import { EmbeddedDocument as _CudocEmbed } from "cudoc-remark/runtime";\nimport _cudocData from ${JSON.stringify(relativeData)};`;
64
- tree.children.unshift({
65
- type: "mdxjsEsm",
66
- value,
67
- data: {
68
- estree: parse(value, { ecmaVersion: "latest", sourceType: "module" }),
69
- },
70
- });
71
- }
82
+ visit(node);
83
+ }
84
+ /** Splice prepared embeds into the current host compilation. */
85
+ const embed = (options = {}) => (tree, file) => {
86
+ expandPreparedEmbeds(tree,
87
+ // Resolved only when a fence is met: a file outside every root is fine
88
+ // as long as it embeds nothing.
89
+ () => {
90
+ const roots = resolveRoots(options.roots === undefined && options.sourceRoot === undefined
91
+ ? { sourceRoot: "docs" }
92
+ : options);
93
+ const documentId = documentIdOf(roots, file.path);
94
+ if (documentId === undefined)
95
+ throw new Error(`cudoc: ${file.path} is outside every collection root, so its embeds have no prepared data`);
96
+ return {
97
+ outDir: options.outDir ?? ".cudoc/documents",
98
+ documentId,
99
+ // The loader may have appended its marker line; the snapshot was
100
+ // taken from the file itself.
101
+ source: stripLibraryMarker(String(file.value)),
102
+ };
103
+ }, (block, documentId) => restoreExpressions(block, documentId));
72
104
  };
73
105
  export default embed;
74
106
  //# sourceMappingURL=embed.js.map
package/dist/embed.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"embed.js","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EACL,kBAAkB,EAClB,QAAQ,GAET,MAAM,qCAAqC,CAAA;AAE5C,mEAAmE;AACnE,MAAM,KAAK,GACT,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,CACjB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;IACb,IAAI,QAAoC,CAAA;IACxC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,8EAA8E;IAC9E,gFAAgF;IAChF,IAAI,YAAY,GAAG,IAAI;SACpB,QAAQ,CACP,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,kBAAkB,EAAE,aAAa,CAAC,CAClE;SACA,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IACZ,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,YAAY,GAAG,KAAK,YAAY,EAAE,CAAA;IACrE,MAAM,UAAU,GAAG,IAAI;SACpB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;SAC/D,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SACf,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IAC1B,MAAM,MAAM,GAAG,C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AE,OAAO,CAAC,MAAM,IAAI,kBAAkB;YAC5C,UAAU;YACV,iEAAiE;YACjE,8BAA8B;YAC9B,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC/C,CAAA;IACH,CAAC,EACD,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CACpB,kBAAkB,CAAC,KAAgC,EAAE,UAAU,CAAC,CACnE,CAAA;AACH,CAAC,CAAA;AACH,eAAe,KAAK,CAAA"}
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import type { PluggableList } from "unified";
8
8
  import { type CudocRemarkOptions } from "./options.js";
9
- export type HostPluginOptions = Omit<CudocRemarkOptions, "toc"> & {
9
+ export type HostPluginOptions = Omit<CudocRemarkOptions, "toc" | "host" | "headingIds"> & {
10
10
  /**
11
11
  * Copy each anchor id onto its heading so the host uses it instead of
12
12
  * slugifying the heading text. On by default; turning it off leaves the
@@ -14,5 +14,10 @@ export type HostPluginOptions = Omit<CudocRemarkOptions, "toc"> & {
14
14
  */
15
15
  promoteHeadingIds?: boolean;
16
16
  };
17
- export declare const createHostPlugins: (options: HostPluginOptions | undefined, adapter: string) => PluggableList;
17
+ /**
18
+ * The remark plugins a Docusaurus or Nextra adapter hands its host, in order.
19
+ * `host` is the adapter's own, and decides what the host is given: Docusaurus
20
+ * receives a settled id its slugger would change as `{#id}` text.
21
+ */
22
+ export declare const createHostPlugins: (options: HostPluginOptions | undefined, adapter: string, host: "docusaurus" | "nextra") => PluggableList;
18
23
  //# sourceMappingURL=host-plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-plugins.d.ts","sourceRoot":"","sources":["../src/host-plugins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAItE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,GAAG;IAChE;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AA6BD,eAAO,MAAM,iBAAiB,GAC5B,SAAS,iBAAiB,YAAK,EAC/B,SAAS,MAAM,KACd,aAkCF,CAAA"}
1
+ {"version":3,"file":"host-plugins.d.ts","sourceRoot":"","sources":["../src/host-plugins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAU,aAAa,EAAE,MAAM,SAAS,CAAA;AAGpD,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAItE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,kBAAkB,EAClB,KAAK,GAAG,MAAM,GAAG,YAAY,CAC9B,GAAG;IACF;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAgED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,iBAAiB,YAAK,EAC/B,SAAS,MAAM,EACf,MAAM,YAAY,GAAG,QAAQ,KAC5B,aAsCF,CAAA"}
@@ -4,20 +4,22 @@
4
4
  * Docusaurus and Nextra share the transforms and heading id promotion.
5
5
  * Default output uses native elements without a cudoc component provider.
6
6
  */
7
+ import { visit } from "unist-util-visit";
7
8
  import cudocPrepare from "./prepare.js";
8
9
  import { resolveOptions } from "./options.js";
9
10
  import { promoteAnchorIds } from "./heading-ids.js";
11
+ // `host` and `headingIds` are the adapter's to set, so neither is accepted.
10
12
  const KNOWN_KEYS = new Set([
11
13
  "syntax",
12
- "host",
13
14
  "format",
14
15
  "calloutTypes",
15
16
  "components",
16
- "headingIds",
17
17
  "tableCellList",
18
18
  "headingMetadata",
19
19
  "badge",
20
20
  "tableColumnLayout",
21
+ "tableColumnWidths",
22
+ "ignoreDiagnostics",
21
23
  "transforms",
22
24
  "promoteHeadingIds",
23
25
  ]);
@@ -31,7 +33,44 @@ const readAnchorNaming = (options) => {
31
33
  idAttribute: headingMetadata.anchor?.idAttribute,
32
34
  };
33
35
  };
34
- export const createHostPlugins = (options = {}, adapter) => {
36
+ /**
37
+ * Whether Docusaurus's slugger leaves an id as it is: letters, digits,
38
+ * hyphens and underscores only. The slugger runs with the case kept for an id
39
+ * already on a heading, and removes or replaces everything else.
40
+ */
41
+ const slugStable = (id) => /^[\p{L}\p{M}\p{N}_-]+$/u.test(id);
42
+ /**
43
+ * Hands Docusaurus the heading ids cudoc settled that its slugger would change.
44
+ *
45
+ * Docusaurus runs an id already on a heading through its slugger again, which
46
+ * turns `v1.2` into `v12`, but takes a `{#id}` at the end of the heading text
47
+ * as written. Its table of contents reads the same id, so the heading, its
48
+ * anchor and the entry stay one value.
49
+ *
50
+ * Every other id stays on the heading for the slugger, which returns it
51
+ * unchanged and records it, so a later heading whose text slugs to the same
52
+ * value is numbered past it instead of taking it. The page's `#` heading keeps
53
+ * its id there too: Docusaurus reads the page title from that heading's text
54
+ * before it takes a `{#id}` out.
55
+ */
56
+ const docusaurusHeadingIds = () => (tree) => {
57
+ visit(tree, "heading", (heading) => {
58
+ const properties = heading.data?.hProperties;
59
+ const id = properties?.id;
60
+ if (typeof id !== "string" || !id)
61
+ return;
62
+ if (heading.depth === 1 || slugStable(id))
63
+ return;
64
+ delete properties.id;
65
+ heading.children.push({ type: "text", value: ` {#${id}}` });
66
+ });
67
+ };
68
+ /**
69
+ * The remark plugins a Docusaurus or Nextra adapter hands its host, in order.
70
+ * `host` is the adapter's own, and decides what the host is given: Docusaurus
71
+ * receives a settled id its slugger would change as `{#id}` text.
72
+ */
73
+ export const createHostPlugins = (options = {}, adapter, host) => {
35
74
  if (typeof options !== "object" || options === null) {
36
75
  throw new TypeError(`${adapter}: options must be an object`);
37
76
  }
@@ -40,10 +79,9 @@ export const createHostPlugins = (options = {}, adapter) => {
40
79
  throw new TypeError(`${adapter}: unknown option "${key}"`);
41
80
  }
42
81
  }
82
+ if (host !== "docusaurus" && host !== "nextra")
83
+ throw new TypeError(`${adapter}: host must be "docusaurus" or "nextra"`);
43
84
  const { promoteHeadingIds = true, ...remarkOptions } = options;
44
- const host = adapter.includes("docusaurus")
45
- ? "docusaurus"
46
- : "nextra";
47
85
  const resolvedOptions = {
48
86
  ...remarkOptions,
49
87
  host,
@@ -59,6 +97,11 @@ export const createHostPlugins = (options = {}, adapter) => {
59
97
  if (promoteHeadingIds) {
60
98
  plugins.push([promoteAnchorIds, readAnchorNaming(remarkOptions)]);
61
99
  }
100
+ // Last, once every id cudoc assigns is on its heading. Bare rather than
101
+ // `[plugin]`: Docusaurus accepts a plugin or a `[plugin, options]` pair and
102
+ // refuses a one-element array when it validates its config.
103
+ if (host === "docusaurus")
104
+ plugins.push(docusaurusHeadingIds);
62
105
  return plugins;
63
106
  };
64
107
  //# sourceMappingURL=host-plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-plugins.js","sourceRoot":"","sources":["../src/host-plugins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,YAAY,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,cAAc,EAA2B,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAYnD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS;IACjC,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,iBAAiB;IACjB,OAAO;IACP,mBAAmB;IACnB,YAAY;IACZ,mBAAmB;CACkB,CAAC,CAAA;AAExC,iFAAiF;AACjF,MAAM,gBAAgB,GAAG,CACvB,OAA2B,EACF,EAAE;IAC3B,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAA;IAC/C,IAAI,CAAC,eAAe,IAAI,eAAe,KAAK,IAAI;QAAE,OAAO,EAAE,CAAA;IAC3D,OAAO;QACL,UAAU,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI;QACxC,WAAW,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C,YAAY,EAAE,eAAe,CAAC,CAAC,CAAA;IAEhE,oEAAoE;IACpE,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;IACnE,CAAC;IAED,wEAAwE;IACxE,4EAA4E;IAC5E,4DAA4D;IAC5D,IAAI,IAAI,KAAK,YAAY;QAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAE7D,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -12,5 +12,5 @@ export { promoteAnchorIds } from "./heading-ids.js";
12
12
  export type { PromoteAnchorIdsOptions } from "./heading-ids.js";
13
13
  export { createHostPlugins } from "./host-plugins.js";
14
14
  export type { HostPluginOptions } from "./host-plugins.js";
15
- export { createCompilerCapture } from "./capture.js";
15
+ export { createCompilerCapture, type CompilerCaptureOptions, } from "./capture.js";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,IAAI,YAAY,EACvB,eAAe,EACf,aAAa,GACd,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,0BAA0B,GAC3B,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAC9B,YAAY,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AwB,EAAE,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,GAC5B,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -6,5 +6,5 @@ export { transformTableCellList } from "./transforms/table-cell-list/index.js";
6
6
  export { createTableColumnLayoutTransform, resolveTableColumnLayoutOptions, } from "./transforms/table-column-layout/index.js";
7
7
  export { promoteAnchorIds } from "./heading-ids.js";
8
8
  export { createHostPlugins } from "./host-plugins.js";
9
- export { createCompilerCapture } from "./capture.js";
9
+ export { createCompilerCapture, } from "./capture.js";
10
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,IAAI,YAAY,EACvB,eAAe,EACf,aAAa,GACd,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAO7C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,UAAU,CAAA;AAEjB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EACL,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,2CAA2C,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,EAAE,iBAAiB,EA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