Skip to content

Commit 33afae9

Browse files
committed
fix: taglinks |-x| |==| not recognized
Problem: taglinks like `|-x|` and `|==|` are matched against the $.word pattern `/\|---[-+]+\|/` and `/\|===[=+]+\|/`, respectively (treesitter bug?). This prevents valid taglinks from being recognized. Solution: Give up on "|====|" and "|----|" plaintext nodes. These will now be parsed as taglinks. Consumers must ignore these cases manually.
1 parent ecb4300 commit 33afae9

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

corpus/taglink.txt

+25-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ taglink in text
1717
================================================================================
1818
Hello |world| hello
1919

20+
|-+| +[num] line
21+
|-e| -e Ex
22+
|-| - minus
23+
24+
2025

2126
--------------------------------------------------------------------------------
2227

@@ -26,6 +31,22 @@ Hello |world| hello
2631
(word)
2732
(taglink
2833
(word))
34+
(word)))
35+
(block
36+
(line
37+
(taglink
38+
(word))
39+
(word)
40+
(word))
41+
(line
42+
(taglink
43+
(word))
44+
(word)
45+
(word))
46+
(line
47+
(taglink
48+
(word))
49+
(word)
2950
(word))))
3051

3152
================================================================================
@@ -78,8 +99,10 @@ Note: ":autocmd" can...
7899
(word))
79100
(line
80101
(word)
81-
(word)
82-
(word)))
102+
(taglink
103+
(word))
104+
(taglink
105+
(word))))
83106
(block
84107
(line_li
85108
(line

grammar.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ module.exports = grammar({
5454

5555
// Explicit special cases: these are plaintext, not errors.
5656
_word_common: () => choice(
57-
// "|====|" and "|----|" are (plain text) table borders, not taglinks.
58-
/\|(([+=][+=][+=][+=]+)|([+-][+-][+-][+-]+))\|/,
5957
// NOT optionlink: single "'".
6058
/[\t ]'[\t ]/,
6159
// NOT optionlink: contains any non-lowercase char.
@@ -115,7 +113,7 @@ module.exports = grammar({
115113
$.codeblock,
116114
$._line_noli,
117115
),
118-
// Listitem line: consumes "*" line and all adjacent non-list lines.
116+
// Listitem: consumes prefixed line and all adjacent non-prefixed lines.
119117
line_li: ($) => prec.right(1, seq(
120118
optional(token.immediate('<')), // Treat codeblock-terminating "<" as whitespace.
121119
_li_token,
@@ -136,8 +134,9 @@ module.exports = grammar({
136134

137135
// "Column heading": plaintext followed by "~".
138136
// Intended for table column names per `:help help-writing`.
137+
// TODO: children should be $.word (plaintext), not $.atom.
139138
column_heading: ($) => seq(
140-
field('name', seq(choice($._atom_noli, $._uppercase_words), repeat($._atom))), // TODO: should be $.word (plaintext).
139+
field('name', seq(choice($._atom_noli, $._uppercase_words), repeat($._atom))),
141140
choice(
142141
token.immediate(/~[\t ]*\n/),
143142
/~[\t ]*\n/,

0 commit comments

Comments
 (0)