markdown-magic 2.6.1 → 3.0.1

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.
Files changed (58) hide show
  1. package/README.md +47 -37
  2. package/cli.js +5 -82
  3. package/lib/block-parser-js.test.js +171 -0
  4. package/lib/block-parser.js +382 -0
  5. package/lib/block-parser.test.js +479 -0
  6. package/lib/cli.js +245 -0
  7. package/lib/cli.test.js +409 -0
  8. package/lib/defaults.js +12 -0
  9. package/lib/globals.d.ts +66 -0
  10. package/lib/index.js +353 -184
  11. package/lib/index.test.js +11 -0
  12. package/lib/process-contents.js +371 -0
  13. package/lib/process-file.js +37 -0
  14. package/lib/transforms/code.js +67 -28
  15. package/lib/transforms/file.js +17 -17
  16. package/lib/transforms/index.js +0 -114
  17. package/lib/transforms/remote.js +8 -6
  18. package/lib/transforms/sectionToc.js +18 -0
  19. package/lib/transforms/toc.js +12 -265
  20. package/lib/transforms/wordCount.js +5 -0
  21. package/lib/types.js +11 -0
  22. package/lib/utils/fs.js +342 -0
  23. package/lib/utils/fs.test.js +267 -0
  24. package/lib/utils/index.js +19 -0
  25. package/{cli-utils.js → lib/utils/load-config.js} +2 -6
  26. package/lib/utils/logs.js +94 -0
  27. package/lib/utils/md/filters.js +20 -0
  28. package/lib/utils/md/find-code-blocks.js +88 -0
  29. package/lib/utils/md/find-date.js +32 -0
  30. package/lib/utils/md/find-frontmatter.js +92 -0
  31. package/lib/utils/md/find-frontmatter.test.js +17 -0
  32. package/lib/utils/md/find-html-tags.js +105 -0
  33. package/lib/utils/md/find-images-md.js +27 -0
  34. package/lib/utils/md/find-images.js +107 -0
  35. package/lib/utils/md/find-links.js +220 -0
  36. package/lib/utils/md/find-unmatched-html-tags.js +32 -0
  37. package/lib/utils/md/fixtures/2022-01-22-date-in-filename.md +14 -0
  38. package/lib/utils/md/fixtures/file-with-frontmatter.md +32 -0
  39. package/lib/utils/md/fixtures/file-with-links.md +153 -0
  40. package/lib/utils/md/md.test.js +105 -0
  41. package/lib/utils/md/parse.js +146 -0
  42. package/lib/utils/md/utils.js +19 -0
  43. package/lib/utils/regex-timeout.js +84 -0
  44. package/lib/utils/regex.js +40 -6
  45. package/lib/utils/remoteRequest.js +55 -0
  46. package/lib/utils/syntax.js +82 -0
  47. package/lib/utils/text.js +328 -0
  48. package/lib/utils/text.test.js +305 -0
  49. package/lib/utils/toc.js +315 -0
  50. package/package.json +30 -26
  51. package/index.js +0 -46
  52. package/lib/processFile.js +0 -154
  53. package/lib/updateContents.js +0 -125
  54. package/lib/utils/_md.test.js +0 -63
  55. package/lib/utils/new-parser.js +0 -412
  56. package/lib/utils/new-parser.test.js +0 -324
  57. package/lib/utils/weird-parse.js +0 -230
  58. 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()