the home site for me: also iteration 3 or 4 of my site
1%YAML 1.2
2---
3# Not strictly just PEM. Includes some other stuff, just to be helpful.
4
5# https://www.sublimetext.com/docs/syntax.html
6# https://datatracker.ietf.org/doc/html/rfc7468 (PEM)
7# https://datatracker.ietf.org/doc/html/rfc4716 (OpenSSH)
8# https://datatracker.ietf.org/doc/html/rfc4880 (OpenPGP)
9
10name: Private Encrypted Mail (PEM) Key
11scope: source.pem
12version: 2
13extends: SSH Common.sublime-syntax
14
15file_extensions:
16 - pem
17
18hidden_file_extensions:
19 - cer
20 - cert
21 - crt
22 - id_dsa
23 - id_ed25519
24 - id_ed448
25 - id_eddsa
26 - id_rsa
27
28first_line_match: |-
29 ^(?x:
30 (-{4}[ -])
31 BEGIN [ ]
32 ( (?:[0-9A-Z -]+[ ])? (?: PUBLIC | PRIVATE ) [ ] KEY
33 | (?:[0-9A-Z -]+[ ])? CERTIFICATE (?:[ ] REQUEST )?
34 | (?:[0-9A-Z -]+[ ])? PARAMETERS
35 | X509 [ ] CRL
36 | PKCS7
37 | PKCS [ ] \#7 [ ] SIGNED [ ] DATA
38 | CMS
39 | PGP [ ] MESSAGE (?:,[ ] PART [ ] \d+(?:/\d+)?)?
40 | PGP [ ] (?: PUBLIC | PRIVATE ) [ ] KEY [ ] BLOCK
41 | PGP [ ] SIGNATURE
42 )
43 ([ -]-{4})
44 )
45
46contexts:
47 main:
48 - include: comments-number-sign
49 - match: |-
50 ^(?x:
51 (-{4}[ -])
52 BEGIN [ ]
53 ( (?:[0-9A-Z -]+[ ])? (?: PUBLIC | PRIVATE ) [ ] KEY
54 | (?:[0-9A-Z -]+[ ])? CERTIFICATE (?:[ ] REQUEST )?
55 | (?:[0-9A-Z -]+[ ])? PARAMETERS
56 | X509 [ ] CRL
57 | PKCS7
58 | PKCS [ ] \#7 [ ] SIGNED [ ] DATA
59 | CMS
60 | PGP [ ] MESSAGE (?:,[ ] PART [ ] \d+(?:/\d+)?)?
61 | PGP [ ] (?: PUBLIC | PRIVATE ) [ ] KEY [ ] BLOCK
62 | PGP [ ] SIGNATURE
63 )
64 ([ -]-{4})
65 )
66 scope: punctuation.section.block.begin.pem
67 push: pem-key
68 - include: setext-headings
69
70 pem-key:
71 - meta_scope: meta.block.pem
72 - match: ^\1END \2\3
73 scope: punctuation.section.block.end.pem
74 pop: 1
75 - include: comments-number-sign
76 - match: ^{{base64_char}}{1,100}(={0,3})?$
77 scope: string.unquoted.pem
78 captures:
79 1: punctuation.definition.string.end.pem
80 - include: headers
81
82 headers:
83 - match: ^(?i:(Comment))(:)
84 captures:
85 1: keyword.other.comment.pem
86 2: punctuation.separator.key-value.pem
87 push:
88 - meta_content_scope: comment.line.pem
89 - include: header-end
90 - match: ^((x-)?[\w-]+)(:)
91 captures:
92 1: meta.mapping.key.pem keyword.other.pem
93 2: variable.annotation.pem
94 3: punctuation.separator.key-value.pem
95 push: header-value
96
97 header-value:
98 - meta_scope: meta.mapping.pem
99 - meta_content_scope: meta.mapping.value.pem
100 - include: header-end
101 - include: punctuation-comma-sequence
102 - match: =
103 scope: punctuation.separator.key-value.pem
104 - match: '\b(?x: ENCRYPTED | MIC-ONLY | MIC-CLEAR )\b'
105 scope: storage.modifier.pem
106 - match: |-
107 \b(?x:
108 ( AES-(?:128|256)-CBC
109 | DES-(?:EDE3-)?CBC
110 )\b
111 ( (,) .+ )?
112 )
113 captures:
114 1: meta.function-call.identifier.pem
115 support.function.cipher.ssh.crypto
116 2: meta.function-call.arguments.pem
117 3: punctuation.section.arguments.begin.pem
118
119 header-end:
120 - match: \\\r?\n
121 scope: punctuation.separator.continuation.line.pem
122 push:
123 - match: ^
124 pop: 1
125 - match: (?=$)
126 pop: 1
127
128 setext-headings:
129 - match: ^(?:=+|(?=\S))
130 branch_point: maybe-heading
131 branch:
132 - setext-heading
133 - not-heading
134
135 setext-heading:
136 - meta_scope: markup.heading.pem
137 - meta_content_scope: entity.name.section.pem
138 - match: ^(={5,})[ \t]*$(\n?)
139 captures:
140 1: punctuation.definition.heading.setext.pem
141 2: meta.whitespace.newline.pem
142 pop: 1
143 - match: ^(?!=+)$
144 fail: maybe-heading
145
146 not-heading:
147 - match: ''
148 pop: 1
149
150variables:
151 base64_char: '[a-zA-Z0-9+/]'