markdown-magic 2.6.0 → 3.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 +6 -10
- package/cli.js +5 -82
- package/lib/block-parser-js.test.js +179 -0
- package/lib/block-parser.js +389 -0
- package/lib/{utils/new-parser.test.js → block-parser.test.js} +168 -50
- package/lib/cli.js +234 -0
- package/lib/cli.test.js +409 -0
- package/lib/defaults.js +12 -0
- package/lib/index.js +319 -184
- package/lib/index.test.js +11 -0
- package/lib/options-parser.js +498 -0
- package/lib/options-parser.test.js +1237 -0
- package/lib/process-contents.js +330 -0
- package/lib/process-file.js +34 -0
- package/lib/transforms/code.js +67 -22
- package/lib/transforms/file.js +13 -10
- package/lib/transforms/remote.js +9 -6
- package/lib/transforms/toc.js +136 -64
- package/lib/transforms/wordCount.js +5 -0
- package/lib/utils/fs.js +340 -0
- package/lib/utils/fs.test.js +268 -0
- package/lib/utils/html-to-json/compat.js +42 -0
- package/lib/utils/html-to-json/format.js +64 -0
- package/lib/utils/html-to-json/index.js +37 -0
- package/lib/utils/html-to-json/lexer.js +345 -0
- package/lib/utils/html-to-json/parser.js +146 -0
- package/lib/utils/html-to-json/stringify.js +37 -0
- package/lib/utils/html-to-json/tags.js +171 -0
- package/lib/utils/index.js +19 -0
- package/{cli-utils.js → lib/utils/load-config.js} +2 -6
- package/lib/utils/logs.js +89 -0
- package/lib/utils/md/filters.js +20 -0
- package/lib/utils/md/find-code-blocks.js +80 -0
- package/lib/utils/md/find-date.js +32 -0
- package/lib/utils/md/find-frontmatter.js +94 -0
- package/lib/utils/md/find-frontmatter.test.js +17 -0
- package/lib/utils/md/find-html-tags.js +105 -0
- package/lib/utils/md/find-images.js +102 -0
- package/lib/utils/md/find-links.js +202 -0
- package/lib/utils/md/find-unmatched-html-tags.js +33 -0
- package/lib/utils/md/fixtures/2022-01-22-date-in-filename.md +14 -0
- package/lib/utils/md/fixtures/file-with-frontmatter.md +32 -0
- package/lib/utils/md/fixtures/file-with-links.md +143 -0
- package/lib/utils/md/md.test.js +37 -0
- package/lib/utils/md/parse.js +122 -0
- package/lib/utils/md/utils.js +19 -0
- package/lib/utils/regex-timeout.js +83 -0
- package/lib/utils/regex.js +38 -5
- package/lib/utils/remoteRequest.js +54 -0
- package/lib/utils/syntax.js +79 -0
- package/lib/utils/text.js +260 -0
- package/lib/utils/text.test.js +311 -0
- package/package.json +26 -26
- package/index.js +0 -46
- package/lib/processFile.js +0 -154
- package/lib/transforms/index.js +0 -114
- package/lib/updateContents.js +0 -125
- package/lib/utils/_md.test.js +0 -63
- package/lib/utils/new-parser.js +0 -412
- package/lib/utils/weird-parse.js +0 -230
- package/lib/utils/weird-parse.test.js +0 -217
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
const { test } = require('uvu')
|
|
2
|
-
const assert = require('uvu/assert')
|
|
3
|
-
const weirdParse = require('./weird-parse')
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const bigExample = `width={999}
|
|
7
|
-
height={{111}}
|
|
8
|
-
numberAsString="12345"
|
|
9
|
-
great={["scoot", "sco ot", 'scooo ttt']}
|
|
10
|
-
nice={{ value: nice, cool: "true" }}
|
|
11
|
-
soclose=[jdjdjd, hdhfhfhffh]
|
|
12
|
-
rad="boss"
|
|
13
|
-
cool=true notCool=false
|
|
14
|
-
nooooo={[one, two, 3, 4]}
|
|
15
|
-
numberZero=0,
|
|
16
|
-
xyz=999,
|
|
17
|
-
nope=false,
|
|
18
|
-
// comment
|
|
19
|
-
yes={true}
|
|
20
|
-
isWhat,
|
|
21
|
-
/* comment */
|
|
22
|
-
foo={{ rad: ["whatever", "man"], cool: { beans: 'here' } }}
|
|
23
|
-
# other comment
|
|
24
|
-
what='xnxnx'
|
|
25
|
-
isLoading
|
|
26
|
-
whatever={{ chill: "https://app.netlify.com/start/deploy?repository=https://github.com/netlify/netlify-faunadb-example&stack=fauna", pill: ['yo']}}
|
|
27
|
-
href="https://fooo.com/start/deploy?repository=https://github.com/netlify/netlify-faunadb-example&stack=fauna"
|
|
28
|
-
src="https://user-images.github{user}content.com/532272/123136878-46f1a300-d408-11eb-82f2-ad452498457b.jpg"
|
|
29
|
-
deep={{ rad: 'blue', what: { nice: 'cool', wow: { deep: true } } }}`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
test('Multi line', () => {
|
|
33
|
-
const parsedValue = weirdParse(bigExample)
|
|
34
|
-
// console.log('parsedValue', parsedValue)
|
|
35
|
-
assert.equal(parsedValue, {
|
|
36
|
-
width: 999,
|
|
37
|
-
height: 111,
|
|
38
|
-
numberAsString: "12345",
|
|
39
|
-
great: [ 'scoot', 'sco ot', 'scooo ttt' ],
|
|
40
|
-
nice: { value: 'nice', cool: 'true' },
|
|
41
|
-
soclose: [ 'jdjdjd', 'hdhfhfhffh' ],
|
|
42
|
-
rad: 'boss',
|
|
43
|
-
cool: true,
|
|
44
|
-
notCool: false,
|
|
45
|
-
nooooo: [ 'one', 'two', 3, 4 ],
|
|
46
|
-
numberZero: 0,
|
|
47
|
-
xyz: 999,
|
|
48
|
-
nope: false,
|
|
49
|
-
yes: true,
|
|
50
|
-
isWhat: true,
|
|
51
|
-
foo: { rad: [ 'whatever', 'man' ], cool: { beans: 'here' } },
|
|
52
|
-
what: 'xnxnx',
|
|
53
|
-
isLoading: true,
|
|
54
|
-
whatever: {
|
|
55
|
-
chill: 'https://app.netlify.com/start/deploy?repositoryhttps://github.com/netlify/netlify-faunadb-example&stackfauna',
|
|
56
|
-
pill: [ 'yo' ]
|
|
57
|
-
},
|
|
58
|
-
href: 'https://fooo.com/start/deploy?repositoryhttps://github.com/netlify/netlify-faunadb-example&stackfauna',
|
|
59
|
-
src: 'https://user-images.github{user}content.com/532272/123136878-46f1a300-d408-11eb-82f2-ad452498457b.jpg',
|
|
60
|
-
deep: { rad: 'blue', what: { nice: 'cool', wow: { deep: true } } }
|
|
61
|
-
}, 'matches original')
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
const testSpacing = `width={999}
|
|
65
|
-
height={{111}}
|
|
66
|
-
numberAsString="12345"
|
|
67
|
-
great={["scoot", "sco ot", 'scooo ttt']}
|
|
68
|
-
nope=false,
|
|
69
|
-
// comment
|
|
70
|
-
yes={true}
|
|
71
|
-
isWhat,
|
|
72
|
-
/* comment */
|
|
73
|
-
foo={{ rad: ["whatever", "man"], cool: { beans: 'here' } }}
|
|
74
|
-
# other comment
|
|
75
|
-
what='xnxnx'
|
|
76
|
-
isLoading
|
|
77
|
-
href="https://fooo.com/start/deploy?repository=https://github.com/netlify/netlify-faunadb-example&stack=fauna"
|
|
78
|
-
src="https://user-images.github{user}content.com/532272/123136878-46f1a300-d408-11eb-82f2-ad452498457b.jpg"
|
|
79
|
-
deep={{ rad: 'blue', what: { nice: 'cool', wow: { deep: true } } }}
|
|
80
|
-
`
|
|
81
|
-
|
|
82
|
-
// Verify indentation doesnt matter
|
|
83
|
-
test('Multi line indent', () => {
|
|
84
|
-
const parsedValue = weirdParse(testSpacing)
|
|
85
|
-
// console.log('parsedValue', parsedValue)
|
|
86
|
-
assert.equal(parsedValue, {
|
|
87
|
-
width: 999,
|
|
88
|
-
height: 111,
|
|
89
|
-
numberAsString: '12345',
|
|
90
|
-
great: [ 'scoot', 'sco ot', 'scooo ttt' ],
|
|
91
|
-
nope: false,
|
|
92
|
-
yes: true,
|
|
93
|
-
isWhat: true,
|
|
94
|
-
foo: { rad: [ 'whatever', 'man' ], cool: { beans: 'here' } },
|
|
95
|
-
what: 'xnxnx',
|
|
96
|
-
isLoading: true,
|
|
97
|
-
href: 'https://fooo.com/start/deploy?repositoryhttps://github.com/netlify/netlify-faunadb-example&stackfauna',
|
|
98
|
-
src: 'https://user-images.github{user}content.com/532272/123136878-46f1a300-d408-11eb-82f2-ad452498457b.jpg',
|
|
99
|
-
deep: { rad: 'blue', what: { nice: 'cool', wow: { deep: true } } }
|
|
100
|
-
}, 'matches original')
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('Single line', () => {
|
|
104
|
-
const parsedValue = weirdParse(`width={999} height={{111}} numberAsString="12345" great={["scoot", "sco ot", 'scooo ttt']} nice={{ value: nice, cool: "true" }} soclose=[jdjdjd, hdhfhfhffh] rad="boss" cool=true isCool notCool=false nooooo={[one, two, 3, 4]}`)
|
|
105
|
-
console.log('parsedValue', parsedValue)
|
|
106
|
-
assert.equal(parsedValue, {
|
|
107
|
-
width: 999,
|
|
108
|
-
height: 111,
|
|
109
|
-
numberAsString: '12345',
|
|
110
|
-
great: [ 'scoot', 'sco ot', 'scooo ttt' ],
|
|
111
|
-
nice: { value: 'nice', cool: 'true' },
|
|
112
|
-
soclose: [ 'jdjdjd', 'hdhfhfhffh' ],
|
|
113
|
-
rad: 'boss',
|
|
114
|
-
cool: true,
|
|
115
|
-
isCool: true,
|
|
116
|
-
notCool: false,
|
|
117
|
-
nooooo: [ 'one', 'two', 3, 4 ]
|
|
118
|
-
}, 'matches original')
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
test('Simple string equal (single quotes)', () => {
|
|
122
|
-
const parsedValue = weirdParse(`bob='cool'`)
|
|
123
|
-
assert.equal(parsedValue, {
|
|
124
|
-
bob: 'cool',
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
test('Simple string equal (double quotes)', () => {
|
|
129
|
-
const parsedValue = weirdParse(`bob="cool"`)
|
|
130
|
-
assert.equal(parsedValue, {
|
|
131
|
-
bob: 'cool',
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
test('Simple string equal (no quotes)', () => {
|
|
136
|
-
const parsedValue = weirdParse(`bob=cool`)
|
|
137
|
-
// console.log('parsedValue', parsedValue)
|
|
138
|
-
assert.equal(parsedValue, {
|
|
139
|
-
bob: 'cool',
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
test('Simple string equal (no quotes with spaces)', () => {
|
|
144
|
-
const answer = { bob: 'cool' }
|
|
145
|
-
const one = weirdParse(`bob = cool`)
|
|
146
|
-
const two = weirdParse(`bob= cool`)
|
|
147
|
-
const three = weirdParse(`bob =cool`)
|
|
148
|
-
// console.log('parsedValue', parsedValue)
|
|
149
|
-
assert.equal(one, answer)
|
|
150
|
-
assert.equal(two, answer)
|
|
151
|
-
assert.equal(three, answer)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test('Simple boolean', () => {
|
|
155
|
-
const answer = { isCool: true }
|
|
156
|
-
const one = weirdParse(`isCool`)
|
|
157
|
-
const two = weirdParse(`isCool = true`)
|
|
158
|
-
const three = weirdParse(`isCool =true`)
|
|
159
|
-
const four = weirdParse(`isCool=true`)
|
|
160
|
-
const fourx = weirdParse(`isCool={true}`)
|
|
161
|
-
const foury = weirdParse(`isCool={{true}}`)
|
|
162
|
-
|
|
163
|
-
assert.equal(one, answer)
|
|
164
|
-
assert.equal(two, answer)
|
|
165
|
-
assert.equal(three, answer)
|
|
166
|
-
assert.equal(four, answer)
|
|
167
|
-
assert.equal(fourx, answer)
|
|
168
|
-
assert.equal(foury, answer)
|
|
169
|
-
|
|
170
|
-
const answerTwo = { isNotCool: false }
|
|
171
|
-
const five = weirdParse(`isNotCool=false`)
|
|
172
|
-
const six = weirdParse(`isNotCool = false`)
|
|
173
|
-
const seven = weirdParse(`isNotCool =false`)
|
|
174
|
-
const eight = weirdParse(`isNotCool=false`)
|
|
175
|
-
const nine = weirdParse(`isNotCool= false`)
|
|
176
|
-
const ten = weirdParse(`isNotCool={false}`)
|
|
177
|
-
const eleven = weirdParse(`isNotCool={{false}}`)
|
|
178
|
-
|
|
179
|
-
assert.equal(five, answerTwo, 'five')
|
|
180
|
-
assert.equal(six, answerTwo, 'six')
|
|
181
|
-
assert.equal(seven, answerTwo, 'seven')
|
|
182
|
-
assert.equal(eight, answerTwo, 'eight')
|
|
183
|
-
assert.equal(nine, answerTwo, 'nine')
|
|
184
|
-
assert.equal(ten, answerTwo, 'ten')
|
|
185
|
-
assert.equal(eleven, answerTwo, 'eleven')
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
test('Simple object', () => {
|
|
189
|
-
const a = { key: { a: 'b' }}
|
|
190
|
-
assert.equal(a, weirdParse(`key={{ "a": "b" }}`))
|
|
191
|
-
assert.equal(a, weirdParse(`key={{ "a": b }}`))
|
|
192
|
-
assert.equal(a, weirdParse(`key={{ a: "b" }}`))
|
|
193
|
-
assert.equal(a, weirdParse(`key={{ a: b }}`))
|
|
194
|
-
assert.equal(a, weirdParse(`key={ a : b }`), 'single {')
|
|
195
|
-
|
|
196
|
-
const answer = { nice: { value: 'nice', cool: 'true', awesome: false } }
|
|
197
|
-
const one = weirdParse(`nice={{ value: nice, cool: "true", awesome: false }}`)
|
|
198
|
-
assert.equal(one, answer)
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
test('Simple array', () => {
|
|
202
|
-
const x = { key: [ 1, 2, 3 ] }
|
|
203
|
-
const y = weirdParse(`key=[ 1, 2, 3 ]`)
|
|
204
|
-
assert.equal(x, y)
|
|
205
|
-
|
|
206
|
-
const z = weirdParse(`key=[ "1", "2", "3" ]`)
|
|
207
|
-
assert.equal(z, { key: [ "1", "2", "3" ] })
|
|
208
|
-
|
|
209
|
-
const a = weirdParse(`key=[ one, two, three ]`)
|
|
210
|
-
assert.equal(a, { key: [ "one", "two", "three" ] })
|
|
211
|
-
|
|
212
|
-
const answer = { great: [ 'scoot', 'sco ot', 'scooo ttt', 'one', 'two', 3, 4, true ] }
|
|
213
|
-
const one = weirdParse(`great={["scoot", "sco ot", 'scooo ttt', one, two, 3, 4, true]} `)
|
|
214
|
-
assert.equal(one, answer)
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
test.run()
|