cudoc-markdown-it 0.5.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.
- package/README.md +4 -2
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +31 -8
- package/dist/compiler.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +9 -2
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +18 -2
- package/dist/options.js.map +1 -1
- package/dist/plugin.d.ts +6 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +328 -45
- package/dist/plugin.js.map +1 -1
- package/dist/text.d.ts +12 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +30 -0
- package/dist/text.js.map +1 -0
- package/dist/tokens.d.ts +17 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +132 -13
- package/dist/tokens.js.map +1 -1
- package/package.json +13 -4
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# cudoc-markdown-it
|
|
2
2
|
|
|
3
|
+
> **A VitePress or Eleventy site does not install this package.** It is the markdown-it layer inside `cudoc-vitepress` and `cudoc-eleventy`, which depend on it and set it up, so follow the [VitePress](https://github.com/cudoment/cudoc/tree/main/docs/vitepress.md) or [Eleventy](https://github.com/cudoment/cudoc/tree/main/docs/eleventy.md) guide instead. Use it directly in one case only: connecting cudoc to another markdown-it host that has no adapter yet. Otherwise start from [your site generator](https://github.com/cudoment/cudoc#pick-your-site-generator).
|
|
4
|
+
|
|
3
5
|
Connect cudoc Markdown syntax, document collection and embedding to a markdown-it 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`. It is the markdown-it counterpart of `cudoc-remark`: the VitePress and Eleventy adapters depend on it, so the two hosts share one token conversion, one embed expansion and one collection path.
|
|
7
|
+
This separate package is a pipeline adapter, not a second implementation of cudoc's rules. Shared document semantics live in `@cudoment/cudoc`. It is the markdown-it counterpart of `cudoc-remark`: the VitePress and Eleventy adapters depend on it, so the two hosts share one token conversion, one embed expansion and one collection path.
|
|
6
8
|
|
|
7
9
|
ESM · Node.js 20+
|
|
8
10
|
|
|
@@ -25,7 +27,7 @@ export default function cudocMyHost(md, options = {}) {
|
|
|
25
27
|
export const createDocumentCompiler = (md) => createHostCompiler(md, host)
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
The plugin converts the actual token stream and never parses the Markdown a second time. It reads the host's own anchor, link and container tokens, then copies the resolved heading ids and titles back onto the host tokens so native heading and TOC behavior is preserved. `MarkdownItHost` names everything a host does differently: its own tokens, the document id in its markdown-it env, whether it resolves links in renderer rules, and whether it strips front matter outside markdown-it.
|
|
30
|
+
The plugin converts the actual token stream and never parses the Markdown a second time. It reads the host's own anchor, link and container tokens, then copies the resolved heading ids and titles back onto the host tokens so native heading and TOC behavior is preserved. The host still renders its own code blocks, HTML blocks and every token cudoc does not map, such as a table of contents or a code group, so its highlighting and plugins keep working. Diagnostics raised while the site renders go to an `onDiagnostic` option, a warning on stderr by default. `MarkdownItHost` names everything a host does differently: its own tokens, the document id in its markdown-it env, whether it resolves links in renderer rules, and whether it strips front matter outside markdown-it.
|
|
29
31
|
|
|
30
32
|
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.
|
|
31
33
|
|
package/dist/compiler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AAIzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAS/C,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,cAAc,GACnB,gBAAgB,CA+DlB"}
|
package/dist/compiler.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* and a source replacement go through the actual host compiler rather than a
|
|
6
6
|
* second parser that could disagree with it.
|
|
7
7
|
*/
|
|
8
|
+
import { markdownItText } from "./text.js";
|
|
8
9
|
export function createHostCompiler(md, host) {
|
|
9
10
|
return (source, context) => {
|
|
10
11
|
if (context.options.format === "mdx")
|
|
@@ -21,24 +22,46 @@ export function createHostCompiler(md, host) {
|
|
|
21
22
|
if (!captured)
|
|
22
23
|
throw new Error(`${host.adapter}: install the plugin on the supplied renderer`);
|
|
23
24
|
const tree = structuredClone(captured.tree);
|
|
24
|
-
|
|
25
|
+
// The body the renderer saw is what follows the front matter, as
|
|
26
|
+
// markdown-it read it. Searching for it instead would find an earlier
|
|
27
|
+
// copy of the same text, such as a front-matter field that repeats the
|
|
28
|
+
// first paragraph.
|
|
29
|
+
const read = markdownItText(source);
|
|
30
|
+
const offset = read.text.endsWith(captured.source)
|
|
31
|
+
? read.text.length - captured.source.length
|
|
32
|
+
: read.text.indexOf(captured.source);
|
|
25
33
|
if (offset < 0)
|
|
26
34
|
throw new Error(`${host.adapter}: cannot map processed Markdown back to source`);
|
|
27
|
-
const lines =
|
|
35
|
+
const lines = read.text.slice(0, offset).split("\n").length - 1;
|
|
36
|
+
// Offsets go back to the file's own text, `\r\n` and all, which is what
|
|
37
|
+
// the source snapshot slices; lines are the same in both.
|
|
38
|
+
const shift = (position) => {
|
|
39
|
+
for (const point of [position.start, position.end]) {
|
|
40
|
+
if (point.offset !== undefined)
|
|
41
|
+
point.offset = read.toSource(point.offset + offset);
|
|
42
|
+
point.line += lines;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
28
45
|
const adjust = (node) => {
|
|
29
46
|
if (node.position)
|
|
30
|
-
|
|
31
|
-
if (point.offset !== undefined)
|
|
32
|
-
point.offset += offset;
|
|
33
|
-
point.line += lines;
|
|
34
|
-
}
|
|
47
|
+
shift(node.position);
|
|
35
48
|
node.children?.forEach(adjust);
|
|
36
49
|
};
|
|
37
50
|
adjust(tree);
|
|
51
|
+
// A diagnostic's position was measured in the same body, so it moves the
|
|
52
|
+
// same way; without this the line printed for a document with front
|
|
53
|
+
// matter would be short by the front matter's height.
|
|
54
|
+
const diagnostics = captured.diagnostics.map((diagnostic) => {
|
|
55
|
+
if (!diagnostic.position)
|
|
56
|
+
return diagnostic;
|
|
57
|
+
const position = structuredClone(diagnostic.position);
|
|
58
|
+
shift(position);
|
|
59
|
+
return { ...diagnostic, position };
|
|
60
|
+
});
|
|
38
61
|
return {
|
|
39
62
|
tree,
|
|
40
63
|
frontmatter: split?.data ?? env.frontmatter ?? {},
|
|
41
|
-
diagnostics
|
|
64
|
+
diagnostics,
|
|
42
65
|
};
|
|
43
66
|
};
|
|
44
67
|
}
|
package/dist/compiler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAQ1C,MAAM,UAAU,kBAAkB,CAChC,EAAc,EACd,IAAoB;IAEpB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACzB,IAAI,OAAO,CAAC,OAAO,CAAC,M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|
|
3
3
|
export { installHostPlugin } from "./plugin.js";
|
|
4
4
|
export { createHostCompiler } from "./compiler.js";
|
|
5
5
|
export { resolveHostOptions } from "./options.js";
|
|
6
|
+
export { markdownItText } from "./text.js";
|
|
6
7
|
export type { HostPluginOptions } from "./options.js";
|
|
7
8
|
export type { MarkdownItHost, TokenNode, TokenContext } from "./host.js";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { tokensToAst } from "./tokens.js";
|
|
|
2
2
|
export { installHostPlugin } from "./plugin.js";
|
|
3
3
|
export { createHostCompiler } from "./compiler.js";
|
|
4
4
|
export { resolveHostOptions } from "./options.js";
|
|
5
|
+
export { markdownItText } from "./text.js";
|
|
5
6
|
//# 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,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/options.d.ts
CHANGED
|
@@ -7,15 +7,22 @@
|
|
|
7
7
|
* a markdown-it core rule is much harder to place.
|
|
8
8
|
*/
|
|
9
9
|
import type { Root } from "mdast";
|
|
10
|
-
import { type DocumentOptions } from "@cudoment/cudoc/document";
|
|
10
|
+
import { type DocumentDiagnostic, type DocumentOptions } from "@cudoment/cudoc/document";
|
|
11
11
|
import type { Library } from "@cudoment/cudoc/node/library";
|
|
12
|
-
export type HostPluginOptions = Omit<DocumentOptions, "host" | "format"> & {
|
|
12
|
+
export type HostPluginOptions = Omit<DocumentOptions, "host" | "format" | "components"> & {
|
|
13
13
|
/** Called with the document tree built from the actual host token stream. */
|
|
14
14
|
onDocument?: (tree: Root, source: string, env: Record<string, unknown>) => void;
|
|
15
15
|
/** Collected documents, required before any embed can be expanded. */
|
|
16
16
|
library?: Library;
|
|
17
17
|
/** Where `prepareEmbeds` wrote its results; defaults to `.cudoc/documents`. */
|
|
18
18
|
outDir?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Receives each diagnostic normalization reports while the site renders a
|
|
21
|
+
* page — an unregistered callout type, two headings sharing an id. Defaults
|
|
22
|
+
* to a warning on stderr naming the document and line. Collection reports
|
|
23
|
+
* its own, so nothing is passed here while collecting.
|
|
24
|
+
*/
|
|
25
|
+
onDiagnostic?: (diagnostic: DocumentDiagnostic, documentId: string) => void;
|
|
19
26
|
};
|
|
20
27
|
/**
|
|
21
28
|
* Validates the options and resolves the syntax modes once.
|
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAM3D,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,eAAe,EACf,MAAM,GAAG,QAAQ,GAAG,YAAY,CACjC,GAAG;IACF,6EAA6E;IAC7E,UAAU,CAAC,EAAE,CACX,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACzB,IAAI,CAAA;IACT,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5E,CAAA;AAeD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,iBAAiB,EAC1B,SAAS,MAAM,KACd,iBAiCF,CAAA"}
|
package/dist/options.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* loads rather than at the first document, because an error raised from inside
|
|
7
7
|
* a markdown-it core rule is much harder to place.
|
|
8
8
|
*/
|
|
9
|
-
import { resolveSyntax } from "@cudoment/cudoc/document";
|
|
9
|
+
import { resolveSyntax, } from "@cudoment/cudoc/document";
|
|
10
|
+
import { resolveTableColumnLayoutOptions, resolveTableColumnWidthOptions, } from "@cudoment/cudoc/transforms/table-column-layout";
|
|
10
11
|
const KNOWN_KEYS = new Set([
|
|
11
12
|
"syntax",
|
|
12
13
|
"calloutTypes",
|
|
13
|
-
"components",
|
|
14
14
|
"tableColumnLayout",
|
|
15
15
|
"tableColumnWidths",
|
|
16
16
|
"ignoreDiagnostics",
|
|
@@ -18,6 +18,7 @@ const KNOWN_KEYS = new Set([
|
|
|
18
18
|
"onDocument",
|
|
19
19
|
"library",
|
|
20
20
|
"outDir",
|
|
21
|
+
"onDiagnostic",
|
|
21
22
|
]);
|
|
22
23
|
/**
|
|
23
24
|
* Validates the options and resolves the syntax modes once.
|
|
@@ -29,12 +30,27 @@ const KNOWN_KEYS = new Set([
|
|
|
29
30
|
export const resolveHostOptions = (options, adapter) => {
|
|
30
31
|
if (typeof options !== "object" || options === null)
|
|
31
32
|
throw new TypeError(`${adapter}: options must be an object`);
|
|
33
|
+
if ("components" in options)
|
|
34
|
+
throw new TypeError(`${adapter}: components maps MDX elements, which markdown-it never produces; there is nothing for it to map`);
|
|
32
35
|
for (const key of Object.keys(options))
|
|
33
36
|
if (!KNOWN_KEYS.has(key))
|
|
34
37
|
throw new TypeError(`${adapter}: unknown option "${key}"`);
|
|
35
38
|
if (options.headingIds && options.headingIds !== "host")
|
|
36
39
|
throw new TypeError(`${adapter}: headingIds must be "host"; the host slugger assigns ids`);
|
|
37
40
|
resolveSyntax(options.syntax);
|
|
41
|
+
// The table rules are checked the way the remark adapters check them, so
|
|
42
|
+
// a mistyped rule fails here rather than inside the first page's render.
|
|
43
|
+
for (const [key, resolve] of [
|
|
44
|
+
["tableColumnLayout", resolveTableColumnLayoutOptions],
|
|
45
|
+
["tableColumnWidths", resolveTableColumnWidthOptions],
|
|
46
|
+
]) {
|
|
47
|
+
const rules = options[key];
|
|
48
|
+
if (rules === undefined)
|
|
49
|
+
continue;
|
|
50
|
+
if (!Array.isArray(rules))
|
|
51
|
+
throw new TypeError(`${adapter}: ${key} must be an array of rules`);
|
|
52
|
+
rules.forEach((rule, index) => resolve(rule, `${key}[${index}]`));
|
|
53
|
+
}
|
|
38
54
|
return options;
|
|
39
55
|
};
|
|
40
56
|
//# sourceMappingURL=options.js.map
|
package/dist/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,aAAa,GAGd,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,gDAAgD,CAAA;AAyBvD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS;IACjC,QAAQ;IACR,cAAc;IACd,mBAAmB;IACnB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IAAI,EAAE,KAAK,EAAE,EAAE,CAC3B,OAAqD,CACpD,IAAI,EACJ,GAAG,GAAG,IAAI,KAAK,GAAG,CACnB,CACF,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The rule runs in `md.core`, after the host's own core passes, so native
|
|
9
9
|
* anchors, links and containers are already tokens by the time cudoc reads
|
|
10
|
-
* them.
|
|
11
|
-
*
|
|
10
|
+
* them. The page is then rendered in two layers. The host renders the token
|
|
11
|
+
* stream as it always does — its render-time work, such as VitePress lifting
|
|
12
|
+
* `<script setup>` out of the page or collecting links, happens once — and
|
|
13
|
+
* cudoc renders the normalized document, putting the host's own output back
|
|
14
|
+
* for every code block and HTML block it did not change, so line
|
|
15
|
+
* highlighting, copy buttons and snippet imports survive.
|
|
12
16
|
*/
|
|
13
17
|
import type MarkdownIt from "markdown-it";
|
|
14
18
|
import { type HostPluginOptions } from "./options.js";
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AAmBzC,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAiC/C;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,cAAc,GACnB,IAAI,CAmWN"}
|
package/dist/plugin.js
CHANGED
|
@@ -7,20 +7,35 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The rule runs in `md.core`, after the host's own core passes, so native
|
|
9
9
|
* anchors, links and containers are already tokens by the time cudoc reads
|
|
10
|
-
* them.
|
|
11
|
-
*
|
|
10
|
+
* them. The page is then rendered in two layers. The host renders the token
|
|
11
|
+
* stream as it always does — its render-time work, such as VitePress lifting
|
|
12
|
+
* `<script setup>` out of the page or collecting links, happens once — and
|
|
13
|
+
* cudoc renders the normalized document, putting the host's own output back
|
|
14
|
+
* for every code block and HTML block it did not change, so line
|
|
15
|
+
* highlighting, copy buttons and snippet imports survive.
|
|
12
16
|
*/
|
|
13
17
|
import { normalizeDocument, nodeText, } from "@cudoment/cudoc/document";
|
|
14
18
|
import { renderDocument } from "@cudoment/cudoc/render";
|
|
19
|
+
import { expandPreparedEmbeds } from "@cudoment/cudoc/node/prepare-embeds";
|
|
15
20
|
import { resolveEmbed, parseEmbedSpec, } from "@cudoment/cudoc/node/resolve-embed";
|
|
16
|
-
import { readPreparedEmbeds, embedKey, } from "@cudoment/cudoc/node/prepare-embeds";
|
|
17
21
|
import { tokensToAst } from "./tokens.js";
|
|
18
22
|
import { resolveHostOptions } from "./options.js";
|
|
23
|
+
import { markdownItText } from "./text.js";
|
|
19
24
|
/** Clones a token deeply enough that rendering it cannot touch the original. */
|
|
20
25
|
const cloneToken = (token) => Object.assign(Object.create(Object.getPrototypeOf(token)), token, {
|
|
21
26
|
attrs: token.attrs?.map((pair) => [...pair]) ?? null,
|
|
22
27
|
children: token.children?.map(cloneToken) ?? null,
|
|
23
28
|
});
|
|
29
|
+
/** The fences cudoc turns into something else: embeds and page breaks. */
|
|
30
|
+
const CUDOC_FENCES = ["cudoc-embed", "cudoc-pagebreak"];
|
|
31
|
+
/** The block types whose host rendering is put back into cudoc's HTML. */
|
|
32
|
+
const HOST_BLOCKS = ["fence", "code_block", "html_block"];
|
|
33
|
+
/**
|
|
34
|
+
* The HTML a markdown-it front-matter fence, or nothing, would leave before
|
|
35
|
+
* the Markdown body: what a stored source may have ahead of the text the
|
|
36
|
+
* renderer was given.
|
|
37
|
+
*/
|
|
38
|
+
const FRONT_MATTER = /^(?:---|\+\+\+)[^\n]*\n(?:[\s\S]*?\n)?(?:---|\+\+\+)[ \t]*\r?\n?\s*$/;
|
|
24
39
|
/**
|
|
25
40
|
* Installs the shared pipeline on a configured markdown-it instance.
|
|
26
41
|
*
|
|
@@ -30,18 +45,59 @@ const cloneToken = (token) => Object.assign(Object.create(Object.getPrototypeOf(
|
|
|
30
45
|
*/
|
|
31
46
|
export function installHostPlugin(md, options, host) {
|
|
32
47
|
resolveHostOptions(options, host.adapter);
|
|
33
|
-
const
|
|
48
|
+
const pending = new WeakMap();
|
|
49
|
+
const report = options.onDiagnostic ??
|
|
50
|
+
((diagnostic, documentId) => console.warn(`${host.adapter}: ${documentId}:${diagnostic.position?.start.line ?? 1}: ${diagnostic.code}: ${diagnostic.message}`));
|
|
51
|
+
/**
|
|
52
|
+
* Renders tokens the conversion has no mapping for — a table of contents,
|
|
53
|
+
* a code group, math, footnotes — through the host's own rules, handed the
|
|
54
|
+
* whole token list so a rule that reads its neighbours still finds them.
|
|
55
|
+
*/
|
|
56
|
+
const renderHosted = (env) => (list, start, end, inline) => {
|
|
57
|
+
// Links rendered here are rendered again with the page; a host that
|
|
58
|
+
// records them (VitePress checks them for dead links) sees them once.
|
|
59
|
+
const scoped = { ...env, links: [] };
|
|
60
|
+
if (inline)
|
|
61
|
+
return md.renderer.renderInline(list.slice(start, end + 1), md.options, scoped);
|
|
62
|
+
let html = "";
|
|
63
|
+
for (let i = start; i <= end; i++) {
|
|
64
|
+
const token = list[i];
|
|
65
|
+
const rule = md.renderer.rules[token.type];
|
|
66
|
+
html +=
|
|
67
|
+
token.type === "inline"
|
|
68
|
+
? md.renderer.renderInline(token.children ?? [], md.options, scoped)
|
|
69
|
+
: rule
|
|
70
|
+
? rule(list, i, md.options, scoped, md.renderer)
|
|
71
|
+
: md.renderer.renderToken(list, i, md.options);
|
|
72
|
+
}
|
|
73
|
+
return html;
|
|
74
|
+
};
|
|
75
|
+
// The fences cudoc replaces are never shown as code: collection renders a
|
|
76
|
+
// page only to run the rules, and a page cudoc composes puts an embed's
|
|
77
|
+
// content or a page break where the fence was. Handing them to the host
|
|
78
|
+
// would only have its highlighter warn about a language it does not know.
|
|
34
79
|
const nativeFence = md.renderer.rules.fence;
|
|
35
|
-
md.renderer.rules.fence = (tokens, index, renderOptions, env, self) => tokens[index].info.trim()
|
|
36
|
-
env
|
|
80
|
+
md.renderer.rules.fence = (tokens, index, renderOptions, env, self) => CUDOC_FENCES.includes(tokens[index].info.trim()) &&
|
|
81
|
+
(pending.has(env) || env?.cudocCollect)
|
|
37
82
|
? ""
|
|
38
83
|
: nativeFence
|
|
39
84
|
? nativeFence(tokens, index, renderOptions, env, self)
|
|
40
85
|
: self.renderToken(tokens, index, renderOptions);
|
|
41
86
|
const nativeRender = md.renderer.render.bind(md.renderer);
|
|
42
87
|
md.renderer.render = (tokens, renderOptions, env) => {
|
|
43
|
-
const
|
|
44
|
-
|
|
88
|
+
const document = env ? pending.get(env) : undefined;
|
|
89
|
+
if (!document)
|
|
90
|
+
return nativeRender(tokens, renderOptions, env);
|
|
91
|
+
let html;
|
|
92
|
+
try {
|
|
93
|
+
html = composeHtml(md.renderer, document, () => nativeRender(tokens, renderOptions, env), renderOptions, env);
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
// Only now: the host's own pass reads it to leave cudoc's fences out.
|
|
97
|
+
pending.delete(env);
|
|
98
|
+
}
|
|
99
|
+
env.cudocRendered = html;
|
|
100
|
+
return html;
|
|
45
101
|
};
|
|
46
102
|
md.core.ruler.push("cudoc", (state) => {
|
|
47
103
|
let tokens = state.tokens;
|
|
@@ -54,7 +110,50 @@ export function installHostPlugin(md, options, host) {
|
|
|
54
110
|
links: [],
|
|
55
111
|
});
|
|
56
112
|
}
|
|
113
|
+
const collecting = Boolean(state.env.cudocCollect);
|
|
114
|
+
const origins = new Map();
|
|
115
|
+
const renderNow = renderHosted(state.env);
|
|
116
|
+
const deferred = new Map();
|
|
117
|
+
const conversion = {
|
|
118
|
+
adapter: host.adapter,
|
|
119
|
+
token: host.token,
|
|
120
|
+
// A block the host renders is rendered once the ids and titles cudoc
|
|
121
|
+
// settles are on the host's heading tokens, so a table of contents
|
|
122
|
+
// built from them links to the headings the page shows. It is rendered
|
|
123
|
+
// from the host's own tokens, which are what those settle onto.
|
|
124
|
+
render: (list, start, end, inline) => {
|
|
125
|
+
if (inline)
|
|
126
|
+
return renderNow(list, start, end, inline);
|
|
127
|
+
const marker = `\u0000cudoc-hosted-${deferred.size}\u0000`;
|
|
128
|
+
deferred.set(marker, () => renderNow(list === tokens ? state.tokens : list, start, end, false));
|
|
129
|
+
return marker;
|
|
130
|
+
},
|
|
131
|
+
origins,
|
|
132
|
+
};
|
|
57
133
|
const tree = tokensToAst(tokens, state.src, options, conversion);
|
|
134
|
+
// The host slugged every heading before this rule without knowing the
|
|
135
|
+
// ids cudoc settles from `(#id)`. Its ids are held aside until those are
|
|
136
|
+
// known, so the duplicate check sees only ids written in the document,
|
|
137
|
+
// and each then goes back numbered past any id already taken, the way the
|
|
138
|
+
// host's slugger numbers past its own.
|
|
139
|
+
const hostIds = new Map();
|
|
140
|
+
const holdHostIds = (node) => {
|
|
141
|
+
const properties = node.data?.hProperties;
|
|
142
|
+
if (node.type === "heading" &&
|
|
143
|
+
node.position &&
|
|
144
|
+
node.data?.cudoc?.explicitId !== true &&
|
|
145
|
+
typeof properties?.id === "string") {
|
|
146
|
+
hostIds.set(node.position.start.line, properties.id);
|
|
147
|
+
delete properties.id;
|
|
148
|
+
}
|
|
149
|
+
node.children?.forEach(holdHostIds);
|
|
150
|
+
};
|
|
151
|
+
holdHostIds(tree);
|
|
152
|
+
// The clones exist only to read final link attributes; the host renders
|
|
153
|
+
// its own tokens, so that is what each block is traced back to.
|
|
154
|
+
if (tokens !== state.tokens)
|
|
155
|
+
for (const [node, token] of origins)
|
|
156
|
+
origins.set(node, state.tokens[tokens.indexOf(token)] ?? token);
|
|
58
157
|
const diagnostics = normalizeDocument(tree, state.src, { ...options, host: host.host, format: "md", headingIds: "host" }, (source) => {
|
|
59
158
|
const inline = [];
|
|
60
159
|
const env = { ...state.env, links: [] };
|
|
@@ -64,9 +163,71 @@ export function installHostPlugin(md, options, host) {
|
|
|
64
163
|
token.type = "text";
|
|
65
164
|
if (host.resolveInlineAttributes)
|
|
66
165
|
md.renderer.renderInline(inline, md.options, env);
|
|
67
|
-
return tokensToAst(inline, source, options,
|
|
68
|
-
|
|
166
|
+
return tokensToAst(inline, source, options, {
|
|
167
|
+
...conversion,
|
|
168
|
+
render: renderHosted(env),
|
|
169
|
+
}).children;
|
|
69
170
|
});
|
|
171
|
+
const headings = [];
|
|
172
|
+
const collectAll = (node) => {
|
|
173
|
+
if (node.type === "heading")
|
|
174
|
+
headings.push(node);
|
|
175
|
+
node.children?.forEach(collectAll);
|
|
176
|
+
};
|
|
177
|
+
collectAll(tree);
|
|
178
|
+
const taken = new Set(headings
|
|
179
|
+
.map((node) => node.data?.hProperties?.id)
|
|
180
|
+
.filter((id) => typeof id === "string"));
|
|
181
|
+
for (const node of headings) {
|
|
182
|
+
if (typeof node.data?.hProperties?.id === "string" || !node.position)
|
|
183
|
+
continue;
|
|
184
|
+
const base = hostIds.get(node.position.start.line);
|
|
185
|
+
if (!base)
|
|
186
|
+
continue;
|
|
187
|
+
let id = base;
|
|
188
|
+
for (let n = 1; taken.has(id); n++)
|
|
189
|
+
id = `${base}-${n}`;
|
|
190
|
+
taken.add(id);
|
|
191
|
+
node.data = {
|
|
192
|
+
...node.data,
|
|
193
|
+
hProperties: { ...node.data?.hProperties, id },
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const documentId = () => {
|
|
197
|
+
try {
|
|
198
|
+
return host.documentId(state.env);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return "document";
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
// Collection prints what it compiled; the site build reports here, once
|
|
205
|
+
// per render, the way the remark hosts report through the file. The host
|
|
206
|
+
// hands over the page without its front matter, so the line is counted
|
|
207
|
+
// from the collected file when the library holds it.
|
|
208
|
+
if (!collecting && diagnostics.length) {
|
|
209
|
+
const id = documentId();
|
|
210
|
+
const collected = options.library
|
|
211
|
+
? documentIndexOf(options.library).get(id)?.source.text
|
|
212
|
+
: undefined;
|
|
213
|
+
// Compared as markdown-it reads it, line endings and all.
|
|
214
|
+
const text = collected && markdownItText(collected).text;
|
|
215
|
+
const offset = text && text.endsWith(state.src)
|
|
216
|
+
? (text.slice(0, text.length - state.src.length).match(/\n/g) ?? [])
|
|
217
|
+
.length
|
|
218
|
+
: 0;
|
|
219
|
+
const shift = (point) => point ? { ...point, line: point.line + offset } : point;
|
|
220
|
+
for (const diagnostic of diagnostics)
|
|
221
|
+
report(offset && diagnostic.position
|
|
222
|
+
? {
|
|
223
|
+
...diagnostic,
|
|
224
|
+
position: {
|
|
225
|
+
start: shift(diagnostic.position.start),
|
|
226
|
+
end: shift(diagnostic.position.end),
|
|
227
|
+
},
|
|
228
|
+
}
|
|
229
|
+
: diagnostic, id);
|
|
230
|
+
}
|
|
70
231
|
const updateHeading = (node) => {
|
|
71
232
|
if (node.type === "heading")
|
|
72
233
|
for (const child of node.children ?? []) {
|
|
@@ -95,8 +256,11 @@ export function installHostPlugin(md, options, host) {
|
|
|
95
256
|
const heading = headingMap.get((token.map?.[0] ?? -1) + 1);
|
|
96
257
|
if (!heading)
|
|
97
258
|
return;
|
|
98
|
-
|
|
259
|
+
const id = heading.data?.hProperties?.id;
|
|
260
|
+
if (typeof id === "string")
|
|
261
|
+
token.attrSet("id", id);
|
|
99
262
|
const inline = state.tokens[index + 1];
|
|
263
|
+
const written = inline.content;
|
|
100
264
|
const title = heading.children
|
|
101
265
|
?.filter((n) => !["badge", "permalink"].includes(n.data?.cudoc?.kind ?? ""))
|
|
102
266
|
.map(nodeText)
|
|
@@ -106,48 +270,167 @@ export function installHostPlugin(md, options, host) {
|
|
|
106
270
|
const label = new state.Token("text", "", 0);
|
|
107
271
|
label.content = title;
|
|
108
272
|
inline.children = [label];
|
|
273
|
+
// A permalink labelled from the heading as written would read out the
|
|
274
|
+
// anchor marker too: "Permalink to Other (#intro)".
|
|
275
|
+
for (const child of heading.children ?? []) {
|
|
276
|
+
const properties = child.data?.hProperties;
|
|
277
|
+
const aria = properties?.["aria-label"];
|
|
278
|
+
if (child.data?.cudoc?.kind === "permalink" &&
|
|
279
|
+
typeof aria === "string" &&
|
|
280
|
+
written &&
|
|
281
|
+
written !== title)
|
|
282
|
+
properties["aria-label"] = aria.split(written).join(title);
|
|
283
|
+
}
|
|
109
284
|
});
|
|
285
|
+
const fill = (node) => {
|
|
286
|
+
if (node.type === "html" && typeof node.value === "string") {
|
|
287
|
+
const render = deferred.get(node.value);
|
|
288
|
+
if (render)
|
|
289
|
+
node.value = render();
|
|
290
|
+
}
|
|
291
|
+
node.children?.forEach(fill);
|
|
292
|
+
};
|
|
293
|
+
fill(tree);
|
|
110
294
|
state.env.cudoc = {
|
|
111
295
|
tree: structuredClone(tree),
|
|
112
296
|
source: state.src,
|
|
113
297
|
diagnostics,
|
|
114
298
|
};
|
|
115
299
|
options.onDocument?.(structuredClone(tree), state.src, state.env);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
300
|
+
// Collection keeps the fences: the library records what a document
|
|
301
|
+
// embeds, and the host renders nothing that is kept.
|
|
302
|
+
if (collecting)
|
|
303
|
+
return;
|
|
304
|
+
const hasEmbeds = [...origins.keys()].some((node) => node.type === "code" && node.lang === "cudoc-embed");
|
|
305
|
+
if (hasEmbeds)
|
|
306
|
+
expandEmbeds(tree, state.src, state.env);
|
|
307
|
+
pending.set(state.env, { tree, origins, Token: state.Token });
|
|
308
|
+
});
|
|
309
|
+
/**
|
|
310
|
+
* Splices every embed in the page into its tree: resolved on the spot from
|
|
311
|
+
* a library that still has its compiler, or read from the blocks
|
|
312
|
+
* `prepareEmbeds` wrote for a library loaded from disk.
|
|
313
|
+
*/
|
|
314
|
+
const expandEmbeds = (tree, src, env) => {
|
|
315
|
+
const library = options.library;
|
|
316
|
+
if (!library)
|
|
317
|
+
throw new Error(`${host.adapter}: build documents and provide library before rendering embeds`);
|
|
318
|
+
const documentId = host.documentId(env);
|
|
319
|
+
const snapshot = documentIndexOf(library).get(documentId);
|
|
320
|
+
// The renderer is given the page without whatever the host strips first,
|
|
321
|
+
// so the collected source may carry front matter ahead of it and nothing
|
|
322
|
+
// else. Text removed or added anywhere means the library is behind.
|
|
323
|
+
if (snapshot) {
|
|
324
|
+
// As markdown-it reads it, so a file written with `\r\n` matches. The
|
|
325
|
+
// host strips a byte order mark with the front matter; the collected
|
|
326
|
+
// text keeps it.
|
|
327
|
+
const { text } = markdownItText(snapshot.source.text);
|
|
328
|
+
const ahead = text
|
|
329
|
+
.slice(0, text.length - src.length)
|
|
330
|
+
.replace(/^\uFEFF/, "");
|
|
331
|
+
if (!text.endsWith(src) ||
|
|
332
|
+
(ahead.trim() !== "" && !FRONT_MATTER.test(ahead)))
|
|
333
|
+
throw new Error(Array.isArray(env.includes) && env.includes.length
|
|
334
|
+
? `${host.adapter}: ${documentId} includes other files with <!--@include-->, which collection does not expand, so its embeds cannot be matched; move the embed out of a page that includes`
|
|
335
|
+
: `${host.adapter}: stale collected source ${documentId}; recollect documents`);
|
|
336
|
+
}
|
|
337
|
+
if (library.compiler) {
|
|
338
|
+
let index = 0;
|
|
339
|
+
const expand = (node) => {
|
|
340
|
+
if (!node.children)
|
|
341
|
+
return;
|
|
342
|
+
node.children = node.children.flatMap((child) => {
|
|
343
|
+
if (child.type === "code" && child.lang === "cudoc-embed")
|
|
344
|
+
return resolveEmbed(library, parseEmbedSpec(child.value), {
|
|
345
|
+
documentId,
|
|
346
|
+
prefix: `embed-${++index}`,
|
|
347
|
+
}).children;
|
|
348
|
+
expand(child);
|
|
349
|
+
return [child];
|
|
350
|
+
});
|
|
351
|
+
};
|
|
145
352
|
expand(tree);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
expandPreparedEmbeds(tree, {
|
|
356
|
+
outDir: options.outDir ?? ".cudoc/documents",
|
|
357
|
+
documentId,
|
|
358
|
+
source: snapshot?.source.text ?? src,
|
|
150
359
|
});
|
|
151
|
-
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
const indexes = new WeakMap();
|
|
363
|
+
/** The library's documents by id, built once per library. */
|
|
364
|
+
const documentIndexOf = (library) => {
|
|
365
|
+
let index = indexes.get(library.documents);
|
|
366
|
+
if (!index) {
|
|
367
|
+
index = new Map(library.documents.map((d) => [d.id, d]));
|
|
368
|
+
indexes.set(library.documents, index);
|
|
369
|
+
}
|
|
370
|
+
return index;
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* The page's HTML: cudoc's rendering of the normalized document, with the
|
|
374
|
+
* host's own output for every block it left alone.
|
|
375
|
+
*
|
|
376
|
+
* The host renders the whole token stream first, as it would without cudoc,
|
|
377
|
+
* and the output of each code and HTML block is recorded as it goes. A code
|
|
378
|
+
* block that came from another document through an embed has no host token,
|
|
379
|
+
* so one is made for it and handed to the host's fence rule, and it looks like
|
|
380
|
+
* the page's own. An HTML block the host rendered to nothing — VitePress's
|
|
381
|
+
* `<script setup>` and `<style>`, which it lifts into the component — stays
|
|
382
|
+
* nothing.
|
|
383
|
+
*/
|
|
384
|
+
function composeHtml(renderer, document, renderNative, renderOptions, env) {
|
|
385
|
+
const recorded = new Map();
|
|
386
|
+
const rules = renderer.rules;
|
|
387
|
+
const saved = HOST_BLOCKS.map((type) => [type, rules[type]]);
|
|
388
|
+
for (const [type, rule] of saved)
|
|
389
|
+
rules[type] = (tokens, index, options, ruleEnv, self) => {
|
|
390
|
+
const html = rule
|
|
391
|
+
? rule(tokens, index, options, ruleEnv, self)
|
|
392
|
+
: self.renderToken(tokens, index, options);
|
|
393
|
+
recorded.set(tokens[index], html);
|
|
394
|
+
return html;
|
|
395
|
+
};
|
|
396
|
+
try {
|
|
397
|
+
renderNative();
|
|
398
|
+
}
|
|
399
|
+
finally {
|
|
400
|
+
for (const [type, rule] of saved)
|
|
401
|
+
rules[type] = rule;
|
|
402
|
+
}
|
|
403
|
+
const hostHtml = (node) => {
|
|
404
|
+
const origin = document.origins.get(node);
|
|
405
|
+
if (origin)
|
|
406
|
+
return recorded.get(origin);
|
|
407
|
+
if (node.type !== "code")
|
|
408
|
+
return undefined;
|
|
409
|
+
const token = new document.Token("fence", "code", 0);
|
|
410
|
+
token.info = [node.lang, node.meta].filter(Boolean).join(" ");
|
|
411
|
+
token.content = `${node.value ?? ""}\n`;
|
|
412
|
+
token.markup = "```";
|
|
413
|
+
token.block = true;
|
|
414
|
+
const fence = rules.fence;
|
|
415
|
+
return fence
|
|
416
|
+
? fence([token], 0, renderOptions, env, renderer)
|
|
417
|
+
: renderer.renderToken([token], 0, renderOptions);
|
|
418
|
+
};
|
|
419
|
+
const substitute = (node) => {
|
|
420
|
+
if (!node.children)
|
|
421
|
+
return;
|
|
422
|
+
node.children = node.children.flatMap((child) => {
|
|
423
|
+
if (child.type === "code" || document.origins.has(child)) {
|
|
424
|
+
const html = hostHtml(child);
|
|
425
|
+
if (html === undefined)
|
|
426
|
+
return [child];
|
|
427
|
+
return html ? [{ type: "html", value: html }] : [];
|
|
428
|
+
}
|
|
429
|
+
substitute(child);
|
|
430
|
+
return [child];
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
substitute(document.tree);
|
|
434
|
+
return renderDocument(document.tree);
|
|
152
435
|
}
|
|
153
436
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EACL,iBAAiB,EACjB,QAAQ,GAET,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EACL,YAAY,EACZ,cAAc,GACf,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,kBAAkB,EAClB,QAAQ,GACT,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAA0B,MAAM,cAAc,CAAA;AAGzE,gFAAgF;AAChF,MAAM,UAAU,GAAG,CAAC,KAAY,EAAS,EAAE,CACzC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE;IAChE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,IAAI;IACpD,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI;CAClD,CAAC,CAAA;AAEJ;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAc,EACd,OAA0B,EAC1B,IAAoB;IAEpB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,E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I,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;gBAC5B,IAAI,IAAI,KAAK,SAAS;oBAAE,OAAO,CAAC,KAAK,CAAC,CAAA;gBACtC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;YACpD,CAAC;YACD,UAAU,CAAC,KAAK,CAAC,CAAA;YACjB,OAAO,CAAC,KAAK,CAAC,CAAA;QAChB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,UAAU,CAAC,QAAQ,CAAC,IAA+B,CAAC,CAAA;IACpD,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC"}
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text markdown-it reads from a source, and a map from offsets in it back
|
|
3
|
+
* to the source's. Before it parses, markdown-it turns every `\r\n` and lone
|
|
4
|
+
* `\r` into `\n` and every NUL into U+FFFD, so its offsets count in that
|
|
5
|
+
* text; they differ from the source's only after a `\r\n` it made one
|
|
6
|
+
* character of.
|
|
7
|
+
*/
|
|
8
|
+
export declare function markdownItText(source: string): {
|
|
9
|
+
text: string;
|
|
10
|
+
toSource: (offset: number) => number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;CACrC,CAuBA"}
|
package/dist/text.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text markdown-it reads from a source, and a map from offsets in it back
|
|
3
|
+
* to the source's. Before it parses, markdown-it turns every `\r\n` and lone
|
|
4
|
+
* `\r` into `\n` and every NUL into U+FFFD, so its offsets count in that
|
|
5
|
+
* text; they differ from the source's only after a `\r\n` it made one
|
|
6
|
+
* character of.
|
|
7
|
+
*/
|
|
8
|
+
export function markdownItText(source) {
|
|
9
|
+
// Where each `\n` that was a `\r\n` stands in the text markdown-it reads.
|
|
10
|
+
const joined = [];
|
|
11
|
+
for (let at = source.indexOf("\r\n"); at !== -1; at = source.indexOf("\r\n", at + 2))
|
|
12
|
+
joined.push(at - joined.length);
|
|
13
|
+
const text = source.replace(/\r\n?/g, "\n").replace(/\0/g, "\uFFFD");
|
|
14
|
+
return {
|
|
15
|
+
text,
|
|
16
|
+
toSource: (offset) => {
|
|
17
|
+
let low = 0;
|
|
18
|
+
let high = joined.length;
|
|
19
|
+
while (low < high) {
|
|
20
|
+
const middle = (low + high) >> 1;
|
|
21
|
+
if (joined[middle] < offset)
|
|
22
|
+
low = middle + 1;
|
|
23
|
+
else
|
|
24
|
+
high = middle;
|
|
25
|
+
}
|
|
26
|
+
return offset + low;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=text.js.map
|
package/dist/text.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAI3C,0EAA0E;IAC1E,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,KACE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAC/B,EAAE,KAAK,CAAC,CAAC,EACT,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC;QAEnC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;IACjC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IACpE,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YACnB,IAAI,GAAG,GAAG,CAAC,CAAA;YACX,IAAI,IAAI,GAAG,MAAM,CAAC,MAAM,CAAA;YACxB,OAAO,GAAG,GAAG,IAAI,EAAE,CAAC;gBAClB,MAAM,MAAM,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;gBAChC,IAAI,MAAM,CAAC,MAAM,CAAE,GAAG,MAAM;oBAAE,GAAG,GAAG,MAAM,GAAG,CAAC,CAAA;;oBACzC,IAAI,GAAG,MAAM,CAAA;YACpB,CAAC;YACD,OAAO,MAAM,GAAG,GAAG,CAAA;QACrB,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/tokens.d.ts
CHANGED
|
@@ -7,13 +7,29 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type Token from "markdown-it/lib/token.mjs";
|
|
9
9
|
import type { Root } from "mdast";
|
|
10
|
-
import { type DocumentOptions } from "@cudoment/cudoc/document";
|
|
10
|
+
import { type DocumentNode, type DocumentOptions } from "@cudoment/cudoc/document";
|
|
11
11
|
import type { TokenNode } from "./host.js";
|
|
12
12
|
export type TokenConversion = {
|
|
13
13
|
/** Adapter package name used when a token has no mapping. */
|
|
14
14
|
adapter?: string;
|
|
15
15
|
/** Converts a token contributed by the host's own markdown-it plugins. */
|
|
16
16
|
token?: TokenNode;
|
|
17
|
+
/**
|
|
18
|
+
* Renders tokens nothing here maps — a table of contents, math, footnotes —
|
|
19
|
+
* the host's own way. `start` and `end` are the first and last index of the
|
|
20
|
+
* token, or of an open token and its matching close, in `tokens`; `inline`
|
|
21
|
+
* says whether they are an inline token's children. A container that is not
|
|
22
|
+
* a callout, such as a code group, is the exception: its open and its close
|
|
23
|
+
* token are rendered each on its own, and what lies between is converted as
|
|
24
|
+
* usual. The HTML is kept as an `html` node, so the host's rendering
|
|
25
|
+
* survives. Without it, such a token is an error.
|
|
26
|
+
*/
|
|
27
|
+
render?: (tokens: Token[], start: number, end: number, inline: boolean) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Filled with the block token each `code` and `html` node was converted
|
|
30
|
+
* from, so a renderer can put the host's own output for that token back.
|
|
31
|
+
*/
|
|
32
|
+
origins?: Map<DocumentNode, Token>;
|
|
17
33
|
};
|
|
18
34
|
/** Converts the actual markdown-it tokens; it does not parse Markdown again. */
|
|
19
35
|
export declare function tokensToAst(tokens: Token[], source: string, options?: DocumentOptions, conversion?: TokenConversion): Root;
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,MAAM,MAAM,eAAe,GAAG;IAC5B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,CACP,MAAM,EAAE,KAAK,EAAE,EACf,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,KACZ,MAAM,CAAA;IACX;;;OAGG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;CACnC,CAAA;AAuED,gFAAgF;AAChF,wBAAgB,WAAW,CACzB,MAAM,EAAE,KAAK,EAAE,EACf,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,EAC7B,UAAU,GAAE,eAAoB,GAC/B,IAAI,CAoRN"}
|
package/dist/tokens.js
CHANGED
|
@@ -6,6 +6,31 @@
|
|
|
6
6
|
* contributed by a host's own plugins go through the host's `token` hook first.
|
|
7
7
|
*/
|
|
8
8
|
import { makeCallout, resolveSyntax, isHost, } from "@cudoment/cudoc/document";
|
|
9
|
+
/**
|
|
10
|
+
* Container names that mean a callout: the five cudoc types, and the host
|
|
11
|
+
* names `canonicalCalloutType` maps onto them. A container the site
|
|
12
|
+
* registered under any other name — VitePress's `raw` and `code-group`, or
|
|
13
|
+
* one of the site's own — opens and closes the way the host plugin that
|
|
14
|
+
* registered it renders, around content converted like the rest of the page.
|
|
15
|
+
*/
|
|
16
|
+
const CONTAINER_CALLOUTS = new Set([
|
|
17
|
+
"note",
|
|
18
|
+
"tip",
|
|
19
|
+
"important",
|
|
20
|
+
"warning",
|
|
21
|
+
"caution",
|
|
22
|
+
"info",
|
|
23
|
+
"default",
|
|
24
|
+
"danger",
|
|
25
|
+
"error",
|
|
26
|
+
"warn",
|
|
27
|
+
]);
|
|
28
|
+
/**
|
|
29
|
+
* Whether a heading line names its id the host's way, `{#id}` at the end,
|
|
30
|
+
* outside code spans: `` ## Write `{#id}` here `` documents the syntax rather
|
|
31
|
+
* than using it.
|
|
32
|
+
*/
|
|
33
|
+
const namesExplicitId = (line) => /\{#[^}]+\}\s*$/.test(line.replace(/(`+)[\s\S]*?\1/g, ""));
|
|
9
34
|
/** The block and inline tokens every markdown-it host produces alike. */
|
|
10
35
|
const NESTING_TYPES = {
|
|
11
36
|
paragraph_open: "paragraph",
|
|
@@ -23,9 +48,30 @@ const NESTING_TYPES = {
|
|
|
23
48
|
s_open: "delete",
|
|
24
49
|
link_open: "link",
|
|
25
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* An image label as plain text, which is what its alt text is: the text of
|
|
53
|
+
* every inline in it, code and entities included, an inner image by its own
|
|
54
|
+
* label, a soft line break as a newline and a hard one as nothing, which is
|
|
55
|
+
* how mdast reads a `break` node. markdown-it's own renderer drops code
|
|
56
|
+
* and entities from alt text; the remark hosts keep them, and the stored tree
|
|
57
|
+
* reads the same on both lineages.
|
|
58
|
+
*/
|
|
59
|
+
const labelText = (tokens) => tokens
|
|
60
|
+
.map((token) => ["text", "text_special", "code_inline", "html_inline", "emoji"].includes(token.type)
|
|
61
|
+
? token.content
|
|
62
|
+
: token.type === "image"
|
|
63
|
+
? labelText(token.children ?? [])
|
|
64
|
+
: token.type === "softbreak"
|
|
65
|
+
? "\n"
|
|
66
|
+
: "")
|
|
67
|
+
.join("");
|
|
26
68
|
/** Converts the actual markdown-it tokens; it does not parse Markdown again. */
|
|
27
69
|
export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
28
70
|
const adapter = conversion.adapter ?? "cudoc-markdown-it";
|
|
71
|
+
const calloutTypes = new Set([
|
|
72
|
+
...CONTAINER_CALLOUTS,
|
|
73
|
+
...(options.calloutTypes ?? []).map((type) => type.toLowerCase()),
|
|
74
|
+
]);
|
|
29
75
|
const root = { type: "root", children: [] };
|
|
30
76
|
const stack = [root];
|
|
31
77
|
const offsets = [0];
|
|
@@ -50,10 +96,57 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
50
96
|
const add = (node) => {
|
|
51
97
|
parent().children.push(node);
|
|
52
98
|
};
|
|
99
|
+
/** The index of the token that closes the one at `start`. */
|
|
100
|
+
const closing = (list, start) => {
|
|
101
|
+
if (list[start].nesting !== 1)
|
|
102
|
+
return start;
|
|
103
|
+
let depth = 0;
|
|
104
|
+
for (let i = start; i < list.length; i++) {
|
|
105
|
+
depth += list[i].nesting;
|
|
106
|
+
if (depth === 0)
|
|
107
|
+
return i;
|
|
108
|
+
}
|
|
109
|
+
return list.length - 1;
|
|
110
|
+
};
|
|
111
|
+
/** The close token of each open container the host renders, innermost last. */
|
|
112
|
+
const hostContainers = [];
|
|
113
|
+
const hosted = (list, start, end, inline) => add({
|
|
114
|
+
type: "html",
|
|
115
|
+
value: conversion.render(list, start, end, inline),
|
|
116
|
+
...(inline ? {} : { position: position(list[start]) }),
|
|
117
|
+
});
|
|
118
|
+
const walk = (list, inline) => {
|
|
119
|
+
for (let i = 0; i < list.length; i++) {
|
|
120
|
+
const token = list[i];
|
|
121
|
+
if (token.nesting === -1 && hostContainers.at(-1) === token.type) {
|
|
122
|
+
hostContainers.pop();
|
|
123
|
+
hosted(list, i, i, inline);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (consume(token))
|
|
127
|
+
continue;
|
|
128
|
+
if (!conversion.render)
|
|
129
|
+
throw new Error(`${adapter}: unsupported token ${token.type}; provide a token adapter before exporting`);
|
|
130
|
+
// A container the site registered opens and closes the host's way, and
|
|
131
|
+
// what it holds is converted like the rest of the page, so a heading
|
|
132
|
+
// anchor or an embed inside it is still one.
|
|
133
|
+
if (!inline &&
|
|
134
|
+
token.nesting === 1 &&
|
|
135
|
+
token.type.startsWith("container_")) {
|
|
136
|
+
hostContainers.push(token.type.replace(/_open$/, "_close"));
|
|
137
|
+
hosted(list, i, i, inline);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const end = closing(list, i);
|
|
141
|
+
hosted(list, i, end, inline);
|
|
142
|
+
i = end;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/** Converts one token, or returns false for a token nothing here maps. */
|
|
53
146
|
const consume = (token) => {
|
|
54
147
|
if (token.nesting === -1) {
|
|
55
148
|
stack.pop();
|
|
56
|
-
return;
|
|
149
|
+
return true;
|
|
57
150
|
}
|
|
58
151
|
if (token.type === "inline") {
|
|
59
152
|
if (parent().type === "tableCell") {
|
|
@@ -73,13 +166,13 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
73
166
|
},
|
|
74
167
|
};
|
|
75
168
|
}
|
|
76
|
-
token.children
|
|
77
|
-
return;
|
|
169
|
+
walk(token.children ?? [], true);
|
|
170
|
+
return true;
|
|
78
171
|
}
|
|
79
172
|
const attrs = Object.fromEntries(token.attrs ?? []);
|
|
80
173
|
const common = {
|
|
81
174
|
position: position(token),
|
|
82
|
-
...(token.attrs?.length ? { data: { hProperties: attrs } } : {}),
|
|
175
|
+
...(token.attrs?.length ? { data: { hProperties: { ...attrs } } } : {}),
|
|
83
176
|
};
|
|
84
177
|
const hosted = conversion.token?.(token, {
|
|
85
178
|
source,
|
|
@@ -92,13 +185,16 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
92
185
|
node = hosted;
|
|
93
186
|
else if (["text", "text_special"].includes(token.type))
|
|
94
187
|
node = { type: "text", value: token.content };
|
|
188
|
+
// markdown-it-emoji, which VitePress enables: the token holds the emoji.
|
|
189
|
+
else if (token.type === "emoji")
|
|
190
|
+
node = { type: "text", value: token.content };
|
|
95
191
|
else if (token.type === "softbreak")
|
|
96
192
|
node = { type: "text", value: "\n" };
|
|
97
193
|
else if (token.type === "hardbreak")
|
|
98
194
|
node = { type: "break" };
|
|
99
195
|
else if (token.type === "code_inline")
|
|
100
196
|
node = { type: "inlineCode", value: token.content };
|
|
101
|
-
else if (["fence", "code_block"].includes(token.type))
|
|
197
|
+
else if (["fence", "code_block"].includes(token.type)) {
|
|
102
198
|
node = {
|
|
103
199
|
type: "code",
|
|
104
200
|
value: token.content.replace(/\n$/, ""),
|
|
@@ -106,16 +202,32 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
106
202
|
meta: token.info.split(/\s+/).slice(1).join(" "),
|
|
107
203
|
...common,
|
|
108
204
|
};
|
|
109
|
-
|
|
205
|
+
conversion.origins?.set(node, token);
|
|
206
|
+
}
|
|
207
|
+
else if (token.type === "image") {
|
|
110
208
|
node = {
|
|
111
209
|
type: "image",
|
|
112
210
|
url: String(attrs.src ?? ""),
|
|
113
|
-
alt: token.
|
|
211
|
+
alt: labelText(token.children ?? []),
|
|
114
212
|
title: attrs.title ?? null,
|
|
115
213
|
...common,
|
|
116
214
|
};
|
|
117
|
-
|
|
215
|
+
// markdown-it keeps the alt among the attributes as a placeholder its
|
|
216
|
+
// renderer fills from the label, empty until then; as a hast property
|
|
217
|
+
// it would win over the node's own alt.
|
|
218
|
+
const properties = node.data?.hProperties;
|
|
219
|
+
if (properties) {
|
|
220
|
+
delete properties.alt;
|
|
221
|
+
if (!Object.keys(properties).length)
|
|
222
|
+
delete node.data;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else if (token.type === "html_inline")
|
|
226
|
+
node = { type: "html", value: token.content, ...common };
|
|
227
|
+
else if (token.type === "html_block") {
|
|
118
228
|
node = { type: "html", value: token.content, ...common };
|
|
229
|
+
conversion.origins?.set(node, token);
|
|
230
|
+
}
|
|
119
231
|
else if (token.type === "hr")
|
|
120
232
|
node = { type: "thematicBreak", ...common };
|
|
121
233
|
else if (token.type === "github_alert_open") {
|
|
@@ -126,7 +238,10 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
126
238
|
const repeatsType = label.toLowerCase() === String(token.meta.type ?? "").toLowerCase();
|
|
127
239
|
node = makeCallout(token.meta.type, label && !repeatsType ? [{ type: "text", value: label }] : [], [], position(token));
|
|
128
240
|
}
|
|
129
|
-
else if (token.type.startsWith("container_") &&
|
|
241
|
+
else if (token.type.startsWith("container_") &&
|
|
242
|
+
token.nesting === 1 &&
|
|
243
|
+
(token.type === "container_details_open" ||
|
|
244
|
+
calloutTypes.has(token.type.slice(10, -5).toLowerCase()))) {
|
|
130
245
|
const type = token.type.slice(10, -5);
|
|
131
246
|
const title = token.info.trim().slice(type.length).trim();
|
|
132
247
|
node =
|
|
@@ -158,10 +273,10 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
158
273
|
else {
|
|
159
274
|
if (["thead_open", "tbody_open"].includes(token.type)) {
|
|
160
275
|
stack.push(parent());
|
|
161
|
-
return;
|
|
276
|
+
return true;
|
|
162
277
|
}
|
|
163
278
|
if (!NESTING_TYPES[token.type])
|
|
164
|
-
|
|
279
|
+
return false;
|
|
165
280
|
node = { type: NESTING_TYPES[token.type], children: [], ...common };
|
|
166
281
|
if (node.type === "heading") {
|
|
167
282
|
node.depth = Number(token.tag.slice(1));
|
|
@@ -169,12 +284,15 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
169
284
|
...node.data,
|
|
170
285
|
cudoc: {
|
|
171
286
|
kind: "heading",
|
|
172
|
-
explicitId:
|
|
287
|
+
explicitId: namesExplicitId(source
|
|
288
|
+
.slice(node.position?.start.offset, node.position?.end.offset)
|
|
289
|
+
.trimEnd()),
|
|
173
290
|
},
|
|
174
291
|
};
|
|
175
292
|
}
|
|
176
293
|
if (node.type === "link") {
|
|
177
294
|
node.url = String(attrs.href ?? "");
|
|
295
|
+
node.title = attrs.title ?? null;
|
|
178
296
|
// A host's heading permalink is marked here, before normalization, so
|
|
179
297
|
// every transform that reads a heading's own text can exclude it. Its
|
|
180
298
|
// href is corrected afterwards, once the heading id is resolved.
|
|
@@ -208,8 +326,9 @@ export function tokensToAst(tokens, source, options = {}, conversion = {}) {
|
|
|
208
326
|
add(node);
|
|
209
327
|
if (token.nesting === 1)
|
|
210
328
|
stack.push(node);
|
|
329
|
+
return true;
|
|
211
330
|
};
|
|
212
|
-
tokens
|
|
331
|
+
walk(tokens, false);
|
|
213
332
|
return root;
|
|
214
333
|
}
|
|
215
334
|
//# sourceMappingURL=tokens.js.map
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EACL,WAAW,EACX,aAAa,EACb,MAAM,GAGP,MAAM,0BAA0B,CAAA;AAUjC,yEAAyE;AACzE,MAAM,aAAa,GAA2B;IAC5C,cAAc,EAAE,WAAW;IAC3B,YAAY,EAAE,SAAS;IACvB,eAAe,EAAE,YAAY;IAC7B,gBAAgB,EAAE,MAAM;IACxB,iBAAiB,EAAE,MAAM;IACzB,cAAc,EAAE,UAAU;IAC1B,UAAU,EAAE,OAAO;IACnB,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,WAAW;IACpB,OAAO,EAAE,WAAW;IACpB,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,MAAM;CAClB,CAAA;AAED,gFAAgF;AAChF,MAAM,UAAU,WAAW,CACzB,MAAe,EACf,MAAc,EACd,UAA2B,EAAE,EAC7B,aAA8B,EAAE;IAEhC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,mBAAmB,CAAA;IACzD,MAAM,IAAI,GAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IACzD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAA;IACpB,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,CAAA;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE;QACpC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC7C,MAAM,QA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AC,KAAK,IAAI,IAAI,CAAC,CAAA;oBAC7B,KAAK,CAAC,KAAK,GAAG,OAAO,CAAA;gBACvB,CAAC;YACH,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,mBAAmB,CAAA;gBACjD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;gBAC3D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;YACrB,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC7B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;gBACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACrB,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,CAAA;QACT,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzC,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IACD,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IACnB,OAAO,IAAuB,CAAA;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cudoc-markdown-it",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Shared markdown-it pipeline for cudoc host adapters",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
".": {
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
28
|
"default": "./dist/index.js"
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"dist",
|
|
@@ -41,10 +42,13 @@
|
|
|
41
42
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
+
"@types/mdast": "^4.0.4",
|
|
46
|
+
"@types/unist": "^3.0.3",
|
|
47
|
+
"@cudoment/cudoc": "0.6.0"
|
|
45
48
|
},
|
|
46
49
|
"peerDependencies": {
|
|
47
|
-
"markdown-it": "^14.1.0"
|
|
50
|
+
"markdown-it": "^14.1.0",
|
|
51
|
+
"@types/markdown-it": "^14.1.0"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
54
|
"@types/markdown-it": "^14.2.0"
|
|
@@ -52,5 +56,10 @@
|
|
|
52
56
|
"author": "cudoment",
|
|
53
57
|
"engines": {
|
|
54
58
|
"node": ">=20"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"@types/markdown-it": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
}
|