nvim-treesitter/queries/rst/injections.scm

80 lines
2.2 KiB
Scheme
Raw Normal View History

((doctest_block) @injection.content
2024-01-06 15:05:50 +09:00
(#set! injection.language "python"))
2024-01-06 15:05:50 +09:00
; Directives with nested content without arguments nor options
((directive
2024-01-06 15:05:50 +09:00
name: (type) @_type
body: (body) @injection.content)
(#set! injection.language "rst")
(#any-of? @_type "attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition" "line-block" "parsed-literal" "epigraph" "highlights" "pull-quote" "compound" "header" "footer" "meta" "replace"))
2024-01-06 15:05:50 +09:00
; Directives with nested content without arguments, but with options
((directive
2024-01-06 15:05:50 +09:00
name: (type) @_type
body:
(body
(options)
(content) @injection.content))
(#set! injection.language "rst")
(#any-of? @_type "attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition" "line-block" "parsed-literal" "compound"))
2024-01-06 15:05:50 +09:00
; Directives with nested content with arguments and options
((directive
2024-01-06 15:05:50 +09:00
name: (type) @_type
body:
(body
(content) @injection.content))
(#set! injection.language "rst")
(#any-of? @_type "figure" "topic" "sidebar" "container" "table" "list-table" "class" "role" "restructuredtext-test-directive"))
2024-01-06 15:05:50 +09:00
; Special directives
((directive
2024-01-06 15:05:50 +09:00
name: (type) @_type
body:
(body
(arguments) @injection.language
(content) @injection.content))
(#any-of? @_type "code" "code-block" "sourcecode"))
((directive
2024-01-06 15:05:50 +09:00
name: (type) @_type
body:
(body
(arguments) @injection.language
(content) @injection.content))
(#eq? @_type "raw"))
((directive
2024-01-06 15:05:50 +09:00
name: (type) @_type
body:
(body
(content) @injection.content))
(#set! injection.language "latex")
(#eq? @_type "math"))
; TODO: re-add when a parser for csv is added.
2023-08-17 04:07:43 -04:00
((directive
2024-01-06 15:05:50 +09:00
name: (type) @_type
body:
(body
(content) @injection.content))
(#set! injection.language "csv")
(#eq? @_type "csv-table"))
2024-01-06 15:05:50 +09:00
; Special roles - prefix
((interpreted_text
(role) @_role
"interpreted_text" @injection.content)
2024-01-06 15:05:50 +09:00
(#eq? @_role ":math:")
(#set! injection.language "latex"))
2024-01-06 15:05:50 +09:00
; Special roles - suffix
((interpreted_text
"interpreted_text" @injection.content
(role) @_role)
2024-01-06 15:05:50 +09:00
(#eq? @_role ":math:")
(#set! injection.language "latex"))
((comment) @injection.content
2024-01-06 15:05:50 +09:00
(#set! injection.language "comment"))