@@ -250,7 +250,7 @@ const org_grammar = {
250250 field ( 'name' , $ . expr ) ,
251251 optional ( repeat1 ( field ( 'parameter' , $ . expr ) ) ) ,
252252 $ . _nl ,
253- optional ( field ( 'contents' , $ . contents ) ) ,
253+ optional ( field ( 'contents' , alias ( $ . _block_contents , $ . contents ) ) ) ,
254254 alias ( / # \+ e n d _ / i, '#+end_' ) ,
255255 field ( 'end_name' , alias ( $ . _immediate_expr , $ . expr ) ) ,
256256 $ . _eol ,
@@ -262,12 +262,18 @@ const org_grammar = {
262262 field ( 'name' , $ . expr ) ,
263263 repeat ( field ( 'parameter' , $ . expr ) ) ,
264264 $ . _nl ,
265- optional ( field ( 'contents' , $ . contents ) ) ,
265+ optional ( field ( 'contents' , alias ( $ . _block_contents , $ . contents ) ) ) ,
266266 alias ( / # \+ e n d : / i, '#+end:' ) ,
267267 optional ( field ( 'end_name' , $ . expr ) ) ,
268268 $ . _eol ,
269269 ) ,
270270
271+ _block_contents : $ => seq (
272+ optional ( repeat1 ( $ . expr ) ) ,
273+ repeat1 ( $ . _nl ) ,
274+ repeat ( seq ( repeat1 ( $ . expr ) , repeat1 ( $ . _nl ) ) ) ,
275+ ) ,
276+
271277 list : $ => seq (
272278 optional ( $ . _directive_list ) ,
273279 $ . _liststart , // captures indent length and bullet type
@@ -329,19 +335,19 @@ const org_grammar = {
329335 field ( 'name' , alias ( / [ \p{ L} \p{ N} * ] + / , $ . name ) ) ,
330336 token . immediate ( '}' ) ,
331337 $ . _nl ,
332- optional ( field ( 'contents' , $ . contents ) ) ,
338+ optional ( field ( 'contents' , alias ( $ . _block_contents , $ . contents ) ) ) ,
333339 alias ( / \\ e n d \{ / i, '\\end{' ) ,
334340 alias ( / [ \p{ L} \p{ N} * ] + / , $ . name ) ,
335341 token . immediate ( '}' ) ,
336342 ) ,
337343 seq (
338344 token ( seq ( '\\[' , choice ( '\n' , '\r' ) ) ) ,
339- optional ( field ( 'contents' , $ . contents ) ) ,
345+ optional ( field ( 'contents' , alias ( $ . _block_contents , $ . contents ) ) ) ,
340346 '\\]' ,
341347 ) ,
342348 seq (
343349 token ( seq ( '\\(' , choice ( '\n' , '\r' ) ) ) ,
344- optional ( field ( 'contents' , $ . contents ) ) ,
350+ optional ( field ( 'contents' , alias ( $ . _block_contents , $ . contents ) ) ) ,
345351 '\\)' ,
346352 ) ,
347353 ) ,
0 commit comments