emdp 1.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/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/cjs/cli.js +36 -0
- package/dist/cjs/gfm.js +26 -0
- package/dist/cjs/index.js +26 -0
- package/dist/cjs/parser/block-parser.js +644 -0
- package/dist/cjs/parser/blocks/blockquote.js +28 -0
- package/dist/cjs/parser/blocks/code-block-fenced.js +58 -0
- package/dist/cjs/parser/blocks/code-block-indented.js +47 -0
- package/dist/cjs/parser/blocks/heading-atx.js +29 -0
- package/dist/cjs/parser/blocks/heading-setext.js +24 -0
- package/dist/cjs/parser/blocks/html-block.js +83 -0
- package/dist/cjs/parser/blocks/link-reference.js +109 -0
- package/dist/cjs/parser/blocks/list.js +155 -0
- package/dist/cjs/parser/blocks/paragraph.js +20 -0
- package/dist/cjs/parser/blocks/table.js +163 -0
- package/dist/cjs/parser/blocks/task-list.js +66 -0
- package/dist/cjs/parser/blocks/thematic-break.js +17 -0
- package/dist/cjs/parser/entities.js +2133 -0
- package/dist/cjs/parser/gfm/block-parser.js +773 -0
- package/dist/cjs/parser/gfm/index.js +125 -0
- package/dist/cjs/parser/gfm/inline-parser.js +813 -0
- package/dist/cjs/parser/gfm/renderer.js +513 -0
- package/dist/cjs/parser/index.js +104 -0
- package/dist/cjs/parser/inline-parser.js +564 -0
- package/dist/cjs/parser/inlines/autolink-extended.js +364 -0
- package/dist/cjs/parser/inlines/autolink.js +44 -0
- package/dist/cjs/parser/inlines/code-span.js +48 -0
- package/dist/cjs/parser/inlines/emphasis.js +64 -0
- package/dist/cjs/parser/inlines/entity.js +25 -0
- package/dist/cjs/parser/inlines/escape.js +25 -0
- package/dist/cjs/parser/inlines/footnote.js +41 -0
- package/dist/cjs/parser/inlines/hard-break.js +45 -0
- package/dist/cjs/parser/inlines/image.js +9 -0
- package/dist/cjs/parser/inlines/link.js +166 -0
- package/dist/cjs/parser/inlines/soft-break.js +18 -0
- package/dist/cjs/parser/inlines/strikethrough.js +48 -0
- package/dist/cjs/parser/inlines/text.js +20 -0
- package/dist/cjs/parser/renderer.js +345 -0
- package/dist/cjs/parser/types.js +5 -0
- package/dist/cjs/parser/utils.js +277 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +36 -0
- package/dist/esm/cli.js +34 -0
- package/dist/esm/gfm.js +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parser/block-parser.js +640 -0
- package/dist/esm/parser/blocks/blockquote.js +22 -0
- package/dist/esm/parser/blocks/code-block-fenced.js +52 -0
- package/dist/esm/parser/blocks/code-block-indented.js +42 -0
- package/dist/esm/parser/blocks/heading-atx.js +24 -0
- package/dist/esm/parser/blocks/heading-setext.js +19 -0
- package/dist/esm/parser/blocks/html-block.js +77 -0
- package/dist/esm/parser/blocks/link-reference.js +105 -0
- package/dist/esm/parser/blocks/list.js +145 -0
- package/dist/esm/parser/blocks/paragraph.js +15 -0
- package/dist/esm/parser/blocks/table.js +152 -0
- package/dist/esm/parser/blocks/task-list.js +61 -0
- package/dist/esm/parser/blocks/thematic-break.js +13 -0
- package/dist/esm/parser/entities.js +2130 -0
- package/dist/esm/parser/gfm/block-parser.js +769 -0
- package/dist/esm/parser/gfm/index.js +115 -0
- package/dist/esm/parser/gfm/inline-parser.js +809 -0
- package/dist/esm/parser/gfm/renderer.js +509 -0
- package/dist/esm/parser/index.js +80 -0
- package/dist/esm/parser/inline-parser.js +560 -0
- package/dist/esm/parser/inlines/autolink-extended.js +357 -0
- package/dist/esm/parser/inlines/autolink.js +40 -0
- package/dist/esm/parser/inlines/code-span.js +44 -0
- package/dist/esm/parser/inlines/emphasis.js +59 -0
- package/dist/esm/parser/inlines/entity.js +21 -0
- package/dist/esm/parser/inlines/escape.js +21 -0
- package/dist/esm/parser/inlines/footnote.js +38 -0
- package/dist/esm/parser/inlines/hard-break.js +41 -0
- package/dist/esm/parser/inlines/image.js +4 -0
- package/dist/esm/parser/inlines/link.js +156 -0
- package/dist/esm/parser/inlines/soft-break.js +14 -0
- package/dist/esm/parser/inlines/strikethrough.js +42 -0
- package/dist/esm/parser/inlines/text.js +16 -0
- package/dist/esm/parser/renderer.js +341 -0
- package/dist/esm/parser/types.js +4 -0
- package/dist/esm/parser/utils.js +254 -0
- package/dist/gfm.d.ts +6 -0
- package/dist/gfm.js +26 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +26 -0
- package/dist/parser/block-parser.d.ts +25 -0
- package/dist/parser/block-parser.js +644 -0
- package/dist/parser/blocks/blockquote.d.ts +8 -0
- package/dist/parser/blocks/blockquote.js +28 -0
- package/dist/parser/blocks/code-block-fenced.d.ts +14 -0
- package/dist/parser/blocks/code-block-fenced.js +58 -0
- package/dist/parser/blocks/code-block-indented.d.ts +7 -0
- package/dist/parser/blocks/code-block-indented.js +47 -0
- package/dist/parser/blocks/heading-atx.d.ts +10 -0
- package/dist/parser/blocks/heading-atx.js +29 -0
- package/dist/parser/blocks/heading-setext.d.ts +8 -0
- package/dist/parser/blocks/heading-setext.js +24 -0
- package/dist/parser/blocks/html-block.d.ts +9 -0
- package/dist/parser/blocks/html-block.js +83 -0
- package/dist/parser/blocks/link-reference.d.ts +11 -0
- package/dist/parser/blocks/link-reference.js +109 -0
- package/dist/parser/blocks/list.d.ts +25 -0
- package/dist/parser/blocks/list.js +155 -0
- package/dist/parser/blocks/paragraph.d.ts +7 -0
- package/dist/parser/blocks/paragraph.js +20 -0
- package/dist/parser/blocks/table.d.ts +13 -0
- package/dist/parser/blocks/table.js +163 -0
- package/dist/parser/blocks/task-list.d.ts +10 -0
- package/dist/parser/blocks/task-list.js +66 -0
- package/dist/parser/blocks/thematic-break.d.ts +6 -0
- package/dist/parser/blocks/thematic-break.js +17 -0
- package/dist/parser/entities.d.ts +4 -0
- package/dist/parser/entities.js +2133 -0
- package/dist/parser/gfm/block-parser.d.ts +32 -0
- package/dist/parser/gfm/block-parser.js +773 -0
- package/dist/parser/gfm/index.d.ts +31 -0
- package/dist/parser/gfm/index.js +125 -0
- package/dist/parser/gfm/inline-parser.d.ts +25 -0
- package/dist/parser/gfm/inline-parser.js +813 -0
- package/dist/parser/gfm/renderer.d.ts +43 -0
- package/dist/parser/gfm/renderer.js +513 -0
- package/dist/parser/index.d.ts +33 -0
- package/dist/parser/index.js +104 -0
- package/dist/parser/inline-parser.d.ts +16 -0
- package/dist/parser/inline-parser.js +564 -0
- package/dist/parser/inlines/autolink-extended.d.ts +24 -0
- package/dist/parser/inlines/autolink-extended.js +364 -0
- package/dist/parser/inlines/autolink.d.ts +9 -0
- package/dist/parser/inlines/autolink.js +44 -0
- package/dist/parser/inlines/code-span.d.ts +9 -0
- package/dist/parser/inlines/code-span.js +48 -0
- package/dist/parser/inlines/emphasis.d.ts +14 -0
- package/dist/parser/inlines/emphasis.js +64 -0
- package/dist/parser/inlines/entity.d.ts +8 -0
- package/dist/parser/inlines/entity.js +25 -0
- package/dist/parser/inlines/escape.d.ts +8 -0
- package/dist/parser/inlines/escape.js +25 -0
- package/dist/parser/inlines/footnote.d.ts +9 -0
- package/dist/parser/inlines/footnote.js +41 -0
- package/dist/parser/inlines/hard-break.d.ts +9 -0
- package/dist/parser/inlines/hard-break.js +45 -0
- package/dist/parser/inlines/image.d.ts +4 -0
- package/dist/parser/inlines/image.js +9 -0
- package/dist/parser/inlines/link.d.ts +33 -0
- package/dist/parser/inlines/link.js +166 -0
- package/dist/parser/inlines/soft-break.d.ts +9 -0
- package/dist/parser/inlines/soft-break.js +18 -0
- package/dist/parser/inlines/strikethrough.d.ts +16 -0
- package/dist/parser/inlines/strikethrough.js +48 -0
- package/dist/parser/inlines/text.d.ts +6 -0
- package/dist/parser/inlines/text.js +20 -0
- package/dist/parser/renderer.d.ts +33 -0
- package/dist/parser/renderer.js +345 -0
- package/dist/parser/types.d.ts +152 -0
- package/dist/parser/types.js +5 -0
- package/dist/parser/utils.d.ts +32 -0
- package/dist/parser/utils.js +277 -0
- package/dist/types/cli.d.ts +6 -0
- package/dist/types/gfm.d.ts +6 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/parser/block-parser.d.ts +25 -0
- package/dist/types/parser/blocks/blockquote.d.ts +8 -0
- package/dist/types/parser/blocks/code-block-fenced.d.ts +14 -0
- package/dist/types/parser/blocks/code-block-indented.d.ts +7 -0
- package/dist/types/parser/blocks/heading-atx.d.ts +10 -0
- package/dist/types/parser/blocks/heading-setext.d.ts +8 -0
- package/dist/types/parser/blocks/html-block.d.ts +9 -0
- package/dist/types/parser/blocks/link-reference.d.ts +11 -0
- package/dist/types/parser/blocks/list.d.ts +25 -0
- package/dist/types/parser/blocks/paragraph.d.ts +7 -0
- package/dist/types/parser/blocks/table.d.ts +13 -0
- package/dist/types/parser/blocks/task-list.d.ts +10 -0
- package/dist/types/parser/blocks/thematic-break.d.ts +6 -0
- package/dist/types/parser/entities.d.ts +4 -0
- package/dist/types/parser/gfm/block-parser.d.ts +32 -0
- package/dist/types/parser/gfm/index.d.ts +31 -0
- package/dist/types/parser/gfm/inline-parser.d.ts +25 -0
- package/dist/types/parser/gfm/renderer.d.ts +43 -0
- package/dist/types/parser/index.d.ts +33 -0
- package/dist/types/parser/inline-parser.d.ts +16 -0
- package/dist/types/parser/inlines/autolink-extended.d.ts +24 -0
- package/dist/types/parser/inlines/autolink.d.ts +9 -0
- package/dist/types/parser/inlines/code-span.d.ts +9 -0
- package/dist/types/parser/inlines/emphasis.d.ts +14 -0
- package/dist/types/parser/inlines/entity.d.ts +8 -0
- package/dist/types/parser/inlines/escape.d.ts +8 -0
- package/dist/types/parser/inlines/footnote.d.ts +9 -0
- package/dist/types/parser/inlines/hard-break.d.ts +9 -0
- package/dist/types/parser/inlines/image.d.ts +4 -0
- package/dist/types/parser/inlines/link.d.ts +33 -0
- package/dist/types/parser/inlines/soft-break.d.ts +9 -0
- package/dist/types/parser/inlines/strikethrough.d.ts +16 -0
- package/dist/types/parser/inlines/text.d.ts +6 -0
- package/dist/types/parser/renderer.d.ts +33 -0
- package/dist/types/parser/types.d.ts +152 -0
- package/dist/types/parser/utils.d.ts +32 -0
- package/package.json +54 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared text-processing utilities for the parser, including entity decoding, escaping,
|
|
3
|
+
* whitespace handling, and URI normalization.
|
|
4
|
+
*/
|
|
5
|
+
import { HTML_ENTITIES } from './entities.js';
|
|
6
|
+
export function decodeHtmlEntities(str) {
|
|
7
|
+
return str.replace(/&(#[xX]?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/g, (match, capture) => {
|
|
8
|
+
if (capture.startsWith('#x') || capture.startsWith('#X')) {
|
|
9
|
+
const code = parseInt(capture.slice(2), 16);
|
|
10
|
+
if (!isNaN(code) && code >= 0 && code <= 0x10ffff) {
|
|
11
|
+
if (code === 0)
|
|
12
|
+
return '\uFFFD';
|
|
13
|
+
return String.fromCodePoint(code);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else if (capture.startsWith('#')) {
|
|
17
|
+
const code = parseInt(capture.slice(1), 10);
|
|
18
|
+
if (!isNaN(code) && code >= 0 && code <= 0x10ffff) {
|
|
19
|
+
if (code === 0)
|
|
20
|
+
return '\uFFFD';
|
|
21
|
+
return String.fromCodePoint(code);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (HTML_ENTITIES[capture]) {
|
|
25
|
+
return HTML_ENTITIES[capture];
|
|
26
|
+
}
|
|
27
|
+
return match;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function escapeXml(str) {
|
|
31
|
+
return str
|
|
32
|
+
.replace(/&/g, '&')
|
|
33
|
+
.replace(/</g, '<')
|
|
34
|
+
.replace(/>/g, '>')
|
|
35
|
+
.replace(/"/g, '"');
|
|
36
|
+
}
|
|
37
|
+
export function escapeHtml(str, preserveEntities = false) {
|
|
38
|
+
if (preserveEntities) {
|
|
39
|
+
return str
|
|
40
|
+
.replace(/&(?![#a-zA-Z0-9]+;)/g, '&')
|
|
41
|
+
.replace(/</g, '<')
|
|
42
|
+
.replace(/>/g, '>')
|
|
43
|
+
.replace(/"/g, '"');
|
|
44
|
+
}
|
|
45
|
+
return escapeXml(str);
|
|
46
|
+
}
|
|
47
|
+
export const ASCII_PUNCTUATION_REGEX = /[!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~]/;
|
|
48
|
+
export const ASCII_PUNCTUATION_CHARS = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
|
|
49
|
+
export function isAsciiPunctuation(char) {
|
|
50
|
+
return ASCII_PUNCTUATION_REGEX.test(char);
|
|
51
|
+
}
|
|
52
|
+
export function isWhitespace(char) {
|
|
53
|
+
return char === ' ' || char === '\t' || char === '\n' || char === '\r' || char === '\f';
|
|
54
|
+
}
|
|
55
|
+
export function isUnicodeWhitespace(char) {
|
|
56
|
+
return /\s/.test(char);
|
|
57
|
+
}
|
|
58
|
+
export function isUnicodePunctuation(char) {
|
|
59
|
+
return /[\p{P}\p{S}]/u.test(char);
|
|
60
|
+
}
|
|
61
|
+
export function normalizeLineEndings(str) {
|
|
62
|
+
return str.replace(/\r\n?/g, '\n');
|
|
63
|
+
}
|
|
64
|
+
export function expandTabs(line, tabStop = 4) {
|
|
65
|
+
let result = '';
|
|
66
|
+
let column = 0;
|
|
67
|
+
for (const char of line) {
|
|
68
|
+
if (char === '\t') {
|
|
69
|
+
const spaces = tabStop - (column % tabStop);
|
|
70
|
+
result += ' '.repeat(spaces);
|
|
71
|
+
column += spaces;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
result += char;
|
|
75
|
+
column++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
export function expandTabsPartial(line, startColumn, tabStop = 4) {
|
|
81
|
+
let result = '';
|
|
82
|
+
let column = startColumn;
|
|
83
|
+
for (const char of line) {
|
|
84
|
+
if (char === '\t') {
|
|
85
|
+
const spaces = tabStop - (column % tabStop);
|
|
86
|
+
result += ' '.repeat(spaces);
|
|
87
|
+
column += spaces;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
result += char;
|
|
91
|
+
column++;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
export function trimLeadingSpaces(line, max = 3) {
|
|
97
|
+
let count = 0;
|
|
98
|
+
let i = 0;
|
|
99
|
+
while (i < line.length && line[i] === ' ' && count < max) {
|
|
100
|
+
count++;
|
|
101
|
+
i++;
|
|
102
|
+
}
|
|
103
|
+
return { trimmed: line.slice(i), count };
|
|
104
|
+
}
|
|
105
|
+
export function countLeadingSpaces(line) {
|
|
106
|
+
let count = 0;
|
|
107
|
+
for (const char of line) {
|
|
108
|
+
if (char === ' ')
|
|
109
|
+
count++;
|
|
110
|
+
else if (char === '\t')
|
|
111
|
+
count += 4 - (count % 4);
|
|
112
|
+
else
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return count;
|
|
116
|
+
}
|
|
117
|
+
export function countLeadingChars(line) {
|
|
118
|
+
let spaces = 0;
|
|
119
|
+
let chars = 0;
|
|
120
|
+
for (const char of line) {
|
|
121
|
+
if (char === ' ') {
|
|
122
|
+
spaces++;
|
|
123
|
+
chars++;
|
|
124
|
+
}
|
|
125
|
+
else if (char === '\t') {
|
|
126
|
+
const tabWidth = 4 - (spaces % 4);
|
|
127
|
+
spaces += tabWidth;
|
|
128
|
+
chars++;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return { spaces, chars };
|
|
135
|
+
}
|
|
136
|
+
export function removeIndent(line, indent) {
|
|
137
|
+
let removed = 0;
|
|
138
|
+
let i = 0;
|
|
139
|
+
while (i < line.length && removed < indent) {
|
|
140
|
+
if (line[i] === ' ') {
|
|
141
|
+
removed++;
|
|
142
|
+
i++;
|
|
143
|
+
}
|
|
144
|
+
else if (line[i] === '\t') {
|
|
145
|
+
const tabWidth = 4 - (removed % 4);
|
|
146
|
+
if (removed + tabWidth <= indent) {
|
|
147
|
+
removed += tabWidth;
|
|
148
|
+
i++;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const remaining = indent - removed;
|
|
152
|
+
const spacesFromTab = tabWidth - remaining;
|
|
153
|
+
const originalColumn = removed + tabWidth;
|
|
154
|
+
return ' '.repeat(spacesFromTab) + expandRestOfLine(line, i + 1, originalColumn);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return line.slice(i);
|
|
162
|
+
}
|
|
163
|
+
function expandRestOfLine(line, startIdx, startColumn) {
|
|
164
|
+
let result = '';
|
|
165
|
+
let column = startColumn;
|
|
166
|
+
for (let i = startIdx; i < line.length; i++) {
|
|
167
|
+
const char = line[i];
|
|
168
|
+
if (char === '\t') {
|
|
169
|
+
const tabWidth = 4 - (column % 4);
|
|
170
|
+
result += ' '.repeat(tabWidth);
|
|
171
|
+
column += tabWidth;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
result += char;
|
|
175
|
+
column++;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
export function extractContentAfterMarker(line, startColumn, charIndex) {
|
|
181
|
+
if (charIndex > 0 && line[charIndex - 1] === '\t') {
|
|
182
|
+
let col = 0;
|
|
183
|
+
let idx = 0;
|
|
184
|
+
while (idx < charIndex - 1) {
|
|
185
|
+
if (line[idx] === '\t') {
|
|
186
|
+
col = col + (4 - (col % 4));
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
col++;
|
|
190
|
+
}
|
|
191
|
+
idx++;
|
|
192
|
+
}
|
|
193
|
+
const tabEndColumn = col + (4 - (col % 4));
|
|
194
|
+
if (startColumn > col && startColumn < tabEndColumn) {
|
|
195
|
+
const remainingSpaces = tabEndColumn - startColumn;
|
|
196
|
+
return ' '.repeat(remainingSpaces) + line.slice(charIndex);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return line.slice(charIndex);
|
|
200
|
+
}
|
|
201
|
+
export function normalizeUri(uri) {
|
|
202
|
+
try {
|
|
203
|
+
let result = '';
|
|
204
|
+
let i = 0;
|
|
205
|
+
while (i < uri.length) {
|
|
206
|
+
const char = uri[i];
|
|
207
|
+
if (char === '%' && i + 2 < uri.length && /^[0-9a-fA-F]{2}$/.test(uri.slice(i + 1, i + 3))) {
|
|
208
|
+
result += uri.slice(i, i + 3).toUpperCase();
|
|
209
|
+
i += 3;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const code = char.charCodeAt(0);
|
|
213
|
+
if (code > 0x7f || char === ' ') {
|
|
214
|
+
result += encodeURIComponent(char);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
result += char;
|
|
218
|
+
}
|
|
219
|
+
i++;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return uri;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
export function unescapeString(str) {
|
|
229
|
+
return str.replace(/\\([!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])/g, '$1');
|
|
230
|
+
}
|
|
231
|
+
export function normalizeLabel(label) {
|
|
232
|
+
return label
|
|
233
|
+
.trim()
|
|
234
|
+
.replace(/[ \t\r\n]+/g, ' ')
|
|
235
|
+
.replace(/\u1e9e/g, 'ss')
|
|
236
|
+
.toLowerCase();
|
|
237
|
+
}
|
|
238
|
+
const TAG_FILTER = new Set([
|
|
239
|
+
'title',
|
|
240
|
+
'textarea',
|
|
241
|
+
'style',
|
|
242
|
+
'xmp',
|
|
243
|
+
'iframe',
|
|
244
|
+
'noembed',
|
|
245
|
+
'noframes',
|
|
246
|
+
'script',
|
|
247
|
+
'plaintext',
|
|
248
|
+
]);
|
|
249
|
+
export function isTagFilterTag(tagName) {
|
|
250
|
+
return TAG_FILTER.has(tagName.toLowerCase());
|
|
251
|
+
}
|
|
252
|
+
export function applyTagFilter(html) {
|
|
253
|
+
return html.replace(/<(?=[ \t\n\r]*\/?[ \t\n\r]*(?:title|textarea|style|xmp|iframe|noembed|noframes|script|plaintext)\b)/gi, '<');
|
|
254
|
+
}
|
package/dist/gfm.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for GitHub Flavored Markdown that re-exports GFM helpers, renderer, and AST types.
|
|
3
|
+
*/
|
|
4
|
+
export * from './parser/gfm/index.js';
|
|
5
|
+
export { default } from './parser/gfm/index.js';
|
|
6
|
+
export type { DocumentNode, BlockNode, InlineNode, ParagraphNode, HeadingNode, ThematicBreakNode, CodeBlockNode, BlockquoteNode, ListNode, ListItemNode, HtmlBlockNode, TableNode, TableRowNode, TableCellNode, TableAlignment, TextNode, SoftbreakNode, HardbreakNode, CodeSpanNode, EmphasisNode, StrongNode, StrikethroughNode, LinkNode, ImageNode, HtmlInlineNode, ParseOptions, RenderOptions, } from './parser/types.js';
|
package/dist/gfm.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Entry point for GitHub Flavored Markdown that re-exports GFM helpers, renderer, and AST types.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.default = void 0;
|
|
24
|
+
__exportStar(require("./parser/gfm/index.js"), exports);
|
|
25
|
+
var index_js_1 = require("./parser/gfm/index.js");
|
|
26
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(index_js_1).default; } });
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Main entry point for the CommonMark parser that re-exports public APIs.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.default = void 0;
|
|
24
|
+
__exportStar(require("./parser/index.js"), exports);
|
|
25
|
+
var index_js_1 = require("./parser/index.js");
|
|
26
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(index_js_1).default; } });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block parsing phase that builds block nodes like paragraphs, headings, lists, code blocks,
|
|
3
|
+
* blockquotes, and HTML blocks while collecting link reference definitions.
|
|
4
|
+
*/
|
|
5
|
+
import type { DocumentNode, LinkReferenceDefinition } from './types.js';
|
|
6
|
+
export declare class BlockParser {
|
|
7
|
+
private lines;
|
|
8
|
+
private lineIndex;
|
|
9
|
+
private linkReferences;
|
|
10
|
+
private static readonly LAZY_PREFIX;
|
|
11
|
+
parse(input: string): {
|
|
12
|
+
document: DocumentNode;
|
|
13
|
+
linkReferences: Map<string, LinkReferenceDefinition>;
|
|
14
|
+
};
|
|
15
|
+
private currentLine;
|
|
16
|
+
private advance;
|
|
17
|
+
private parseBlocks;
|
|
18
|
+
private parseList;
|
|
19
|
+
private parseListItem;
|
|
20
|
+
private lastNonBlankLine;
|
|
21
|
+
private getBlockquotePrefix;
|
|
22
|
+
private allowsLazyAfterListMarker;
|
|
23
|
+
private extractBlockquoteContent;
|
|
24
|
+
private extractListItemContent;
|
|
25
|
+
}
|