Skip to content

Commit 2dab167

Browse files
committed
merge
2 parents 6967680 + ab92d47 commit 2dab167

File tree

8 files changed

+33558
-32326
lines changed

8 files changed

+33558
-32326
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| a | b |
2+
|---|---|
3+
| $|$ | math |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| Test | Description |
2+
|------|-------------|
3+
| `|` | backtick code with pipe |
4+
| $|$ | latex span with pipe |
5+
| `a|b` | more code |
6+
| $x|y$ | more math |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| Column 1 | Column 2 | Column 3 |
2+
|----------|----------|----------|
3+
| $|$ | normal text | $a|b$ |
4+
| regular | $||$ | more text |
5+
| $x | y$ | text | $|>$ |

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,17 @@ module.exports = grammar({
475475
$._code_span_close,
476476
),
477477

478+
// Latex span within pipe table cells - simplified version that only handles dollar signs
479+
_pipe_table_latex_span: $ => seq(
480+
$._latex_span_start,
481+
repeat(choice(
482+
$._word,
483+
$._whitespace,
484+
common.punctuation_without($, []),
485+
)),
486+
$._latex_span_close,
487+
),
488+
478489
_pipe_table_cell_contents: $ => prec.right(
479490
seq(
480491
choice(
@@ -483,6 +494,7 @@ module.exports = grammar({
483494
$._inline_math_state_track_marker,
484495
$._backslash_escape,
485496
$._pipe_table_code_span,
497+
$._pipe_table_latex_span,
486498
common.punctuation_without($, ['|']),
487499
),
488500
repeat(choice(
@@ -492,6 +504,7 @@ module.exports = grammar({
492504
$._whitespace,
493505
$._backslash_escape,
494506
$._pipe_table_code_span,
507+
$._pipe_table_latex_span,
495508
common.punctuation_without($, ['|']),
496509
)))),
497510

@@ -598,6 +611,10 @@ module.exports = grammar({
598611
// code span delimiters for parsing pipe table cells
599612
$._code_span_start,
600613
$._code_span_close,
614+
615+
// latex span delimiters for parsing pipe table cells
616+
$._latex_span_start,
617+
$._latex_span_close,
601618
],
602619
precedences: $ => [
603620
[$._setext_heading1, $._block],

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

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5600,6 +5600,185 @@
56005600
}
56015601
]
56025602
},
5603+
"_pipe_table_latex_span": {
5604+
"type": "SEQ",
5605+
"members": [
5606+
{
5607+
"type": "SYMBOL",
5608+
"name": "_latex_span_start"
5609+
},
5610+
{
5611+
"type": "REPEAT",
5612+
"content": {
5613+
"type": "CHOICE",
5614+
"members": [
5615+
{
5616+
"type": "SYMBOL",
5617+
"name": "_word"
5618+
},
5619+
{
5620+
"type": "SYMBOL",
5621+
"name": "_whitespace"
5622+
},
5623+
{
5624+
"type": "SEQ",
5625+
"members": [
5626+
{
5627+
"type": "CHOICE",
5628+
"members": [
5629+
{
5630+
"type": "STRING",
5631+
"value": "!"
5632+
},
5633+
{
5634+
"type": "STRING",
5635+
"value": "\""
5636+
},
5637+
{
5638+
"type": "STRING",
5639+
"value": "#"
5640+
},
5641+
{
5642+
"type": "STRING",
5643+
"value": "$"
5644+
},
5645+
{
5646+
"type": "STRING",
5647+
"value": "%"
5648+
},
5649+
{
5650+
"type": "STRING",
5651+
"value": "&"
5652+
},
5653+
{
5654+
"type": "STRING",
5655+
"value": "'"
5656+
},
5657+
{
5658+
"type": "STRING",
5659+
"value": "("
5660+
},
5661+
{
5662+
"type": "STRING",
5663+
"value": ")"
5664+
},
5665+
{
5666+
"type": "STRING",
5667+
"value": "*"
5668+
},
5669+
{
5670+
"type": "STRING",
5671+
"value": "+"
5672+
},
5673+
{
5674+
"type": "STRING",
5675+
"value": ","
5676+
},
5677+
{
5678+
"type": "STRING",
5679+
"value": "-"
5680+
},
5681+
{
5682+
"type": "STRING",
5683+
"value": "."
5684+
},
5685+
{
5686+
"type": "STRING",
5687+
"value": "/"
5688+
},
5689+
{
5690+
"type": "STRING",
5691+
"value": ":"
5692+
},
5693+
{
5694+
"type": "STRING",
5695+
"value": ";"
5696+
},
5697+
{
5698+
"type": "STRING",
5699+
"value": "<"
5700+
},
5701+
{
5702+
"type": "STRING",
5703+
"value": "="
5704+
},
5705+
{
5706+
"type": "STRING",
5707+
"value": ">"
5708+
},
5709+
{
5710+
"type": "STRING",
5711+
"value": "?"
5712+
},
5713+
{
5714+
"type": "STRING",
5715+
"value": "@"
5716+
},
5717+
{
5718+
"type": "STRING",
5719+
"value": "["
5720+
},
5721+
{
5722+
"type": "STRING",
5723+
"value": "\\"
5724+
},
5725+
{
5726+
"type": "STRING",
5727+
"value": "]"
5728+
},
5729+
{
5730+
"type": "STRING",
5731+
"value": "^"
5732+
},
5733+
{
5734+
"type": "STRING",
5735+
"value": "_"
5736+
},
5737+
{
5738+
"type": "STRING",
5739+
"value": "`"
5740+
},
5741+
{
5742+
"type": "STRING",
5743+
"value": "{"
5744+
},
5745+
{
5746+
"type": "STRING",
5747+
"value": "|"
5748+
},
5749+
{
5750+
"type": "STRING",
5751+
"value": "}"
5752+
},
5753+
{
5754+
"type": "STRING",
5755+
"value": "~"
5756+
}
5757+
]
5758+
},
5759+
{
5760+
"type": "CHOICE",
5761+
"members": [
5762+
{
5763+
"type": "SYMBOL",
5764+
"name": "_last_token_punctuation"
5765+
},
5766+
{
5767+
"type": "BLANK"
5768+
}
5769+
]
5770+
}
5771+
]
5772+
}
5773+
]
5774+
}
5775+
},
5776+
{
5777+
"type": "SYMBOL",
5778+
"name": "_latex_span_close"
5779+
}
5780+
]
5781+
},
56035782
"_pipe_table_cell_contents": {
56045783
"type": "PREC_RIGHT",
56055784
"value": 0,
@@ -5629,6 +5808,10 @@
56295808
"type": "SYMBOL",
56305809
"name": "_pipe_table_code_span"
56315810
},
5811+
{
5812+
"type": "SYMBOL",
5813+
"name": "_pipe_table_latex_span"
5814+
},
56325815
{
56335816
"type": "SEQ",
56345817
"members": [
@@ -5806,6 +5989,10 @@
58065989
"type": "SYMBOL",
58075990
"name": "_pipe_table_code_span"
58085991
},
5992+
{
5993+
"type": "SYMBOL",
5994+
"name": "_pipe_table_latex_span"
5995+
},
58095996
{
58105997
"type": "SEQ",
58115998
"members": [
@@ -6198,6 +6385,14 @@
61986385
{
61996386
"type": "SYMBOL",
62006387
"name": "_code_span_close"
6388+
},
6389+
{
6390+
"type": "SYMBOL",
6391+
"name": "_latex_span_start"
6392+
},
6393+
{
6394+
"type": "SYMBOL",
6395+
"name": "_latex_span_close"
62016396
}
62026397
],
62036398
"inline": [],

0 commit comments

Comments
 (0)