Skip to content

Commit 871498a

Browse files
authored
Merge #53 feat(codeblock): conceal ">", "<" delimiters
2 parents 6ffd5e3 + 2a743c2 commit 871498a

File tree

8 files changed

+4729
-5109
lines changed

8 files changed

+4729
-5109
lines changed

binding.gyp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name": "tree_sitter_help_binding",
5+
"include_dirs": [
6+
"<!(node -e \"require('nan')\")",
7+
"src"
8+
],
9+
"sources": [
10+
"bindings/node/binding.cc",
11+
"src/parser.c",
12+
# If your language uses an external scanner, add it here.
13+
],
14+
"cflags_c": [
15+
"-std=c99",
16+
]
17+
}
18+
]
19+
}

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

src/grammar.json

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@
280280
{
281281
"type": "STRING",
282282
"value": "~"
283+
},
284+
{
285+
"type": "STRING",
286+
"value": ">"
283287
}
284288
]
285289
},
@@ -445,8 +449,15 @@
445449
"type": "SEQ",
446450
"members": [
447451
{
448-
"type": "PATTERN",
449-
"value": ">[\\t ]*\\n"
452+
"type": "STRING",
453+
"value": ">"
454+
},
455+
{
456+
"type": "IMMEDIATE_TOKEN",
457+
"content": {
458+
"type": "STRING",
459+
"value": "\n"
460+
}
450461
},
451462
{
452463
"type": "REPEAT1",
@@ -742,11 +753,28 @@
742753
}
743754
},
744755
{
745-
"type": "REPEAT",
746-
"content": {
747-
"type": "SYMBOL",
748-
"name": "tag"
749-
}
756+
"type": "CHOICE",
757+
"members": [
758+
{
759+
"type": "SEQ",
760+
"members": [
761+
{
762+
"type": "SYMBOL",
763+
"name": "tag"
764+
},
765+
{
766+
"type": "REPEAT",
767+
"content": {
768+
"type": "SYMBOL",
769+
"name": "_atom"
770+
}
771+
}
772+
]
773+
},
774+
{
775+
"type": "BLANK"
776+
}
777+
]
750778
},
751779
{
752780
"type": "STRING",

src/node-types.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,37 @@
225225
"multiple": true,
226226
"required": false,
227227
"types": [
228+
{
229+
"type": "argument",
230+
"named": true
231+
},
232+
{
233+
"type": "codespan",
234+
"named": true
235+
},
236+
{
237+
"type": "keycode",
238+
"named": true
239+
},
240+
{
241+
"type": "optionlink",
242+
"named": true
243+
},
228244
{
229245
"type": "tag",
230246
"named": true
247+
},
248+
{
249+
"type": "taglink",
250+
"named": true
251+
},
252+
{
253+
"type": "url",
254+
"named": true
255+
},
256+
{
257+
"type": "word",
258+
"named": true
231259
}
232260
]
233261
}
@@ -439,6 +467,10 @@
439467
"type": "<",
440468
"named": false
441469
},
470+
{
471+
"type": ">",
472+
"named": false
473+
},
442474
{
443475
"type": "`",
444476
"named": false

0 commit comments

Comments
 (0)