diff options
| author | Santos Gallegos <stsewd@protonmail.com> | 2021-01-02 16:56:05 -0500 |
|---|---|---|
| committer | Santos Gallegos <stsewd@protonmail.com> | 2021-01-02 17:19:08 -0500 |
| commit | 6aaf240d0c6ad10676e252f2e89110820d706718 (patch) | |
| tree | 851304df51d0851ac45e52b7f92c6359cb45e84e /queries | |
| parent | 6114a6ed97527ffd1938815f2276d77d908c94c2 (diff) | |
RST: update injection queries
Finally, highlight for code blocks
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/rst/highlights.scm | 3 | ||||
| -rw-r--r-- | queries/rst/injections.scm | 43 | ||||
| -rw-r--r-- | queries/rst/locals.scm | 2 |
3 files changed, 32 insertions, 16 deletions
diff --git a/queries/rst/highlights.scm b/queries/rst/highlights.scm index 683f0437..b0c1735e 100644 --- a/queries/rst/highlights.scm +++ b/queries/rst/highlights.scm @@ -17,6 +17,9 @@ (directive name: (type) @function) +(directive + body: (body (arguments) @parameter)) + ((directive name: (type) @include) (#eq? @include "include")) diff --git a/queries/rst/injections.scm b/queries/rst/injections.scm index 01d84086..475ad2f4 100644 --- a/queries/rst/injections.scm +++ b/queries/rst/injections.scm @@ -1,35 +1,48 @@ (doctest_block) @python -;; Directives with nested content - +;; Directives with nested content without arguments nor options ((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)$")) + "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(line-block|parsed-literal|epigraph|highlights|pull-quote|compound)|(header|footer)|(meta)|(replace)$")) -;; Special directives +;; Directives with nested content without arguments, but with options +((directive + name: (type) @_type + body: (body (options) (content) @rst)) + (#match? + @_type + "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(line-block|parsed-literal|compound)$")) + +;; Directives with nested content with arguments and options +((directive + name: (type) @_type + body: (body (content) @rst)) + (#match? + @_type + "^(figure)|(topic|sidebar|container)|(table|list-table)|(class|role|restructuredtext-test-directive)$")) -;; TODO: using @language and @content on the same capture raises an error. -;; ((directive -;; name: (type) @_type -;; body: (body) @language @content) -;; (#eq? @_type "code")) +;; Special directives +((directive + name: (type) @_type + body: (body (arguments) @language (content) @content)) + (#eq? @_type "code")) -;; ((directive -;; name: (type) @_type -;; body: (body) @language @content) -;; (#eq? @_type "raw")) +((directive + name: (type) @_type + body: (body (arguments) @language (content) @content)) + (#eq? @_type "raw")) ((directive name: (type) @_type - body: (body) @latex) + body: (body (content) @latex)) (#eq? @_type "math")) ((directive name: (type) @_type - body: (body) @csv) + body: (body (content) @csv)) (#eq? @_type "csv-table")) ;; Special roles - prefix diff --git a/queries/rst/locals.scm b/queries/rst/locals.scm index c0c99179..bf8bd041 100644 --- a/queries/rst/locals.scm +++ b/queries/rst/locals.scm @@ -26,7 +26,7 @@ ; The role directive can define a new role ((directive name: (type) @_type - body: (body) @definition) + body: (body (arguments) @definition)) (#eq? @_type "role")) ;; References |
