Skip to content

Commit

Permalink
Fix deeply nested blocks
Browse files Browse the repository at this point in the history
Switches the blocks scope to using a negative lookahead end pattern
matcher instead of the while pattern.

Fixes #37.
  • Loading branch information
trond-snekvik committed Aug 20, 2023
1 parent 0de9133 commit 8404ab2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion syntaxes/rst.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
},
"block": {
"begin": "^(\\s*)(\\.{2}\\s+\\S+::)(.*)",
"while": "^\\1(?=\\s)|^\\s*$",
"end": "^(?!\\1\\s|\\s*$)",
"beginCaptures": {
"2": {
"name": "keyword.control"
Expand Down
25 changes: 25 additions & 0 deletions syntaxes/test/_nested-blocks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- SYNTAX TEST "source.rst" "nested blocks"

:param: abc
-- <----- -keyword.control

.. note:: aa
-- <--------- keyword.control

:param: abc
--^^^^^^^ keyword.control

.. note:: b
--^^^^^^^^^ keyword.control

.. note:: c
-- ^^^^^^^^^ keyword.control

.. comment c
-- ^^^^^^^^^^^^ comment.block

.. comment b
--^^^^^^^^^^^^ comment.block

.. comment a
-- <------------ comment.block

0 comments on commit 8404ab2

Please # to comment.