kramdown-syntax_tree_sitter 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f502118720a3beff9d1b8fe65e9fa4ca4d1b61a5e1173c5e761ae833f788ffa
|
4
|
+
data.tar.gz: 7eda0db649bfdf5bef38257dd50b9b58f914832b5134db10f9c815b7c3317c5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2601a86a81fd2e96831d18dbaf970199b6649e1402a269b058b09726a02a33398e9ce1a035a5d3607bdbb12f997a599c5899188e01d258fa5bd8abe1460ad341
|
7
|
+
data.tar.gz: 83323e231e5ced95442e3629c5f179e227200dff6216c9c498d8e5c96a3fce0975acb07ee0783e916224123f66579da56500921261161484bcfad997252527a4
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Kramdown Tree-sitter Highlighter
|
2
2
|
|
3
|
-
[![Build status](https://img.shields.io/github/workflow/status/andrewtbiehl/kramdown-syntax_tree_sitter/
|
3
|
+
[![Build status](https://img.shields.io/github/actions/workflow/status/andrewtbiehl/kramdown-syntax_tree_sitter/quality-control.yml?branch=main&style=flat-square&logo=github)](https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter/actions/workflows/quality-control.yml)
|
4
4
|
[![RubyGems page](https://img.shields.io/gem/v/kramdown-syntax_tree_sitter?style=flat-square&color=blue&logo=rubygems&logoColor=white)](https://rubygems.org/gems/kramdown-syntax_tree_sitter)
|
5
5
|
|
6
6
|
***Syntax highlight code with [Tree-sitter](https://tree-sitter.github.io/tree-sitter)
|
@@ -22,8 +22,8 @@ essentially an adapter for the
|
|
22
22
|
hence also requires a compatible [Rust](https://www.rust-lang.org) installation to
|
23
23
|
function. It is officially compatible with the following environments:
|
24
24
|
|
25
|
-
- **Ruby**: 2.7, 3.0, 3.1
|
26
|
-
- **Rust**: 1.
|
25
|
+
- **Ruby**: 2.7, 3.0, 3.1, 3.2
|
26
|
+
- **Rust**: 1.65, 1.66, 1.67, 1.68
|
27
27
|
- **Platforms**: MacOS, Linux
|
28
28
|
|
29
29
|
### Installation
|
@@ -56,7 +56,7 @@ require 'kramdown'
|
|
56
56
|
require 'kramdown/syntax_tree_sitter'
|
57
57
|
|
58
58
|
text = <<~MARKDOWN
|
59
|
-
~~~
|
59
|
+
~~~python
|
60
60
|
print('Hello, World!')
|
61
61
|
~~~
|
62
62
|
MARKDOWN
|
@@ -64,6 +64,13 @@ MARKDOWN
|
|
64
64
|
Kramdown::Document.new(text, syntax_highlighter: :'tree-sitter').to_html
|
65
65
|
```
|
66
66
|
|
67
|
+
### General usage
|
68
|
+
|
69
|
+
To successfully highlight input text via Kramdown with this plugin enabled, make sure
|
70
|
+
that every language referenced has a corresponding Tree-sitter parser library installed.
|
71
|
+
See the subsequent ['Language identifiers'](#language-identifiers) and
|
72
|
+
['Tree-sitter parsers'](#tree-sitter-parsers) sections for more information.
|
73
|
+
|
67
74
|
### Usage with Jekyll
|
68
75
|
|
69
76
|
This plugin can be used with the popular static site generator
|
@@ -82,11 +89,9 @@ kramdown:
|
|
82
89
|
# Other Kramdown options...
|
83
90
|
```
|
84
91
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
subsequent ['Language identifiers'](#language-identifiers) and
|
89
|
-
['Tree-sitter parsers'](#tree-sitter-parsers) sections for more information.
|
92
|
+
Note that this plugin's general usage prerequisites (described in the previous
|
93
|
+
['General usage'](#general-usage) section) still apply when using this plugin with
|
94
|
+
Jekyll.
|
90
95
|
|
91
96
|
Also, there are multiple ways to render highlighted code blocks with Jekyll, as
|
92
97
|
illustrated in the following table:
|
@@ -103,13 +108,13 @@ illustrated in the following table:
|
|
103
108
|
|
104
109
|
---
|
105
110
|
````
|
106
|
-
```
|
111
|
+
```python
|
107
112
|
print('Hello, World!')
|
108
113
|
```
|
109
114
|
|
110
115
|
or
|
111
116
|
|
112
|
-
~~~
|
117
|
+
~~~python
|
113
118
|
print('Hello, World!')
|
114
119
|
~~~
|
115
120
|
````
|
@@ -125,7 +130,7 @@ print('Hello, World!')
|
|
125
130
|
---
|
126
131
|
```
|
127
132
|
print('Hello, World!')
|
128
|
-
{: class="language-
|
133
|
+
{: class="language-python" }
|
129
134
|
```
|
130
135
|
---
|
131
136
|
|
@@ -138,7 +143,7 @@ print('Hello, World!')
|
|
138
143
|
|
139
144
|
---
|
140
145
|
```
|
141
|
-
{% highlight
|
146
|
+
{% highlight python %}
|
142
147
|
print('Hello, World!')
|
143
148
|
{% endhighlight %}
|
144
149
|
```
|
@@ -171,12 +176,18 @@ can be found on
|
|
171
176
|
|
172
177
|
### Language identifiers
|
173
178
|
|
174
|
-
|
175
|
-
|
176
|
-
'
|
177
|
-
|
178
|
-
|
179
|
-
|
179
|
+
For most popular languages, this plugin recognizes the same language identifiers as used
|
180
|
+
by the popular highlighter [Rouge](https://github.com/rouge-ruby/rouge). For example,
|
181
|
+
both 'python' and 'py' may be used to identify a code block written in Python. For the
|
182
|
+
complete list of Rouge language identifiers recognized by this plugin, see
|
183
|
+
[`lib/kramdown/syntax_tree_sitter/languages.rb`](https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter/blob/main/lib/kramdown/syntax_tree_sitter/languages.rb).
|
184
|
+
|
185
|
+
This plugin also automatically supports the language identifier format used by
|
186
|
+
Tree-sitter, known as as the 'scope' name. For example, the scope name for Python is
|
187
|
+
'source.python', whereas for HTML it is 'text.html.basic'.
|
188
|
+
|
189
|
+
For any identifiers currently supported by Rouge but not by this plugin, feel free to
|
190
|
+
open an issue or pull request on GitHub to have them included.
|
180
191
|
|
181
192
|
### CSS styling
|
182
193
|
|
@@ -11,15 +11,6 @@ dependencies = [
|
|
11
11
|
"memchr",
|
12
12
|
]
|
13
13
|
|
14
|
-
[[package]]
|
15
|
-
name = "android_system_properties"
|
16
|
-
version = "0.1.5"
|
17
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
-
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
19
|
-
dependencies = [
|
20
|
-
"libc",
|
21
|
-
]
|
22
|
-
|
23
14
|
[[package]]
|
24
15
|
name = "ansi_term"
|
25
16
|
version = "0.12.1"
|
@@ -31,9 +22,9 @@ dependencies = [
|
|
31
22
|
|
32
23
|
[[package]]
|
33
24
|
name = "anyhow"
|
34
|
-
version = "1.0.
|
25
|
+
version = "1.0.70"
|
35
26
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
36
|
-
checksum = "
|
27
|
+
checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4"
|
37
28
|
|
38
29
|
[[package]]
|
39
30
|
name = "ascii"
|
@@ -70,6 +61,12 @@ version = "3.11.1"
|
|
70
61
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
71
62
|
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
72
63
|
|
64
|
+
[[package]]
|
65
|
+
name = "bytes"
|
66
|
+
version = "1.4.0"
|
67
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
68
|
+
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
69
|
+
|
73
70
|
[[package]]
|
74
71
|
name = "cc"
|
75
72
|
version = "1.0.74"
|
@@ -77,22 +74,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
77
74
|
checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574"
|
78
75
|
|
79
76
|
[[package]]
|
80
|
-
name = "
|
81
|
-
version = "1.
|
77
|
+
name = "cesu8"
|
78
|
+
version = "1.1.0"
|
82
79
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
83
|
-
checksum = "
|
80
|
+
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
|
84
81
|
|
85
82
|
[[package]]
|
86
|
-
name = "
|
87
|
-
version = "0.
|
83
|
+
name = "cfg-if"
|
84
|
+
version = "1.0.0"
|
88
85
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
89
|
-
checksum = "
|
90
|
-
dependencies = [
|
91
|
-
"iana-time-zone",
|
92
|
-
"num-integer",
|
93
|
-
"num-traits",
|
94
|
-
"winapi",
|
95
|
-
]
|
86
|
+
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
96
87
|
|
97
88
|
[[package]]
|
98
89
|
name = "chunked_transfer"
|
@@ -116,64 +107,30 @@ dependencies = [
|
|
116
107
|
]
|
117
108
|
|
118
109
|
[[package]]
|
119
|
-
name = "
|
120
|
-
version = "
|
110
|
+
name = "combine"
|
111
|
+
version = "4.6.6"
|
121
112
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
122
|
-
checksum = "
|
113
|
+
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
|
123
114
|
dependencies = [
|
124
|
-
"
|
125
|
-
"
|
126
|
-
]
|
127
|
-
|
128
|
-
[[package]]
|
129
|
-
name = "core-foundation-sys"
|
130
|
-
version = "0.8.3"
|
131
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
132
|
-
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
133
|
-
|
134
|
-
[[package]]
|
135
|
-
name = "cxx"
|
136
|
-
version = "1.0.81"
|
137
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
138
|
-
checksum = "97abf9f0eca9e52b7f81b945524e76710e6cb2366aead23b7d4fbf72e281f888"
|
139
|
-
dependencies = [
|
140
|
-
"cc",
|
141
|
-
"cxxbridge-flags",
|
142
|
-
"cxxbridge-macro",
|
143
|
-
"link-cplusplus",
|
115
|
+
"bytes",
|
116
|
+
"memchr",
|
144
117
|
]
|
145
118
|
|
146
119
|
[[package]]
|
147
|
-
name = "
|
148
|
-
version = "
|
120
|
+
name = "core-foundation"
|
121
|
+
version = "0.9.3"
|
149
122
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
150
|
-
checksum = "
|
123
|
+
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
|
151
124
|
dependencies = [
|
152
|
-
"
|
153
|
-
"
|
154
|
-
"once_cell",
|
155
|
-
"proc-macro2",
|
156
|
-
"quote",
|
157
|
-
"scratch",
|
158
|
-
"syn",
|
125
|
+
"core-foundation-sys",
|
126
|
+
"libc",
|
159
127
|
]
|
160
128
|
|
161
129
|
[[package]]
|
162
|
-
name = "
|
163
|
-
version = "
|
164
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
165
|
-
checksum = "8ca220e4794c934dc6b1207c3b42856ad4c302f2df1712e9f8d2eec5afaacf1f"
|
166
|
-
|
167
|
-
[[package]]
|
168
|
-
name = "cxxbridge-macro"
|
169
|
-
version = "1.0.81"
|
130
|
+
name = "core-foundation-sys"
|
131
|
+
version = "0.8.3"
|
170
132
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
171
|
-
checksum = "
|
172
|
-
dependencies = [
|
173
|
-
"proc-macro2",
|
174
|
-
"quote",
|
175
|
-
"syn",
|
176
|
-
]
|
133
|
+
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
177
134
|
|
178
135
|
[[package]]
|
179
136
|
name = "difference"
|
@@ -190,6 +147,15 @@ dependencies = [
|
|
190
147
|
"dirs-sys",
|
191
148
|
]
|
192
149
|
|
150
|
+
[[package]]
|
151
|
+
name = "dirs"
|
152
|
+
version = "4.0.0"
|
153
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
154
|
+
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
155
|
+
dependencies = [
|
156
|
+
"dirs-sys",
|
157
|
+
]
|
158
|
+
|
193
159
|
[[package]]
|
194
160
|
name = "dirs-sys"
|
195
161
|
version = "0.3.7"
|
@@ -258,28 +224,10 @@ dependencies = [
|
|
258
224
|
]
|
259
225
|
|
260
226
|
[[package]]
|
261
|
-
name = "
|
262
|
-
version = "0.
|
263
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
264
|
-
checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765"
|
265
|
-
dependencies = [
|
266
|
-
"android_system_properties",
|
267
|
-
"core-foundation-sys",
|
268
|
-
"iana-time-zone-haiku",
|
269
|
-
"js-sys",
|
270
|
-
"wasm-bindgen",
|
271
|
-
"winapi",
|
272
|
-
]
|
273
|
-
|
274
|
-
[[package]]
|
275
|
-
name = "iana-time-zone-haiku"
|
276
|
-
version = "0.1.1"
|
227
|
+
name = "httpdate"
|
228
|
+
version = "1.0.2"
|
277
229
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
278
|
-
checksum = "
|
279
|
-
dependencies = [
|
280
|
-
"cxx",
|
281
|
-
"cxx-build",
|
282
|
-
]
|
230
|
+
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
283
231
|
|
284
232
|
[[package]]
|
285
233
|
name = "idna"
|
@@ -307,6 +255,28 @@ version = "1.0.4"
|
|
307
255
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
308
256
|
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
|
309
257
|
|
258
|
+
[[package]]
|
259
|
+
name = "jni"
|
260
|
+
version = "0.21.1"
|
261
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
262
|
+
checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
|
263
|
+
dependencies = [
|
264
|
+
"cesu8",
|
265
|
+
"cfg-if",
|
266
|
+
"combine",
|
267
|
+
"jni-sys",
|
268
|
+
"log",
|
269
|
+
"thiserror",
|
270
|
+
"walkdir",
|
271
|
+
"windows-sys",
|
272
|
+
]
|
273
|
+
|
274
|
+
[[package]]
|
275
|
+
name = "jni-sys"
|
276
|
+
version = "0.3.0"
|
277
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
278
|
+
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
279
|
+
|
310
280
|
[[package]]
|
311
281
|
name = "js-sys"
|
312
282
|
version = "0.3.60"
|
@@ -339,21 +309,21 @@ dependencies = [
|
|
339
309
|
]
|
340
310
|
|
341
311
|
[[package]]
|
342
|
-
name = "
|
343
|
-
version = "
|
312
|
+
name = "log"
|
313
|
+
version = "0.4.17"
|
344
314
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
345
|
-
checksum = "
|
315
|
+
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
346
316
|
dependencies = [
|
347
|
-
"
|
317
|
+
"cfg-if",
|
348
318
|
]
|
349
319
|
|
350
320
|
[[package]]
|
351
|
-
name = "
|
352
|
-
version = "0.
|
321
|
+
name = "malloc_buf"
|
322
|
+
version = "0.0.6"
|
353
323
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
354
|
-
checksum = "
|
324
|
+
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
355
325
|
dependencies = [
|
356
|
-
"
|
326
|
+
"libc",
|
357
327
|
]
|
358
328
|
|
359
329
|
[[package]]
|
@@ -363,22 +333,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
363
333
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
364
334
|
|
365
335
|
[[package]]
|
366
|
-
name = "
|
367
|
-
version = "0.1.
|
336
|
+
name = "ndk-context"
|
337
|
+
version = "0.1.1"
|
368
338
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
369
|
-
checksum = "
|
370
|
-
dependencies = [
|
371
|
-
"autocfg",
|
372
|
-
"num-traits",
|
373
|
-
]
|
339
|
+
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
|
374
340
|
|
375
341
|
[[package]]
|
376
|
-
name = "
|
377
|
-
version = "0.2.
|
342
|
+
name = "objc"
|
343
|
+
version = "0.2.7"
|
378
344
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
379
|
-
checksum = "
|
345
|
+
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
|
380
346
|
dependencies = [
|
381
|
-
"
|
347
|
+
"malloc_buf",
|
382
348
|
]
|
383
349
|
|
384
350
|
[[package]]
|
@@ -411,6 +377,12 @@ dependencies = [
|
|
411
377
|
"proc-macro2",
|
412
378
|
]
|
413
379
|
|
380
|
+
[[package]]
|
381
|
+
name = "raw-window-handle"
|
382
|
+
version = "0.5.2"
|
383
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
384
|
+
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
385
|
+
|
414
386
|
[[package]]
|
415
387
|
name = "redox_syscall"
|
416
388
|
version = "0.2.16"
|
@@ -479,12 +451,6 @@ dependencies = [
|
|
479
451
|
"winapi-util",
|
480
452
|
]
|
481
453
|
|
482
|
-
[[package]]
|
483
|
-
name = "scratch"
|
484
|
-
version = "1.0.2"
|
485
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
486
|
-
checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
|
487
|
-
|
488
454
|
[[package]]
|
489
455
|
name = "semver"
|
490
456
|
version = "1.0.14"
|
@@ -546,15 +512,6 @@ dependencies = [
|
|
546
512
|
"unicode-ident",
|
547
513
|
]
|
548
514
|
|
549
|
-
[[package]]
|
550
|
-
name = "termcolor"
|
551
|
-
version = "1.1.3"
|
552
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
553
|
-
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
554
|
-
dependencies = [
|
555
|
-
"winapi-util",
|
556
|
-
]
|
557
|
-
|
558
515
|
[[package]]
|
559
516
|
name = "textwrap"
|
560
517
|
version = "0.11.0"
|
@@ -586,15 +543,14 @@ dependencies = [
|
|
586
543
|
|
587
544
|
[[package]]
|
588
545
|
name = "tiny_http"
|
589
|
-
version = "0.
|
546
|
+
version = "0.12.0"
|
590
547
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
591
|
-
checksum = "
|
548
|
+
checksum = "389915df6413a2e74fb181895f933386023c71110878cd0825588928e64cdc82"
|
592
549
|
dependencies = [
|
593
550
|
"ascii",
|
594
|
-
"chrono",
|
595
551
|
"chunked_transfer",
|
552
|
+
"httpdate",
|
596
553
|
"log",
|
597
|
-
"url",
|
598
554
|
]
|
599
555
|
|
600
556
|
[[package]]
|
@@ -623,9 +579,9 @@ dependencies = [
|
|
623
579
|
|
624
580
|
[[package]]
|
625
581
|
name = "tree-sitter"
|
626
|
-
version = "0.20.
|
582
|
+
version = "0.20.10"
|
627
583
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
628
|
-
checksum = "
|
584
|
+
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
|
629
585
|
dependencies = [
|
630
586
|
"cc",
|
631
587
|
"regex",
|
@@ -633,16 +589,16 @@ dependencies = [
|
|
633
589
|
|
634
590
|
[[package]]
|
635
591
|
name = "tree-sitter-cli"
|
636
|
-
version = "0.20.
|
592
|
+
version = "0.20.8"
|
637
593
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
638
|
-
checksum = "
|
594
|
+
checksum = "ae7e9d844d4d38e511a7b93fe8ced79f2a364c32fdea10d04546f1c8317d5a0c"
|
639
595
|
dependencies = [
|
640
596
|
"ansi_term",
|
641
597
|
"anyhow",
|
642
598
|
"atty",
|
643
599
|
"clap",
|
644
600
|
"difference",
|
645
|
-
"dirs",
|
601
|
+
"dirs 3.0.2",
|
646
602
|
"glob",
|
647
603
|
"html-escape",
|
648
604
|
"indexmap",
|
@@ -674,7 +630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
674
630
|
checksum = "f5fec4cb27f052ead2246631b332dba0cb6af9a54ce012badee59c4b0ded5e03"
|
675
631
|
dependencies = [
|
676
632
|
"anyhow",
|
677
|
-
"dirs",
|
633
|
+
"dirs 3.0.2",
|
678
634
|
"serde",
|
679
635
|
"serde_json",
|
680
636
|
]
|
@@ -698,7 +654,7 @@ checksum = "d0b17eef4833c7c139abed66d562dfa23228e97e647597baf246fd56c21bbfaf"
|
|
698
654
|
dependencies = [
|
699
655
|
"anyhow",
|
700
656
|
"cc",
|
701
|
-
"dirs",
|
657
|
+
"dirs 3.0.2",
|
702
658
|
"libloading",
|
703
659
|
"once_cell",
|
704
660
|
"regex",
|
@@ -866,13 +822,19 @@ dependencies = [
|
|
866
822
|
|
867
823
|
[[package]]
|
868
824
|
name = "webbrowser"
|
869
|
-
version = "0.
|
825
|
+
version = "0.8.9"
|
870
826
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
871
|
-
checksum = "
|
827
|
+
checksum = "b692165700260bbd40fbc5ff23766c03e339fbaca907aeea5cb77bf0a553ca83"
|
872
828
|
dependencies = [
|
829
|
+
"core-foundation",
|
830
|
+
"dirs 4.0.0",
|
831
|
+
"jni",
|
832
|
+
"log",
|
833
|
+
"ndk-context",
|
834
|
+
"objc",
|
835
|
+
"raw-window-handle",
|
836
|
+
"url",
|
873
837
|
"web-sys",
|
874
|
-
"widestring",
|
875
|
-
"winapi",
|
876
838
|
]
|
877
839
|
|
878
840
|
[[package]]
|
@@ -886,12 +848,6 @@ dependencies = [
|
|
886
848
|
"once_cell",
|
887
849
|
]
|
888
850
|
|
889
|
-
[[package]]
|
890
|
-
name = "widestring"
|
891
|
-
version = "0.4.3"
|
892
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
893
|
-
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
|
894
|
-
|
895
851
|
[[package]]
|
896
852
|
name = "winapi"
|
897
853
|
version = "0.3.9"
|
@@ -922,3 +878,69 @@ name = "winapi-x86_64-pc-windows-gnu"
|
|
922
878
|
version = "0.4.0"
|
923
879
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
924
880
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
881
|
+
|
882
|
+
[[package]]
|
883
|
+
name = "windows-sys"
|
884
|
+
version = "0.45.0"
|
885
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
886
|
+
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
887
|
+
dependencies = [
|
888
|
+
"windows-targets",
|
889
|
+
]
|
890
|
+
|
891
|
+
[[package]]
|
892
|
+
name = "windows-targets"
|
893
|
+
version = "0.42.2"
|
894
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
895
|
+
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
|
896
|
+
dependencies = [
|
897
|
+
"windows_aarch64_gnullvm",
|
898
|
+
"windows_aarch64_msvc",
|
899
|
+
"windows_i686_gnu",
|
900
|
+
"windows_i686_msvc",
|
901
|
+
"windows_x86_64_gnu",
|
902
|
+
"windows_x86_64_gnullvm",
|
903
|
+
"windows_x86_64_msvc",
|
904
|
+
]
|
905
|
+
|
906
|
+
[[package]]
|
907
|
+
name = "windows_aarch64_gnullvm"
|
908
|
+
version = "0.42.2"
|
909
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
910
|
+
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
|
911
|
+
|
912
|
+
[[package]]
|
913
|
+
name = "windows_aarch64_msvc"
|
914
|
+
version = "0.42.2"
|
915
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
916
|
+
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
|
917
|
+
|
918
|
+
[[package]]
|
919
|
+
name = "windows_i686_gnu"
|
920
|
+
version = "0.42.2"
|
921
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
922
|
+
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
|
923
|
+
|
924
|
+
[[package]]
|
925
|
+
name = "windows_i686_msvc"
|
926
|
+
version = "0.42.2"
|
927
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
928
|
+
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
|
929
|
+
|
930
|
+
[[package]]
|
931
|
+
name = "windows_x86_64_gnu"
|
932
|
+
version = "0.42.2"
|
933
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
934
|
+
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
|
935
|
+
|
936
|
+
[[package]]
|
937
|
+
name = "windows_x86_64_gnullvm"
|
938
|
+
version = "0.42.2"
|
939
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
940
|
+
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
|
941
|
+
|
942
|
+
[[package]]
|
943
|
+
name = "windows_x86_64_msvc"
|
944
|
+
version = "0.42.2"
|
945
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
946
|
+
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'kramdown'
|
4
4
|
require 'tree_sitter_adapter'
|
5
5
|
|
6
|
+
require_relative '../../syntax_tree_sitter/languages'
|
7
|
+
|
6
8
|
module Kramdown
|
7
9
|
module Converter # rubocop:disable Style/Documentation
|
8
10
|
module SyntaxHighlighter
|
@@ -13,13 +15,14 @@ module Kramdown
|
|
13
15
|
module TreeSitter
|
14
16
|
DEFAULT_PARSERS_DIR = '~/tree_sitter_parsers'
|
15
17
|
|
16
|
-
def self.call(converter, raw_text,
|
17
|
-
return nil unless
|
18
|
+
def self.call(converter, raw_text, language_alias, type, _)
|
19
|
+
return nil unless language_alias
|
18
20
|
|
21
|
+
language_scope = LANGUAGE_SCOPES.fetch(language_alias, language_alias)
|
19
22
|
rendered_text = TreeSitterAdapter.highlight(
|
20
23
|
raw_text,
|
21
24
|
get_parsers_dir(converter),
|
22
|
-
|
25
|
+
language_scope,
|
23
26
|
get_use_css_classes(converter)
|
24
27
|
)
|
25
28
|
# Code blocks are additionally wrapped in HTML code tags
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kramdown
|
4
|
+
module Converter
|
5
|
+
module SyntaxHighlighter
|
6
|
+
module TreeSitter
|
7
|
+
# Maps each recognized language alias to its corresponding Tree-sitter scope
|
8
|
+
LANGUAGE_SCOPES =
|
9
|
+
{
|
10
|
+
'source.R' => %w[R S r s],
|
11
|
+
'source.bash' => %w[bash ksh sh shell zsh],
|
12
|
+
'source.c' => %w[c],
|
13
|
+
'source.cpp' => %w[c++ cpp],
|
14
|
+
'source.cs' => %w[c# cs csharp],
|
15
|
+
'source.css' => %w[css],
|
16
|
+
'source.d' => %w[d dlang],
|
17
|
+
'source.dot' => %w[dot],
|
18
|
+
'source.elixir' => %w[elixir exs],
|
19
|
+
'source.elm' => %w[elm],
|
20
|
+
'source.emacs.lisp' => %w[elisp emacs-lisp],
|
21
|
+
'source.go' => %w[go golang],
|
22
|
+
'source.hack' => %w[hack hh],
|
23
|
+
'source.haskell' => %w[haskell hs],
|
24
|
+
'source.hcl' => %w[hcl],
|
25
|
+
'source.java' => %w[java],
|
26
|
+
'source.js' => %w[javascript js],
|
27
|
+
'source.json' => %w[json],
|
28
|
+
'source.julia' => %w[jl julia],
|
29
|
+
'source.lua' => %w[lua],
|
30
|
+
'source.mk' => %w[bsdmake gnumake make makefile mf],
|
31
|
+
'source.nix' => %w[nix nixos],
|
32
|
+
'source.objc' => %w[obj-c obj_c objc objective_c objectivec],
|
33
|
+
'source.ocaml' => %w[ocaml],
|
34
|
+
'source.perl' => %w[perl pl],
|
35
|
+
'source.php' => %w[php php3 php4 php5],
|
36
|
+
'source.proto' => %w[proto protobuf],
|
37
|
+
'source.python' => %w[py python],
|
38
|
+
'source.racket' => %w[racket],
|
39
|
+
'source.ruby' => %w[rb ruby],
|
40
|
+
'source.rust' => %w[rs rust],
|
41
|
+
'source.scala' => %w[scala],
|
42
|
+
'source.sparql' => %w[sparql],
|
43
|
+
'source.sql' => %w[sql],
|
44
|
+
'source.swift' => %w[swift],
|
45
|
+
'source.toml' => %w[toml],
|
46
|
+
'source.ts' => %w[ts typescript],
|
47
|
+
'source.vhd' => %w[vhdl],
|
48
|
+
'text.html.basic' => %w[html],
|
49
|
+
'text.html.erb' => %w[erb eruby rhtml]
|
50
|
+
}
|
51
|
+
.map { |scope, aliases| aliases.map { |alias_| [alias_, scope] } }
|
52
|
+
.flatten(1)
|
53
|
+
.to_h
|
54
|
+
.freeze
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-syntax_tree_sitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew T. Biehl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -56,72 +56,72 @@ dependencies:
|
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 5.18.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 5.18.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rouge
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 4.1.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 4.1.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.50.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.50.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubocop-minitest
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.30.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.30.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop-rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.6.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.6.0
|
125
125
|
description:
|
126
126
|
email:
|
127
127
|
executables: []
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- ext/tree_sitter_adapter/src/tree_sitter_adapter.rs
|
140
140
|
- lib/kramdown/converter/syntax_highlighter/tree_sitter.rb
|
141
141
|
- lib/kramdown/syntax_tree_sitter.rb
|
142
|
+
- lib/kramdown/syntax_tree_sitter/languages.rb
|
142
143
|
- lib/kramdown/syntax_tree_sitter/version.rb
|
143
144
|
- lib/tree_sitter_adapter.rb
|
144
145
|
homepage: https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter
|
@@ -161,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
162
|
- !ruby/object:Gem::Version
|
162
163
|
version: '0'
|
163
164
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
165
|
+
rubygems_version: 3.4.1
|
165
166
|
signing_key:
|
166
167
|
specification_version: 4
|
167
168
|
summary: Syntax highlight code with Tree-sitter via Kramdown.
|