diff options
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/rst/highlights.scm | 31 | ||||
| -rw-r--r-- | queries/rst/injections.scm | 47 | ||||
| -rw-r--r-- | queries/rst/locals.scm | 2 |
3 files changed, 68 insertions, 12 deletions
diff --git a/queries/rst/highlights.scm b/queries/rst/highlights.scm index c569336b8..683f0437a 100644 --- a/queries/rst/highlights.scm +++ b/queries/rst/highlights.scm @@ -19,21 +19,20 @@ ((directive name: (type) @include) - (#match? @include "^include::$")) + (#eq? @include "include")) ((directive name: (type) @function.builtin) - (#vim-match? + (#match? @function.builtin ; https://docutils.sourceforge.io/docs/ref/rst/directives.html - "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(image|figure)|(topic|sidebar|line-block|parsed-literal|code|math|rubric|epigraph|highlights|pull-quote|compound|container)|(table|csv-table|list-table)|(contents|sectnum|section-numbering|header|footer)|(target-notes)|(meta)|(replace|unicode|date)|(raw|class|role|default-role|title|restructuredtext-test-directive)::$")) + "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(image|figure)|(topic|sidebar|line-block|parsed-literal|code|math|rubric|epigraph|highlights|pull-quote|compound|container)|(table|csv-table|list-table)|(contents|sectnum|section-numbering|header|footer)|(target-notes)|(meta)|(replace|unicode|date)|(raw|class|role|default-role|title|restructuredtext-test-directive)$")) ;; Blocks [ (literal_block) (line_block) - (doctest_block) ] @text.literal (block_quote @@ -50,7 +49,7 @@ (target name: (name)? @constant - link: (_) @text.literal) + link: (_)? @text.literal) ;; Lists @@ -73,11 +72,16 @@ (role) @function ((role) @function.builtin - (#vim-match? + (#match? @function.builtin ; https://docutils.sourceforge.io/docs/ref/rst/roles.html "^:(emphasis|literal|code|math|pep-reference|PEP|rfc-reference|RFC|strong|subscript|sub|superscript|sup|title-reference|title|t|raw):$")) +[ + "interpreted_text" + (literal) +] @text.literal + ; Prefix role ((interpreted_text (role) @_role @@ -89,7 +93,12 @@ "interpreted_text" @text.strong) (#eq? @_role ":strong:")) -; Sufix role +((interpreted_text + (role) @_role + "interpreted_text" @none) + (#eq? @_role ":math:")) + +; Suffix role ((interpreted_text "interpreted_text" @text.emphasis (role) @_role) @@ -100,10 +109,10 @@ (role) @_role) (#eq? @_role ":strong:")) -[ - "interpreted_text" - (literal) -] @text.literal +((interpreted_text + "interpreted_text" @none + (role) @_role) + (#eq? @_role ":math:")) [ (inline_target) diff --git a/queries/rst/injections.scm b/queries/rst/injections.scm new file mode 100644 index 000000000..01d84086b --- /dev/null +++ b/queries/rst/injections.scm @@ -0,0 +1,47 @@ +(doctest_block) @python + +;; Directives with nested content + +((directive + name: (type) @_type + body: (body) @rst) + (#match? + @_type + "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(image|figure)|(topic|sidebar|line-block|parsed-literal|rubric|epigraph|highlights|pull-quote|compound|container)|(table|list-table)|(contents|sectnum|section-numbering|header|footer)|(target-notes)|(meta)|(replace|unicode|date)|(include|class|role|default-role|title|restructuredtext-test-directive)$")) + +;; Special directives + +;; TODO: using @language and @content on the same capture raises an error. +;; ((directive +;; name: (type) @_type +;; body: (body) @language @content) +;; (#eq? @_type "code")) + +;; ((directive +;; name: (type) @_type +;; body: (body) @language @content) +;; (#eq? @_type "raw")) + +((directive + name: (type) @_type + body: (body) @latex) + (#eq? @_type "math")) + +((directive + name: (type) @_type + body: (body) @csv) + (#eq? @_type "csv-table")) + +;; Special roles - prefix + +((interpreted_text + (role) @_role + "interpreted_text" @latex) + (#eq? @_role ":math:")) + +;; Special roles - suffix + +((interpreted_text + "interpreted_text" @latex + (role) @_role) + (#eq? @_role ":math:")) diff --git a/queries/rst/locals.scm b/queries/rst/locals.scm index 45da96292..c0c99179c 100644 --- a/queries/rst/locals.scm +++ b/queries/rst/locals.scm @@ -27,7 +27,7 @@ ((directive name: (type) @_type body: (body) @definition) - (#match? @_type "role::")) + (#eq? @_type "role")) ;; References |
