Skip to content

Commit a8b18fe

Browse files
committed
tree-sitter character classes which include dashes must have dashes at the end of class 🤷
1 parent 3272c55 commit a8b18fe

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ module.exports = grammar(add_inline_rules({
216216
alias("}", $.citation_delimiter),
217217
),
218218
seq(alias($._cite_author_in_text, $.citation_delimiter),
219-
alias(new RegExp('[0-9A-Za-z_]+([:.#$%&-+?<>~/][0-9A-Za-z_]+)*'), $.citation_id_author_in_text)
219+
alias(new RegExp('[0-9A-Za-z_]+([:.#$%&+?<>~/-][0-9A-Za-z_]+)*'), $.citation_id_author_in_text)
220220
),
221221
seq(alias($._cite_suppress_author, $.citation_delimiter),
222-
alias(new RegExp('[0-9A-Za-z_]+([:.#$%&-+?<>~/][0-9A-Za-z_]+)*'), $.citation_id_suppress_author)
222+
alias(new RegExp('[0-9A-Za-z_]+([:.#$%&+?<>~/-][0-9A-Za-z_]+)*'), $.citation_id_suppress_author)
223223
),
224224
),
225225

@@ -266,8 +266,8 @@ module.exports = grammar(add_inline_rules({
266266
// - URLs with query parameters have both question marks and equals signs
267267

268268
shortcode_naked_string: $ =>
269-
choice(token(prec(1, /(?:[A-Za-z0-9_\-.~:/?#\]@!$&()+,;]|\[)+/)),
270-
token(prec(1, /(?:[A-Za-z0-9_\-.~:/?#\]@!$&()+,;]|\[)+[?](?:[A-Za-z0-9_\-.~:/?#\]@!$&()+,;?=]|\[)+/))),
269+
choice(token(prec(1, /(?:[A-Za-z0-9_.~:/?#\]@!$&()+,;-]|\[)+/)),
270+
token(prec(1, /(?:[A-Za-z0-9_.~:/?#\]@!$&()+,;-]|\[)+[?](?:[A-Za-z0-9_.~:/?#\]@!$&()+,;?=-]|\[)+/))),
271271

272272
// shortcode_string: $ => new RegExp("[a-zA-Z_][a-zA-Z0-9_-]*"),
273273
shortcode_string: $ => choice(

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,7 +2662,7 @@
26622662
"type": "ALIAS",
26632663
"content": {
26642664
"type": "PATTERN",
2665-
"value": "[0-9A-Za-z_]+([:.#$%&-+?<>~/][0-9A-Za-z_]+)*"
2665+
"value": "[0-9A-Za-z_]+([:.#$%&+?<>~/-][0-9A-Za-z_]+)*"
26662666
},
26672667
"named": true,
26682668
"value": "citation_id_author_in_text"
@@ -2685,7 +2685,7 @@
26852685
"type": "ALIAS",
26862686
"content": {
26872687
"type": "PATTERN",
2688-
"value": "[0-9A-Za-z_]+([:.#$%&-+?<>~/][0-9A-Za-z_]+)*"
2688+
"value": "[0-9A-Za-z_]+([:.#$%&+?<>~/-][0-9A-Za-z_]+)*"
26892689
},
26902690
"named": true,
26912691
"value": "citation_id_suppress_author"
@@ -2878,7 +2878,7 @@
28782878
"value": 1,
28792879
"content": {
28802880
"type": "PATTERN",
2881-
"value": "(?:[A-Za-z0-9_\\-.~:/?#\\]@!$&()+,;]|\\[)+"
2881+
"value": "(?:[A-Za-z0-9_.~:/?#\\]@!$&()+,;-]|\\[)+"
28822882
}
28832883
}
28842884
},
@@ -2889,7 +2889,7 @@
28892889
"value": 1,
28902890
"content": {
28912891
"type": "PATTERN",
2892-
"value": "(?:[A-Za-z0-9_\\-.~:/?#\\]@!$&()+,;]|\\[)+[?](?:[A-Za-z0-9_\\-.~:/?#\\]@!$&()+,;?=]|\\[)+"
2892+
"value": "(?:[A-Za-z0-9_.~:/?#\\]@!$&()+,;-]|\\[)+[?](?:[A-Za-z0-9_.~:/?#\\]@!$&()+,;?=-]|\\[)+"
28932893
}
28942894
}
28952895
}

crates/tree-sitter-qmd/tree-sitter-markdown-inline/src/parser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14213,9 +14213,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
1421314213
END_STATE();
1421414214
case 2260:
1421514215
ACCEPT_TOKEN(aux_sym_citation_token2);
14216-
if (('#' <= lookahead && lookahead <= '+') ||
14217-
lookahead == '.' ||
14218-
lookahead == '/' ||
14216+
if (('#' <= lookahead && lookahead <= '&') ||
14217+
lookahead == '+' ||
14218+
('-' <= lookahead && lookahead <= '/') ||
1421914219
lookahead == ':' ||
1422014220
lookahead == '<' ||
1422114221
lookahead == '>' ||

crates/tree-sitter-qmd/tree-sitter-markdown-inline/test/corpus/syntax.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,14 @@ Mixed nested spans
213213
(text_base)
214214
(emphasis_delimiter))
215215
(soft_line_break))
216+
================================================================================
217+
cites with dashes
218+
================================================================================
219+
see @fig-1
220+
--------------------------------------------------------------------------------
221+
(inline
222+
(text_base)
223+
(text_base)
224+
(citation
225+
(citation_delimiter)
226+
(citation_id_author_in_text)))

0 commit comments

Comments
 (0)