commonmarker 1.1.3 → 1.1.4
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.
- checksums.yaml +4 -4
- data/Cargo.lock +81 -119
- data/ext/commonmarker/Cargo.toml +1 -1
- data/ext/commonmarker/src/lib.rs +31 -111
- data/ext/commonmarker/src/node.rs +61 -22
- data/ext/commonmarker/src/options.rs +10 -0
- data/ext/commonmarker/src/plugins/syntax_highlighting.rs +99 -7
- data/ext/commonmarker/src/plugins.rs +3 -0
- data/lib/commonmarker/config.rb +2 -0
- data/lib/commonmarker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be52deebe50e109769f29b7eab77a0d5c02974c1ce2b435e4ac73bc31afca368
|
|
4
|
+
data.tar.gz: 968471b3c0cca03f9594aaf3ffdc4971a47fe0baa6b4e1c734b8a03a83ef7c82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0282620e926dd8a97d68444e239423e4c0bac4b90cf379afbebcaa8d372aca330525a36efcd96c15e621c3fb39a88921336c8e2f01e39ade06dad0e4a76ef10d'
|
|
7
|
+
data.tar.gz: d8e90f12bc9e9cf1ccb81ae814945cd991845657482bd3d81797aae275db424bd6f2811bc0389a79af1405a3b35ea8affe3ede16c00f005a2bc5024bc083a7a8
|
data/Cargo.lock
CHANGED
|
@@ -19,47 +19,48 @@ dependencies = [
|
|
|
19
19
|
|
|
20
20
|
[[package]]
|
|
21
21
|
name = "anstream"
|
|
22
|
-
version = "0.6.
|
|
22
|
+
version = "0.6.14"
|
|
23
23
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
-
checksum = "
|
|
24
|
+
checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b"
|
|
25
25
|
dependencies = [
|
|
26
26
|
"anstyle",
|
|
27
27
|
"anstyle-parse",
|
|
28
28
|
"anstyle-query",
|
|
29
29
|
"anstyle-wincon",
|
|
30
30
|
"colorchoice",
|
|
31
|
+
"is_terminal_polyfill",
|
|
31
32
|
"utf8parse",
|
|
32
33
|
]
|
|
33
34
|
|
|
34
35
|
[[package]]
|
|
35
36
|
name = "anstyle"
|
|
36
|
-
version = "1.0.
|
|
37
|
+
version = "1.0.7"
|
|
37
38
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
38
|
-
checksum = "
|
|
39
|
+
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
|
|
39
40
|
|
|
40
41
|
[[package]]
|
|
41
42
|
name = "anstyle-parse"
|
|
42
|
-
version = "0.2.
|
|
43
|
+
version = "0.2.4"
|
|
43
44
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
44
|
-
checksum = "
|
|
45
|
+
checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4"
|
|
45
46
|
dependencies = [
|
|
46
47
|
"utf8parse",
|
|
47
48
|
]
|
|
48
49
|
|
|
49
50
|
[[package]]
|
|
50
51
|
name = "anstyle-query"
|
|
51
|
-
version = "1.0.
|
|
52
|
+
version = "1.0.3"
|
|
52
53
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
53
|
-
checksum = "
|
|
54
|
+
checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5"
|
|
54
55
|
dependencies = [
|
|
55
56
|
"windows-sys 0.52.0",
|
|
56
57
|
]
|
|
57
58
|
|
|
58
59
|
[[package]]
|
|
59
60
|
name = "anstyle-wincon"
|
|
60
|
-
version = "3.0.
|
|
61
|
+
version = "3.0.3"
|
|
61
62
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
62
|
-
checksum = "
|
|
63
|
+
checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19"
|
|
63
64
|
dependencies = [
|
|
64
65
|
"anstyle",
|
|
65
66
|
"windows-sys 0.52.0",
|
|
@@ -97,7 +98,7 @@ dependencies = [
|
|
|
97
98
|
"regex",
|
|
98
99
|
"rustc-hash",
|
|
99
100
|
"shlex",
|
|
100
|
-
"syn
|
|
101
|
+
"syn",
|
|
101
102
|
]
|
|
102
103
|
|
|
103
104
|
[[package]]
|
|
@@ -135,9 +136,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
|
|
135
136
|
|
|
136
137
|
[[package]]
|
|
137
138
|
name = "cc"
|
|
138
|
-
version = "1.0.
|
|
139
|
+
version = "1.0.98"
|
|
139
140
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
140
|
-
checksum = "
|
|
141
|
+
checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f"
|
|
141
142
|
|
|
142
143
|
[[package]]
|
|
143
144
|
name = "cexpr"
|
|
@@ -184,7 +185,7 @@ dependencies = [
|
|
|
184
185
|
"anstream",
|
|
185
186
|
"anstyle",
|
|
186
187
|
"clap_lex",
|
|
187
|
-
"strsim
|
|
188
|
+
"strsim",
|
|
188
189
|
"terminal_size",
|
|
189
190
|
]
|
|
190
191
|
|
|
@@ -197,7 +198,7 @@ dependencies = [
|
|
|
197
198
|
"heck",
|
|
198
199
|
"proc-macro2",
|
|
199
200
|
"quote",
|
|
200
|
-
"syn
|
|
201
|
+
"syn",
|
|
201
202
|
]
|
|
202
203
|
|
|
203
204
|
[[package]]
|
|
@@ -208,9 +209,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
|
|
|
208
209
|
|
|
209
210
|
[[package]]
|
|
210
211
|
name = "colorchoice"
|
|
211
|
-
version = "1.0.
|
|
212
|
+
version = "1.0.1"
|
|
212
213
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
213
|
-
checksum = "
|
|
214
|
+
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
|
|
214
215
|
|
|
215
216
|
[[package]]
|
|
216
217
|
name = "commonmarker"
|
|
@@ -226,15 +227,14 @@ dependencies = [
|
|
|
226
227
|
|
|
227
228
|
[[package]]
|
|
228
229
|
name = "comrak"
|
|
229
|
-
version = "0.
|
|
230
|
+
version = "0.24.1"
|
|
230
231
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
231
|
-
checksum = "
|
|
232
|
+
checksum = "5a972c8ec1be8065f7b597b5f7f5b3be535db780280644aebdcd1966decf58dc"
|
|
232
233
|
dependencies = [
|
|
233
234
|
"clap",
|
|
234
235
|
"derive_builder",
|
|
235
236
|
"emojis",
|
|
236
237
|
"entities",
|
|
237
|
-
"in-place",
|
|
238
238
|
"memchr",
|
|
239
239
|
"once_cell",
|
|
240
240
|
"regex",
|
|
@@ -248,18 +248,18 @@ dependencies = [
|
|
|
248
248
|
|
|
249
249
|
[[package]]
|
|
250
250
|
name = "crc32fast"
|
|
251
|
-
version = "1.4.
|
|
251
|
+
version = "1.4.2"
|
|
252
252
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
253
|
-
checksum = "
|
|
253
|
+
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
|
254
254
|
dependencies = [
|
|
255
255
|
"cfg-if",
|
|
256
256
|
]
|
|
257
257
|
|
|
258
258
|
[[package]]
|
|
259
259
|
name = "darling"
|
|
260
|
-
version = "0.
|
|
260
|
+
version = "0.20.9"
|
|
261
261
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
262
|
-
checksum = "
|
|
262
|
+
checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1"
|
|
263
263
|
dependencies = [
|
|
264
264
|
"darling_core",
|
|
265
265
|
"darling_macro",
|
|
@@ -267,27 +267,27 @@ dependencies = [
|
|
|
267
267
|
|
|
268
268
|
[[package]]
|
|
269
269
|
name = "darling_core"
|
|
270
|
-
version = "0.
|
|
270
|
+
version = "0.20.9"
|
|
271
271
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
272
|
-
checksum = "
|
|
272
|
+
checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120"
|
|
273
273
|
dependencies = [
|
|
274
274
|
"fnv",
|
|
275
275
|
"ident_case",
|
|
276
276
|
"proc-macro2",
|
|
277
277
|
"quote",
|
|
278
|
-
"strsim
|
|
279
|
-
"syn
|
|
278
|
+
"strsim",
|
|
279
|
+
"syn",
|
|
280
280
|
]
|
|
281
281
|
|
|
282
282
|
[[package]]
|
|
283
283
|
name = "darling_macro"
|
|
284
|
-
version = "0.
|
|
284
|
+
version = "0.20.9"
|
|
285
285
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
286
|
-
checksum = "
|
|
286
|
+
checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178"
|
|
287
287
|
dependencies = [
|
|
288
288
|
"darling_core",
|
|
289
289
|
"quote",
|
|
290
|
-
"syn
|
|
290
|
+
"syn",
|
|
291
291
|
]
|
|
292
292
|
|
|
293
293
|
[[package]]
|
|
@@ -301,52 +301,52 @@ dependencies = [
|
|
|
301
301
|
|
|
302
302
|
[[package]]
|
|
303
303
|
name = "derive_builder"
|
|
304
|
-
version = "0.
|
|
304
|
+
version = "0.20.0"
|
|
305
305
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
306
|
-
checksum = "
|
|
306
|
+
checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7"
|
|
307
307
|
dependencies = [
|
|
308
308
|
"derive_builder_macro",
|
|
309
309
|
]
|
|
310
310
|
|
|
311
311
|
[[package]]
|
|
312
312
|
name = "derive_builder_core"
|
|
313
|
-
version = "0.
|
|
313
|
+
version = "0.20.0"
|
|
314
314
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
315
|
-
checksum = "
|
|
315
|
+
checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d"
|
|
316
316
|
dependencies = [
|
|
317
317
|
"darling",
|
|
318
318
|
"proc-macro2",
|
|
319
319
|
"quote",
|
|
320
|
-
"syn
|
|
320
|
+
"syn",
|
|
321
321
|
]
|
|
322
322
|
|
|
323
323
|
[[package]]
|
|
324
324
|
name = "derive_builder_macro"
|
|
325
|
-
version = "0.
|
|
325
|
+
version = "0.20.0"
|
|
326
326
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
327
|
-
checksum = "
|
|
327
|
+
checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b"
|
|
328
328
|
dependencies = [
|
|
329
329
|
"derive_builder_core",
|
|
330
|
-
"syn
|
|
330
|
+
"syn",
|
|
331
331
|
]
|
|
332
332
|
|
|
333
333
|
[[package]]
|
|
334
334
|
name = "deunicode"
|
|
335
|
-
version = "1.
|
|
335
|
+
version = "1.6.0"
|
|
336
336
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
337
|
-
checksum = "
|
|
337
|
+
checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00"
|
|
338
338
|
|
|
339
339
|
[[package]]
|
|
340
340
|
name = "either"
|
|
341
|
-
version = "1.
|
|
341
|
+
version = "1.12.0"
|
|
342
342
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
343
|
-
checksum = "
|
|
343
|
+
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
|
|
344
344
|
|
|
345
345
|
[[package]]
|
|
346
346
|
name = "emojis"
|
|
347
|
-
version = "0.
|
|
347
|
+
version = "0.6.2"
|
|
348
348
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
349
|
-
checksum = "
|
|
349
|
+
checksum = "9f619a926616ae7149a0d82610b051134a0d6c4ae2962d990c06c847a445c5d9"
|
|
350
350
|
dependencies = [
|
|
351
351
|
"phf",
|
|
352
352
|
]
|
|
@@ -365,9 +365,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
|
|
365
365
|
|
|
366
366
|
[[package]]
|
|
367
367
|
name = "errno"
|
|
368
|
-
version = "0.3.
|
|
368
|
+
version = "0.3.9"
|
|
369
369
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
370
|
-
checksum = "
|
|
370
|
+
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
|
|
371
371
|
dependencies = [
|
|
372
372
|
"libc",
|
|
373
373
|
"windows-sys 0.52.0",
|
|
@@ -383,12 +383,6 @@ dependencies = [
|
|
|
383
383
|
"regex",
|
|
384
384
|
]
|
|
385
385
|
|
|
386
|
-
[[package]]
|
|
387
|
-
name = "fastrand"
|
|
388
|
-
version = "2.1.0"
|
|
389
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
390
|
-
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
|
|
391
|
-
|
|
392
386
|
[[package]]
|
|
393
387
|
name = "flate2"
|
|
394
388
|
version = "1.0.30"
|
|
@@ -429,15 +423,6 @@ version = "1.0.1"
|
|
|
429
423
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
430
424
|
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
|
431
425
|
|
|
432
|
-
[[package]]
|
|
433
|
-
name = "in-place"
|
|
434
|
-
version = "0.2.0"
|
|
435
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
436
|
-
checksum = "1cdb69f3adfd5f493210cece799f4620417bf9965bc1536c22ae0e29ba27a8c0"
|
|
437
|
-
dependencies = [
|
|
438
|
-
"tempfile",
|
|
439
|
-
]
|
|
440
|
-
|
|
441
426
|
[[package]]
|
|
442
427
|
name = "indexmap"
|
|
443
428
|
version = "2.2.6"
|
|
@@ -448,6 +433,12 @@ dependencies = [
|
|
|
448
433
|
"hashbrown",
|
|
449
434
|
]
|
|
450
435
|
|
|
436
|
+
[[package]]
|
|
437
|
+
name = "is_terminal_polyfill"
|
|
438
|
+
version = "1.70.0"
|
|
439
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
440
|
+
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
|
|
441
|
+
|
|
451
442
|
[[package]]
|
|
452
443
|
name = "itertools"
|
|
453
444
|
version = "0.12.1"
|
|
@@ -477,9 +468,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
|
477
468
|
|
|
478
469
|
[[package]]
|
|
479
470
|
name = "libc"
|
|
480
|
-
version = "0.2.
|
|
471
|
+
version = "0.2.155"
|
|
481
472
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
482
|
-
checksum = "
|
|
473
|
+
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
|
483
474
|
|
|
484
475
|
[[package]]
|
|
485
476
|
name = "libloading"
|
|
@@ -505,9 +496,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
|
|
505
496
|
|
|
506
497
|
[[package]]
|
|
507
498
|
name = "linux-raw-sys"
|
|
508
|
-
version = "0.4.
|
|
499
|
+
version = "0.4.14"
|
|
509
500
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
510
|
-
checksum = "
|
|
501
|
+
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
|
511
502
|
|
|
512
503
|
[[package]]
|
|
513
504
|
name = "log"
|
|
@@ -535,7 +526,7 @@ checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
|
|
|
535
526
|
dependencies = [
|
|
536
527
|
"proc-macro2",
|
|
537
528
|
"quote",
|
|
538
|
-
"syn
|
|
529
|
+
"syn",
|
|
539
530
|
]
|
|
540
531
|
|
|
541
532
|
[[package]]
|
|
@@ -552,9 +543,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
|
552
543
|
|
|
553
544
|
[[package]]
|
|
554
545
|
name = "miniz_oxide"
|
|
555
|
-
version = "0.7.
|
|
546
|
+
version = "0.7.3"
|
|
556
547
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
557
|
-
checksum = "
|
|
548
|
+
checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae"
|
|
558
549
|
dependencies = [
|
|
559
550
|
"adler",
|
|
560
551
|
]
|
|
@@ -649,9 +640,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
|
|
649
640
|
|
|
650
641
|
[[package]]
|
|
651
642
|
name = "proc-macro2"
|
|
652
|
-
version = "1.0.
|
|
643
|
+
version = "1.0.83"
|
|
653
644
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
654
|
-
checksum = "
|
|
645
|
+
checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43"
|
|
655
646
|
dependencies = [
|
|
656
647
|
"unicode-ident",
|
|
657
648
|
]
|
|
@@ -695,7 +686,7 @@ dependencies = [
|
|
|
695
686
|
"quote",
|
|
696
687
|
"regex",
|
|
697
688
|
"shell-words",
|
|
698
|
-
"syn
|
|
689
|
+
"syn",
|
|
699
690
|
]
|
|
700
691
|
|
|
701
692
|
[[package]]
|
|
@@ -760,9 +751,9 @@ dependencies = [
|
|
|
760
751
|
|
|
761
752
|
[[package]]
|
|
762
753
|
name = "ryu"
|
|
763
|
-
version = "1.0.
|
|
754
|
+
version = "1.0.18"
|
|
764
755
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
765
|
-
checksum = "
|
|
756
|
+
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
|
766
757
|
|
|
767
758
|
[[package]]
|
|
768
759
|
name = "same-file"
|
|
@@ -781,29 +772,29 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
|
|
|
781
772
|
|
|
782
773
|
[[package]]
|
|
783
774
|
name = "serde"
|
|
784
|
-
version = "1.0.
|
|
775
|
+
version = "1.0.202"
|
|
785
776
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
786
|
-
checksum = "
|
|
777
|
+
checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
|
|
787
778
|
dependencies = [
|
|
788
779
|
"serde_derive",
|
|
789
780
|
]
|
|
790
781
|
|
|
791
782
|
[[package]]
|
|
792
783
|
name = "serde_derive"
|
|
793
|
-
version = "1.0.
|
|
784
|
+
version = "1.0.202"
|
|
794
785
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
795
|
-
checksum = "
|
|
786
|
+
checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
|
|
796
787
|
dependencies = [
|
|
797
788
|
"proc-macro2",
|
|
798
789
|
"quote",
|
|
799
|
-
"syn
|
|
790
|
+
"syn",
|
|
800
791
|
]
|
|
801
792
|
|
|
802
793
|
[[package]]
|
|
803
794
|
name = "serde_json"
|
|
804
|
-
version = "1.0.
|
|
795
|
+
version = "1.0.117"
|
|
805
796
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
806
|
-
checksum = "
|
|
797
|
+
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
|
|
807
798
|
dependencies = [
|
|
808
799
|
"itoa",
|
|
809
800
|
"ryu",
|
|
@@ -838,12 +829,6 @@ dependencies = [
|
|
|
838
829
|
"wasm-bindgen",
|
|
839
830
|
]
|
|
840
831
|
|
|
841
|
-
[[package]]
|
|
842
|
-
name = "strsim"
|
|
843
|
-
version = "0.10.0"
|
|
844
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
845
|
-
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|
846
|
-
|
|
847
832
|
[[package]]
|
|
848
833
|
name = "strsim"
|
|
849
834
|
version = "0.11.1"
|
|
@@ -852,20 +837,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|
|
852
837
|
|
|
853
838
|
[[package]]
|
|
854
839
|
name = "syn"
|
|
855
|
-
version = "
|
|
856
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
857
|
-
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
|
858
|
-
dependencies = [
|
|
859
|
-
"proc-macro2",
|
|
860
|
-
"quote",
|
|
861
|
-
"unicode-ident",
|
|
862
|
-
]
|
|
863
|
-
|
|
864
|
-
[[package]]
|
|
865
|
-
name = "syn"
|
|
866
|
-
version = "2.0.60"
|
|
840
|
+
version = "2.0.65"
|
|
867
841
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
868
|
-
checksum = "
|
|
842
|
+
checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106"
|
|
869
843
|
dependencies = [
|
|
870
844
|
"proc-macro2",
|
|
871
845
|
"quote",
|
|
@@ -895,18 +869,6 @@ dependencies = [
|
|
|
895
869
|
"yaml-rust",
|
|
896
870
|
]
|
|
897
871
|
|
|
898
|
-
[[package]]
|
|
899
|
-
name = "tempfile"
|
|
900
|
-
version = "3.10.1"
|
|
901
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
902
|
-
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
|
|
903
|
-
dependencies = [
|
|
904
|
-
"cfg-if",
|
|
905
|
-
"fastrand",
|
|
906
|
-
"rustix",
|
|
907
|
-
"windows-sys 0.52.0",
|
|
908
|
-
]
|
|
909
|
-
|
|
910
872
|
[[package]]
|
|
911
873
|
name = "terminal_size"
|
|
912
874
|
version = "0.3.0"
|
|
@@ -919,22 +881,22 @@ dependencies = [
|
|
|
919
881
|
|
|
920
882
|
[[package]]
|
|
921
883
|
name = "thiserror"
|
|
922
|
-
version = "1.0.
|
|
884
|
+
version = "1.0.61"
|
|
923
885
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
924
|
-
checksum = "
|
|
886
|
+
checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
|
|
925
887
|
dependencies = [
|
|
926
888
|
"thiserror-impl",
|
|
927
889
|
]
|
|
928
890
|
|
|
929
891
|
[[package]]
|
|
930
892
|
name = "thiserror-impl"
|
|
931
|
-
version = "1.0.
|
|
893
|
+
version = "1.0.61"
|
|
932
894
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
933
|
-
checksum = "
|
|
895
|
+
checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
|
|
934
896
|
dependencies = [
|
|
935
897
|
"proc-macro2",
|
|
936
898
|
"quote",
|
|
937
|
-
"syn
|
|
899
|
+
"syn",
|
|
938
900
|
]
|
|
939
901
|
|
|
940
902
|
[[package]]
|
|
@@ -1023,7 +985,7 @@ dependencies = [
|
|
|
1023
985
|
"once_cell",
|
|
1024
986
|
"proc-macro2",
|
|
1025
987
|
"quote",
|
|
1026
|
-
"syn
|
|
988
|
+
"syn",
|
|
1027
989
|
"wasm-bindgen-shared",
|
|
1028
990
|
]
|
|
1029
991
|
|
|
@@ -1045,7 +1007,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
|
|
|
1045
1007
|
dependencies = [
|
|
1046
1008
|
"proc-macro2",
|
|
1047
1009
|
"quote",
|
|
1048
|
-
"syn
|
|
1010
|
+
"syn",
|
|
1049
1011
|
"wasm-bindgen-backend",
|
|
1050
1012
|
"wasm-bindgen-shared",
|
|
1051
1013
|
]
|
data/ext/commonmarker/Cargo.toml
CHANGED
|
@@ -10,7 +10,7 @@ magnus = { version = "0.6", features = ["rb-sys"] }
|
|
|
10
10
|
rb-sys = { version = "*", default-features = false, features = [
|
|
11
11
|
"stable-api-compiled-fallback",
|
|
12
12
|
] }
|
|
13
|
-
comrak = { version = "0.
|
|
13
|
+
comrak = { version = "0.24", features = ["shortcodes"] }
|
|
14
14
|
syntect = { version = "5.2", features = ["plist-load"] }
|
|
15
15
|
typed-arena = "2.0"
|
|
16
16
|
rctree = "0.6"
|
data/ext/commonmarker/src/lib.rs
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
extern crate core;
|
|
2
2
|
|
|
3
|
-
use
|
|
4
|
-
|
|
5
|
-
use ::syntect::highlighting::ThemeSet;
|
|
6
|
-
use comrak::{
|
|
7
|
-
adapters::SyntaxHighlighterAdapter,
|
|
8
|
-
markdown_to_html, markdown_to_html_with_plugins, parse_document,
|
|
9
|
-
plugins::syntect::{SyntectAdapter, SyntectAdapterBuilder},
|
|
10
|
-
ComrakOptions, ComrakPlugins,
|
|
11
|
-
};
|
|
12
|
-
use magnus::{
|
|
13
|
-
define_module, exception, function, r_hash::ForEach, scan_args, Error, RHash, Symbol, Value,
|
|
14
|
-
};
|
|
3
|
+
use comrak::{markdown_to_html_with_plugins, parse_document, ComrakOptions};
|
|
4
|
+
use magnus::{define_module, function, r_hash::ForEach, scan_args, Error, RHash, Symbol, Value};
|
|
15
5
|
use node::CommonmarkerNode;
|
|
6
|
+
use plugins::syntax_highlighting::construct_syntax_highlighter_from_plugin;
|
|
16
7
|
|
|
17
8
|
mod options;
|
|
18
9
|
use options::iterate_options_hash;
|
|
19
10
|
|
|
20
11
|
mod plugins;
|
|
21
|
-
|
|
22
|
-
syntax_highlighting::{fetch_syntax_highlighter_path, fetch_syntax_highlighter_theme},
|
|
23
|
-
SYNTAX_HIGHLIGHTER_PLUGIN,
|
|
24
|
-
};
|
|
12
|
+
|
|
25
13
|
use typed_arena::Arena;
|
|
26
14
|
|
|
27
15
|
mod node;
|
|
@@ -63,6 +51,32 @@ fn commonmark_to_html(args: &[Value]) -> Result<String, magnus::Error> {
|
|
|
63
51
|
)?;
|
|
64
52
|
let (rb_options, rb_plugins) = kwargs.optional;
|
|
65
53
|
|
|
54
|
+
let comrak_options = match format_options(rb_options) {
|
|
55
|
+
Ok(options) => options,
|
|
56
|
+
Err(err) => return Err(err),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
let mut comrak_plugins = comrak::Plugins::default();
|
|
60
|
+
|
|
61
|
+
let syntect_adapter = match construct_syntax_highlighter_from_plugin(rb_plugins) {
|
|
62
|
+
Ok(Some(adapter)) => Some(adapter),
|
|
63
|
+
Ok(None) => None,
|
|
64
|
+
Err(err) => return Err(err),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
match syntect_adapter {
|
|
68
|
+
Some(ref adapter) => comrak_plugins.render.codefence_syntax_highlighter = Some(adapter),
|
|
69
|
+
None => comrak_plugins.render.codefence_syntax_highlighter = None,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Ok(markdown_to_html_with_plugins(
|
|
73
|
+
&rb_commonmark,
|
|
74
|
+
&comrak_options,
|
|
75
|
+
&comrak_plugins,
|
|
76
|
+
))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn format_options(rb_options: Option<RHash>) -> Result<comrak::Options, magnus::Error> {
|
|
66
80
|
let mut comrak_options = ComrakOptions::default();
|
|
67
81
|
|
|
68
82
|
if let Some(rb_options) = rb_options {
|
|
@@ -72,101 +86,7 @@ fn commonmark_to_html(args: &[Value]) -> Result<String, magnus::Error> {
|
|
|
72
86
|
})?;
|
|
73
87
|
}
|
|
74
88
|
|
|
75
|
-
|
|
76
|
-
let mut comrak_plugins = ComrakPlugins::default();
|
|
77
|
-
|
|
78
|
-
let syntax_highlighter: Option<&dyn SyntaxHighlighterAdapter>;
|
|
79
|
-
let adapter: SyntectAdapter;
|
|
80
|
-
|
|
81
|
-
let theme = match rb_plugins.get(Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN)) {
|
|
82
|
-
Some(syntax_highlighter_options) => {
|
|
83
|
-
match fetch_syntax_highlighter_theme(syntax_highlighter_options) {
|
|
84
|
-
Ok(theme) => theme,
|
|
85
|
-
Err(e) => {
|
|
86
|
-
return Err(e);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
None => None, // no `syntax_highlighter:` defined
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
match theme {
|
|
94
|
-
None => syntax_highlighter = None,
|
|
95
|
-
Some(theme) => {
|
|
96
|
-
if theme.is_empty() {
|
|
97
|
-
// no theme? uss css classes
|
|
98
|
-
adapter = SyntectAdapter::new(None);
|
|
99
|
-
syntax_highlighter = Some(&adapter);
|
|
100
|
-
} else {
|
|
101
|
-
let path = match rb_plugins.get(Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN)) {
|
|
102
|
-
Some(syntax_highlighter_options) => {
|
|
103
|
-
fetch_syntax_highlighter_path(syntax_highlighter_options)?
|
|
104
|
-
}
|
|
105
|
-
None => PathBuf::from("".to_string()), // no `syntax_highlighter:` defined
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
if path.exists() {
|
|
109
|
-
if !path.is_dir() {
|
|
110
|
-
return Err(Error::new(
|
|
111
|
-
exception::arg_error(),
|
|
112
|
-
"`path` needs to be a directory",
|
|
113
|
-
));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
let builder = SyntectAdapterBuilder::new();
|
|
117
|
-
let mut ts = ThemeSet::load_defaults();
|
|
118
|
-
|
|
119
|
-
match ts.add_from_folder(&path) {
|
|
120
|
-
Ok(_) => {}
|
|
121
|
-
Err(e) => {
|
|
122
|
-
return Err(Error::new(
|
|
123
|
-
exception::arg_error(),
|
|
124
|
-
format!("failed to load theme set from path: {e}"),
|
|
125
|
-
));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// check if the theme exists in the dir
|
|
130
|
-
match ts.themes.get(&theme) {
|
|
131
|
-
Some(theme) => theme,
|
|
132
|
-
None => {
|
|
133
|
-
return Err(Error::new(
|
|
134
|
-
exception::arg_error(),
|
|
135
|
-
format!("theme `{}` does not exist", theme),
|
|
136
|
-
));
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
adapter = builder.theme_set(ts).theme(&theme).build();
|
|
141
|
-
|
|
142
|
-
syntax_highlighter = Some(&adapter);
|
|
143
|
-
} else {
|
|
144
|
-
// no path? default theme lookup
|
|
145
|
-
ThemeSet::load_defaults()
|
|
146
|
-
.themes
|
|
147
|
-
.get(&theme)
|
|
148
|
-
.ok_or_else(|| {
|
|
149
|
-
Error::new(
|
|
150
|
-
exception::arg_error(),
|
|
151
|
-
format!("theme `{}` does not exist", theme),
|
|
152
|
-
)
|
|
153
|
-
})?;
|
|
154
|
-
adapter = SyntectAdapter::new(Some(&theme));
|
|
155
|
-
syntax_highlighter = Some(&adapter);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
comrak_plugins.render.codefence_syntax_highlighter = syntax_highlighter;
|
|
161
|
-
|
|
162
|
-
Ok(markdown_to_html_with_plugins(
|
|
163
|
-
&rb_commonmark,
|
|
164
|
-
&comrak_options,
|
|
165
|
-
&comrak_plugins,
|
|
166
|
-
))
|
|
167
|
-
} else {
|
|
168
|
-
Ok(markdown_to_html(&rb_commonmark, &comrak_options))
|
|
169
|
-
}
|
|
89
|
+
Ok(comrak_options)
|
|
170
90
|
}
|
|
171
91
|
|
|
172
92
|
#[magnus::init]
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
use comrak::arena_tree::Node as ComrakNode;
|
|
1
2
|
use comrak::nodes::{
|
|
2
3
|
Ast as ComrakAst, AstNode as ComrakAstNode, ListDelimType, ListType, NodeCode, NodeCodeBlock,
|
|
3
4
|
NodeDescriptionItem, NodeFootnoteDefinition, NodeFootnoteReference, NodeHeading, NodeHtmlBlock,
|
|
4
5
|
NodeLink, NodeList, NodeMath, NodeMultilineBlockQuote, NodeShortCode, NodeTable,
|
|
5
|
-
NodeValue as ComrakNodeValue, TableAlignment,
|
|
6
|
+
NodeValue as ComrakNodeValue, NodeWikiLink, TableAlignment,
|
|
6
7
|
};
|
|
7
|
-
use comrak::{arena_tree::Node as ComrakNode, ComrakOptions};
|
|
8
8
|
use magnus::RArray;
|
|
9
|
-
use magnus::{
|
|
10
|
-
function, method, r_hash::ForEach, scan_args, Module, Object, RHash, RModule, Symbol, Value,
|
|
11
|
-
};
|
|
9
|
+
use magnus::{function, method, scan_args, Module, Object, RHash, RModule, Symbol, Value};
|
|
12
10
|
use rctree::Node;
|
|
13
11
|
use typed_arena::Arena;
|
|
14
12
|
|
|
15
13
|
use std::cell::RefCell;
|
|
16
14
|
|
|
17
|
-
use crate::
|
|
15
|
+
use crate::format_options;
|
|
16
|
+
|
|
17
|
+
use crate::plugins::syntax_highlighting::construct_syntax_highlighter_from_plugin;
|
|
18
18
|
|
|
19
19
|
#[derive(Debug, Clone)]
|
|
20
20
|
#[magnus::wrap(class = "Commonmarker::Node::Ast", size, mark)]
|
|
@@ -453,6 +453,15 @@ impl CommonmarkerNode {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
"escaped" => ComrakNodeValue::Escaped,
|
|
456
|
+
|
|
457
|
+
"wikilink" => {
|
|
458
|
+
let kwargs =
|
|
459
|
+
scan_args::get_kwargs::<_, (String,), (), ()>(args.keywords, &["url"], &[])?;
|
|
460
|
+
|
|
461
|
+
let (url,) = kwargs.required;
|
|
462
|
+
|
|
463
|
+
ComrakNodeValue::WikiLink(NodeWikiLink { url })
|
|
464
|
+
}
|
|
456
465
|
_ => panic!("unknown node type {}", node_type),
|
|
457
466
|
};
|
|
458
467
|
|
|
@@ -539,6 +548,7 @@ impl CommonmarkerNode {
|
|
|
539
548
|
ComrakNodeValue::MultilineBlockQuote(_) => Symbol::new("multiline_block_quote"),
|
|
540
549
|
ComrakNodeValue::Escaped => Symbol::new("escaped"),
|
|
541
550
|
ComrakNodeValue::Math(..) => Symbol::new("math"),
|
|
551
|
+
ComrakNodeValue::WikiLink(..) => Symbol::new("wikilink"),
|
|
542
552
|
}
|
|
543
553
|
}
|
|
544
554
|
|
|
@@ -895,15 +905,24 @@ impl CommonmarkerNode {
|
|
|
895
905
|
&[],
|
|
896
906
|
&["options", "plugins"],
|
|
897
907
|
)?;
|
|
898
|
-
let (rb_options,
|
|
908
|
+
let (rb_options, rb_plugins) = kwargs.optional;
|
|
899
909
|
|
|
900
|
-
let
|
|
910
|
+
let comrak_options = match format_options(rb_options) {
|
|
911
|
+
Ok(options) => options,
|
|
912
|
+
Err(err) => return Err(err),
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
let mut comrak_plugins = comrak::Plugins::default();
|
|
916
|
+
|
|
917
|
+
let syntect_adapter = match construct_syntax_highlighter_from_plugin(rb_plugins) {
|
|
918
|
+
Ok(Some(adapter)) => Some(adapter),
|
|
919
|
+
Ok(None) => None,
|
|
920
|
+
Err(err) => return Err(err),
|
|
921
|
+
};
|
|
901
922
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
Ok(ForEach::Continue)
|
|
906
|
-
})?;
|
|
923
|
+
match syntect_adapter {
|
|
924
|
+
Some(ref adapter) => comrak_plugins.render.codefence_syntax_highlighter = Some(adapter),
|
|
925
|
+
None => comrak_plugins.render.codefence_syntax_highlighter = None,
|
|
907
926
|
}
|
|
908
927
|
|
|
909
928
|
let arena: Arena<ComrakAstNode> = Arena::new();
|
|
@@ -936,7 +955,12 @@ impl CommonmarkerNode {
|
|
|
936
955
|
}
|
|
937
956
|
|
|
938
957
|
let mut output = vec![];
|
|
939
|
-
match comrak::
|
|
958
|
+
match comrak::format_html_with_plugins(
|
|
959
|
+
&comrak_root_node,
|
|
960
|
+
&comrak_options,
|
|
961
|
+
&mut output,
|
|
962
|
+
&comrak_plugins,
|
|
963
|
+
) {
|
|
940
964
|
Ok(_) => {}
|
|
941
965
|
Err(e) => {
|
|
942
966
|
return Err(magnus::Error::new(
|
|
@@ -963,15 +987,25 @@ impl CommonmarkerNode {
|
|
|
963
987
|
&[],
|
|
964
988
|
&["options", "plugins"],
|
|
965
989
|
)?;
|
|
966
|
-
let (rb_options,
|
|
990
|
+
let (rb_options, rb_plugins) = kwargs.optional;
|
|
967
991
|
|
|
968
|
-
let
|
|
992
|
+
let _comrak_options = format_options(rb_options);
|
|
993
|
+
let comrak_options = match format_options(rb_options) {
|
|
994
|
+
Ok(options) => options,
|
|
995
|
+
Err(err) => return Err(err),
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
let mut comrak_plugins = comrak::Plugins::default();
|
|
999
|
+
|
|
1000
|
+
let syntect_adapter = match construct_syntax_highlighter_from_plugin(rb_plugins) {
|
|
1001
|
+
Ok(Some(adapter)) => Some(adapter),
|
|
1002
|
+
Ok(None) => None,
|
|
1003
|
+
Err(err) => return Err(err),
|
|
1004
|
+
};
|
|
969
1005
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
Ok(ForEach::Continue)
|
|
974
|
-
})?;
|
|
1006
|
+
match syntect_adapter {
|
|
1007
|
+
Some(ref adapter) => comrak_plugins.render.codefence_syntax_highlighter = Some(adapter),
|
|
1008
|
+
None => comrak_plugins.render.codefence_syntax_highlighter = None,
|
|
975
1009
|
}
|
|
976
1010
|
|
|
977
1011
|
let arena: Arena<ComrakAstNode> = Arena::new();
|
|
@@ -1004,7 +1038,12 @@ impl CommonmarkerNode {
|
|
|
1004
1038
|
}
|
|
1005
1039
|
|
|
1006
1040
|
let mut output = vec![];
|
|
1007
|
-
match comrak::
|
|
1041
|
+
match comrak::format_commonmark_with_plugins(
|
|
1042
|
+
&comrak_root_node,
|
|
1043
|
+
&comrak_options,
|
|
1044
|
+
&mut output,
|
|
1045
|
+
&comrak_plugins,
|
|
1046
|
+
) {
|
|
1008
1047
|
Ok(_) => {}
|
|
1009
1048
|
Err(e) => {
|
|
1010
1049
|
return Err(magnus::Error::new(
|
|
@@ -86,6 +86,8 @@ const EXTENSION_SHORTCODES: &str = "shortcodes";
|
|
|
86
86
|
const EXTENSION_MULTILINE_BLOCK_QUOTES: &str = "multiline_block_quotes";
|
|
87
87
|
const EXTENSION_MATH_DOLLARS: &str = "math_dollars";
|
|
88
88
|
const EXTENSION_MATH_CODE: &str = "math_code";
|
|
89
|
+
const EXTENSION_WIKILINKS_TITLE_AFTER_PIPE: &str = "wikilinks_title_after_pipe";
|
|
90
|
+
const EXTENSION_WIKILINKS_TITLE_BEFORE_PIPE: &str = "wikilinks_title_before_pipe";
|
|
89
91
|
|
|
90
92
|
fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
|
|
91
93
|
options_hash
|
|
@@ -138,6 +140,14 @@ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: R
|
|
|
138
140
|
Ok(Cow::Borrowed(EXTENSION_MATH_CODE)) => {
|
|
139
141
|
comrak_options.extension.math_code = TryConvert::try_convert(value)?;
|
|
140
142
|
}
|
|
143
|
+
Ok(Cow::Borrowed(EXTENSION_WIKILINKS_TITLE_AFTER_PIPE)) => {
|
|
144
|
+
comrak_options.extension.wikilinks_title_after_pipe =
|
|
145
|
+
TryConvert::try_convert(value)?;
|
|
146
|
+
}
|
|
147
|
+
Ok(Cow::Borrowed(EXTENSION_WIKILINKS_TITLE_BEFORE_PIPE)) => {
|
|
148
|
+
comrak_options.extension.wikilinks_title_before_pipe =
|
|
149
|
+
TryConvert::try_convert(value)?;
|
|
150
|
+
}
|
|
141
151
|
_ => {}
|
|
142
152
|
}
|
|
143
153
|
Ok(ForEach::Continue)
|
|
@@ -1,14 +1,106 @@
|
|
|
1
1
|
use std::path::PathBuf;
|
|
2
2
|
|
|
3
|
+
use comrak::plugins::syntect::{SyntectAdapter, SyntectAdapterBuilder};
|
|
4
|
+
|
|
3
5
|
use magnus::value::ReprValue;
|
|
4
|
-
use magnus::{RHash, Symbol, TryConvert, Value};
|
|
6
|
+
use magnus::{exception, RHash, Symbol, TryConvert, Value};
|
|
7
|
+
use syntect::highlighting::ThemeSet;
|
|
5
8
|
|
|
6
9
|
use crate::EMPTY_STR;
|
|
7
10
|
|
|
8
|
-
pub
|
|
9
|
-
|
|
11
|
+
pub fn construct_syntax_highlighter_from_plugin(
|
|
12
|
+
rb_plugins: Option<RHash>,
|
|
13
|
+
) -> Result<Option<SyntectAdapter>, magnus::Error> {
|
|
14
|
+
match rb_plugins {
|
|
15
|
+
None => Ok(None),
|
|
16
|
+
Some(rb_plugins) => {
|
|
17
|
+
let theme = match rb_plugins.get(Symbol::new(super::SYNTAX_HIGHLIGHTER_PLUGIN)) {
|
|
18
|
+
Some(syntax_highlighter_options) => {
|
|
19
|
+
match fetch_syntax_highlighter_theme(syntax_highlighter_options) {
|
|
20
|
+
Ok(theme) => theme,
|
|
21
|
+
Err(e) => {
|
|
22
|
+
return Err(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
None => None, // no `syntax_highlighter:` defined
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let adapter: SyntectAdapter;
|
|
30
|
+
|
|
31
|
+
match theme {
|
|
32
|
+
None => Ok(None),
|
|
33
|
+
Some(theme) => {
|
|
34
|
+
if theme.is_empty() {
|
|
35
|
+
// no theme? uss css classes
|
|
36
|
+
adapter = SyntectAdapter::new(None);
|
|
37
|
+
Ok(Some(adapter))
|
|
38
|
+
} else {
|
|
39
|
+
let path =
|
|
40
|
+
match rb_plugins.get(Symbol::new(super::SYNTAX_HIGHLIGHTER_PLUGIN)) {
|
|
41
|
+
Some(syntax_highlighter_options) => {
|
|
42
|
+
fetch_syntax_highlighter_path(syntax_highlighter_options)?
|
|
43
|
+
}
|
|
44
|
+
None => PathBuf::from("".to_string()), // no `syntax_highlighter:` defined
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if path.exists() {
|
|
48
|
+
if !path.is_dir() {
|
|
49
|
+
return Err(magnus::Error::new(
|
|
50
|
+
exception::arg_error(),
|
|
51
|
+
"`path` needs to be a directory",
|
|
52
|
+
));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let builder = SyntectAdapterBuilder::new();
|
|
56
|
+
let mut ts = ThemeSet::load_defaults();
|
|
57
|
+
|
|
58
|
+
match ts.add_from_folder(&path) {
|
|
59
|
+
Ok(_) => {}
|
|
60
|
+
Err(e) => {
|
|
61
|
+
return Err(magnus::Error::new(
|
|
62
|
+
exception::arg_error(),
|
|
63
|
+
format!("failed to load theme set from path: {e}"),
|
|
64
|
+
));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// check if the theme exists in the dir
|
|
69
|
+
match ts.themes.get(&theme) {
|
|
70
|
+
Some(theme) => theme,
|
|
71
|
+
None => {
|
|
72
|
+
return Err(magnus::Error::new(
|
|
73
|
+
exception::arg_error(),
|
|
74
|
+
format!("theme `{}` does not exist", theme),
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
adapter = builder.theme_set(ts).theme(&theme).build();
|
|
80
|
+
|
|
81
|
+
Ok(Some(adapter))
|
|
82
|
+
} else {
|
|
83
|
+
// no path? default theme lookup
|
|
84
|
+
ThemeSet::load_defaults()
|
|
85
|
+
.themes
|
|
86
|
+
.get(&theme)
|
|
87
|
+
.ok_or_else(|| {
|
|
88
|
+
magnus::Error::new(
|
|
89
|
+
exception::arg_error(),
|
|
90
|
+
format!("theme `{}` does not exist", theme),
|
|
91
|
+
)
|
|
92
|
+
})?;
|
|
93
|
+
adapter = SyntectAdapter::new(Some(&theme));
|
|
94
|
+
Ok(Some(adapter))
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
10
102
|
|
|
11
|
-
|
|
103
|
+
fn fetch_syntax_highlighter_theme(value: Value) -> Result<Option<String>, magnus::Error> {
|
|
12
104
|
if value.is_nil() {
|
|
13
105
|
// `syntax_highlighter: nil`
|
|
14
106
|
return Ok(None);
|
|
@@ -29,7 +121,7 @@ pub fn fetch_syntax_highlighter_theme(value: Value) -> Result<Option<String>, ma
|
|
|
29
121
|
));
|
|
30
122
|
}
|
|
31
123
|
|
|
32
|
-
let theme_key = Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN_THEME_KEY);
|
|
124
|
+
let theme_key = Symbol::new(super::SYNTAX_HIGHLIGHTER_PLUGIN_THEME_KEY);
|
|
33
125
|
|
|
34
126
|
match syntax_highlighter_plugin.get(theme_key) {
|
|
35
127
|
Some(theme) => {
|
|
@@ -48,14 +140,14 @@ pub fn fetch_syntax_highlighter_theme(value: Value) -> Result<Option<String>, ma
|
|
|
48
140
|
}
|
|
49
141
|
}
|
|
50
142
|
|
|
51
|
-
|
|
143
|
+
fn fetch_syntax_highlighter_path(value: Value) -> Result<PathBuf, magnus::Error> {
|
|
52
144
|
if value.is_nil() {
|
|
53
145
|
// `syntax_highlighter: nil`
|
|
54
146
|
return Ok(PathBuf::from(EMPTY_STR));
|
|
55
147
|
}
|
|
56
148
|
|
|
57
149
|
let syntax_highlighter_plugin: RHash = TryConvert::try_convert(value)?;
|
|
58
|
-
let path_key = Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN_PATH_KEY);
|
|
150
|
+
let path_key = Symbol::new(super::SYNTAX_HIGHLIGHTER_PLUGIN_PATH_KEY);
|
|
59
151
|
|
|
60
152
|
match syntax_highlighter_plugin.get(path_key) {
|
|
61
153
|
Some(path) => {
|
data/lib/commonmarker/config.rb
CHANGED
data/lib/commonmarker/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: commonmarker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Garen Torikian
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2024-
|
|
12
|
+
date: 2024-06-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rb_sys
|