Skip to content

Commit 318bf1b

Browse files
committed
feat: add support for hotlinks and options
1 parent f134a79 commit 318bf1b

File tree

6 files changed

+442
-234
lines changed

6 files changed

+442
-234
lines changed

corpus/hotlink.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
================================================================================
2+
Hotlink alone
3+
================================================================================
4+
5+
|world|
6+
7+
--------------------------------------------------------------------------------
8+
9+
(help_file
10+
(line
11+
(hotlink
12+
(word))))
13+
14+
================================================================================
15+
Hotlink in text
16+
================================================================================
17+
18+
Hello |world| hello
19+
20+
--------------------------------------------------------------------------------
21+
22+
(help_file
23+
(line
24+
(word)
25+
(hotlink
26+
(word))
27+
(word)))

corpus/option.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
================================================================================
2+
Option alone
3+
================================================================================
4+
5+
'hello'
6+
7+
--------------------------------------------------------------------------------
8+
9+
(help_file
10+
(line
11+
(option
12+
(word))))
13+
14+
================================================================================
15+
Option in text
16+
================================================================================
17+
18+
world 'hello' world
19+
20+
--------------------------------------------------------------------------------
21+
22+
(help_file
23+
(line
24+
(word)
25+
(option
26+
(word))
27+
(word)))

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = grammar({
1818
),
1919
line: ($) => prec.right(seq(repeat1($._atom), optional('\n'))),
2020

21-
_atom: ($) => choice($.word, $.tag, $.code_block),
21+
_atom: ($) => choice($.word, $.tag, $.code_block, $.tag, $.option, $.hotlink),
2222

2323
uppercase_name: ($) => repeat1(/[A-Z]+/),
2424
column_name: ($) => repeat1($.word),

src/grammar.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@
113113
{
114114
"type": "SYMBOL",
115115
"name": "code_block"
116+
},
117+
{
118+
"type": "SYMBOL",
119+
"name": "tag"
120+
},
121+
{
122+
"type": "SYMBOL",
123+
"name": "option"
124+
},
125+
{
126+
"type": "SYMBOL",
127+
"name": "hotlink"
116128
}
117129
]
118130
},

src/node-types.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@
8686
]
8787
}
8888
},
89+
{
90+
"type": "hotlink",
91+
"named": true,
92+
"fields": {
93+
"destination": {
94+
"multiple": false,
95+
"required": true,
96+
"types": [
97+
{
98+
"type": "word",
99+
"named": true
100+
}
101+
]
102+
}
103+
}
104+
},
89105
{
90106
"type": "line",
91107
"named": true,
@@ -98,6 +114,14 @@
98114
"type": "code_block",
99115
"named": true
100116
},
117+
{
118+
"type": "hotlink",
119+
"named": true
120+
},
121+
{
122+
"type": "option",
123+
"named": true
124+
},
101125
{
102126
"type": "tag",
103127
"named": true
@@ -109,6 +133,22 @@
109133
]
110134
}
111135
},
136+
{
137+
"type": "option",
138+
"named": true,
139+
"fields": {
140+
"name": {
141+
"multiple": false,
142+
"required": true,
143+
"types": [
144+
{
145+
"type": "word",
146+
"named": true
147+
}
148+
]
149+
}
150+
}
151+
},
112152
{
113153
"type": "tag",
114154
"named": true,

0 commit comments

Comments
 (0)