mrkdwn.js 4.0.6 → 6.6.2
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 +85 -66
- package/dist/ast/ast.d.cts +1 -1
- package/dist/ast/ast.d.ts +1 -1
- package/dist/{ast-8XCbjRQT.d.cts → ast-CNfTgS0N.d.cts} +35 -35
- package/dist/{ast-8XCbjRQT.d.ts → ast-CNfTgS0N.d.ts} +35 -35
- package/dist/block/block.cjs +12 -4
- package/dist/block/block.d.cts +9 -5
- package/dist/block/block.d.ts +9 -5
- package/dist/block/block.js +8 -4
- package/dist/block/definitions.d.cts +2 -2
- package/dist/block/definitions.d.ts +2 -2
- package/dist/block/node.d.cts +4 -4
- package/dist/block/node.d.ts +4 -4
- package/dist/block/table.d.cts +1 -1
- package/dist/block/table.d.ts +1 -1
- package/dist/codec.cjs +1 -1
- package/dist/codec.d.cts +1631 -29
- package/dist/codec.d.ts +1631 -29
- package/dist/codec.js +2 -2
- package/dist/defaults/defaults.d.cts +1 -1
- package/dist/defaults/defaults.d.ts +1 -1
- package/dist/diagnostics/diagnostics.cjs +17 -7
- package/dist/diagnostics/diagnostics.d.cts +2 -2
- package/dist/diagnostics/diagnostics.d.ts +2 -2
- package/dist/diagnostics/diagnostics.js +17 -8
- package/dist/{diagnostics-BWK1iGy7.d.cts → diagnostics-CjfBoW4K.d.cts} +14 -10
- package/dist/{diagnostics-BWK1iGy7.d.ts → diagnostics-CjfBoW4K.d.ts} +14 -10
- package/dist/emit/emit.cjs +378 -42
- package/dist/emit/emit.js +381 -45
- package/dist/emit/front-matter.cjs +22 -5
- package/dist/emit/front-matter.js +22 -5
- package/dist/emit/html-table.cjs +104 -0
- package/dist/emit/html-table.d.cts +7 -0
- package/dist/emit/html-table.d.ts +7 -0
- package/dist/emit/html-table.js +102 -0
- package/dist/emit/inline.cjs +69 -26
- package/dist/emit/inline.d.cts +2 -12
- package/dist/emit/inline.d.ts +2 -12
- package/dist/emit/inline.js +68 -27
- package/dist/emit/table.cjs +18 -11
- package/dist/emit/table.d.cts +3 -2
- package/dist/emit/table.d.ts +3 -2
- package/dist/emit/table.js +18 -11
- package/dist/html/html-table.cjs +243 -0
- package/dist/html/html-table.d.cts +5 -0
- package/dist/html/html-table.d.ts +5 -0
- package/dist/html/html-table.js +242 -0
- package/dist/html/render.d.cts +1 -1
- package/dist/html/render.d.ts +1 -1
- package/dist/image/image.cjs +4 -4
- package/dist/image/image.d.cts +1 -1
- package/dist/image/image.d.ts +1 -1
- package/dist/image/image.js +4 -4
- package/dist/{image-C4KYmz_L.d.cts → image-B5L0HpAJ.d.cts} +1 -1
- package/dist/{image-DescdRgq.d.cts → image-BtmTG4_a.d.cts} +1 -1
- package/dist/{image-DescdRgq.d.ts → image-BtmTG4_a.d.ts} +1 -1
- package/dist/{image-Cm3hT5PS.d.ts → image-C390OIB3.d.ts} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/inline/delimiter.d.cts +2 -2
- package/dist/inline/delimiter.d.ts +2 -2
- package/dist/inline/inline.d.cts +1 -1
- package/dist/inline/inline.d.ts +1 -1
- package/dist/inline/link.d.cts +17 -1
- package/dist/inline/link.d.ts +17 -1
- package/dist/inline/node.d.cts +2 -2
- package/dist/inline/node.d.ts +2 -2
- package/dist/{inline-CXVQWQnW.d.cts → inline-CnO86zMw.d.cts} +2 -2
- package/dist/inline-DCIKQ83j.d.cts +14 -0
- package/dist/{inline-B_V7bs5j.d.ts → inline-DItZ-VVw.d.ts} +2 -2
- package/dist/inline-INoDAG37.d.ts +14 -0
- package/dist/lower/front-matter.cjs +73 -26
- package/dist/lower/front-matter.d.cts +2 -1
- package/dist/lower/front-matter.d.ts +2 -1
- package/dist/lower/front-matter.js +72 -25
- package/dist/lower/image.d.cts +1 -1
- package/dist/lower/image.d.ts +1 -1
- package/dist/lower/inline.cjs +87 -33
- package/dist/lower/inline.d.cts +9 -12
- package/dist/lower/inline.d.ts +9 -12
- package/dist/lower/inline.js +89 -34
- package/dist/lower/lower.cjs +143 -113
- package/dist/lower/lower.d.cts +8 -1
- package/dist/lower/lower.d.ts +8 -1
- package/dist/lower/lower.js +144 -115
- package/dist/lower/table.cjs +3 -2
- package/dist/lower/table.d.cts +1 -1
- package/dist/lower/table.d.ts +1 -1
- package/dist/lower/table.js +3 -2
- package/dist/options/options.d.cts +10 -10
- package/dist/options/options.d.ts +10 -10
- package/dist/read.cjs +45 -9
- package/dist/read.d.cts +3 -3
- package/dist/read.d.ts +3 -3
- package/dist/read.js +47 -11
- package/dist/scan/entity-table.cjs +2125 -2125
- package/dist/scan/entity-table.js +2125 -2125
- package/dist/shared/line-ending.cjs +7 -0
- package/dist/shared/line-ending.d.cts +5 -0
- package/dist/shared/line-ending.d.ts +5 -0
- package/dist/shared/line-ending.js +5 -0
- package/dist/shared/list-id.cjs +11 -3
- package/dist/shared/list-id.d.cts +7 -4
- package/dist/shared/list-id.d.ts +7 -4
- package/dist/shared/list-id.js +11 -4
- package/dist/shared/style-constants.cjs +0 -2
- package/dist/shared/style-constants.d.cts +1 -2
- package/dist/shared/style-constants.d.ts +1 -2
- package/dist/shared/style-constants.js +1 -2
- package/dist/write.cjs +33 -6
- package/dist/write.d.cts +2 -2
- package/dist/write.d.ts +2 -2
- package/dist/write.js +34 -7
- package/package.json +29 -30
- package/dist/link-Dv4kxVjk.d.cts +0 -18
- package/dist/link-Dv4kxVjk.d.ts +0 -18
package/dist/lower/inline.cjs
CHANGED
|
@@ -12,7 +12,7 @@ function buildRun(text, style, fontFamily) {
|
|
|
12
12
|
...fontFamily !== void 0 ? { fontFamily } : {}
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function lowerNestedEmphasisLike(kind, node, style, context) {
|
|
15
|
+
function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
|
|
16
16
|
if (style[kind] === true) context.sink({
|
|
17
17
|
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.NESTED_EMPHASIS_FLATTENED,
|
|
18
18
|
severity: "info",
|
|
@@ -22,15 +22,31 @@ function lowerNestedEmphasisLike(kind, node, style, context) {
|
|
|
22
22
|
...style,
|
|
23
23
|
[kind]: true
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
lowerNodesInto(node.children, childStyle, context, runs, extents);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function lowerInlineNodeInto(node, style, context, runs, extents) {
|
|
28
28
|
switch (node.type) {
|
|
29
|
-
case "text":
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case "
|
|
33
|
-
|
|
29
|
+
case "text":
|
|
30
|
+
if (node.value.length > 0) runs.push(buildRun(node.value, style));
|
|
31
|
+
return;
|
|
32
|
+
case "entity":
|
|
33
|
+
if (node.value.length > 0) runs.push(buildRun(node.value, style));
|
|
34
|
+
return;
|
|
35
|
+
case "softBreak":
|
|
36
|
+
runs.push({
|
|
37
|
+
...buildRun(" ", style),
|
|
38
|
+
source: {
|
|
39
|
+
format: "markdown",
|
|
40
|
+
xml: "\n"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
case "hardBreak":
|
|
45
|
+
runs.push(buildRun("\n", style));
|
|
46
|
+
return;
|
|
47
|
+
case "codeSpan":
|
|
48
|
+
runs.push(buildRun(node.literal, style, require_shared_style_constants.MONOSPACE_FONT_FAMILY));
|
|
49
|
+
return;
|
|
34
50
|
case "rawHtml":
|
|
35
51
|
if (context.rawHtml === "drop") {
|
|
36
52
|
context.sink({
|
|
@@ -38,47 +54,70 @@ function lowerInlineNode(node, style, context) {
|
|
|
38
54
|
severity: "info",
|
|
39
55
|
message: "inline raw HTML was dropped per the rawHtml: \"drop\" option"
|
|
40
56
|
});
|
|
41
|
-
return
|
|
57
|
+
return;
|
|
42
58
|
}
|
|
43
59
|
context.sink({
|
|
44
60
|
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.RAW_HTML_PRESERVED_AS_TEXT,
|
|
45
61
|
severity: "info",
|
|
46
|
-
message: "inline raw HTML was preserved as literal text; it will not be rendered as HTML by any consumer of the resulting ContentDocument"
|
|
62
|
+
message: "inline raw HTML was preserved as literal text; it will not be rendered as HTML by any consumer of the resulting ContentDocument, and its verbatim original rides the run's own markdown residue for this package's writer to re-emit as-is"
|
|
63
|
+
});
|
|
64
|
+
if (node.literal.length > 0) runs.push({
|
|
65
|
+
...buildRun(node.literal, style),
|
|
66
|
+
source: {
|
|
67
|
+
format: "markdown",
|
|
68
|
+
xml: node.literal
|
|
69
|
+
}
|
|
47
70
|
});
|
|
48
|
-
return
|
|
71
|
+
return;
|
|
49
72
|
case "mathInline":
|
|
50
73
|
context.sink({
|
|
51
74
|
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.MATH_INLINE_PRESERVED_AS_TEXT,
|
|
52
75
|
severity: "info",
|
|
53
76
|
message: "inline math (\\( \\)) was preserved as literal raw LaTeX text; it is not parsed as LaTeX or converted to MathML by this package"
|
|
54
77
|
});
|
|
55
|
-
|
|
78
|
+
runs.push(buildRun(node.literal, style, require_shared_style_constants.MATH_INLINE_FONT_MARKER));
|
|
79
|
+
return;
|
|
56
80
|
case "footnoteReference":
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
81
|
+
runs.push(buildRun(`[^${node.label}]`, style));
|
|
82
|
+
extents.push({
|
|
83
|
+
descriptor: {
|
|
84
|
+
kind: "anchor",
|
|
85
|
+
anchorType: "footnote",
|
|
86
|
+
name: node.label
|
|
87
|
+
},
|
|
88
|
+
startRun: runs.length - 1,
|
|
89
|
+
endRun: runs.length - 1
|
|
61
90
|
});
|
|
62
|
-
return
|
|
91
|
+
return;
|
|
63
92
|
case "autolink": {
|
|
64
93
|
const destination = node.email ? `mailto:${node.destination}` : node.destination;
|
|
65
|
-
|
|
94
|
+
runs.push(buildRun(node.destination, {
|
|
66
95
|
...style,
|
|
67
96
|
hyperlink: destination
|
|
68
|
-
})
|
|
97
|
+
}));
|
|
98
|
+
return;
|
|
69
99
|
}
|
|
70
100
|
case "link": {
|
|
71
|
-
if (node.title !== void 0) context.sink({
|
|
72
|
-
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LINK_TITLE_DROPPED,
|
|
73
|
-
severity: "info",
|
|
74
|
-
message: `link title "${node.title}" has no ContentRun equivalent and was dropped`
|
|
75
|
-
});
|
|
76
101
|
const childStyle = {
|
|
77
102
|
...style,
|
|
78
103
|
hyperlink: node.destination
|
|
79
104
|
};
|
|
80
|
-
const
|
|
81
|
-
|
|
105
|
+
const startRun = runs.length;
|
|
106
|
+
lowerNodesInto(node.children, childStyle, context, runs, extents);
|
|
107
|
+
if (runs.length === startRun) runs.push(buildRun("", childStyle));
|
|
108
|
+
if (node.title !== void 0) extents.push({
|
|
109
|
+
descriptor: {
|
|
110
|
+
kind: "link",
|
|
111
|
+
target: {
|
|
112
|
+
kind: "external",
|
|
113
|
+
uri: node.destination
|
|
114
|
+
},
|
|
115
|
+
title: node.title
|
|
116
|
+
},
|
|
117
|
+
startRun,
|
|
118
|
+
endRun: runs.length
|
|
119
|
+
});
|
|
120
|
+
return;
|
|
82
121
|
}
|
|
83
122
|
case "image":
|
|
84
123
|
if (node.title !== void 0) context.sink({
|
|
@@ -86,17 +125,33 @@ function lowerInlineNode(node, style, context) {
|
|
|
86
125
|
severity: "info",
|
|
87
126
|
message: `image title "${node.title}" has no ContentRun equivalent and was dropped`
|
|
88
127
|
});
|
|
89
|
-
|
|
128
|
+
runs.push(buildRun(node.alt, {
|
|
90
129
|
...style,
|
|
91
130
|
hyperlink: node.destination
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
case "
|
|
95
|
-
|
|
131
|
+
}));
|
|
132
|
+
return;
|
|
133
|
+
case "emphasis":
|
|
134
|
+
lowerNestedEmphasisLike("italic", node, style, context, runs, extents);
|
|
135
|
+
return;
|
|
136
|
+
case "strong":
|
|
137
|
+
lowerNestedEmphasisLike("bold", node, style, context, runs, extents);
|
|
138
|
+
return;
|
|
139
|
+
case "strikethrough":
|
|
140
|
+
lowerNestedEmphasisLike("strike", node, style, context, runs, extents);
|
|
141
|
+
return;
|
|
96
142
|
}
|
|
97
143
|
}
|
|
144
|
+
function lowerNodesInto(nodes, style, context, runs, extents) {
|
|
145
|
+
for (const node of nodes) lowerInlineNodeInto(node, style, context, runs, extents);
|
|
146
|
+
}
|
|
98
147
|
function lowerInlineNodes(nodes, context) {
|
|
99
|
-
|
|
148
|
+
const runs = [];
|
|
149
|
+
const extents = [];
|
|
150
|
+
lowerNodesInto(nodes, {}, context, runs, extents);
|
|
151
|
+
return {
|
|
152
|
+
runs,
|
|
153
|
+
runConstructExtents: extents
|
|
154
|
+
};
|
|
100
155
|
}
|
|
101
156
|
function lowerCodeBlockRun(literal) {
|
|
102
157
|
return {
|
|
@@ -106,5 +161,4 @@ function lowerCodeBlockRun(literal) {
|
|
|
106
161
|
}
|
|
107
162
|
//#endregion
|
|
108
163
|
exports.lowerCodeBlockRun = lowerCodeBlockRun;
|
|
109
|
-
exports.lowerInlineNode = lowerInlineNode;
|
|
110
164
|
exports.lowerInlineNodes = lowerInlineNodes;
|
package/dist/lower/inline.d.cts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { v as MarkdownInlineNode } from "../ast-
|
|
2
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
3
|
-
import { ContentRun } from "document-schema.js";
|
|
1
|
+
import { v as MarkdownInlineNode } from "../ast-CNfTgS0N.cjs";
|
|
2
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
|
|
3
|
+
import { ContentRun, RunConstructExtent } from "document-schema.js";
|
|
4
4
|
//#region src/lower/inline.d.ts
|
|
5
5
|
interface InlineLowerContext {
|
|
6
6
|
readonly sink: MarkdownDiagnosticSink;
|
|
7
|
-
readonly rawHtml:
|
|
7
|
+
readonly rawHtml: "preserve" | "drop";
|
|
8
8
|
}
|
|
9
|
-
interface
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
readonly strike?: boolean;
|
|
13
|
-
readonly hyperlink?: string;
|
|
9
|
+
interface InlineLowerResult {
|
|
10
|
+
readonly runs: ContentRun[];
|
|
11
|
+
readonly runConstructExtents: readonly RunConstructExtent[];
|
|
14
12
|
}
|
|
15
|
-
declare function
|
|
16
|
-
declare function lowerInlineNodes(nodes: readonly MarkdownInlineNode[], context: InlineLowerContext): ContentRun[];
|
|
13
|
+
declare function lowerInlineNodes(nodes: readonly MarkdownInlineNode[], context: InlineLowerContext): InlineLowerResult;
|
|
17
14
|
declare function lowerCodeBlockRun(literal: string): ContentRun;
|
|
18
15
|
//#endregion
|
|
19
|
-
export { InlineLowerContext,
|
|
16
|
+
export { InlineLowerContext, InlineLowerResult, lowerCodeBlockRun, lowerInlineNodes };
|
package/dist/lower/inline.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { v as MarkdownInlineNode } from "../ast-
|
|
2
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
3
|
-
import { ContentRun } from "document-schema.js";
|
|
1
|
+
import { v as MarkdownInlineNode } from "../ast-CNfTgS0N.js";
|
|
2
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
|
|
3
|
+
import { ContentRun, RunConstructExtent } from "document-schema.js";
|
|
4
4
|
//#region src/lower/inline.d.ts
|
|
5
5
|
interface InlineLowerContext {
|
|
6
6
|
readonly sink: MarkdownDiagnosticSink;
|
|
7
|
-
readonly rawHtml:
|
|
7
|
+
readonly rawHtml: "preserve" | "drop";
|
|
8
8
|
}
|
|
9
|
-
interface
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
readonly strike?: boolean;
|
|
13
|
-
readonly hyperlink?: string;
|
|
9
|
+
interface InlineLowerResult {
|
|
10
|
+
readonly runs: ContentRun[];
|
|
11
|
+
readonly runConstructExtents: readonly RunConstructExtent[];
|
|
14
12
|
}
|
|
15
|
-
declare function
|
|
16
|
-
declare function lowerInlineNodes(nodes: readonly MarkdownInlineNode[], context: InlineLowerContext): ContentRun[];
|
|
13
|
+
declare function lowerInlineNodes(nodes: readonly MarkdownInlineNode[], context: InlineLowerContext): InlineLowerResult;
|
|
17
14
|
declare function lowerCodeBlockRun(literal: string): ContentRun;
|
|
18
15
|
//#endregion
|
|
19
|
-
export { InlineLowerContext,
|
|
16
|
+
export { InlineLowerContext, InlineLowerResult, lowerCodeBlockRun, lowerInlineNodes };
|
package/dist/lower/inline.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MarkdownDiagnosticCodes } from "../diagnostics/diagnostics.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MATH_INLINE_FONT_MARKER, MONOSPACE_FONT_FAMILY } from "../shared/style-constants.js";
|
|
3
3
|
//#region src/lower/inline.ts
|
|
4
4
|
function buildRun(text, style, fontFamily) {
|
|
5
5
|
return {
|
|
@@ -11,7 +11,7 @@ function buildRun(text, style, fontFamily) {
|
|
|
11
11
|
...fontFamily !== void 0 ? { fontFamily } : {}
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function lowerNestedEmphasisLike(kind, node, style, context) {
|
|
14
|
+
function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
|
|
15
15
|
if (style[kind] === true) context.sink({
|
|
16
16
|
code: MarkdownDiagnosticCodes.NESTED_EMPHASIS_FLATTENED,
|
|
17
17
|
severity: "info",
|
|
@@ -21,15 +21,31 @@ function lowerNestedEmphasisLike(kind, node, style, context) {
|
|
|
21
21
|
...style,
|
|
22
22
|
[kind]: true
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
lowerNodesInto(node.children, childStyle, context, runs, extents);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function lowerInlineNodeInto(node, style, context, runs, extents) {
|
|
27
27
|
switch (node.type) {
|
|
28
|
-
case "text":
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
case "
|
|
32
|
-
|
|
28
|
+
case "text":
|
|
29
|
+
if (node.value.length > 0) runs.push(buildRun(node.value, style));
|
|
30
|
+
return;
|
|
31
|
+
case "entity":
|
|
32
|
+
if (node.value.length > 0) runs.push(buildRun(node.value, style));
|
|
33
|
+
return;
|
|
34
|
+
case "softBreak":
|
|
35
|
+
runs.push({
|
|
36
|
+
...buildRun(" ", style),
|
|
37
|
+
source: {
|
|
38
|
+
format: "markdown",
|
|
39
|
+
xml: "\n"
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
case "hardBreak":
|
|
44
|
+
runs.push(buildRun("\n", style));
|
|
45
|
+
return;
|
|
46
|
+
case "codeSpan":
|
|
47
|
+
runs.push(buildRun(node.literal, style, MONOSPACE_FONT_FAMILY));
|
|
48
|
+
return;
|
|
33
49
|
case "rawHtml":
|
|
34
50
|
if (context.rawHtml === "drop") {
|
|
35
51
|
context.sink({
|
|
@@ -37,47 +53,70 @@ function lowerInlineNode(node, style, context) {
|
|
|
37
53
|
severity: "info",
|
|
38
54
|
message: "inline raw HTML was dropped per the rawHtml: \"drop\" option"
|
|
39
55
|
});
|
|
40
|
-
return
|
|
56
|
+
return;
|
|
41
57
|
}
|
|
42
58
|
context.sink({
|
|
43
59
|
code: MarkdownDiagnosticCodes.RAW_HTML_PRESERVED_AS_TEXT,
|
|
44
60
|
severity: "info",
|
|
45
|
-
message: "inline raw HTML was preserved as literal text; it will not be rendered as HTML by any consumer of the resulting ContentDocument"
|
|
61
|
+
message: "inline raw HTML was preserved as literal text; it will not be rendered as HTML by any consumer of the resulting ContentDocument, and its verbatim original rides the run's own markdown residue for this package's writer to re-emit as-is"
|
|
62
|
+
});
|
|
63
|
+
if (node.literal.length > 0) runs.push({
|
|
64
|
+
...buildRun(node.literal, style),
|
|
65
|
+
source: {
|
|
66
|
+
format: "markdown",
|
|
67
|
+
xml: node.literal
|
|
68
|
+
}
|
|
46
69
|
});
|
|
47
|
-
return
|
|
70
|
+
return;
|
|
48
71
|
case "mathInline":
|
|
49
72
|
context.sink({
|
|
50
73
|
code: MarkdownDiagnosticCodes.MATH_INLINE_PRESERVED_AS_TEXT,
|
|
51
74
|
severity: "info",
|
|
52
75
|
message: "inline math (\\( \\)) was preserved as literal raw LaTeX text; it is not parsed as LaTeX or converted to MathML by this package"
|
|
53
76
|
});
|
|
54
|
-
|
|
77
|
+
runs.push(buildRun(node.literal, style, MATH_INLINE_FONT_MARKER));
|
|
78
|
+
return;
|
|
55
79
|
case "footnoteReference":
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
runs.push(buildRun(`[^${node.label}]`, style));
|
|
81
|
+
extents.push({
|
|
82
|
+
descriptor: {
|
|
83
|
+
kind: "anchor",
|
|
84
|
+
anchorType: "footnote",
|
|
85
|
+
name: node.label
|
|
86
|
+
},
|
|
87
|
+
startRun: runs.length - 1,
|
|
88
|
+
endRun: runs.length - 1
|
|
60
89
|
});
|
|
61
|
-
return
|
|
90
|
+
return;
|
|
62
91
|
case "autolink": {
|
|
63
92
|
const destination = node.email ? `mailto:${node.destination}` : node.destination;
|
|
64
|
-
|
|
93
|
+
runs.push(buildRun(node.destination, {
|
|
65
94
|
...style,
|
|
66
95
|
hyperlink: destination
|
|
67
|
-
})
|
|
96
|
+
}));
|
|
97
|
+
return;
|
|
68
98
|
}
|
|
69
99
|
case "link": {
|
|
70
|
-
if (node.title !== void 0) context.sink({
|
|
71
|
-
code: MarkdownDiagnosticCodes.LINK_TITLE_DROPPED,
|
|
72
|
-
severity: "info",
|
|
73
|
-
message: `link title "${node.title}" has no ContentRun equivalent and was dropped`
|
|
74
|
-
});
|
|
75
100
|
const childStyle = {
|
|
76
101
|
...style,
|
|
77
102
|
hyperlink: node.destination
|
|
78
103
|
};
|
|
79
|
-
const
|
|
80
|
-
|
|
104
|
+
const startRun = runs.length;
|
|
105
|
+
lowerNodesInto(node.children, childStyle, context, runs, extents);
|
|
106
|
+
if (runs.length === startRun) runs.push(buildRun("", childStyle));
|
|
107
|
+
if (node.title !== void 0) extents.push({
|
|
108
|
+
descriptor: {
|
|
109
|
+
kind: "link",
|
|
110
|
+
target: {
|
|
111
|
+
kind: "external",
|
|
112
|
+
uri: node.destination
|
|
113
|
+
},
|
|
114
|
+
title: node.title
|
|
115
|
+
},
|
|
116
|
+
startRun,
|
|
117
|
+
endRun: runs.length
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
81
120
|
}
|
|
82
121
|
case "image":
|
|
83
122
|
if (node.title !== void 0) context.sink({
|
|
@@ -85,17 +124,33 @@ function lowerInlineNode(node, style, context) {
|
|
|
85
124
|
severity: "info",
|
|
86
125
|
message: `image title "${node.title}" has no ContentRun equivalent and was dropped`
|
|
87
126
|
});
|
|
88
|
-
|
|
127
|
+
runs.push(buildRun(node.alt, {
|
|
89
128
|
...style,
|
|
90
129
|
hyperlink: node.destination
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
case "
|
|
94
|
-
|
|
130
|
+
}));
|
|
131
|
+
return;
|
|
132
|
+
case "emphasis":
|
|
133
|
+
lowerNestedEmphasisLike("italic", node, style, context, runs, extents);
|
|
134
|
+
return;
|
|
135
|
+
case "strong":
|
|
136
|
+
lowerNestedEmphasisLike("bold", node, style, context, runs, extents);
|
|
137
|
+
return;
|
|
138
|
+
case "strikethrough":
|
|
139
|
+
lowerNestedEmphasisLike("strike", node, style, context, runs, extents);
|
|
140
|
+
return;
|
|
95
141
|
}
|
|
96
142
|
}
|
|
143
|
+
function lowerNodesInto(nodes, style, context, runs, extents) {
|
|
144
|
+
for (const node of nodes) lowerInlineNodeInto(node, style, context, runs, extents);
|
|
145
|
+
}
|
|
97
146
|
function lowerInlineNodes(nodes, context) {
|
|
98
|
-
|
|
147
|
+
const runs = [];
|
|
148
|
+
const extents = [];
|
|
149
|
+
lowerNodesInto(nodes, {}, context, runs, extents);
|
|
150
|
+
return {
|
|
151
|
+
runs,
|
|
152
|
+
runConstructExtents: extents
|
|
153
|
+
};
|
|
99
154
|
}
|
|
100
155
|
function lowerCodeBlockRun(literal) {
|
|
101
156
|
return {
|
|
@@ -104,4 +159,4 @@ function lowerCodeBlockRun(literal) {
|
|
|
104
159
|
};
|
|
105
160
|
}
|
|
106
161
|
//#endregion
|
|
107
|
-
export { lowerCodeBlockRun,
|
|
162
|
+
export { lowerCodeBlockRun, lowerInlineNodes };
|