markdown-magic 3.0.0 → 3.0.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 +43 -29
- package/lib/block-parser-js.test.js +148 -156
- package/lib/block-parser.js +255 -262
- package/lib/block-parser.test.js +43 -6
- package/lib/cli.js +30 -19
- package/lib/cli.test.js +73 -73
- package/lib/globals.d.ts +66 -0
- package/lib/index.js +43 -9
- package/lib/process-contents.js +80 -39
- package/lib/process-file.js +4 -1
- package/lib/transforms/code.js +4 -10
- package/lib/transforms/file.js +7 -10
- package/lib/transforms/index.js +0 -0
- package/lib/transforms/remote.js +2 -3
- package/lib/transforms/sectionToc.js +18 -0
- package/lib/transforms/toc.js +10 -335
- package/lib/types.js +11 -0
- package/lib/utils/fs.js +21 -19
- package/lib/utils/fs.test.js +4 -5
- package/lib/utils/logs.js +7 -2
- package/lib/utils/md/filters.js +5 -5
- package/lib/utils/md/find-code-blocks.js +16 -8
- package/lib/utils/md/find-frontmatter.js +11 -13
- package/lib/utils/md/find-frontmatter.test.js +2 -2
- package/lib/utils/md/find-html-tags.js +1 -1
- package/lib/utils/md/find-images-md.js +27 -0
- package/lib/utils/md/find-images.js +39 -34
- package/lib/utils/md/find-links.js +72 -54
- package/lib/utils/md/find-unmatched-html-tags.js +1 -2
- package/lib/utils/md/fixtures/file-with-links.md +10 -0
- package/lib/utils/md/md.test.js +72 -4
- package/lib/utils/md/parse.js +91 -67
- package/lib/utils/regex-timeout.js +2 -1
- package/lib/utils/regex.js +3 -2
- package/lib/utils/remoteRequest.js +1 -0
- package/lib/utils/syntax.js +3 -0
- package/lib/utils/text.js +71 -3
- package/lib/utils/text.test.js +3 -9
- package/lib/utils/toc.js +315 -0
- package/package.json +7 -3
- package/lib/options-parser.js +0 -498
- package/lib/options-parser.test.js +0 -1237
- package/lib/utils/html-to-json/compat.js +0 -42
- package/lib/utils/html-to-json/format.js +0 -64
- package/lib/utils/html-to-json/index.js +0 -37
- package/lib/utils/html-to-json/lexer.js +0 -345
- package/lib/utils/html-to-json/parser.js +0 -146
- package/lib/utils/html-to-json/stringify.js +0 -37
- package/lib/utils/html-to-json/tags.js +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Tags which contain arbitrary non-parsed content
|
|
3
|
-
For example: <script> JavaScript should not be parsed
|
|
4
|
-
*/
|
|
5
|
-
const childlessTags = ['style', 'script', 'template']
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
Tags which auto-close because they cannot be nested
|
|
9
|
-
For example: <p>Outer<p>Inner is <p>Outer</p><p>Inner</p>
|
|
10
|
-
*/
|
|
11
|
-
const closingTags = [
|
|
12
|
-
'html', 'head', 'body', 'p', 'dt', 'dd', 'li', 'option',
|
|
13
|
-
'thead', 'th', 'tbody', 'tr', 'td', 'tfoot', 'colgroup'
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
/*
|
|
17
|
-
Closing tags which have ancestor tags which
|
|
18
|
-
may exist within them which prevent the
|
|
19
|
-
closing tag from auto-closing.
|
|
20
|
-
For example: in <li><ul><li></ul></li>,
|
|
21
|
-
the top-level <li> should not auto-close.
|
|
22
|
-
*/
|
|
23
|
-
const closingTagAncestorBreakers = {
|
|
24
|
-
li: ['ul', 'ol', 'menu'],
|
|
25
|
-
dt: ['dl'],
|
|
26
|
-
dd: ['dl'],
|
|
27
|
-
tbody: ['table'],
|
|
28
|
-
thead: ['table'],
|
|
29
|
-
tfoot: ['table'],
|
|
30
|
-
tr: ['table'],
|
|
31
|
-
td: ['table']
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/*
|
|
35
|
-
Tags which do not need the closing tag
|
|
36
|
-
For example: <img> does not need </img>
|
|
37
|
-
*/
|
|
38
|
-
const voidTags = [
|
|
39
|
-
'!doctype', 'area', 'base', 'br', 'col', 'command',
|
|
40
|
-
'embed', 'hr', 'img', 'input', 'keygen', 'link',
|
|
41
|
-
'meta', 'param', 'source', 'track', 'wbr'
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
// https://github.com/sindresorhus/html-tags/blob/main/html-tags.json
|
|
45
|
-
const htmlTags = [
|
|
46
|
-
"a",
|
|
47
|
-
"abbr",
|
|
48
|
-
"address",
|
|
49
|
-
"area",
|
|
50
|
-
"article",
|
|
51
|
-
"aside",
|
|
52
|
-
"audio",
|
|
53
|
-
"b",
|
|
54
|
-
"base",
|
|
55
|
-
"bdi",
|
|
56
|
-
"bdo",
|
|
57
|
-
"blockquote",
|
|
58
|
-
"body",
|
|
59
|
-
"br",
|
|
60
|
-
"button",
|
|
61
|
-
"canvas",
|
|
62
|
-
"caption",
|
|
63
|
-
"cite",
|
|
64
|
-
"code",
|
|
65
|
-
"col",
|
|
66
|
-
"colgroup",
|
|
67
|
-
"data",
|
|
68
|
-
"datalist",
|
|
69
|
-
"dd",
|
|
70
|
-
"del",
|
|
71
|
-
"details",
|
|
72
|
-
"dfn",
|
|
73
|
-
"dialog",
|
|
74
|
-
"div",
|
|
75
|
-
"dl",
|
|
76
|
-
"dt",
|
|
77
|
-
"em",
|
|
78
|
-
"embed",
|
|
79
|
-
"fieldset",
|
|
80
|
-
"figcaption",
|
|
81
|
-
"figure",
|
|
82
|
-
"footer",
|
|
83
|
-
"form",
|
|
84
|
-
"h1",
|
|
85
|
-
"h2",
|
|
86
|
-
"h3",
|
|
87
|
-
"h4",
|
|
88
|
-
"h5",
|
|
89
|
-
"h6",
|
|
90
|
-
"head",
|
|
91
|
-
"header",
|
|
92
|
-
"hgroup",
|
|
93
|
-
"hr",
|
|
94
|
-
"html",
|
|
95
|
-
"i",
|
|
96
|
-
"iframe",
|
|
97
|
-
"img",
|
|
98
|
-
"input",
|
|
99
|
-
"ins",
|
|
100
|
-
"kbd",
|
|
101
|
-
"label",
|
|
102
|
-
"legend",
|
|
103
|
-
"li",
|
|
104
|
-
"link",
|
|
105
|
-
"main",
|
|
106
|
-
"map",
|
|
107
|
-
"mark",
|
|
108
|
-
"math",
|
|
109
|
-
"menu",
|
|
110
|
-
"menuitem",
|
|
111
|
-
"meta",
|
|
112
|
-
"meter",
|
|
113
|
-
"nav",
|
|
114
|
-
"noscript",
|
|
115
|
-
"object",
|
|
116
|
-
"ol",
|
|
117
|
-
"optgroup",
|
|
118
|
-
"option",
|
|
119
|
-
"output",
|
|
120
|
-
"p",
|
|
121
|
-
"param",
|
|
122
|
-
"picture",
|
|
123
|
-
"pre",
|
|
124
|
-
"progress",
|
|
125
|
-
"q",
|
|
126
|
-
"rb",
|
|
127
|
-
"rp",
|
|
128
|
-
"rt",
|
|
129
|
-
"rtc",
|
|
130
|
-
"ruby",
|
|
131
|
-
"s",
|
|
132
|
-
"samp",
|
|
133
|
-
"script",
|
|
134
|
-
"section",
|
|
135
|
-
"select",
|
|
136
|
-
"slot",
|
|
137
|
-
"small",
|
|
138
|
-
"source",
|
|
139
|
-
"span",
|
|
140
|
-
"strong",
|
|
141
|
-
"style",
|
|
142
|
-
"sub",
|
|
143
|
-
"summary",
|
|
144
|
-
"sup",
|
|
145
|
-
"svg",
|
|
146
|
-
"table",
|
|
147
|
-
"tbody",
|
|
148
|
-
"td",
|
|
149
|
-
"template",
|
|
150
|
-
"textarea",
|
|
151
|
-
"tfoot",
|
|
152
|
-
"th",
|
|
153
|
-
"thead",
|
|
154
|
-
"time",
|
|
155
|
-
"title",
|
|
156
|
-
"tr",
|
|
157
|
-
"track",
|
|
158
|
-
"u",
|
|
159
|
-
"ul",
|
|
160
|
-
"var",
|
|
161
|
-
"video",
|
|
162
|
-
"wbr"
|
|
163
|
-
]
|
|
164
|
-
|
|
165
|
-
module.exports = {
|
|
166
|
-
childlessTags,
|
|
167
|
-
closingTags,
|
|
168
|
-
closingTagAncestorBreakers,
|
|
169
|
-
voidTags,
|
|
170
|
-
htmlTags
|
|
171
|
-
}
|