Skip to content

Commit 8154851

Browse files
committed
fix: exclude <> from link_destination
1 parent 5cdc549 commit 8154851

File tree

11 files changed

+62272
-59232
lines changed

11 files changed

+62272
-59232
lines changed

common/common.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,35 @@ module.exports.rules = {
4848
$._soft_line_break
4949
)), ']'),
5050

51-
link_destination: $ => prec.dynamic(PRECEDENCE_LEVEL_LINK, choice(
52-
seq('<', repeat(choice($._text_no_angle, $.backslash_escape, $.entity_reference, $.numeric_character_reference)), '>'),
53-
seq(
54-
choice( // first character is not a '<'
55-
$._word,
56-
punctuation_without($, ['<', '(', ')']),
57-
$.backslash_escape,
58-
$.entity_reference,
59-
$.numeric_character_reference,
60-
$._link_destination_parenthesis
61-
),
62-
repeat(choice(
63-
$._word,
64-
punctuation_without($, ['(', ')']),
51+
link_destination: $ => prec.dynamic(PRECEDENCE_LEVEL_LINK, seq(
52+
choice( // first character is not a '<'
53+
$._word,
54+
punctuation_without($, ['<', '(', ')']),
55+
$.backslash_escape,
56+
$.entity_reference,
57+
$.numeric_character_reference,
58+
$._link_destination_parenthesis
59+
),
60+
repeat(choice(
61+
$._word,
62+
punctuation_without($, ['(', ')']),
63+
$.backslash_escape,
64+
$.entity_reference,
65+
$.numeric_character_reference,
66+
$._link_destination_parenthesis
67+
)),
68+
)),
69+
_link_destination_angle: $ => prec.dynamic(PRECEDENCE_LEVEL_LINK,
70+
seq('<', alias(repeat(
71+
choice(
72+
$._text_no_angle,
6573
$.backslash_escape,
6674
$.entity_reference,
67-
$.numeric_character_reference,
68-
$._link_destination_parenthesis
75+
$.numeric_character_reference
6976
)),
70-
)
71-
)),
77+
$.link_destination
78+
), '>'),
79+
),
7280
_link_destination_parenthesis: $ => seq('(', repeat(choice(
7381
$._word,
7482
punctuation_without($, ['(', ')']),

tree-sitter-markdown-inline/grammar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ module.exports = grammar(add_inline_rules({
163163
optional(seq(
164164
choice(
165165
seq(
166-
$.link_destination,
166+
choice(
167+
$.link_destination,
168+
$._link_destination_angle,
169+
),
167170
optional(seq(
168171
repeat1(choice($._whitespace, $._soft_line_break)),
169172
$.link_title

0 commit comments

Comments
 (0)