Skip to content

Commit 5270353

Browse files
committed
restore shortcode parsing
1 parent d5c4125 commit 5270353

6 files changed

Lines changed: 35989 additions & 34655 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: crates/quarto-markdown-pandoc/tests/test.rs
3+
expression: output
4+
---
5+
[ Para [Span ( "" , ["quarto-shortcode__"] , [("data-is-shortcode", "1")] ) [Span ( "" , ["quarto-shortcode__-param"] , [("data-value", "include"), ("data-is-shortcode", "1"), ("data-raw", "include")] ) [], Span ( "" , ["quarto-shortcode__-param"] , [("data-is-shortcode", "1"), ("data-value", "/docs/prerelease/1.5/_pre-release-feature.qmd"), ("data-raw", "/docs/prerelease/1.5/_pre-release-feature.qmd")] ) []]] ]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{< include /docs/prerelease/1.5/_pre-release-feature.qmd >}}

crates/tree-sitter-qmd/tree-sitter-markdown/grammar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ module.exports = grammar({
397397
optional($.block_continuation)
398398
),
399399
// Some symbols get parsed as single tokens so that html blocks get detected properly
400-
_code_line: $ => prec.right(repeat1(choice($._word, '<', '>', $._display_math_state_track_marker, $._inline_math_state_track_marker, $._whitespace, $._html_comment, common.punctuation_without($, [])))),
400+
_code_line: $ => prec.right(repeat1(choice($._word, '<', '>', '{{<', '}}>', $._display_math_state_track_marker, $._inline_math_state_track_marker, $._whitespace, $._html_comment, common.punctuation_without($, [])))),
401401

402402
// the gymnastics around `:` in _line exist to make the parser reject paragraphs that start with a colon.
403403
// Those are technically valid in Markdown, but disallowing them here makes it possible to detect an
@@ -414,6 +414,7 @@ module.exports = grammar({
414414
$._autolink,
415415
$._escaped_characters,
416416
$._pipe_table_code_span,
417+
'{{<', '>}}', // shortcodes
417418
'[>>', // this needs to be accepted for highlights in editorial comments
418419
),
419420

crates/tree-sitter-qmd/tree-sitter-markdown/src/grammar.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,14 @@
30323032
"type": "STRING",
30333033
"value": ">"
30343034
},
3035+
{
3036+
"type": "STRING",
3037+
"value": "{{<"
3038+
},
3039+
{
3040+
"type": "STRING",
3041+
"value": "}}>"
3042+
},
30353043
{
30363044
"type": "SYMBOL",
30373045
"name": "_display_math_state_track_marker"
@@ -3233,6 +3241,14 @@
32333241
"type": "SYMBOL",
32343242
"name": "_pipe_table_code_span"
32353243
},
3244+
{
3245+
"type": "STRING",
3246+
"value": "{{<"
3247+
},
3248+
{
3249+
"type": "STRING",
3250+
"value": ">}}"
3251+
},
32363252
{
32373253
"type": "STRING",
32383254
"value": "[>>"

crates/tree-sitter-qmd/tree-sitter-markdown/src/node-types.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,10 @@
10341034
"type": ">",
10351035
"named": false
10361036
},
1037+
{
1038+
"type": ">}}",
1039+
"named": false
1040+
},
10371041
{
10381042
"type": "?",
10391043
"named": false
@@ -1166,6 +1170,10 @@
11661170
"type": "{",
11671171
"named": false
11681172
},
1173+
{
1174+
"type": "{{<",
1175+
"named": false
1176+
},
11691177
{
11701178
"type": "{}",
11711179
"named": false
@@ -1178,6 +1186,10 @@
11781186
"type": "}",
11791187
"named": false
11801188
},
1189+
{
1190+
"type": "}}>",
1191+
"named": false
1192+
},
11811193
{
11821194
"type": "~",
11831195
"named": false

0 commit comments

Comments
 (0)