@md2nativedocx/core 0.6.0 → 0.8.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/dist/diagrams/agentflow/parser.d.ts +20 -0
- package/dist/diagrams/agentflow/parser.js +155 -0
- package/dist/diagrams/agentflow/parser.js.map +1 -0
- package/dist/diagrams/architecture-diagram/icons.d.ts +24 -0
- package/dist/diagrams/architecture-diagram/icons.js +148 -0
- package/dist/diagrams/architecture-diagram/icons.js.map +1 -0
- package/dist/diagrams/architecture-diagram/layout.d.ts +71 -0
- package/dist/diagrams/architecture-diagram/layout.js +388 -0
- package/dist/diagrams/architecture-diagram/layout.js.map +1 -0
- package/dist/diagrams/architecture-diagram/parser.d.ts +14 -19
- package/dist/diagrams/architecture-diagram/parser.js +316 -113
- package/dist/diagrams/architecture-diagram/parser.js.map +1 -1
- package/dist/diagrams/architecture-diagram/translator.d.ts +26 -36
- package/dist/diagrams/architecture-diagram/translator.js +234 -147
- package/dist/diagrams/architecture-diagram/translator.js.map +1 -1
- package/dist/diagrams/architecture-diagram/types.d.ts +26 -16
- package/dist/diagrams/architecture-diagram/types.js +4 -14
- package/dist/diagrams/architecture-diagram/types.js.map +1 -1
- package/dist/diagrams/c4/parser.d.ts +11 -19
- package/dist/diagrams/c4/parser.js +242 -90
- package/dist/diagrams/c4/parser.js.map +1 -1
- package/dist/diagrams/c4/translator.d.ts +23 -43
- package/dist/diagrams/c4/translator.js +333 -204
- package/dist/diagrams/c4/translator.js.map +1 -1
- package/dist/diagrams/c4/types.d.ts +78 -45
- package/dist/diagrams/c4/types.js +17 -38
- package/dist/diagrams/c4/types.js.map +1 -1
- package/dist/diagrams/class-diagram/parser.d.ts +10 -11
- package/dist/diagrams/class-diagram/parser.js +322 -74
- package/dist/diagrams/class-diagram/parser.js.map +1 -1
- package/dist/diagrams/class-diagram/translator.d.ts +10 -10
- package/dist/diagrams/class-diagram/translator.js +305 -33
- package/dist/diagrams/class-diagram/translator.js.map +1 -1
- package/dist/diagrams/class-diagram/types.d.ts +61 -4
- package/dist/diagrams/er-diagram/parser.d.ts +22 -19
- package/dist/diagrams/er-diagram/parser.js +412 -89
- package/dist/diagrams/er-diagram/parser.js.map +1 -1
- package/dist/diagrams/er-diagram/translator.d.ts +8 -0
- package/dist/diagrams/er-diagram/translator.js +170 -38
- package/dist/diagrams/er-diagram/translator.js.map +1 -1
- package/dist/diagrams/er-diagram/types.d.ts +32 -5
- package/dist/diagrams/er-diagram/types.js +2 -5
- package/dist/diagrams/er-diagram/types.js.map +1 -1
- package/dist/diagrams/flowchart-source.d.ts +106 -0
- package/dist/diagrams/flowchart-source.js +272 -0
- package/dist/diagrams/flowchart-source.js.map +1 -0
- package/dist/diagrams/gantt/date-utils.d.ts +55 -33
- package/dist/diagrams/gantt/date-utils.js +147 -58
- package/dist/diagrams/gantt/date-utils.js.map +1 -1
- package/dist/diagrams/gantt/parser.d.ts +31 -22
- package/dist/diagrams/gantt/parser.js +259 -141
- package/dist/diagrams/gantt/parser.js.map +1 -1
- package/dist/diagrams/gantt/time-axis.d.ts +44 -0
- package/dist/diagrams/gantt/time-axis.js +158 -0
- package/dist/diagrams/gantt/time-axis.js.map +1 -0
- package/dist/diagrams/gantt/translator.d.ts +8 -5
- package/dist/diagrams/gantt/translator.js +72 -60
- package/dist/diagrams/gantt/translator.js.map +1 -1
- package/dist/diagrams/gantt/types.d.ts +25 -4
- package/dist/diagrams/gantt/types.js +4 -3
- package/dist/diagrams/gantt/types.js.map +1 -1
- package/dist/diagrams/mindmap/parser.d.ts +18 -14
- package/dist/diagrams/mindmap/parser.js +169 -69
- package/dist/diagrams/mindmap/parser.js.map +1 -1
- package/dist/diagrams/mindmap/translator.js +90 -35
- package/dist/diagrams/mindmap/translator.js.map +1 -1
- package/dist/diagrams/mindmap/types.d.ts +18 -0
- package/dist/diagrams/packet/parser.js +1 -1
- package/dist/diagrams/packet/parser.js.map +1 -1
- package/dist/diagrams/pie/translator.js +5 -4
- package/dist/diagrams/pie/translator.js.map +1 -1
- package/dist/diagrams/plantuml/class-parser.d.ts +2 -1
- package/dist/diagrams/plantuml/class-parser.js +19 -11
- package/dist/diagrams/plantuml/class-parser.js.map +1 -1
- package/dist/diagrams/plantuml/sequence-parser.d.ts +3 -2
- package/dist/diagrams/plantuml/sequence-parser.js +28 -12
- package/dist/diagrams/plantuml/sequence-parser.js.map +1 -1
- package/dist/diagrams/plantuml/state-parser.d.ts +5 -3
- package/dist/diagrams/plantuml/state-parser.js +141 -19
- package/dist/diagrams/plantuml/state-parser.js.map +1 -1
- package/dist/diagrams/quadrant/translator.js +5 -4
- package/dist/diagrams/quadrant/translator.js.map +1 -1
- package/dist/diagrams/railroad/layout.d.ts +89 -0
- package/dist/diagrams/railroad/layout.js +235 -0
- package/dist/diagrams/railroad/layout.js.map +1 -0
- package/dist/diagrams/railroad/parser.d.ts +37 -0
- package/dist/diagrams/railroad/parser.js +605 -0
- package/dist/diagrams/railroad/parser.js.map +1 -0
- package/dist/diagrams/railroad/translator.d.ts +11 -0
- package/dist/diagrams/railroad/translator.js +101 -0
- package/dist/diagrams/railroad/translator.js.map +1 -0
- package/dist/diagrams/railroad/types.d.ts +61 -0
- package/dist/diagrams/railroad/types.js +7 -0
- package/dist/diagrams/railroad/types.js.map +1 -0
- package/dist/diagrams/requirement-diagram/parser.d.ts +26 -19
- package/dist/diagrams/requirement-diagram/parser.js +249 -70
- package/dist/diagrams/requirement-diagram/parser.js.map +1 -1
- package/dist/diagrams/requirement-diagram/translator.d.ts +16 -11
- package/dist/diagrams/requirement-diagram/translator.js +170 -50
- package/dist/diagrams/requirement-diagram/translator.js.map +1 -1
- package/dist/diagrams/requirement-diagram/types.d.ts +30 -9
- package/dist/diagrams/requirement-diagram/types.js +7 -5
- package/dist/diagrams/requirement-diagram/types.js.map +1 -1
- package/dist/diagrams/sequence/parser.d.ts +8 -7
- package/dist/diagrams/sequence/parser.js +129 -32
- package/dist/diagrams/sequence/parser.js.map +1 -1
- package/dist/diagrams/sequence/participant-glyph.d.ts +38 -0
- package/dist/diagrams/sequence/participant-glyph.js +97 -0
- package/dist/diagrams/sequence/participant-glyph.js.map +1 -0
- package/dist/diagrams/sequence/participant-kind.d.ts +7 -0
- package/dist/diagrams/sequence/participant-kind.js +19 -0
- package/dist/diagrams/sequence/participant-kind.js.map +1 -0
- package/dist/diagrams/sequence/translator.d.ts +7 -3
- package/dist/diagrams/sequence/translator.js +140 -28
- package/dist/diagrams/sequence/translator.js.map +1 -1
- package/dist/diagrams/sequence/types.d.ts +24 -1
- package/dist/diagrams/state-diagram/parser.d.ts +24 -24
- package/dist/diagrams/state-diagram/parser.js +259 -73
- package/dist/diagrams/state-diagram/parser.js.map +1 -1
- package/dist/diagrams/state-diagram/translator.d.ts +13 -1
- package/dist/diagrams/state-diagram/translator.js +554 -72
- package/dist/diagrams/state-diagram/translator.js.map +1 -1
- package/dist/diagrams/state-diagram/types.d.ts +57 -11
- package/dist/diagrams/state-diagram/types.js +5 -7
- package/dist/diagrams/state-diagram/types.js.map +1 -1
- package/dist/diagrams/tree-view/implicit-root.d.ts +11 -0
- package/dist/diagrams/tree-view/implicit-root.js +14 -0
- package/dist/diagrams/tree-view/implicit-root.js.map +1 -0
- package/dist/diagrams/tree-view/parser.d.ts +23 -8
- package/dist/diagrams/tree-view/parser.js +242 -98
- package/dist/diagrams/tree-view/parser.js.map +1 -1
- package/dist/diagrams/tree-view/translator.d.ts +6 -5
- package/dist/diagrams/tree-view/translator.js +40 -23
- package/dist/diagrams/tree-view/translator.js.map +1 -1
- package/dist/diagrams/tree-view/types.d.ts +22 -6
- package/dist/diagrams/tree-view/types.js +2 -2
- package/dist/diagrams/treemap/parser.d.ts +2 -2
- package/dist/diagrams/treemap/parser.js +5 -12
- package/dist/diagrams/treemap/parser.js.map +1 -1
- package/dist/diagrams/usecase/parser.d.ts +24 -0
- package/dist/diagrams/usecase/parser.js +232 -0
- package/dist/diagrams/usecase/parser.js.map +1 -0
- package/dist/diagrams/venn/translator.js +5 -4
- package/dist/diagrams/venn/translator.js.map +1 -1
- package/dist/diagrams/zenuml/parser.d.ts +2 -2
- package/dist/diagrams/zenuml/parser.js +14 -7
- package/dist/diagrams/zenuml/parser.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/collapse-subgraphs.d.ts +18 -0
- package/dist/layout/collapse-subgraphs.js +80 -0
- package/dist/layout/collapse-subgraphs.js.map +1 -0
- package/dist/layout/layout.d.ts +11 -0
- package/dist/layout/layout.js +89 -17
- package/dist/layout/layout.js.map +1 -1
- package/dist/parser/css-named-colors.d.ts +7 -0
- package/dist/parser/css-named-colors.js +157 -0
- package/dist/parser/css-named-colors.js.map +1 -0
- package/dist/parser/css-style.d.ts +39 -0
- package/dist/parser/css-style.js +88 -0
- package/dist/parser/css-style.js.map +1 -0
- package/dist/parser/diagram-type.d.ts +12 -1
- package/dist/parser/diagram-type.js +4 -0
- package/dist/parser/diagram-type.js.map +1 -1
- package/dist/parser/entities.d.ts +5 -0
- package/dist/parser/entities.js +52 -0
- package/dist/parser/entities.js.map +1 -0
- package/dist/parser/frontmatter.d.ts +36 -0
- package/dist/parser/frontmatter.js +66 -0
- package/dist/parser/frontmatter.js.map +1 -0
- package/dist/parser/interactive.d.ts +13 -0
- package/dist/parser/interactive.js +17 -0
- package/dist/parser/interactive.js.map +1 -0
- package/dist/parser/label.d.ts +37 -0
- package/dist/parser/label.js +73 -0
- package/dist/parser/label.js.map +1 -0
- package/dist/parser/normalize-statements.d.ts +8 -0
- package/dist/parser/normalize-statements.js +17 -2
- package/dist/parser/normalize-statements.js.map +1 -1
- package/dist/parser/parser.d.ts +2 -1
- package/dist/parser/parser.js +345 -324
- package/dist/parser/parser.js.map +1 -1
- package/dist/render-diagram-odf.d.ts +2 -1
- package/dist/render-diagram-odf.js +39 -8
- package/dist/render-diagram-odf.js.map +1 -1
- package/dist/render-diagram.d.ts +11 -3
- package/dist/render-diagram.js +66 -23
- package/dist/render-diagram.js.map +1 -1
- package/dist/smartart/chain.js +1 -1
- package/dist/smartart/chain.js.map +1 -1
- package/dist/smartart/cycle.js +1 -1
- package/dist/smartart/cycle.js.map +1 -1
- package/dist/smartart/drawing.js +2 -10
- package/dist/smartart/drawing.js.map +1 -1
- package/dist/smartart/embed.d.ts +4 -3
- package/dist/smartart/embed.js +5 -4
- package/dist/smartart/embed.js.map +1 -1
- package/dist/smartart/from-graph.d.ts +13 -3
- package/dist/smartart/from-graph.js +39 -7
- package/dist/smartart/from-graph.js.map +1 -1
- package/dist/smartart/from-tree.d.ts +9 -5
- package/dist/smartart/from-tree.js +23 -11
- package/dist/smartart/from-tree.js.map +1 -1
- package/dist/smartart/text.d.ts +18 -4
- package/dist/smartart/text.js +32 -8
- package/dist/smartart/text.js.map +1 -1
- package/dist/smartart/tree-deep.js +1 -1
- package/dist/smartart/tree-deep.js.map +1 -1
- package/dist/smartart/tree.js +2 -2
- package/dist/smartart/tree.js.map +1 -1
- package/dist/translator/actor-figure.d.ts +45 -0
- package/dist/translator/actor-figure.js +46 -0
- package/dist/translator/actor-figure.js.map +1 -0
- package/dist/translator/boxes.d.ts +12 -1
- package/dist/translator/boxes.js +11 -6
- package/dist/translator/boxes.js.map +1 -1
- package/dist/translator/canvas.d.ts +28 -1
- package/dist/translator/canvas.js +83 -16
- package/dist/translator/canvas.js.map +1 -1
- package/dist/translator/custom-geometry.d.ts +28 -0
- package/dist/translator/custom-geometry.js +59 -0
- package/dist/translator/custom-geometry.js.map +1 -0
- package/dist/translator/elbow-connector.d.ts +52 -0
- package/dist/translator/elbow-connector.js +110 -0
- package/dist/translator/elbow-connector.js.map +1 -0
- package/dist/translator/graph-shapes.d.ts +40 -4
- package/dist/translator/graph-shapes.js +62 -10
- package/dist/translator/graph-shapes.js.map +1 -1
- package/dist/translator/label-runs.d.ts +14 -0
- package/dist/translator/label-runs.js +36 -0
- package/dist/translator/label-runs.js.map +1 -0
- package/dist/translator/odf-translator.js +56 -24
- package/dist/translator/odf-translator.js.map +1 -1
- package/dist/translator/ooxml-translator.d.ts +17 -11
- package/dist/translator/ooxml-translator.js +159 -146
- package/dist/translator/ooxml-translator.js.map +1 -1
- package/dist/translator/text-color.d.ts +9 -0
- package/dist/translator/text-color.js +17 -0
- package/dist/translator/text-color.js.map +1 -0
- package/dist/types.d.ts +27 -4
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid's CSS-like style lists (`classDef`, `style`, `linkStyle`), read the same way for every diagram
|
|
3
|
+
* that takes them: a flowchart, a class diagram and a state diagram. Only `fill`, `stroke` and `color` with a
|
|
4
|
+
* hex value or a CSS colour name (turned into its hex value) are kept, so nothing but a validated colour can reach the XML (AGENTS.md rule 2), and
|
|
5
|
+
* `font-weight` / `font-style` as booleans (read by the state diagram only, for now).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Parse a CSS-like `prop:value,prop:value` property list (`classDef`/`style`/
|
|
9
|
+
* `linkStyle`, spec §6.3) into a lowercase-keyed map. Order-independent by
|
|
10
|
+
* design — unlike the old `classDef` regex this replaces, which required
|
|
11
|
+
* `fill:` to be the first (and only) property, silently failing the whole
|
|
12
|
+
* line otherwise. Values that themselves contain a comma (e.g. a
|
|
13
|
+
* `stroke-dasharray` list) will fragment here, but none of the properties
|
|
14
|
+
* this parser actually reads (`fill`, `stroke`, `stroke-width`) are affected.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseCssStyleProps(text: string): Map<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Normalize a CSS color value to a bare 6-digit uppercase hex string (what
|
|
19
|
+
* the translator's `hexColor()` expects), expanding the 3-digit shorthand
|
|
20
|
+
* (`#f9f` -> `FF99FF`), and a CSS named colour (`red`, `white`, any case) to
|
|
21
|
+
* its standard value ({@link CSS_NAMED_COLORS}). Returns `null` for anything
|
|
22
|
+
* else (`transparent`, a `rgb(...)` call, ...) — same tolerant-degradation
|
|
23
|
+
* style as an unrecognized `@{shape: ...}` name: the property is just dropped
|
|
24
|
+
* rather than failing the whole statement.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseHexColor(value: string): string | null;
|
|
27
|
+
/** The subset of `fill`/`stroke` CSS properties this parser maps to OOXML. */
|
|
28
|
+
export interface NodeStylePatch {
|
|
29
|
+
fill?: string;
|
|
30
|
+
stroke?: string;
|
|
31
|
+
color?: string;
|
|
32
|
+
/** `font-weight: bold` (or `bolder`, or a weight of 600 and up); `false` for `normal` and lighter. */
|
|
33
|
+
bold?: boolean;
|
|
34
|
+
/** `font-style: italic` (or `oblique`); `false` for `normal`. */
|
|
35
|
+
italic?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Extract `fill`/`stroke`/`color` from a parsed property map, dropping anything not
|
|
38
|
+
* a recognized hex color (see {@link parseHexColor}). */
|
|
39
|
+
export declare function extractNodeStyle(props: Map<string, string>): NodeStylePatch;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid's CSS-like style lists (`classDef`, `style`, `linkStyle`), read the same way for every diagram
|
|
3
|
+
* that takes them: a flowchart, a class diagram and a state diagram. Only `fill`, `stroke` and `color` with a
|
|
4
|
+
* hex value or a CSS colour name (turned into its hex value) are kept, so nothing but a validated colour can reach the XML (AGENTS.md rule 2), and
|
|
5
|
+
* `font-weight` / `font-style` as booleans (read by the state diagram only, for now).
|
|
6
|
+
*/
|
|
7
|
+
import { CSS_NAMED_COLORS } from './css-named-colors.js';
|
|
8
|
+
/**
|
|
9
|
+
* Parse a CSS-like `prop:value,prop:value` property list (`classDef`/`style`/
|
|
10
|
+
* `linkStyle`, spec §6.3) into a lowercase-keyed map. Order-independent by
|
|
11
|
+
* design — unlike the old `classDef` regex this replaces, which required
|
|
12
|
+
* `fill:` to be the first (and only) property, silently failing the whole
|
|
13
|
+
* line otherwise. Values that themselves contain a comma (e.g. a
|
|
14
|
+
* `stroke-dasharray` list) will fragment here, but none of the properties
|
|
15
|
+
* this parser actually reads (`fill`, `stroke`, `stroke-width`) are affected.
|
|
16
|
+
*/
|
|
17
|
+
export function parseCssStyleProps(text) {
|
|
18
|
+
const props = new Map();
|
|
19
|
+
for (const part of text.split(',')) {
|
|
20
|
+
const i = part.indexOf(':');
|
|
21
|
+
if (i === -1)
|
|
22
|
+
continue;
|
|
23
|
+
const key = part.slice(0, i).trim().toLowerCase();
|
|
24
|
+
const value = part.slice(i + 1).trim();
|
|
25
|
+
if (key.length > 0 && value.length > 0)
|
|
26
|
+
props.set(key, value);
|
|
27
|
+
}
|
|
28
|
+
return props;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Normalize a CSS color value to a bare 6-digit uppercase hex string (what
|
|
32
|
+
* the translator's `hexColor()` expects), expanding the 3-digit shorthand
|
|
33
|
+
* (`#f9f` -> `FF99FF`), and a CSS named colour (`red`, `white`, any case) to
|
|
34
|
+
* its standard value ({@link CSS_NAMED_COLORS}). Returns `null` for anything
|
|
35
|
+
* else (`transparent`, a `rgb(...)` call, ...) — same tolerant-degradation
|
|
36
|
+
* style as an unrecognized `@{shape: ...}` name: the property is just dropped
|
|
37
|
+
* rather than failing the whole statement.
|
|
38
|
+
*/
|
|
39
|
+
export function parseHexColor(value) {
|
|
40
|
+
const v = value.trim();
|
|
41
|
+
const hex6 = v.match(/^#?([0-9A-Fa-f]{6})$/);
|
|
42
|
+
if (hex6)
|
|
43
|
+
return hex6[1].toUpperCase();
|
|
44
|
+
const hex3 = v.match(/^#?([0-9A-Fa-f]{3})$/);
|
|
45
|
+
if (hex3) {
|
|
46
|
+
const [r, g, b] = hex3[1];
|
|
47
|
+
return `${r}${r}${g}${g}${b}${b}`.toUpperCase();
|
|
48
|
+
}
|
|
49
|
+
return CSS_NAMED_COLORS.get(v.toLowerCase()) ?? null;
|
|
50
|
+
}
|
|
51
|
+
/** Extract `fill`/`stroke`/`color` from a parsed property map, dropping anything not
|
|
52
|
+
* a recognized hex color (see {@link parseHexColor}). */
|
|
53
|
+
export function extractNodeStyle(props) {
|
|
54
|
+
const patch = {};
|
|
55
|
+
const fillValue = props.get('fill');
|
|
56
|
+
if (fillValue) {
|
|
57
|
+
const hex = parseHexColor(fillValue);
|
|
58
|
+
if (hex)
|
|
59
|
+
patch.fill = hex;
|
|
60
|
+
}
|
|
61
|
+
const strokeValue = props.get('stroke');
|
|
62
|
+
if (strokeValue) {
|
|
63
|
+
const hex = parseHexColor(strokeValue);
|
|
64
|
+
if (hex)
|
|
65
|
+
patch.stroke = hex;
|
|
66
|
+
}
|
|
67
|
+
const colorValue = props.get('color');
|
|
68
|
+
if (colorValue) {
|
|
69
|
+
const hex = parseHexColor(colorValue);
|
|
70
|
+
if (hex)
|
|
71
|
+
patch.color = hex;
|
|
72
|
+
}
|
|
73
|
+
const weight = props.get('font-weight')?.toLowerCase();
|
|
74
|
+
if (weight !== undefined) {
|
|
75
|
+
const numeric = Number(weight);
|
|
76
|
+
if (weight === 'bold' || weight === 'bolder' || (Number.isFinite(numeric) && numeric >= 600))
|
|
77
|
+
patch.bold = true;
|
|
78
|
+
else if (weight === 'normal' || weight === 'lighter' || Number.isFinite(numeric))
|
|
79
|
+
patch.bold = false;
|
|
80
|
+
}
|
|
81
|
+
const fontStyle = props.get('font-style')?.toLowerCase();
|
|
82
|
+
if (fontStyle === 'italic' || fontStyle === 'oblique')
|
|
83
|
+
patch.italic = true;
|
|
84
|
+
else if (fontStyle === 'normal')
|
|
85
|
+
patch.italic = false;
|
|
86
|
+
return patch;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=css-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-style.js","sourceRoot":"","sources":["../../src/parser/css-style.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MA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,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;IACvG,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IACzD,IAAI,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,SAAS;QAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;SACtE,IAAI,SAAS,KAAK,QAAQ;QAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IACtD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -28,7 +28,18 @@ export type DiagramType = 'flowchart' | 'unknown' | 'sequence' | 'class' | 'stat
|
|
|
28
28
|
/** PlantUML (`@startuml`) activity diagram (current syntax): drawn as a flowchart. */
|
|
29
29
|
| 'plantumlActivity'
|
|
30
30
|
/** Any other PlantUML diagram (class, activity, mindmap...): not converted yet, shown as a note. */
|
|
31
|
-
| 'plantuml'
|
|
31
|
+
| 'plantuml'
|
|
32
|
+
/** Mermaid `agentflow-beta` (a flow of AI agents): drawn as a flowchart. */
|
|
33
|
+
| 'agentflow'
|
|
34
|
+
/** Mermaid `usecase-beta` (UML use case diagram): drawn as a flowchart. */
|
|
35
|
+
| 'usecase'
|
|
36
|
+
/** Mermaid railroad (syntax) diagram, any dialect: `railroad-beta`, `railroad-ebnf-beta`, `-abnf-`, `-peg-`. */
|
|
37
|
+
| 'railroad'
|
|
38
|
+
/**
|
|
39
|
+
* A Mermaid type this project does not draw yet (none today; kept for the next new Mermaid type):
|
|
40
|
+
* a visible note stands in its place, never a flowchart drawn from text that is not one.
|
|
41
|
+
*/
|
|
42
|
+
| 'mermaidUnsupported';
|
|
32
43
|
export interface DiagramTypeInfo {
|
|
33
44
|
type: DiagramType;
|
|
34
45
|
/** Mermaid's own name for the type, for warnings/notes shown to the user. */
|
|
@@ -50,6 +50,10 @@ const NON_FLOWCHART_HEADERS = [
|
|
|
50
50
|
{ type: 'wardley', label: 'Wardley map', pattern: /^wardley(?:-beta)?\b/i },
|
|
51
51
|
{ type: 'cynefin', label: 'Cynefin framework', pattern: /^cynefin-beta\b/i },
|
|
52
52
|
{ type: 'treeView', label: 'TreeView', pattern: /^treeView-beta\b/i },
|
|
53
|
+
{ type: 'agentflow', label: 'Agentflow diagram', pattern: /^agentflow-beta\b/i },
|
|
54
|
+
{ type: 'usecase', label: 'Use case diagram', pattern: /^usecase-beta\b/i },
|
|
55
|
+
{ type: 'railroad', label: 'Railroad diagram', pattern: /^railroad(?:-(?:ebnf|abnf|peg))?-beta\b/i },
|
|
56
|
+
// A Mermaid type not drawn yet goes here as `mermaidUnsupported`: a note instead of a garbled flowchart.
|
|
53
57
|
];
|
|
54
58
|
/**
|
|
55
59
|
* Classify raw Mermaid text by its first significant line (skipping blank
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagram-type.js","sourceRoot":"","sources":["../../src/parser/diagram-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"diagram-type.js","sourceRoot":"","sources":["../../src/parser/diagram-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA+DH,MAAM,SAAS,GAAoB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAC7E,MAAM,OAAO,GAAoB,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAEvE,yEAAyE;AACzE,yEAAyE;AACzE,6EAA6E;AAC7E,MAAM,qBAAqB,GAAiE;IAC1F,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,qBAAqB,EAAE;IAC/E,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,kBAAkB,EAAE;IACtE,EAAE,IAAI,EA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,KAAK,EAAE,2BAA2B,EAAE,CAAC;YACjG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,IAAI,EAAE,EAAE,CAAC;QACzD,CAAC;QACD,IAAI,8EAA8E,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,YAAY,GAAG,IAAI,CAAC;IAC7I,CAAC;IACD,IAAI,YAAY;QAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAC;IAC1F,0FAA0F;IAC1F,IAAI,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAC;IACtI,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Mermaid's entity syntax in label text: `#123;` (a code point) and `#name;` (an HTML named entity), which
|
|
2
|
+
// Mermaid turns into `&123;`/`&name;` and lets the browser decode. This project draws into Word, with no browser,
|
|
3
|
+
// so it decodes them itself. The names are HTML 4's 252 character entities plus `apos`: Latin-1, Greek, maths,
|
|
4
|
+
// arrows, punctuation (`#infin;`, `#hearts;`, `#rarr;`...). An unknown name stays as written, as in a browser.
|
|
5
|
+
/** HTML 4 character entity name -> code point (generated from a browser decoder, not typed by hand). */
|
|
6
|
+
const NAMED_ENTITIES = {
|
|
7
|
+
nbsp: 0xa0, iexcl: 0xa1, cent: 0xa2, pound: 0xa3, curren: 0xa4, yen: 0xa5, brvbar: 0xa6, sect: 0xa7,
|
|
8
|
+
uml: 0xa8, copy: 0xa9, ordf: 0xaa, laquo: 0xab, not: 0xac, shy: 0xad, reg: 0xae, macr: 0xaf, deg: 0xb0,
|
|
9
|
+
plusmn: 0xb1, sup2: 0xb2, sup3: 0xb3, acute: 0xb4, micro: 0xb5, para: 0xb6, middot: 0xb7, cedil: 0xb8,
|
|
10
|
+
sup1: 0xb9, ordm: 0xba, raquo: 0xbb, frac14: 0xbc, frac12: 0xbd, frac34: 0xbe, iquest: 0xbf, Agrave: 0xc0,
|
|
11
|
+
Aacute: 0xc1, Acirc: 0xc2, Atilde: 0xc3, Auml: 0xc4, Aring: 0xc5, AElig: 0xc6, Ccedil: 0xc7, Egrave: 0xc8,
|
|
12
|
+
Eacute: 0xc9, Ecirc: 0xca, Euml: 0xcb, Igrave: 0xcc, Iacute: 0xcd, Icirc: 0xce, Iuml: 0xcf, ETH: 0xd0,
|
|
13
|
+
Ntilde: 0xd1, Ograve: 0xd2, Oacute: 0xd3, Ocirc: 0xd4, Otilde: 0xd5, Ouml: 0xd6, times: 0xd7, Oslash: 0xd8,
|
|
14
|
+
Ugrave: 0xd9, Uacute: 0xda, Ucirc: 0xdb, Uuml: 0xdc, Yacute: 0xdd, THORN: 0xde, szlig: 0xdf, agrave: 0xe0,
|
|
15
|
+
aacute: 0xe1, acirc: 0xe2, atilde: 0xe3, auml: 0xe4, aring: 0xe5, aelig: 0xe6, ccedil: 0xe7, egrave: 0xe8,
|
|
16
|
+
eacute: 0xe9, ecirc: 0xea, euml: 0xeb, igrave: 0xec, iacute: 0xed, icirc: 0xee, iuml: 0xef, eth: 0xf0,
|
|
17
|
+
ntilde: 0xf1, ograve: 0xf2, oacute: 0xf3, ocirc: 0xf4, otilde: 0xf5, ouml: 0xf6, divide: 0xf7,
|
|
18
|
+
oslash: 0xf8, ugrave: 0xf9, uacute: 0xfa, ucirc: 0xfb, uuml: 0xfc, yacute: 0xfd, thorn: 0xfe, yuml: 0xff,
|
|
19
|
+
fnof: 0x192, Alpha: 0x391, Beta: 0x392, Gamma: 0x393, Delta: 0x394, Epsilon: 0x395, Zeta: 0x396,
|
|
20
|
+
Eta: 0x397, Theta: 0x398, Iota: 0x399, Kappa: 0x39a, Lambda: 0x39b, Mu: 0x39c, Nu: 0x39d, Xi: 0x39e,
|
|
21
|
+
Omicron: 0x39f, Pi: 0x3a0, Rho: 0x3a1, Sigma: 0x3a3, Tau: 0x3a4, Upsilon: 0x3a5, Phi: 0x3a6, Chi: 0x3a7,
|
|
22
|
+
Psi: 0x3a8, Omega: 0x3a9, alpha: 0x3b1, beta: 0x3b2, gamma: 0x3b3, delta: 0x3b4, epsilon: 0x3b5,
|
|
23
|
+
zeta: 0x3b6, eta: 0x3b7, theta: 0x3b8, iota: 0x3b9, kappa: 0x3ba, lambda: 0x3bb, mu: 0x3bc, nu: 0x3bd,
|
|
24
|
+
xi: 0x3be, omicron: 0x3bf, pi: 0x3c0, rho: 0x3c1, sigmaf: 0x3c2, sigma: 0x3c3, tau: 0x3c4, upsilon: 0x3c5,
|
|
25
|
+
phi: 0x3c6, chi: 0x3c7, psi: 0x3c8, omega: 0x3c9, thetasym: 0x3d1, upsih: 0x3d2, piv: 0x3d6, bull: 0x2022,
|
|
26
|
+
hellip: 0x2026, prime: 0x2032, Prime: 0x2033, oline: 0x203e, frasl: 0x2044, weierp: 0x2118, image: 0x2111,
|
|
27
|
+
real: 0x211c, trade: 0x2122, alefsym: 0x2135, larr: 0x2190, uarr: 0x2191, rarr: 0x2192, darr: 0x2193,
|
|
28
|
+
harr: 0x2194, crarr: 0x21b5, lArr: 0x21d0, uArr: 0x21d1, rArr: 0x21d2, dArr: 0x21d3, hArr: 0x21d4,
|
|
29
|
+
forall: 0x2200, part: 0x2202, exist: 0x2203, empty: 0x2205, nabla: 0x2207, isin: 0x2208, notin: 0x2209,
|
|
30
|
+
ni: 0x220b, prod: 0x220f, sum: 0x2211, minus: 0x2212, lowast: 0x2217, radic: 0x221a, prop: 0x221d,
|
|
31
|
+
infin: 0x221e, ang: 0x2220, and: 0x2227, or: 0x2228, cap: 0x2229, cup: 0x222a, int: 0x222b, there4: 0x2234,
|
|
32
|
+
sim: 0x223c, cong: 0x2245, asymp: 0x2248, ne: 0x2260, equiv: 0x2261, le: 0x2264, ge: 0x2265, sub: 0x2282,
|
|
33
|
+
sup: 0x2283, nsub: 0x2284, sube: 0x2286, supe: 0x2287, oplus: 0x2295, otimes: 0x2297, perp: 0x22a5,
|
|
34
|
+
sdot: 0x22c5, lceil: 0x2308, rceil: 0x2309, lfloor: 0x230a, rfloor: 0x230b, lang: 0x27e8, rang: 0x27e9,
|
|
35
|
+
loz: 0x25ca, spades: 0x2660, clubs: 0x2663, hearts: 0x2665, diams: 0x2666, quot: 0x22, amp: 0x26, lt: 0x3c,
|
|
36
|
+
gt: 0x3e, OElig: 0x152, oelig: 0x153, Scaron: 0x160, scaron: 0x161, Yuml: 0x178, circ: 0x2c6, tilde: 0x2dc,
|
|
37
|
+
ensp: 0x2002, emsp: 0x2003, thinsp: 0x2009, zwnj: 0x200c, zwj: 0x200d, lrm: 0x200e, rlm: 0x200f,
|
|
38
|
+
ndash: 0x2013, mdash: 0x2014, lsquo: 0x2018, rsquo: 0x2019, sbquo: 0x201a, ldquo: 0x201c, rdquo: 0x201d,
|
|
39
|
+
bdquo: 0x201e, dagger: 0x2020, Dagger: 0x2021, permil: 0x2030, lsaquo: 0x2039, rsaquo: 0x203a,
|
|
40
|
+
euro: 0x20ac, apos: 0x27,
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Decode Mermaid's `#123;` and `#name;` entities in label text. A code point outside Unicode (or a lone
|
|
44
|
+
* surrogate) and an unknown name are left as written.
|
|
45
|
+
*/
|
|
46
|
+
export function decodeMermaidEntities(text) {
|
|
47
|
+
return text.replace(/#(\d{1,7}|[A-Za-z][A-Za-z0-9]{1,8});/g, (whole, ref) => {
|
|
48
|
+
const code = /^\d/.test(ref) ? Number(ref) : Object.hasOwn(NAMED_ENTITIES, ref) ? NAMED_ENTITIES[ref] : -1;
|
|
49
|
+
return code > 0 && code <= 0x10ffff && !(code >= 0xd800 && code <= 0xdfff) ? String.fromCodePoint(code) : whole;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/parser/entities.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,kHAAkH;AAClH,+GAA+G;AAC/G,+GAA+G;AAE/G,wGAAwG;AACxG,MAAM,cAAc,GAAqC;IACvD,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACnG,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI;IACtG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI;IACrG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI;IACzG,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAA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EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IACvG,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC7F,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,IAAI,CAAC,OAAO,CAAC,uCAAuC,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE;QAClF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5G,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,IAAI,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAClH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid's YAML frontmatter, handled once for every diagram type (TODO §2, "Conformité Mermaid").
|
|
3
|
+
*
|
|
4
|
+
* Mermaid reads a leading `---` … `---` block before it looks at the diagram itself, whatever the type:
|
|
5
|
+
* `title:` names the diagram, `config:` carries theme and layout options (and `displayMode:` a Gantt
|
|
6
|
+
* option). The parsers used to meet those lines as diagram statements and report them as unsupported.
|
|
7
|
+
* {@link prepareSource} removes the block, turns `title:` into the type's own `title` statement when it
|
|
8
|
+
* has one (otherwise returns it for the renderer to draw above the diagram), and reports what is not
|
|
9
|
+
* applied.
|
|
10
|
+
*/
|
|
11
|
+
import type { DiagramType } from './diagram-type.js';
|
|
12
|
+
/** The frontmatter block split from the diagram. */
|
|
13
|
+
export interface Frontmatter {
|
|
14
|
+
/** The diagram without its frontmatter (the source unchanged when there is none). */
|
|
15
|
+
body: string;
|
|
16
|
+
/** `title:`, unquoted; `undefined` when absent or empty. */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Whether any key other than `title` is set (`config:`, `displayMode:`…). */
|
|
19
|
+
hasOptions: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Split the YAML frontmatter from `source`. Only top-level keys are read; nothing is evaluated. */
|
|
22
|
+
export declare function splitFrontmatter(source: string): Frontmatter;
|
|
23
|
+
/**
|
|
24
|
+
* The source a parser should see for `type`, and the warnings frontmatter handling produced.
|
|
25
|
+
*
|
|
26
|
+
* - No frontmatter: `source` unchanged, no warning.
|
|
27
|
+
* - `title:` on a type with a `title` statement and none in the body: inserted after the header line.
|
|
28
|
+
* On another type, returned as `title`: the renderer draws it above the diagram, as Mermaid does.
|
|
29
|
+
* - Any other key: a notice that frontmatter options (theme, colours, layout) are not applied; the
|
|
30
|
+
* Word output uses the document's own look.
|
|
31
|
+
*/
|
|
32
|
+
export declare function prepareSource(source: string, type: DiagramType): {
|
|
33
|
+
source: string;
|
|
34
|
+
warnings: string[];
|
|
35
|
+
title?: string;
|
|
36
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid's YAML frontmatter, handled once for every diagram type (TODO §2, "Conformité Mermaid").
|
|
3
|
+
*
|
|
4
|
+
* Mermaid reads a leading `---` … `---` block before it looks at the diagram itself, whatever the type:
|
|
5
|
+
* `title:` names the diagram, `config:` carries theme and layout options (and `displayMode:` a Gantt
|
|
6
|
+
* option). The parsers used to meet those lines as diagram statements and report them as unsupported.
|
|
7
|
+
* {@link prepareSource} removes the block, turns `title:` into the type's own `title` statement when it
|
|
8
|
+
* has one (otherwise returns it for the renderer to draw above the diagram), and reports what is not
|
|
9
|
+
* applied.
|
|
10
|
+
*/
|
|
11
|
+
/** Mermaid's own pattern: `---` on the first line, YAML, `---` on a line of its own. */
|
|
12
|
+
const FRONTMATTER = /^\uFEFF?\s*---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
13
|
+
/** Split the YAML frontmatter from `source`. Only top-level keys are read; nothing is evaluated. */
|
|
14
|
+
export function splitFrontmatter(source) {
|
|
15
|
+
const match = FRONTMATTER.exec(source);
|
|
16
|
+
if (!match)
|
|
17
|
+
return { body: source, hasOptions: false };
|
|
18
|
+
const yaml = match[1] ?? '';
|
|
19
|
+
const titleLine = /^title:[ \t]*(.*)$/m.exec(yaml);
|
|
20
|
+
const title = titleLine ? unquote((titleLine[1] ?? '').trim()) : undefined;
|
|
21
|
+
const hasOptions = /^(?!title:)[A-Za-z_][\w-]*:/m.test(yaml);
|
|
22
|
+
return { body: source.slice(match[0].length), ...(title ? { title } : {}), hasOptions };
|
|
23
|
+
}
|
|
24
|
+
function unquote(value) {
|
|
25
|
+
const q = value[0];
|
|
26
|
+
return (q === '"' || q === "'") && value.endsWith(q) && value.length >= 2 ? value.slice(1, -1) : value;
|
|
27
|
+
}
|
|
28
|
+
/** Types whose grammar has a `title …` statement, so a frontmatter title can become one. */
|
|
29
|
+
const TITLE_STATEMENT = new Set([
|
|
30
|
+
'c4', 'cynefin', 'gantt', 'gitGraph', 'journey', 'packet', 'pie', 'quadrant', 'radar', 'railroad', 'sequence',
|
|
31
|
+
'timeline', 'treeView', 'venn', 'wardley', 'xychart', 'zenuml',
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* The source a parser should see for `type`, and the warnings frontmatter handling produced.
|
|
35
|
+
*
|
|
36
|
+
* - No frontmatter: `source` unchanged, no warning.
|
|
37
|
+
* - `title:` on a type with a `title` statement and none in the body: inserted after the header line.
|
|
38
|
+
* On another type, returned as `title`: the renderer draws it above the diagram, as Mermaid does.
|
|
39
|
+
* - Any other key: a notice that frontmatter options (theme, colours, layout) are not applied; the
|
|
40
|
+
* Word output uses the document's own look.
|
|
41
|
+
*/
|
|
42
|
+
export function prepareSource(source, type) {
|
|
43
|
+
const fm = splitFrontmatter(source);
|
|
44
|
+
if (fm.body === source)
|
|
45
|
+
return { source, warnings: [] };
|
|
46
|
+
const warnings = [];
|
|
47
|
+
let body = fm.body;
|
|
48
|
+
let title;
|
|
49
|
+
if (fm.title !== undefined) {
|
|
50
|
+
const lines = body.split(/\r?\n/);
|
|
51
|
+
const header = lines.findIndex((l) => l.trim() !== '' && !l.trim().startsWith('%%'));
|
|
52
|
+
const hasTitle = lines.some((l, i) => i > header && /^\s*title\b/i.test(l));
|
|
53
|
+
if (!TITLE_STATEMENT.has(type)) {
|
|
54
|
+
title = fm.title;
|
|
55
|
+
}
|
|
56
|
+
else if (header !== -1 && !hasTitle) {
|
|
57
|
+
lines.splice(header + 1, 0, `title ${fm.title.replace(/[\r\n]+/g, ' ')}`);
|
|
58
|
+
body = lines.join('\n');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (fm.hasOptions) {
|
|
62
|
+
warnings.push('Frontmatter options (theme, colours, layout) are not applied: the Word output uses the document\'s own look.');
|
|
63
|
+
}
|
|
64
|
+
return { source: body, warnings, ...(title !== undefined ? { title } : {}) };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/parser/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAcH,wFAAwF;AACxF,MAAM,WAAW,GAAG,8DAA8D,CAAC;AAEnF,oGAAoG;AACpG,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,IAA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CAAC;YAC1E,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;QAClB,QAAQ,CAAC,IAAI,CAAC,8GAA8G,CAAC,CAAC;IAChI,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid's interactive directives (`click`, and in class diagrams `link` and `callback`) attach a URL or
|
|
3
|
+
* a JavaScript callback to a node. A document made by this project never links outside itself (AGENTS.md
|
|
4
|
+
* rule 3, the Follina lesson), so they are recognized and dropped on purpose, with one warning per diagram.
|
|
5
|
+
*/
|
|
6
|
+
/** The warning given once per diagram that has interactive directives. */
|
|
7
|
+
export declare const INTERACTIVE_DIRECTIVES_IGNORED = "Interactive directives (`click`, `link`, `callback`) are not exported: a document made by md2nativedocx never links outside itself.";
|
|
8
|
+
/**
|
|
9
|
+
* Whether `line` is an interactive directive: the keyword, a node id that is not an edge operator, then
|
|
10
|
+
* a target (`"url"`, `href`, `call`, or a callback name). `click --> B` (a node named `click`) is not one.
|
|
11
|
+
* `keywords` lists the directives the grammar has (`['click']` for flowcharts).
|
|
12
|
+
*/
|
|
13
|
+
export declare function isInteractiveDirective(line: string, keywords: readonly string[]): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid's interactive directives (`click`, and in class diagrams `link` and `callback`) attach a URL or
|
|
3
|
+
* a JavaScript callback to a node. A document made by this project never links outside itself (AGENTS.md
|
|
4
|
+
* rule 3, the Follina lesson), so they are recognized and dropped on purpose, with one warning per diagram.
|
|
5
|
+
*/
|
|
6
|
+
/** The warning given once per diagram that has interactive directives. */
|
|
7
|
+
export const INTERACTIVE_DIRECTIVES_IGNORED = 'Interactive directives (`click`, `link`, `callback`) are not exported: a document made by md2nativedocx never links outside itself.';
|
|
8
|
+
/**
|
|
9
|
+
* Whether `line` is an interactive directive: the keyword, a node id that is not an edge operator, then
|
|
10
|
+
* a target (`"url"`, `href`, `call`, or a callback name). `click --> B` (a node named `click`) is not one.
|
|
11
|
+
* `keywords` lists the directives the grammar has (`['click']` for flowcharts).
|
|
12
|
+
*/
|
|
13
|
+
export function isInteractiveDirective(line, keywords) {
|
|
14
|
+
const m = /^([A-Za-z]+)\s+([^\s\-=.<>~|]+)\s+\S/.exec(line);
|
|
15
|
+
return m !== null && keywords.includes(m[1].toLowerCase());
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/parser/interactive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,8BAA8B,GACzC,qIAAqI,CAAC;AAExI;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,QAA2B;IAC9E,MAAM,CAAC,GAAG,sCAAsC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,OAAO,CAAC,KAAK,IAAI,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid label text -> plain text and rich-text runs, shared by every parser that reads Mermaid's label
|
|
3
|
+
* conventions (flowchart, mindmap). Pure: untrusted text in, tokens out; escaping happens in the translators.
|
|
4
|
+
*/
|
|
5
|
+
import type { LabelToken } from '../types.js';
|
|
6
|
+
/** How {@link parseLabel} reads a label. */
|
|
7
|
+
export interface ParseLabelOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Read the label as Markdown even without backticks. A flowchart reads Markdown only inside a "`…`"
|
|
10
|
+
* string; a mindmap reads every label as Markdown (Mermaid gives all its nodes `labelType: 'markdown'`).
|
|
11
|
+
*/
|
|
12
|
+
markdown?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parse the small set of inline-text conveniences Mermaid supports (found via
|
|
16
|
+
* `docs/markdown-mermaid-compliance-table.md` §5, logged in `TODO.md`) into
|
|
17
|
+
* both a flattened plain-text fallback (`text`, used for box-name attributes
|
|
18
|
+
* and `layout.ts`'s width/height estimation — neither needs to know about a
|
|
19
|
+
* bold/italic span) and a structured rich-text body (`runs`, `types.ts`'s
|
|
20
|
+
* `LabelToken[]` — what the translator actually renders):
|
|
21
|
+
* - Mermaid's entity codes (`#quot;`, `#9829;`, `#infin;`, ...) are decoded to
|
|
22
|
+
* their character first ({@link decodeMermaidEntities}), regardless of the
|
|
23
|
+
* cases below.
|
|
24
|
+
* - `<br/>` (and `<br>`, `<br />`, case-insensitive) becomes a real line
|
|
25
|
+
* break: a `{ break: true }` token in `runs` (`text` flattens it to a
|
|
26
|
+
* single space instead — a fallback string has nowhere to put a second line).
|
|
27
|
+
* - A "Markdown string" (a label wrapped in backticks, or any label with
|
|
28
|
+
* `options.markdown`) has its delimiters stripped, a newline in it is a line
|
|
29
|
+
* break (as Mermaid draws one), and `**bold**`/`__bold__`/`*italic*`/`_italic_`
|
|
30
|
+
* spans become real `LabelRun.bold`/`.italic` tokens. Outside Markdown, a
|
|
31
|
+
* literal `**` stays literal: Mermaid's classic label syntax never
|
|
32
|
+
* interprets it.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseLabel(text: string, options?: ParseLabelOptions): {
|
|
35
|
+
text: string;
|
|
36
|
+
runs: LabelToken[];
|
|
37
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid label text -> plain text and rich-text runs, shared by every parser that reads Mermaid's label
|
|
3
|
+
* conventions (flowchart, mindmap). Pure: untrusted text in, tokens out; escaping happens in the translators.
|
|
4
|
+
*/
|
|
5
|
+
import { decodeMermaidEntities } from './entities.js';
|
|
6
|
+
/**
|
|
7
|
+
* Parse the small set of inline-text conveniences Mermaid supports (found via
|
|
8
|
+
* `docs/markdown-mermaid-compliance-table.md` §5, logged in `TODO.md`) into
|
|
9
|
+
* both a flattened plain-text fallback (`text`, used for box-name attributes
|
|
10
|
+
* and `layout.ts`'s width/height estimation — neither needs to know about a
|
|
11
|
+
* bold/italic span) and a structured rich-text body (`runs`, `types.ts`'s
|
|
12
|
+
* `LabelToken[]` — what the translator actually renders):
|
|
13
|
+
* - Mermaid's entity codes (`#quot;`, `#9829;`, `#infin;`, ...) are decoded to
|
|
14
|
+
* their character first ({@link decodeMermaidEntities}), regardless of the
|
|
15
|
+
* cases below.
|
|
16
|
+
* - `<br/>` (and `<br>`, `<br />`, case-insensitive) becomes a real line
|
|
17
|
+
* break: a `{ break: true }` token in `runs` (`text` flattens it to a
|
|
18
|
+
* single space instead — a fallback string has nowhere to put a second line).
|
|
19
|
+
* - A "Markdown string" (a label wrapped in backticks, or any label with
|
|
20
|
+
* `options.markdown`) has its delimiters stripped, a newline in it is a line
|
|
21
|
+
* break (as Mermaid draws one), and `**bold**`/`__bold__`/`*italic*`/`_italic_`
|
|
22
|
+
* spans become real `LabelRun.bold`/`.italic` tokens. Outside Markdown, a
|
|
23
|
+
* literal `**` stays literal: Mermaid's classic label syntax never
|
|
24
|
+
* interprets it.
|
|
25
|
+
*/
|
|
26
|
+
export function parseLabel(text, options = {}) {
|
|
27
|
+
let decoded = decodeMermaidEntities(text);
|
|
28
|
+
const isMarkdownString = decoded.length >= 2 && decoded.startsWith('`') && decoded.endsWith('`');
|
|
29
|
+
if (isMarkdownString)
|
|
30
|
+
decoded = decoded.slice(1, -1);
|
|
31
|
+
const markdown = isMarkdownString || options.markdown === true;
|
|
32
|
+
const segments = decoded.split(markdown ? /<br\s*\/?>|\r?\n/gi : /<br\s*\/?>/gi);
|
|
33
|
+
const runs = [];
|
|
34
|
+
const plainSegments = [];
|
|
35
|
+
segments.forEach((segment, i) => {
|
|
36
|
+
if (i > 0)
|
|
37
|
+
runs.push({ break: true });
|
|
38
|
+
const segmentRuns = markdown ? parseEmphasis(segment) : segment.length > 0 ? [{ text: segment }] : [];
|
|
39
|
+
runs.push(...segmentRuns);
|
|
40
|
+
plainSegments.push(segmentRuns.map((r) => r.text).join(''));
|
|
41
|
+
});
|
|
42
|
+
return { text: plainSegments.join(' '), runs };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Split a Markdown-string segment (no line break in it — {@link parseLabel}
|
|
46
|
+
* already split those out) into plain/bold/italic {@link LabelRun}s.
|
|
47
|
+
* Non-nested and non-overlapping — CommonMark's full emphasis-resolution
|
|
48
|
+
* algorithm is out of scope here; `**`/`__` (bold) is tried before `*`/`_`
|
|
49
|
+
* (italic) at each position so a bold span is never misread as two italic
|
|
50
|
+
* markers. One CommonMark rule is kept because ordinary text depends on it:
|
|
51
|
+
* `_` does not open or close emphasis inside a word, so `snake_case_name`
|
|
52
|
+
* stays as written (Mermaid's Markdown reader, `marked`, does the same).
|
|
53
|
+
*/
|
|
54
|
+
function parseEmphasis(text) {
|
|
55
|
+
const runs = [];
|
|
56
|
+
const re = /\*\*([\s\S]+?)\*\*|(?<![\p{L}\p{N}_])__([\s\S]+?)__(?![\p{L}\p{N}_])|\*([\s\S]+?)\*|(?<![\p{L}\p{N}_])_([\s\S]+?)_(?![\p{L}\p{N}_])/gu;
|
|
57
|
+
let last = 0;
|
|
58
|
+
let m;
|
|
59
|
+
while ((m = re.exec(text)) !== null) {
|
|
60
|
+
if (m.index > last)
|
|
61
|
+
runs.push({ text: text.slice(last, m.index) });
|
|
62
|
+
const bold = m[1] ?? m[2];
|
|
63
|
+
if (bold !== undefined)
|
|
64
|
+
runs.push({ text: bold, bold: true });
|
|
65
|
+
else
|
|
66
|
+
runs.push({ text: (m[3] ?? m[4]), italic: true });
|
|
67
|
+
last = re.lastIndex;
|
|
68
|
+
}
|
|
69
|
+
if (last < text.length)
|
|
70
|
+
runs.push({ text: text.slice(last) });
|
|
71
|
+
return runs;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/parser/label.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAYtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,UAA6B,EAAE;IACtE,IAAI,OAAO,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACjG,IAAI,gBAAgB;QAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,gBAAgB,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IAE/D,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IACjF,MAAM,IAAI,GAAiB,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;QAC9B,IAAI,CAAC,GAAG,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,MAAM,WAAW,GA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AE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC;IACtB,CAAC;IACD,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -27,7 +27,15 @@ export declare function splitLines(text: string): string[];
|
|
|
27
27
|
*
|
|
28
28
|
* `options.brackets: false` turns the bracket rule off, for a grammar where `{` `}` `(` `)` are operators
|
|
29
29
|
* and not delimiters (the ER cardinalities `||--o{`).
|
|
30
|
+
*
|
|
31
|
+
* The sequence diagram grammar is stricter, and `sequenceDiagram` passes all four options: its message text
|
|
32
|
+
* ends at the first `;` even inside quotes or brackets (`quotes: false`, `brackets: false`), keeps `%%` as
|
|
33
|
+
* text (`comments: false`), and spells a literal semicolon `#59;`, an entity Mermaid decodes before it
|
|
34
|
+
* parses (`entities: true` keeps every `#name;` / `#123;` whole).
|
|
30
35
|
*/
|
|
31
36
|
export declare function splitStatements(line: string, options?: {
|
|
32
37
|
brackets?: boolean;
|
|
38
|
+
quotes?: boolean;
|
|
39
|
+
comments?: boolean;
|
|
40
|
+
entities?: boolean;
|
|
33
41
|
}): string[];
|
|
@@ -31,9 +31,16 @@ export function splitLines(text) {
|
|
|
31
31
|
*
|
|
32
32
|
* `options.brackets: false` turns the bracket rule off, for a grammar where `{` `}` `(` `)` are operators
|
|
33
33
|
* and not delimiters (the ER cardinalities `||--o{`).
|
|
34
|
+
*
|
|
35
|
+
* The sequence diagram grammar is stricter, and `sequenceDiagram` passes all four options: its message text
|
|
36
|
+
* ends at the first `;` even inside quotes or brackets (`quotes: false`, `brackets: false`), keeps `%%` as
|
|
37
|
+
* text (`comments: false`), and spells a literal semicolon `#59;`, an entity Mermaid decodes before it
|
|
38
|
+
* parses (`entities: true` keeps every `#name;` / `#123;` whole).
|
|
34
39
|
*/
|
|
35
40
|
export function splitStatements(line, options = {}) {
|
|
36
41
|
const trackBrackets = options.brackets !== false;
|
|
42
|
+
const trackQuotes = options.quotes !== false;
|
|
43
|
+
const stripComments = options.comments !== false;
|
|
37
44
|
const trimmed = line.trim();
|
|
38
45
|
if (trimmed.length === 0)
|
|
39
46
|
return [];
|
|
@@ -45,7 +52,15 @@ export function splitStatements(line, options = {}) {
|
|
|
45
52
|
let inQuotes = false;
|
|
46
53
|
for (let i = 0; i < trimmed.length; i++) {
|
|
47
54
|
const ch = trimmed[i];
|
|
48
|
-
if (ch === '
|
|
55
|
+
if (options.entities && ch === '#') {
|
|
56
|
+
const entity = /^#\w+;/.exec(trimmed.slice(i));
|
|
57
|
+
if (entity) {
|
|
58
|
+
current += entity[0];
|
|
59
|
+
i += entity[0].length - 1;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (trackQuotes && ch === '"') {
|
|
49
64
|
inQuotes = !inQuotes;
|
|
50
65
|
}
|
|
51
66
|
else if (!inQuotes) {
|
|
@@ -60,7 +75,7 @@ export function splitStatements(line, options = {}) {
|
|
|
60
75
|
continue;
|
|
61
76
|
}
|
|
62
77
|
// A trailing comment needs whitespace before it, so `-->|50%%|` style text is not cut.
|
|
63
|
-
if (ch === '%' && trimmed[i + 1] === '%' && (i === 0 || /\s/.test(trimmed[i - 1])))
|
|
78
|
+
if (stripComments && ch === '%' && trimmed[i + 1] === '%' && (i === 0 || /\s/.test(trimmed[i - 1])))
|
|
64
79
|
break;
|
|
65
80
|
}
|
|
66
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-statements.js","sourceRoot":"","sources":["../../src/parser/normalize-statements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,uFAAuF;AACvF,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AAC;oBACzB,OAAO,GAAG,EAAE,CAAC;oBACb,SAAS;gBACX,CAAC;gBACD,uFAAuF;gBACvF,IAAI,aAAa,IAAI,EAAE,KAAK,GAAG,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC;oBAAE,MAAM;YAC9G,CAAC;QACH,CAAC;QACD,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IACD,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/parser/parser.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* V1 scope (spec §5.1): `graph`/`flowchart` with `TD`/`LR` direction only.
|
|
5
5
|
* Supports node shapes from §6.1, edge types from §6.2, and `subgraph`
|
|
6
|
-
* containers. `classDef
|
|
6
|
+
* containers. `classDef` (including `default`), `class`/`:::` and `style` set a node's fill, stroke
|
|
7
|
+
* and text colour, layered as Mermaid layers them (see resolveNodeStyles); `linkStyle` an edge's.
|
|
7
8
|
*
|
|
8
9
|
* This module is a pure function from untrusted text to a typed AST. It never
|
|
9
10
|
* emits XML itself — escaping happens in the translator.
|