-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathinjections.scm
More file actions
64 lines (58 loc) · 1.84 KB
/
Copy pathinjections.scm
File metadata and controls
64 lines (58 loc) · 1.84 KB
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
; Inject MIME parts based on their Content-Type subtype. A subtype that does
; not correspond to a configured Helix language is left uninterpreted.
(mime_part
(part_headers
(content_type_field
value: (content_type
subtype: (mime_subtype) @injection.language)))
(part_body) @injection.content
(#not-any-of? @injection.language "plain" "md" "x-markdown" "rtf" "x-rtf"))
; MIME aliases whose subtype does not match Helix's language name.
(mime_part
(part_headers
(content_type_field
value: (content_type
subtype: (mime_subtype) @_subtype)))
(part_body) @injection.content
(#any-of? @_subtype "md" "x-markdown")
(#set! injection.language "markdown"))
(mime_part
(part_headers
(content_type_field
value: (content_type
subtype: (mime_subtype) @_subtype)))
(part_body) @injection.content
(#any-of? @_subtype "rtf" "x-rtf")
(#set! injection.language "rtf"))
; Diff-bearing plain-text bodies receive diff highlighting; other text bodies
; are rendered as Markdown.
([
(body_block)
(epilogue)
] @injection.content
(#match? @injection.content "diff --git ")
(#set! injection.language "diff"))
([
(body_block)
(epilogue)
] @injection.content
(#not-match? @injection.content "diff --git ")
(#set! injection.language "markdown"))
(mime_part
(part_headers
(content_type_field
value: (content_type
subtype: (mime_subtype) @_subtype)))
(part_body) @injection.content
(#match? @_subtype "^[Pp][Ll][Aa][Ii][Nn]$")
(#match? @injection.content "diff --git ")
(#set! injection.language "diff"))
(mime_part
(part_headers
(content_type_field
value: (content_type
subtype: (mime_subtype) @_subtype)))
(part_body) @injection.content
(#match? @_subtype "^[Pp][Ll][Aa][Ii][Nn]$")
(#not-match? @injection.content "diff --git ")
(#set! injection.language "markdown"))