markdown-codec 6.7.5 → 7.0.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 +10 -0
- package/dist/block/block.cjs +19 -37
- package/dist/block/block.js +20 -38
- package/dist/block/node.cjs +3 -3
- package/dist/block/node.d.cts +2 -2
- package/dist/block/node.d.ts +2 -2
- package/dist/block/node.js +3 -3
- package/dist/codec.d.cts +36 -36
- package/dist/codec.d.ts +36 -36
- package/dist/emit/emit.cjs +24 -26
- package/dist/emit/emit.js +24 -26
- package/dist/emit/inline.cjs +18 -12
- package/dist/emit/inline.js +18 -12
- package/dist/html/html-table.cjs +14 -22
- package/dist/html/html-table.js +14 -22
- package/dist/image/image.cjs +8 -8
- package/dist/image/image.js +8 -8
- package/dist/inline/delimiter.cjs +0 -4
- package/dist/inline/delimiter.d.cts +1 -2
- package/dist/inline/delimiter.d.ts +1 -2
- package/dist/inline/delimiter.js +1 -4
- package/dist/inline/gfm-autolink.cjs +20 -19
- package/dist/inline/gfm-autolink.js +20 -19
- package/dist/inline/inline.cjs +29 -39
- package/dist/inline/inline.js +30 -40
- package/dist/lower/lower.cjs +7 -10
- package/dist/lower/lower.js +7 -10
- package/package.json +2 -2
|
@@ -36,7 +36,7 @@ const OPAQUE_KINDS = /* @__PURE__ */ new Set([
|
|
|
36
36
|
"autolink"
|
|
37
37
|
]);
|
|
38
38
|
function isWhitespace(char) {
|
|
39
|
-
return char === "
|
|
39
|
+
return char === " " || char === " " || char === "\n" || char === "\r" || char === "\f";
|
|
40
40
|
}
|
|
41
41
|
function isValidStartBoundary(text, index) {
|
|
42
42
|
if (index === 0) return true;
|
|
@@ -53,28 +53,31 @@ function trimTrailingPunctuation(candidate) {
|
|
|
53
53
|
let end = candidate.length;
|
|
54
54
|
for (;;) {
|
|
55
55
|
const before = end;
|
|
56
|
-
while (
|
|
57
|
-
if (
|
|
56
|
+
while (TRAILING_PUNCTUATION.has(candidate.charAt(end - 1))) end -= 1;
|
|
57
|
+
if (candidate.charAt(end - 1) === ")") {
|
|
58
58
|
const slice = candidate.slice(0, end);
|
|
59
59
|
if (slice.split(")").length > slice.split("(").length) end -= 1;
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (entityTail !== null) end -= entityTail[0].length;
|
|
64
|
-
}
|
|
61
|
+
const entityTail = ENTITY_TAIL_PATTERN.exec(candidate.slice(0, end));
|
|
62
|
+
if (entityTail !== null) end -= entityTail[0].length;
|
|
65
63
|
if (end === before) return candidate.slice(0, end);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
function scanRawCandidate(text, start) {
|
|
69
67
|
let end = start;
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
for (;;) {
|
|
69
|
+
const char = text.charAt(end);
|
|
70
|
+
if (char === "" || isWhitespace(char) || char === "<") return text.slice(start, end);
|
|
71
|
+
end += 1;
|
|
72
|
+
}
|
|
72
73
|
}
|
|
73
74
|
function matchPrefixed(text, index, prefixLength, destinationPrefix, requireValidDomain) {
|
|
74
75
|
const trimmed = trimTrailingPunctuation(scanRawCandidate(text, index));
|
|
75
|
-
|
|
76
|
+
const afterPrefix = trimmed.slice(prefixLength);
|
|
77
|
+
if (afterPrefix === "") return;
|
|
76
78
|
if (requireValidDomain) {
|
|
77
|
-
|
|
79
|
+
const domain = afterPrefix.split(/[/?#]/)[0];
|
|
80
|
+
if (!isValidDomain(domain)) return;
|
|
78
81
|
}
|
|
79
82
|
return {
|
|
80
83
|
text: trimmed,
|
|
@@ -84,17 +87,17 @@ function matchPrefixed(text, index, prefixLength, destinationPrefix, requireVali
|
|
|
84
87
|
}
|
|
85
88
|
function scanEmailDomain(text, start) {
|
|
86
89
|
let end = start;
|
|
87
|
-
while (
|
|
90
|
+
while (EMAIL_DOMAIN_PATTERN.test(text.charAt(end))) end += 1;
|
|
88
91
|
return text.slice(start, end);
|
|
89
92
|
}
|
|
90
93
|
function matchEmailAt(text, atIndex) {
|
|
91
94
|
let start = atIndex;
|
|
92
|
-
while (
|
|
95
|
+
while (EMAIL_LOCAL_PART_PATTERN.test(text.charAt(start - 1))) start -= 1;
|
|
93
96
|
if (start === atIndex || !isValidStartBoundary(text, start)) return;
|
|
94
97
|
const local = text.slice(start, atIndex);
|
|
95
98
|
if (local.startsWith(".") || local.endsWith(".")) return;
|
|
96
99
|
const domain = scanEmailDomain(text, atIndex + 1).replace(/\.+$/, "");
|
|
97
|
-
if (domain.endsWith("-") ||
|
|
100
|
+
if (domain.endsWith("-") || !isValidDomain(domain)) return;
|
|
98
101
|
const address = `${local}@${domain}`;
|
|
99
102
|
return {
|
|
100
103
|
text: address,
|
|
@@ -116,11 +119,10 @@ function expandTextNode(node) {
|
|
|
116
119
|
const text = node.literal;
|
|
117
120
|
let cursor = 0;
|
|
118
121
|
let anchor = node;
|
|
119
|
-
let matches = 0;
|
|
120
122
|
let index = 0;
|
|
121
|
-
while (index
|
|
123
|
+
while (text.charAt(index) !== "") {
|
|
122
124
|
const found = findAutolinkAt(text, index);
|
|
123
|
-
if (found === void 0
|
|
125
|
+
if (found === void 0) {
|
|
124
126
|
index += 1;
|
|
125
127
|
continue;
|
|
126
128
|
}
|
|
@@ -135,10 +137,9 @@ function expandTextNode(node) {
|
|
|
135
137
|
anchor.insertAfter(link);
|
|
136
138
|
anchor = link;
|
|
137
139
|
cursor = found.start + found.text.length;
|
|
138
|
-
matches += 1;
|
|
139
140
|
index = cursor;
|
|
140
141
|
}
|
|
141
|
-
if (
|
|
142
|
+
if (anchor === node) return;
|
|
142
143
|
if (cursor < text.length) anchor.insertAfter(createTextNode(text.slice(cursor)));
|
|
143
144
|
node.unlink();
|
|
144
145
|
}
|
package/dist/inline/inline.cjs
CHANGED
|
@@ -12,7 +12,7 @@ const require_inline_math = require("./math.cjs");
|
|
|
12
12
|
const PLAIN_TEXT_PATTERN = /[^\n`[\]\\!<&*_~]+/y;
|
|
13
13
|
const URI_AUTOLINK_PATTERN = /<[A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>]*>/y;
|
|
14
14
|
const EMAIL_AUTOLINK_PATTERN = /<([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/y;
|
|
15
|
-
const
|
|
15
|
+
const HARD_BREAK_SPACE_COUNT = 2;
|
|
16
16
|
const EMPTY_LABEL_LENGTH = 2;
|
|
17
17
|
function stripOneSurroundingSpace(content) {
|
|
18
18
|
if (content.startsWith(" ") && content.endsWith(" ") && /[^ ]/.test(content)) return content.slice(1, content.length - 1);
|
|
@@ -45,6 +45,13 @@ var InlineParser = class {
|
|
|
45
45
|
return this.container;
|
|
46
46
|
}
|
|
47
47
|
step() {
|
|
48
|
+
PLAIN_TEXT_PATTERN.lastIndex = this.pos;
|
|
49
|
+
const plain = PLAIN_TEXT_PATTERN.exec(this.text);
|
|
50
|
+
if (plain !== null) {
|
|
51
|
+
this.appendText(plain[0]);
|
|
52
|
+
this.pos += plain[0].length;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
48
55
|
const char = this.text.charAt(this.pos);
|
|
49
56
|
switch (char) {
|
|
50
57
|
case "\n":
|
|
@@ -71,12 +78,9 @@ var InlineParser = class {
|
|
|
71
78
|
case "]":
|
|
72
79
|
this.parseCloseBracket();
|
|
73
80
|
return;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
this.parsePlainText();
|
|
81
|
+
case "*":
|
|
82
|
+
case "_":
|
|
83
|
+
case "~": this.parseDelimiterRun(char);
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
appendText(literal) {
|
|
@@ -84,25 +88,16 @@ var InlineParser = class {
|
|
|
84
88
|
this.container.appendChild(node);
|
|
85
89
|
return node;
|
|
86
90
|
}
|
|
87
|
-
parsePlainText() {
|
|
88
|
-
PLAIN_TEXT_PATTERN.lastIndex = this.pos;
|
|
89
|
-
const match = PLAIN_TEXT_PATTERN.exec(this.text);
|
|
90
|
-
if (match === null) {
|
|
91
|
-
this.appendText(this.text.charAt(this.pos));
|
|
92
|
-
this.pos += 1;
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
this.appendText(match[0]);
|
|
96
|
-
this.pos += match[0].length;
|
|
97
|
-
}
|
|
98
91
|
parseLineBreak() {
|
|
99
92
|
this.pos += 1;
|
|
100
93
|
const last = this.container.lastChild;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
let hard = false;
|
|
95
|
+
if (last?.kind === "text") {
|
|
96
|
+
const withoutTrailingSpaces = last.literal.replace(/ +$/, "");
|
|
97
|
+
hard = last.literal.length - withoutTrailingSpaces.length >= HARD_BREAK_SPACE_COUNT;
|
|
98
|
+
last.literal = withoutTrailingSpaces;
|
|
99
|
+
}
|
|
100
|
+
this.container.appendChild(new require_inline_node.InlineNode(hard ? "hardBreak" : "softBreak"));
|
|
106
101
|
while (this.text.charAt(this.pos) === " ") this.pos += 1;
|
|
107
102
|
}
|
|
108
103
|
parseBackslash() {
|
|
@@ -114,15 +109,13 @@ var InlineParser = class {
|
|
|
114
109
|
this.container.appendChild(new require_inline_node.InlineNode("hardBreak"));
|
|
115
110
|
return;
|
|
116
111
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
112
|
+
const span = require_inline_math.matchMathInlineSpan(this.text, backslashIndex);
|
|
113
|
+
if (span !== void 0) {
|
|
114
|
+
const node = new require_inline_node.InlineNode("mathInline");
|
|
115
|
+
node.literal = span.slice(2, span.length - 2);
|
|
116
|
+
this.container.appendChild(node);
|
|
117
|
+
this.pos = backslashIndex + span.length;
|
|
118
|
+
return;
|
|
126
119
|
}
|
|
127
120
|
if (require_inline_chars.isAsciiPunctuation(next)) {
|
|
128
121
|
this.appendText(next);
|
|
@@ -137,7 +130,7 @@ var InlineParser = class {
|
|
|
137
130
|
while (this.text.charAt(start + openLength) === "`") openLength += 1;
|
|
138
131
|
const afterOpen = start + openLength;
|
|
139
132
|
let scan = afterOpen;
|
|
140
|
-
while (
|
|
133
|
+
while (this.text.charAt(scan) !== "") {
|
|
141
134
|
if (this.text.charAt(scan) !== "`") {
|
|
142
135
|
scan += 1;
|
|
143
136
|
continue;
|
|
@@ -219,7 +212,7 @@ var InlineParser = class {
|
|
|
219
212
|
}
|
|
220
213
|
const node = this.appendText(this.text.slice(this.pos, this.pos + run.count));
|
|
221
214
|
this.pos += run.count;
|
|
222
|
-
|
|
215
|
+
this.delimiters.push(char, run, node);
|
|
223
216
|
}
|
|
224
217
|
parseLiteralRun(char) {
|
|
225
218
|
let length = 0;
|
|
@@ -343,7 +336,7 @@ var InlineParser = class {
|
|
|
343
336
|
let label;
|
|
344
337
|
if (labelLength > EMPTY_LABEL_LENGTH) label = this.text.slice(labelStart, labelStart + labelLength);
|
|
345
338
|
else if (!opener.bracketAfter) label = this.text.slice(opener.index, afterCloseBracket);
|
|
346
|
-
|
|
339
|
+
this.pos = labelStart + labelLength;
|
|
347
340
|
if (label === void 0) return;
|
|
348
341
|
const definition = this.references.get(require_inline_link.normalizeLinkLabel(label));
|
|
349
342
|
if (definition === void 0) {
|
|
@@ -488,10 +481,7 @@ function toAstNode(node) {
|
|
|
488
481
|
}
|
|
489
482
|
function parseInlines(content, references, footnotes, options = {}) {
|
|
490
483
|
const root = new InlineParser(content, references, footnotes, options).parse();
|
|
491
|
-
if (options.gfmAutolinks ?? true)
|
|
492
|
-
require_inline_gfm_autolink.applyGfmAutolinks(root);
|
|
493
|
-
mergeAdjacentText(root);
|
|
494
|
-
}
|
|
484
|
+
if (options.gfmAutolinks ?? true) require_inline_gfm_autolink.applyGfmAutolinks(root);
|
|
495
485
|
return toChildAstNodes(root);
|
|
496
486
|
}
|
|
497
487
|
//#endregion
|
package/dist/inline/inline.js
CHANGED
|
@@ -2,7 +2,7 @@ import { matchFootnoteLabel } from "./footnote.js";
|
|
|
2
2
|
import { matchHtmlTag } from "../html/html.js";
|
|
3
3
|
import { containsAsciiControlOrSpace, isAsciiPunctuation } from "./chars.js";
|
|
4
4
|
import { matchEntity } from "./entity.js";
|
|
5
|
-
import { DelimiterStack,
|
|
5
|
+
import { DelimiterStack, processEmphasis, scanDelimiterRun } from "./delimiter.js";
|
|
6
6
|
import { InlineNode, createTextNode } from "./node.js";
|
|
7
7
|
import { applyGfmAutolinks } from "./gfm-autolink.js";
|
|
8
8
|
import { matchLinkLabel, normalizeLinkLabel, parseLinkDestination, parseLinkTitle, skipInlineWhitespace } from "./link.js";
|
|
@@ -11,7 +11,7 @@ import { matchMathInlineSpan } from "./math.js";
|
|
|
11
11
|
const PLAIN_TEXT_PATTERN = /[^\n`[\]\\!<&*_~]+/y;
|
|
12
12
|
const URI_AUTOLINK_PATTERN = /<[A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>]*>/y;
|
|
13
13
|
const EMAIL_AUTOLINK_PATTERN = /<([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/y;
|
|
14
|
-
const
|
|
14
|
+
const HARD_BREAK_SPACE_COUNT = 2;
|
|
15
15
|
const EMPTY_LABEL_LENGTH = 2;
|
|
16
16
|
function stripOneSurroundingSpace(content) {
|
|
17
17
|
if (content.startsWith(" ") && content.endsWith(" ") && /[^ ]/.test(content)) return content.slice(1, content.length - 1);
|
|
@@ -44,6 +44,13 @@ var InlineParser = class {
|
|
|
44
44
|
return this.container;
|
|
45
45
|
}
|
|
46
46
|
step() {
|
|
47
|
+
PLAIN_TEXT_PATTERN.lastIndex = this.pos;
|
|
48
|
+
const plain = PLAIN_TEXT_PATTERN.exec(this.text);
|
|
49
|
+
if (plain !== null) {
|
|
50
|
+
this.appendText(plain[0]);
|
|
51
|
+
this.pos += plain[0].length;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
47
54
|
const char = this.text.charAt(this.pos);
|
|
48
55
|
switch (char) {
|
|
49
56
|
case "\n":
|
|
@@ -70,12 +77,9 @@ var InlineParser = class {
|
|
|
70
77
|
case "]":
|
|
71
78
|
this.parseCloseBracket();
|
|
72
79
|
return;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.parsePlainText();
|
|
80
|
+
case "*":
|
|
81
|
+
case "_":
|
|
82
|
+
case "~": this.parseDelimiterRun(char);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
appendText(literal) {
|
|
@@ -83,25 +87,16 @@ var InlineParser = class {
|
|
|
83
87
|
this.container.appendChild(node);
|
|
84
88
|
return node;
|
|
85
89
|
}
|
|
86
|
-
parsePlainText() {
|
|
87
|
-
PLAIN_TEXT_PATTERN.lastIndex = this.pos;
|
|
88
|
-
const match = PLAIN_TEXT_PATTERN.exec(this.text);
|
|
89
|
-
if (match === null) {
|
|
90
|
-
this.appendText(this.text.charAt(this.pos));
|
|
91
|
-
this.pos += 1;
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this.appendText(match[0]);
|
|
95
|
-
this.pos += match[0].length;
|
|
96
|
-
}
|
|
97
90
|
parseLineBreak() {
|
|
98
91
|
this.pos += 1;
|
|
99
92
|
const last = this.container.lastChild;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
let hard = false;
|
|
94
|
+
if (last?.kind === "text") {
|
|
95
|
+
const withoutTrailingSpaces = last.literal.replace(/ +$/, "");
|
|
96
|
+
hard = last.literal.length - withoutTrailingSpaces.length >= HARD_BREAK_SPACE_COUNT;
|
|
97
|
+
last.literal = withoutTrailingSpaces;
|
|
98
|
+
}
|
|
99
|
+
this.container.appendChild(new InlineNode(hard ? "hardBreak" : "softBreak"));
|
|
105
100
|
while (this.text.charAt(this.pos) === " ") this.pos += 1;
|
|
106
101
|
}
|
|
107
102
|
parseBackslash() {
|
|
@@ -113,15 +108,13 @@ var InlineParser = class {
|
|
|
113
108
|
this.container.appendChild(new InlineNode("hardBreak"));
|
|
114
109
|
return;
|
|
115
110
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
111
|
+
const span = matchMathInlineSpan(this.text, backslashIndex);
|
|
112
|
+
if (span !== void 0) {
|
|
113
|
+
const node = new InlineNode("mathInline");
|
|
114
|
+
node.literal = span.slice(2, span.length - 2);
|
|
115
|
+
this.container.appendChild(node);
|
|
116
|
+
this.pos = backslashIndex + span.length;
|
|
117
|
+
return;
|
|
125
118
|
}
|
|
126
119
|
if (isAsciiPunctuation(next)) {
|
|
127
120
|
this.appendText(next);
|
|
@@ -136,7 +129,7 @@ var InlineParser = class {
|
|
|
136
129
|
while (this.text.charAt(start + openLength) === "`") openLength += 1;
|
|
137
130
|
const afterOpen = start + openLength;
|
|
138
131
|
let scan = afterOpen;
|
|
139
|
-
while (
|
|
132
|
+
while (this.text.charAt(scan) !== "") {
|
|
140
133
|
if (this.text.charAt(scan) !== "`") {
|
|
141
134
|
scan += 1;
|
|
142
135
|
continue;
|
|
@@ -218,7 +211,7 @@ var InlineParser = class {
|
|
|
218
211
|
}
|
|
219
212
|
const node = this.appendText(this.text.slice(this.pos, this.pos + run.count));
|
|
220
213
|
this.pos += run.count;
|
|
221
|
-
|
|
214
|
+
this.delimiters.push(char, run, node);
|
|
222
215
|
}
|
|
223
216
|
parseLiteralRun(char) {
|
|
224
217
|
let length = 0;
|
|
@@ -342,7 +335,7 @@ var InlineParser = class {
|
|
|
342
335
|
let label;
|
|
343
336
|
if (labelLength > EMPTY_LABEL_LENGTH) label = this.text.slice(labelStart, labelStart + labelLength);
|
|
344
337
|
else if (!opener.bracketAfter) label = this.text.slice(opener.index, afterCloseBracket);
|
|
345
|
-
|
|
338
|
+
this.pos = labelStart + labelLength;
|
|
346
339
|
if (label === void 0) return;
|
|
347
340
|
const definition = this.references.get(normalizeLinkLabel(label));
|
|
348
341
|
if (definition === void 0) {
|
|
@@ -487,10 +480,7 @@ function toAstNode(node) {
|
|
|
487
480
|
}
|
|
488
481
|
function parseInlines(content, references, footnotes, options = {}) {
|
|
489
482
|
const root = new InlineParser(content, references, footnotes, options).parse();
|
|
490
|
-
if (options.gfmAutolinks ?? true)
|
|
491
|
-
applyGfmAutolinks(root);
|
|
492
|
-
mergeAdjacentText(root);
|
|
493
|
-
}
|
|
483
|
+
if (options.gfmAutolinks ?? true) applyGfmAutolinks(root);
|
|
494
484
|
return toChildAstNodes(root);
|
|
495
485
|
}
|
|
496
486
|
//#endregion
|
package/dist/lower/lower.cjs
CHANGED
|
@@ -49,8 +49,8 @@ function lowerParagraph(node, context) {
|
|
|
49
49
|
const blocks = [];
|
|
50
50
|
const inlineCtx = inlineContext(context);
|
|
51
51
|
let segment = [];
|
|
52
|
-
const flushSegment = (
|
|
53
|
-
if (segment.length === 0
|
|
52
|
+
const flushSegment = () => {
|
|
53
|
+
if (segment.length === 0) return;
|
|
54
54
|
const inline = require_lower_inline.lowerInlineNodes(segment, inlineCtx);
|
|
55
55
|
blocks.push(decorateParagraph({
|
|
56
56
|
kind: "paragraph",
|
|
@@ -76,7 +76,7 @@ function lowerParagraph(node, context) {
|
|
|
76
76
|
segment.push(child);
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
|
-
flushSegment(
|
|
79
|
+
flushSegment();
|
|
80
80
|
if (context.list !== void 0) context.sink({
|
|
81
81
|
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LIST_ITEM_BLOCK_UNLISTED,
|
|
82
82
|
severity: "info",
|
|
@@ -106,7 +106,7 @@ function lowerParagraph(node, context) {
|
|
|
106
106
|
}
|
|
107
107
|
}, image, { kind: "constructEnd" });
|
|
108
108
|
}
|
|
109
|
-
flushSegment(
|
|
109
|
+
flushSegment();
|
|
110
110
|
return blocks;
|
|
111
111
|
}
|
|
112
112
|
function splitInfoString(infoString) {
|
|
@@ -176,10 +176,9 @@ function lowerHtmlBlock(node, context, contentWidthPt) {
|
|
|
176
176
|
severity: "info",
|
|
177
177
|
message: "block-level raw HTML was preserved as literal text (styleId \"HTMLPreformatted\"); it will not be rendered as HTML by any consumer of the resulting ContentDocument, and its verbatim original rides the paragraph's own markdown residue for this package's writer to re-emit as-is"
|
|
178
178
|
});
|
|
179
|
-
const literal = node.literal.replace(/\n+$/, "");
|
|
180
179
|
return [decorateParagraph({
|
|
181
180
|
kind: "paragraph",
|
|
182
|
-
runs:
|
|
181
|
+
runs: [{ text: node.literal }],
|
|
183
182
|
styleId: require_shared_style_constants.HTML_PREFORMATTED_STYLE_ID,
|
|
184
183
|
source: {
|
|
185
184
|
format: "markdown",
|
|
@@ -242,7 +241,6 @@ function lowerListItem(item, numId, level, context, contentWidthPt) {
|
|
|
242
241
|
list: membership
|
|
243
242
|
};
|
|
244
243
|
const blocks = [];
|
|
245
|
-
let ownLevelBlockCount = 0;
|
|
246
244
|
let firstOwnBlock;
|
|
247
245
|
for (const child of item.children) {
|
|
248
246
|
if (child.type === "list") {
|
|
@@ -250,11 +248,10 @@ function lowerListItem(item, numId, level, context, contentWidthPt) {
|
|
|
250
248
|
continue;
|
|
251
249
|
}
|
|
252
250
|
const childBlocks = lowerBlock(child, itemContext, contentWidthPt);
|
|
253
|
-
ownLevelBlockCount += childBlocks.length;
|
|
254
251
|
firstOwnBlock ??= childBlocks[0];
|
|
255
252
|
blocks.push(...childBlocks);
|
|
256
253
|
}
|
|
257
|
-
if (
|
|
254
|
+
if (firstOwnBlock === void 0 || firstOwnBlock.kind === "constructStart") blocks.unshift(decorateParagraph({
|
|
258
255
|
kind: "paragraph",
|
|
259
256
|
runs: []
|
|
260
257
|
}, itemContext));
|
|
@@ -274,7 +271,7 @@ function lowerList(node, ancestorNumId, level, context, contentWidthPt) {
|
|
|
274
271
|
} else {
|
|
275
272
|
numId = ancestorNumId;
|
|
276
273
|
const mintedType = require_shared_list_id.mintedListType(numId);
|
|
277
|
-
if (mintedType
|
|
274
|
+
if (mintedType === (node.markerType === "bullet" ? "ordered" : "bullet")) context.sink({
|
|
278
275
|
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LIST_MARKER_TYPE_CONFLICT,
|
|
279
276
|
severity: "warning",
|
|
280
277
|
message: `a nested ${node.markerType} list sits under a list minted as ${mintedType}; the enclosing list's own marker type is kept (first-wins) and this nested list's own type is not separately represented`
|
package/dist/lower/lower.js
CHANGED
|
@@ -48,8 +48,8 @@ function lowerParagraph(node, context) {
|
|
|
48
48
|
const blocks = [];
|
|
49
49
|
const inlineCtx = inlineContext(context);
|
|
50
50
|
let segment = [];
|
|
51
|
-
const flushSegment = (
|
|
52
|
-
if (segment.length === 0
|
|
51
|
+
const flushSegment = () => {
|
|
52
|
+
if (segment.length === 0) return;
|
|
53
53
|
const inline = lowerInlineNodes(segment, inlineCtx);
|
|
54
54
|
blocks.push(decorateParagraph({
|
|
55
55
|
kind: "paragraph",
|
|
@@ -75,7 +75,7 @@ function lowerParagraph(node, context) {
|
|
|
75
75
|
segment.push(child);
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
78
|
-
flushSegment(
|
|
78
|
+
flushSegment();
|
|
79
79
|
if (context.list !== void 0) context.sink({
|
|
80
80
|
code: MarkdownDiagnosticCodes.LIST_ITEM_BLOCK_UNLISTED,
|
|
81
81
|
severity: "info",
|
|
@@ -105,7 +105,7 @@ function lowerParagraph(node, context) {
|
|
|
105
105
|
}
|
|
106
106
|
}, image, { kind: "constructEnd" });
|
|
107
107
|
}
|
|
108
|
-
flushSegment(
|
|
108
|
+
flushSegment();
|
|
109
109
|
return blocks;
|
|
110
110
|
}
|
|
111
111
|
function splitInfoString(infoString) {
|
|
@@ -175,10 +175,9 @@ function lowerHtmlBlock(node, context, contentWidthPt) {
|
|
|
175
175
|
severity: "info",
|
|
176
176
|
message: "block-level raw HTML was preserved as literal text (styleId \"HTMLPreformatted\"); it will not be rendered as HTML by any consumer of the resulting ContentDocument, and its verbatim original rides the paragraph's own markdown residue for this package's writer to re-emit as-is"
|
|
177
177
|
});
|
|
178
|
-
const literal = node.literal.replace(/\n+$/, "");
|
|
179
178
|
return [decorateParagraph({
|
|
180
179
|
kind: "paragraph",
|
|
181
|
-
runs:
|
|
180
|
+
runs: [{ text: node.literal }],
|
|
182
181
|
styleId: HTML_PREFORMATTED_STYLE_ID,
|
|
183
182
|
source: {
|
|
184
183
|
format: "markdown",
|
|
@@ -241,7 +240,6 @@ function lowerListItem(item, numId, level, context, contentWidthPt) {
|
|
|
241
240
|
list: membership
|
|
242
241
|
};
|
|
243
242
|
const blocks = [];
|
|
244
|
-
let ownLevelBlockCount = 0;
|
|
245
243
|
let firstOwnBlock;
|
|
246
244
|
for (const child of item.children) {
|
|
247
245
|
if (child.type === "list") {
|
|
@@ -249,11 +247,10 @@ function lowerListItem(item, numId, level, context, contentWidthPt) {
|
|
|
249
247
|
continue;
|
|
250
248
|
}
|
|
251
249
|
const childBlocks = lowerBlock(child, itemContext, contentWidthPt);
|
|
252
|
-
ownLevelBlockCount += childBlocks.length;
|
|
253
250
|
firstOwnBlock ??= childBlocks[0];
|
|
254
251
|
blocks.push(...childBlocks);
|
|
255
252
|
}
|
|
256
|
-
if (
|
|
253
|
+
if (firstOwnBlock === void 0 || firstOwnBlock.kind === "constructStart") blocks.unshift(decorateParagraph({
|
|
257
254
|
kind: "paragraph",
|
|
258
255
|
runs: []
|
|
259
256
|
}, itemContext));
|
|
@@ -273,7 +270,7 @@ function lowerList(node, ancestorNumId, level, context, contentWidthPt) {
|
|
|
273
270
|
} else {
|
|
274
271
|
numId = ancestorNumId;
|
|
275
272
|
const mintedType = mintedListType(numId);
|
|
276
|
-
if (mintedType
|
|
273
|
+
if (mintedType === (node.markerType === "bullet" ? "ordered" : "bullet")) context.sink({
|
|
277
274
|
code: MarkdownDiagnosticCodes.LIST_MARKER_TYPE_CONFLICT,
|
|
278
275
|
severity: "warning",
|
|
279
276
|
message: `a nested ${node.markerType} list sits under a list minted as ${mintedType}; the enclosing list's own marker type is kept (first-wins) and this nested list's own type is not separately represented`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-codec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Hand-written CommonMark+GFM <-> DocumentTree codec, built on document-schema.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"license": "MIT",
|
|
84
84
|
"packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"byte-codec": "1.6.
|
|
86
|
+
"byte-codec": "1.6.2",
|
|
87
87
|
"document-schema.js": "7.11.4",
|
|
88
88
|
"zod": "4.4.3"
|
|
89
89
|
},
|