Skip to content

Commit 31fe4fd

Browse files
committed
feat(codeblock): conceal ">", "<" delimiters
Problem: - ">" char node is not anonymous so it can't be concealed by queries. - whitespace after ">" is not a valid codeblock. - query does not define conceal for codeblock ">", "<" delimiters. - h3 does not allow atoms after tags. Solution: - Constrain the (codeblock) rule. - Relax (h3) rule.
1 parent 6ffd5e3 commit 31fe4fd

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

corpus/arguments.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@ EXTERNAL *netrw-externapp* {{{2
151151
(uppercase_name)
152152
(tag
153153
(word))
154-
(ERROR)))))
154+
(word)))))

corpus/codeblock.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,30 @@ codeblock stop and start on same line
352352
(codeblock
353353
(line)
354354
(line)))))
355+
356+
================================================================================
357+
NOT codeblock: whitespace after ">"
358+
================================================================================
359+
x >
360+
line
361+
362+
x x>
363+
line
364+
365+
366+
367+
--------------------------------------------------------------------------------
368+
369+
(help_file
370+
(block
371+
(line
372+
(word)
373+
(word))
374+
(line
375+
(word)))
376+
(block
377+
(line
378+
(word)
379+
(word))
380+
(line
381+
(word))))

grammar.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ module.exports = grammar({
8282
'(',
8383
/\w+\(/,
8484
'~',
85+
// NOT codeblock: random ">" in middle of the motherflippin text.
86+
'>',
8587
),
8688

8789
keycode: () => choice(
@@ -121,7 +123,8 @@ module.exports = grammar({
121123

122124
// Codeblock: preformatted block of lines starting with ">".
123125
codeblock: ($) => prec.right(seq(
124-
/>[\t ]*\n/,
126+
'>',
127+
token.immediate('\n'),
125128
repeat1(alias($.line_code, $.line)),
126129
// Codeblock ends if a line starts with non-whitespace.
127130
// Terminating "<" is consumed in other rules.
@@ -182,7 +185,7 @@ module.exports = grammar({
182185
h3: ($) =>
183186
seq(
184187
field('name', $.uppercase_name),
185-
repeat($.tag),
188+
optional(seq($.tag, repeat($._atom))),
186189
'\n',
187190
),
188191

queries/help/highlights.scm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"`" @conceal (#set! conceal "")
1515
text: (_) @text.literal)
1616
(codeblock) @text.literal
17+
(codeblock
18+
">" @conceal (#set! conceal ""))
19+
(block
20+
"<" @conceal (#set! conceal ""))
1721
(argument) @parameter
1822
(keycode) @string.special
1923
(url) @text.uri

0 commit comments

Comments
 (0)