|
13 | 13 | // @ts-check |
14 | 14 |
|
15 | 15 | const _uppercase_word = /[A-Z0-9.()][-A-Z0-9.()_]+/; |
16 | | -// List-item. |
17 | | -const _li_token = /[-•][ ]+/; |
18 | | -// Numbered list-item. |
19 | | -const _num_li_token = /[0-9]{1,3}\.[ ]+/; |
| 16 | +// Listitem (incl. numbered items). |
| 17 | +const _li_token = /([-•]|([0-9]{1,3}\.))[ ]+/; |
20 | 18 |
|
21 | 19 | module.exports = grammar({ |
22 | 20 | name: 'vimdoc', |
@@ -136,8 +134,7 @@ module.exports = grammar({ |
136 | 134 | choice( |
137 | 135 | repeat1($.line), |
138 | 136 | repeat1($.line_li), |
139 | | - repeat1($.line_li_num), |
140 | | - seq(repeat1($.line), repeat1(choice($.line_li, $.line_li_num))), |
| 137 | + seq(repeat1($.line), repeat1($.line_li)), |
141 | 138 | ), |
142 | 139 | choice( |
143 | 140 | token.immediate('<'), // Treat codeblock-terminating "<" as whitespace. |
@@ -169,17 +166,7 @@ module.exports = grammar({ |
169 | 166 | // Listitem: consumes prefixed line and all adjacent non-prefixed lines. |
170 | 167 | line_li: ($) => prec.right(1, seq( |
171 | 168 | optional(token.immediate('<')), // Treat codeblock-terminating "<" as whitespace. |
172 | | - _li_token, |
173 | | - choice( |
174 | | - alias(seq(repeat1($._atom), /\n/), $.line), |
175 | | - seq(alias(repeat1($._atom), $.line), $.codeblock), |
176 | | - ), |
177 | | - repeat(alias($._line_noli, $.line)), |
178 | | - )), |
179 | | - // Numbered listitem: consumes prefixed line and all adjacent non-prefixed lines. |
180 | | - line_li_num: ($) => prec.right(1, seq( |
181 | | - optional(token.immediate('<')), // Treat codeblock-terminating "<" as whitespace. |
182 | | - _num_li_token, |
| 169 | + alias(_li_token, $.prefix), |
183 | 170 | choice( |
184 | 171 | alias(seq(repeat1($._atom), /\n/), $.line), |
185 | 172 | seq(alias(repeat1($._atom), $.line), $.codeblock), |
|
0 commit comments