Skip to content

Commit 6ccd157

Browse files
committed
fix(tags): be more flexible within tags
This even allows nesting tags, not sure it that will behave correctly. Fixes #3
1 parent 59737f6 commit 6ccd157

File tree

6 files changed

+470
-312
lines changed

6 files changed

+470
-312
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
node_modules

corpus/tags.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,17 @@ Tag on the right
4646
(line
4747
(tag
4848
(word))))
49+
50+
================================================================================
51+
Option in tag
52+
================================================================================
53+
54+
*'option'*
55+
56+
--------------------------------------------------------------------------------
57+
58+
(help_file
59+
(line
60+
(tag
61+
(option
62+
(word)))))

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = grammar({
4444
'\n',
4545
),
4646

47-
tag: ($) => wrapped_word($, '*', 'name'),
47+
tag: ($) => seq('*', $._atom, token.immediate('*')),
4848
option: ($) => wrapped_word($, "'", 'name'),
4949
hotlink: ($) => wrapped_word($, '|', 'destination'),
5050
backtick: ($) => wrapped_word($, '`', 'content'),

src/grammar.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,8 @@
203203
"value": "*"
204204
},
205205
{
206-
"type": "FIELD",
207-
"name": "name",
208-
"content": {
209-
"type": "SYMBOL",
210-
"name": "word"
211-
}
206+
"type": "SYMBOL",
207+
"name": "_atom"
212208
},
213209
{
214210
"type": "IMMEDIATE_TOKEN",

src/node-types.json

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,36 @@
181181
{
182182
"type": "tag",
183183
"named": true,
184-
"fields": {
185-
"name": {
186-
"multiple": false,
187-
"required": true,
188-
"types": [
189-
{
190-
"type": "word",
191-
"named": true
192-
}
193-
]
194-
}
184+
"fields": {},
185+
"children": {
186+
"multiple": false,
187+
"required": true,
188+
"types": [
189+
{
190+
"type": "argument",
191+
"named": true
192+
},
193+
{
194+
"type": "backtick",
195+
"named": true
196+
},
197+
{
198+
"type": "hotlink",
199+
"named": true
200+
},
201+
{
202+
"type": "option",
203+
"named": true
204+
},
205+
{
206+
"type": "tag",
207+
"named": true
208+
},
209+
{
210+
"type": "word",
211+
"named": true
212+
}
213+
]
195214
}
196215
},
197216
{

0 commit comments

Comments
 (0)