aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/rst/injections.scm
blob: 7178de9da16836d9a206e2b7adf37ae9f30e0f48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
((doctest_block) @injection.content
  (#set! injection.language "python"))

; Directives with nested content without arguments nor options
((directive
  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"))

; Directives with nested content without arguments, but with options
((directive
  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"))

; Directives with nested content with arguments and options
((directive
  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"))

; Special directives
((directive
  name: (type) @_type
  body: (body
    (arguments) @injection.language
    (content) @injection.content))
  (#any-of? @_type "raw" "code" "code-block" "sourcecode"))

((directive
  name: (type) @_type
  body: (body
    (content) @injection.content))
  (#set! injection.language "latex")
  (#eq? @_type "math"))

((directive
  name: (type) @_type
  body: (body
    (content) @injection.content))
  (#set! injection.language "csv")
  (#eq? @_type "csv-table"))

; Special roles - prefix
((interpreted_text
  (role) @_role
  "interpreted_text" @injection.content)
  (#eq? @_role ":math:")
  (#set! injection.language "latex"))

; Special roles - suffix
((interpreted_text
  "interpreted_text" @injection.content
  (role) @_role)
  (#eq? @_role ":math:")
  (#set! injection.language "latex"))

((comment) @injection.content
  (#set! injection.language "comment"))