@scalar/highlight 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +52 -13
- package/dist/all.d.ts.map +1 -1
- package/dist/all.js +2 -0
- package/dist/compat/languages.d.ts.map +1 -1
- package/dist/compat/languages.js +2 -4
- package/dist/compat/syntax-highlight.d.ts.map +1 -1
- package/dist/compat/syntax-highlight.js +101 -27
- package/dist/core/compile.d.ts +9 -1
- package/dist/core/compile.d.ts.map +1 -1
- package/dist/core/compile.js +120 -6
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/tokenize.d.ts.map +1 -1
- package/dist/core/tokenize.js +143 -7
- package/dist/core/types.d.ts +74 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/langs/bash.d.ts.map +1 -1
- package/dist/langs/bash.js +60 -13
- package/dist/langs/csharp.d.ts.map +1 -1
- package/dist/langs/csharp.js +11 -5
- package/dist/langs/css.d.ts.map +1 -1
- package/dist/langs/css.js +84 -7
- package/dist/langs/go.d.ts.map +1 -1
- package/dist/langs/go.js +7 -1
- package/dist/langs/html.d.ts +0 -10
- package/dist/langs/html.d.ts.map +1 -1
- package/dist/langs/html.js +63 -24
- package/dist/langs/http.d.ts.map +1 -1
- package/dist/langs/http.js +25 -9
- package/dist/langs/javascript.d.ts.map +1 -1
- package/dist/langs/javascript.js +146 -30
- package/dist/langs/json.d.ts.map +1 -1
- package/dist/langs/json.js +7 -1
- package/dist/langs/julia.d.ts +4 -0
- package/dist/langs/julia.d.ts.map +1 -0
- package/dist/langs/julia.js +181 -0
- package/dist/langs/markdown.d.ts +9 -3
- package/dist/langs/markdown.d.ts.map +1 -1
- package/dist/langs/markdown.js +127 -6
- package/dist/langs/ocaml.d.ts.map +1 -1
- package/dist/langs/ocaml.js +16 -7
- package/dist/langs/php.d.ts.map +1 -1
- package/dist/langs/php.js +69 -19
- package/dist/langs/r.js +9 -9
- package/dist/langs/rust.d.ts.map +1 -1
- package/dist/langs/rust.js +19 -10
- package/dist/langs/sql.d.ts.map +1 -1
- package/dist/langs/sql.js +9 -3
- package/dist/langs/yaml.d.ts +0 -7
- package/dist/langs/yaml.d.ts.map +1 -1
- package/dist/langs/yaml.js +157 -28
- package/dist/lazy.d.ts +1 -0
- package/dist/lazy.d.ts.map +1 -1
- package/dist/lazy.js +2 -0
- package/package.json +2 -2
package/dist/langs/markdown.js
CHANGED
|
@@ -1,9 +1,52 @@
|
|
|
1
|
+
/** HTML blocks that end at their closing tag rather than at a blank line. */
|
|
2
|
+
const RAW_TAGS = 'script|pre|style|textarea';
|
|
3
|
+
/**
|
|
4
|
+
* `RAW_TAGS` matched in any case, for the root state, which is case-sensitive
|
|
5
|
+
* everywhere else. HTML tag names are not: `<SCRIPT>` opens the same block.
|
|
6
|
+
*/
|
|
7
|
+
const RAW_TAGS_ANY_CASE = RAW_TAGS.replace(/[a-z]/g, (c) => `[${c}${c.toUpperCase()}]`);
|
|
8
|
+
/**
|
|
9
|
+
* Right after the `>` that ends a tag, and not one inside a quoted attribute
|
|
10
|
+
* value: `<div title="a>b">` ends at the last `>`. Matched backwards from the
|
|
11
|
+
* `>`, which is checked first, so every other position fails on one character.
|
|
12
|
+
* The repeats are capped so a `>` on a long line costs a bounded scan.
|
|
13
|
+
*/
|
|
14
|
+
const AFTER_TAG = `(?<=<\\/?[A-Za-z][\\w-]{0,64}(?:[^<>"'\\n]|"[^"\\n]{0,512}"|'[^'\\n]{0,512}'){0,512}>)`;
|
|
15
|
+
/**
|
|
16
|
+
* The states between a language fence and its closing fence: `<name>-code`
|
|
17
|
+
* scopes the closing fence and `<name>-body` hands the body to the language.
|
|
18
|
+
* `close` is a run of the opening character, which CommonMark lets be longer
|
|
19
|
+
* than the opener.
|
|
20
|
+
*/
|
|
21
|
+
const codeFence = (name, close) => {
|
|
22
|
+
const closing = `^[ \\t]*${close}[ \\t]*$`;
|
|
23
|
+
return {
|
|
24
|
+
[`${name}-code`]: {
|
|
25
|
+
default: 'string',
|
|
26
|
+
rules: [
|
|
27
|
+
{ match: closing, scope: 'punctuation', pop: true },
|
|
28
|
+
{ match: '^', push: `${name}-body` },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
[`${name}-body`]: {
|
|
32
|
+
default: 'string',
|
|
33
|
+
embed: { language: '{{remembered}}', until: closing },
|
|
34
|
+
rules: [],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
1
38
|
/**
|
|
2
39
|
* Markdown.
|
|
3
40
|
*
|
|
4
|
-
* Prose is left alone; only the marks are styled.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
41
|
+
* Prose is left alone; only the marks are styled. Three kinds of block belong
|
|
42
|
+
* to other languages and are handed to them when they are registered:
|
|
43
|
+
*
|
|
44
|
+
* - a fenced code block that names its language
|
|
45
|
+
* - YAML front matter
|
|
46
|
+
* - HTML that starts a line, and `<script>`, `<pre>` and `<style>` blocks
|
|
47
|
+
*
|
|
48
|
+
* Any other fence becomes a literal state, so its contents are never mistaken
|
|
49
|
+
* for Markdown syntax.
|
|
7
50
|
*/
|
|
8
51
|
const markdown = {
|
|
9
52
|
name: 'markdown',
|
|
@@ -11,13 +54,53 @@ const markdown = {
|
|
|
11
54
|
states: {
|
|
12
55
|
root: {
|
|
13
56
|
rules: [
|
|
57
|
+
// A three-character fence that names a language hands its body to that
|
|
58
|
+
// language. Longer fences keep the literal form below, so a ```` block
|
|
59
|
+
// that shows ``` inside still closes only on its own run.
|
|
60
|
+
// The two fence characters get a state each, because only a run of the
|
|
61
|
+
// character that opened the block closes it.
|
|
62
|
+
{
|
|
63
|
+
match: '^([ \\t]*)(```(?!`))([ \\t]*)([A-Za-z][\\w+#.-]*)([^\\n]*)$',
|
|
64
|
+
scope: [null, 'punctuation', null, 'type', 'type'],
|
|
65
|
+
push: 'backtick-code',
|
|
66
|
+
remember: 4,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
match: '^([ \\t]*)(~~~(?!~))([ \\t]*)([A-Za-z][\\w+#.-]*)([^\\n]*)$',
|
|
70
|
+
scope: [null, 'punctuation', null, 'type', 'type'],
|
|
71
|
+
push: 'tilde-code',
|
|
72
|
+
remember: 4,
|
|
73
|
+
},
|
|
74
|
+
// The fence remembers its run, so only a run of the same character at
|
|
75
|
+
// least as long closes it: a ```` block can show ``` inside.
|
|
14
76
|
{
|
|
15
77
|
match: '^([ \\t]*)(```+|~~~+)([^\\n]*)$',
|
|
16
78
|
scope: [null, 'punctuation', 'type'],
|
|
17
79
|
push: 'fence',
|
|
80
|
+
remember: 2,
|
|
81
|
+
},
|
|
82
|
+
{ match: '<!--', scope: 'comment', push: 'html-comment' },
|
|
83
|
+
// Front matter: a `---` block at the very start, and only when it is
|
|
84
|
+
// closed. An unclosed `---` on the first line is a thematic break, and
|
|
85
|
+
// reading it as YAML would take the whole document with it. The
|
|
86
|
+
// lookahead to the closing line runs once, at position 0.
|
|
87
|
+
{
|
|
88
|
+
match: '(?<![\\s\\S])---(?=[ \\t]*\\r?\\n[\\s\\S]*?^(?:---|\\.\\.\\.)[ \\t]*$)',
|
|
89
|
+
scope: 'punctuation',
|
|
90
|
+
push: 'front-matter',
|
|
18
91
|
},
|
|
92
|
+
// HTML at the start of a line goes to the HTML grammar. `<script>`,
|
|
93
|
+
// `<pre>`, `<style>` and `<textarea>` run to the line that closes them,
|
|
94
|
+
// as in CommonMark. Any other tag gets its line at most: CommonMark would
|
|
95
|
+
// run the block to the next blank line, but MDX and most docs
|
|
96
|
+
// renderers read Markdown inside components, and holding the lines
|
|
97
|
+
// after `<Steps>` as HTML would strip their fences and emphasis.
|
|
98
|
+
// Inline tags inside a paragraph keep the rule below.
|
|
99
|
+
{ match: `^(?=[ \\t]*<(?:${RAW_TAGS_ANY_CASE})(?:[\\s>]|$))`, push: 'html-raw' },
|
|
100
|
+
{ match: '^(?=[ \\t]*<\\/?[A-Za-z][\\w-]*(?:[\\s/>]|$))', push: 'html-line' },
|
|
19
101
|
{ match: '^#{1,6}[ \\t][^\\n]*', scope: 'heading' },
|
|
20
|
-
|
|
102
|
+
// `[^\\r\\n]`, so the `\\r` of a blank CRLF line does not count as text.
|
|
103
|
+
{ match: '^[^\\r\\n]+\\r?\\n(?:={2,}|-{2,})[ \\t]*$', scope: 'heading' },
|
|
21
104
|
{
|
|
22
105
|
match: '^[ \\t]*(?:\\*[ \\t]*){3,}$|^[ \\t]*(?:-[ \\t]*){3,}$|^[ \\t]*(?:_[ \\t]*){3,}$',
|
|
23
106
|
scope: 'punctuation',
|
|
@@ -53,19 +136,57 @@ const markdown = {
|
|
|
53
136
|
{ match: '~~[^~\\n]+~~', scope: 'comment' },
|
|
54
137
|
{ match: '^([ \\t]*)(\\|)', scope: [null, 'punctuation'] },
|
|
55
138
|
{ match: '\\|', scope: 'punctuation' },
|
|
56
|
-
|
|
139
|
+
// The attribute run stops at `<` too, so a line of unclosed `<a ` costs
|
|
140
|
+
// O(n) per tag rather than a scan to the end of the line each.
|
|
141
|
+
{ match: '</?[A-Za-z][\\w:-]*(?:[ \\t][^<>\\n]*)?/?>', scope: 'tag' },
|
|
57
142
|
],
|
|
58
143
|
},
|
|
59
144
|
fence: {
|
|
60
145
|
default: 'string',
|
|
61
146
|
rules: [
|
|
62
147
|
{
|
|
63
|
-
match: '^[ \\t]*
|
|
148
|
+
match: '^[ \\t]*{{remembered}}[`~]*[ \\t]*$',
|
|
64
149
|
scope: 'punctuation',
|
|
65
150
|
pop: true,
|
|
66
151
|
},
|
|
67
152
|
],
|
|
68
153
|
},
|
|
154
|
+
'front-matter': {
|
|
155
|
+
rules: [
|
|
156
|
+
{ match: '^(?:---|\\.\\.\\.)[ \\t]*$', scope: 'punctuation', pop: true },
|
|
157
|
+
{ match: '^', push: 'front-matter-body' },
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
'front-matter-body': {
|
|
161
|
+
embed: { language: 'yaml', until: '^(?:---|\\.\\.\\.)[ \\t]*$' },
|
|
162
|
+
rules: [],
|
|
163
|
+
},
|
|
164
|
+
// Without the HTML grammar registered, HTML renders unscoped, the way a
|
|
165
|
+
// fence in an unregistered language falls back to a plain string.
|
|
166
|
+
'html-raw': {
|
|
167
|
+
// The closing tag may be in any case, as the opening one may.
|
|
168
|
+
ignoreCase: true,
|
|
169
|
+
embed: {
|
|
170
|
+
language: 'html',
|
|
171
|
+
// The line break that ends the line holding the closing tag. The
|
|
172
|
+
// lookahead goes first so the lookbehind only runs at line ends.
|
|
173
|
+
until: `(?=\\n|(?![\\s\\S]))(?<=<\\/(?:${RAW_TAGS})[ \\t]*>[^\\n]*)`,
|
|
174
|
+
},
|
|
175
|
+
rules: [],
|
|
176
|
+
},
|
|
177
|
+
// To the end of the line, or to the first tag-ending `>` followed by text
|
|
178
|
+
// rather than by another tag: in `<span>x</span> **y**` only the opening
|
|
179
|
+
// tag is HTML, and the rest of the line stays Markdown for the inline rules.
|
|
180
|
+
'html-line': {
|
|
181
|
+
embed: { language: 'html', until: `$|${AFTER_TAG}(?![ \\t]*(?:<|$))` },
|
|
182
|
+
rules: [],
|
|
183
|
+
},
|
|
184
|
+
...codeFence('backtick', '`{3,}'),
|
|
185
|
+
...codeFence('tilde', '~{3,}'),
|
|
186
|
+
'html-comment': {
|
|
187
|
+
default: 'comment',
|
|
188
|
+
rules: [{ match: '-->', scope: 'comment', pop: true }],
|
|
189
|
+
},
|
|
69
190
|
},
|
|
70
191
|
};
|
|
71
192
|
export default markdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ocaml.d.ts","sourceRoot":"","sources":["../../src/langs/ocaml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AA2D5C,QAAA,MAAM,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ocaml.d.ts","sourceRoot":"","sources":["../../src/langs/ocaml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AA2D5C,QAAA,MAAM,KAAK,EAAE,OA+RZ,CAAA;AAED,eAAe,KAAK,CAAA"}
|
package/dist/langs/ocaml.js
CHANGED
|
@@ -155,13 +155,14 @@ const ocaml = {
|
|
|
155
155
|
],
|
|
156
156
|
},
|
|
157
157
|
// Comments nest, so the opener pushes another copy of this state and only
|
|
158
|
-
// the matching `*)` pops.
|
|
159
|
-
//
|
|
158
|
+
// the matching `*)` pops. OCaml lexes string literals inside comments, so a
|
|
159
|
+
// `"*)"` there does not close the comment; the string stays comment-coloured.
|
|
160
160
|
comment: {
|
|
161
161
|
default: 'comment',
|
|
162
162
|
rules: [
|
|
163
163
|
{ match: '\\(\\*', push: 'comment' },
|
|
164
164
|
{ match: '\\*\\)', pop: true },
|
|
165
|
+
{ match: '"', push: 'comment-string' },
|
|
165
166
|
],
|
|
166
167
|
},
|
|
167
168
|
'comment-doc': {
|
|
@@ -169,15 +170,23 @@ const ocaml = {
|
|
|
169
170
|
rules: [
|
|
170
171
|
{ match: '\\(\\*', push: 'comment-doc' },
|
|
171
172
|
{ match: '\\*\\)', pop: true },
|
|
173
|
+
{ match: '"', push: 'comment-string' },
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
/** A string literal inside a comment. Still a comment to the reader. */
|
|
177
|
+
'comment-string': {
|
|
178
|
+
default: 'comment',
|
|
179
|
+
rules: [
|
|
180
|
+
{ match: '\\\\[\\s\\S]', scope: 'comment' },
|
|
181
|
+
{ match: '"', scope: 'comment', pop: true },
|
|
172
182
|
],
|
|
173
183
|
},
|
|
174
184
|
// ---- strings, chars and numbers ------------------------------------------
|
|
175
185
|
strings: {
|
|
176
186
|
rules: [
|
|
177
|
-
// `{id|raw|id}`.
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
{ match: '\\{[a-z_]*\\|', scope: 'string', push: 'quoted-string' },
|
|
187
|
+
// `{id|raw|id}`. The identifier is remembered, so only `|id}` closes
|
|
188
|
+
// the literal and a body can hold `|other}`.
|
|
189
|
+
{ match: '\\{([a-z_]*)\\|', scope: 'string', push: 'quoted-string', remember: 1 },
|
|
181
190
|
{ match: '"', scope: 'string', push: 'string' },
|
|
182
191
|
// A char literal closes; a type variable does not. The lookbehind is
|
|
183
192
|
// what keeps the trailing quote of `acc'` from opening one.
|
|
@@ -195,7 +204,7 @@ const ocaml = {
|
|
|
195
204
|
// Deliberately no escape rule: a quoted string literal is raw.
|
|
196
205
|
'quoted-string': {
|
|
197
206
|
default: 'string',
|
|
198
|
-
rules: [{ match: '\\|
|
|
207
|
+
rules: [{ match: '\\|{{remembered}}\\}', scope: 'string', pop: true }],
|
|
199
208
|
},
|
|
200
209
|
numbers: {
|
|
201
210
|
rules: [
|
package/dist/langs/php.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"php.d.ts","sourceRoot":"","sources":["../../src/langs/php.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"php.d.ts","sourceRoot":"","sources":["../../src/langs/php.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAwC5C,QAAA,MAAM,GAAG,EAAE,OAqXV,CAAA;AAED,eAAe,GAAG,CAAA"}
|
package/dist/langs/php.js
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Things worth knowing about:
|
|
10
10
|
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* - A snippet that does not open with markup is code. Code samples and
|
|
12
|
+
* docs routinely leave out `<?php`, and reading them as HTML would render
|
|
13
|
+
* the whole sample unscoped.
|
|
14
|
+
* - Heredocs and nowdocs remember their marker, so only the matching marker
|
|
15
|
+
* closes them.
|
|
14
16
|
* - `#` starts a comment but `#[` starts an attribute, so the attribute rule
|
|
15
17
|
* runs first and lets the argument list tokenize as ordinary PHP.
|
|
16
18
|
* - A line comment stops at `?>`, because PHP itself leaves code mode there.
|
|
@@ -23,20 +25,38 @@ const ID = '[A-Za-z_\\u0080-\\uFFFF][\\w\\u0080-\\uFFFF]*';
|
|
|
23
25
|
const NAME = `\\\\?${ID}(?:\\\\${ID})*`;
|
|
24
26
|
/** An HTML tag or attribute name, for the inline-markup mode. */
|
|
25
27
|
const TAG = '[A-Za-z_][\\w:.-]*';
|
|
28
|
+
/**
|
|
29
|
+
* PHP strings and comments own their delimiters: a quoted `?>` cannot end
|
|
30
|
+
* the region, and a quoted `</script>` cannot end its surrounding embed.
|
|
31
|
+
* Each alternative consumes a distinct prefix so unclosed regions stay linear.
|
|
32
|
+
*/
|
|
33
|
+
const PHP_REGION = String.raw `<\?(?:php\b|=)(?:"(?:\\[\s\S]|[^"\\])*(?:"|(?![\s\S]))|'(?:\\[\s\S]|[^'\\])*(?:'|(?![\s\S]))|/\*[^*]*(?:\*(?!/)[^*]*)*(?:\*/|(?![\s\S]))|(?:\/\/|#(?!\[))(?:(?!\?>)[^\n])*|[^"'/?#]|/(?![/*])|\?(?!>)|#(?=\[))*(?:\?>|(?![\s\S]))`;
|
|
26
34
|
const php = {
|
|
27
35
|
name: 'php',
|
|
28
36
|
aliases: ['php3', 'php4', 'php5', 'php8'],
|
|
29
37
|
states: {
|
|
30
38
|
// ---- inline markup -----------------------------------------------------
|
|
31
|
-
// Outside `<?php … ?>` a PHP file is HTML. It is scoped rather than
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
39
|
+
// Outside `<?php … ?>` a PHP file is HTML. It is scoped here rather than
|
|
40
|
+
// handed to the HTML grammar, because a PHP region can open anywhere in
|
|
41
|
+
// it — inside a tag, inside an attribute value — and an embedded grammar
|
|
42
|
+
// cut off there would lose its place. Only `<script>` and `<style>` bodies,
|
|
43
|
+
// where nothing else in the markup applies, are handed to their languages.
|
|
44
|
+
// Picks the starting mode and is never seen again: input that opens with
|
|
45
|
+
// markup is a template, anything else is code without its `<?php`. Both
|
|
46
|
+
// rules are zero-width, so the first token is tokenized by the mode chosen.
|
|
35
47
|
root: {
|
|
48
|
+
rules: [
|
|
49
|
+
{ match: '(?=\\s*<(?!<<))', set: 'markup' },
|
|
50
|
+
{ match: '(?=[\\s\\S])', set: 'code' },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
markup: {
|
|
36
54
|
ignoreCase: true,
|
|
37
55
|
rules: [
|
|
38
56
|
{ match: '<\\?(?:php\\b|=)', scope: 'tag', push: 'php' },
|
|
39
57
|
{ match: '<!--', scope: 'comment', push: 'html-comment' },
|
|
58
|
+
{ match: '(<)(script)(?=[\\s/>])', scope: ['punctuation.bracket', 'tag'], push: 'script-tag' },
|
|
59
|
+
{ match: '(<)(style)(?=[\\s/>])', scope: ['punctuation.bracket', 'tag'], push: 'style-tag' },
|
|
40
60
|
{
|
|
41
61
|
match: `(</?)(${TAG})`,
|
|
42
62
|
scope: ['punctuation.bracket', 'tag'],
|
|
@@ -44,6 +64,36 @@ const php = {
|
|
|
44
64
|
},
|
|
45
65
|
],
|
|
46
66
|
},
|
|
67
|
+
// `<script>` and `<style>` bodies are JavaScript and CSS, when those are
|
|
68
|
+
// registered. A PHP region inside one is a hole: the embedded language
|
|
69
|
+
// reads straight across it, so `"<?= $name ?>"` stays inside its string,
|
|
70
|
+
// and the region itself is tokenized as PHP.
|
|
71
|
+
'script-tag': {
|
|
72
|
+
ignoreCase: true,
|
|
73
|
+
rules: [
|
|
74
|
+
{ match: '/>', scope: 'punctuation.bracket', pop: true },
|
|
75
|
+
{ match: '>', scope: 'punctuation.bracket', set: 'script-body' },
|
|
76
|
+
{ include: 'html-tag' },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
'script-body': {
|
|
80
|
+
ignoreCase: true,
|
|
81
|
+
embed: { language: 'javascript', until: '</script(?=[\\s/>])', holes: PHP_REGION },
|
|
82
|
+
rules: [],
|
|
83
|
+
},
|
|
84
|
+
'style-tag': {
|
|
85
|
+
ignoreCase: true,
|
|
86
|
+
rules: [
|
|
87
|
+
{ match: '/>', scope: 'punctuation.bracket', pop: true },
|
|
88
|
+
{ match: '>', scope: 'punctuation.bracket', set: 'style-body' },
|
|
89
|
+
{ include: 'html-tag' },
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
'style-body': {
|
|
93
|
+
ignoreCase: true,
|
|
94
|
+
embed: { language: 'css', until: '</style(?=[\\s/>])', holes: PHP_REGION },
|
|
95
|
+
rules: [],
|
|
96
|
+
},
|
|
47
97
|
/** Markup and PHP block comments. Neither form nests. */
|
|
48
98
|
'html-comment': {
|
|
49
99
|
default: 'comment',
|
|
@@ -75,6 +125,10 @@ const php = {
|
|
|
75
125
|
php: {
|
|
76
126
|
rules: [{ match: '\\?>', scope: 'tag', pop: true }, { include: 'expression' }],
|
|
77
127
|
},
|
|
128
|
+
/** Code the input opened with. There is no markup below it to pop back to. */
|
|
129
|
+
code: {
|
|
130
|
+
rules: [{ match: '\\?>', scope: 'tag', set: 'markup' }, { include: 'expression' }],
|
|
131
|
+
},
|
|
78
132
|
expression: {
|
|
79
133
|
rules: [
|
|
80
134
|
// Before the comment rules: `#[` opens an attribute, `#` a comment.
|
|
@@ -208,11 +262,12 @@ const php = {
|
|
|
208
262
|
rules: [
|
|
209
263
|
// Nowdoc before heredoc: they differ only by the quotes on the marker,
|
|
210
264
|
// and only the heredoc interpolates.
|
|
211
|
-
{ match: `<<<[ \\t]*'${ID}'`, scope: 'string.special', push: 'nowdoc' },
|
|
265
|
+
{ match: `<<<[ \\t]*'(${ID})'`, scope: 'string.special', push: 'nowdoc', remember: 1 },
|
|
212
266
|
{
|
|
213
|
-
match: `<<<[ \\t]*"
|
|
267
|
+
match: `<<<[ \\t]*"?(${ID})"?`,
|
|
214
268
|
scope: 'string.special',
|
|
215
269
|
push: 'heredoc',
|
|
270
|
+
remember: 1,
|
|
216
271
|
},
|
|
217
272
|
{ match: '"', scope: 'string', push: 'string-double' },
|
|
218
273
|
{ match: "'", scope: 'string', push: 'string-single' },
|
|
@@ -271,21 +326,16 @@ const php = {
|
|
|
271
326
|
rules: [{ include: 'escapes' }, { include: 'interpolation' }, { match: '`', scope: 'string', pop: true }],
|
|
272
327
|
},
|
|
273
328
|
/**
|
|
274
|
-
* The closing marker of a heredoc or a nowdoc
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* and group numbers shift when rules merge — so any identifier alone on a
|
|
278
|
-
* line, optionally trailed by the punctuation a heredoc can end with
|
|
279
|
-
* (`;`, `,`, `)`, `]`), closes the body. A body line that is a single bare
|
|
280
|
-
* word therefore ends it early. That is rare in the SQL, HTML and shell
|
|
281
|
-
* text heredocs actually carry, and the alternative is not closing at all.
|
|
329
|
+
* The closing marker of a heredoc or a nowdoc: the remembered opening
|
|
330
|
+
* marker, alone on its line apart from the punctuation a heredoc can end
|
|
331
|
+
* with (`;`, `,`, `)`, `]`). PHP 7.3 lets it be indented with the body.
|
|
282
332
|
*/
|
|
283
333
|
'heredoc-end': {
|
|
284
334
|
rules: [
|
|
285
335
|
// The indent stays string-coloured, so only the marker itself stands
|
|
286
|
-
// out
|
|
336
|
+
// out.
|
|
287
337
|
{
|
|
288
|
-
match: '^([ \\t]*)(
|
|
338
|
+
match: '^([ \\t]*)({{remembered}})(?![\\w\\u0080-\\uFFFF])',
|
|
289
339
|
scope: [null, 'string.special'],
|
|
290
340
|
pop: true,
|
|
291
341
|
},
|
package/dist/langs/r.js
CHANGED
|
@@ -209,12 +209,13 @@ const r = {
|
|
|
209
209
|
strings: {
|
|
210
210
|
rules: [
|
|
211
211
|
// A raw string is `r"(…)"`, with any of three bracket pairs and any
|
|
212
|
-
// number of dashes for padding.
|
|
213
|
-
//
|
|
212
|
+
// number of dashes for padding. The dashes are remembered, so only a
|
|
213
|
+
// closer with the same run ends the literal.
|
|
214
214
|
{
|
|
215
|
-
match: '([rR])(["\'][
|
|
215
|
+
match: '([rR])(["\'](-*)[(\\[{])',
|
|
216
216
|
scope: ['string.special', 'string'],
|
|
217
217
|
push: 'raw-string',
|
|
218
|
+
remember: 3,
|
|
218
219
|
},
|
|
219
220
|
{ match: '"', scope: 'string', push: 'string-double' },
|
|
220
221
|
{ match: "'", scope: 'string', push: 'string-single' },
|
|
@@ -240,7 +241,7 @@ const r = {
|
|
|
240
241
|
// R strings may span lines, but an unterminated one should not swallow
|
|
241
242
|
// the file. Stopping at a blank line is the compromise: it is never
|
|
242
243
|
// inside a real literal, and it bounds the damage to one paragraph.
|
|
243
|
-
{ match: '\\n[ \\t]*\\n', pop: true },
|
|
244
|
+
{ match: '\\n[ \\t\\r]*\\n', pop: true },
|
|
244
245
|
],
|
|
245
246
|
},
|
|
246
247
|
'string-single': {
|
|
@@ -248,17 +249,16 @@ const r = {
|
|
|
248
249
|
rules: [
|
|
249
250
|
{ include: 'string-body' },
|
|
250
251
|
{ match: "'", scope: 'string', pop: true },
|
|
251
|
-
{ match: '\\n[ \\t]*\\n', pop: true },
|
|
252
|
+
{ match: '\\n[ \\t\\r]*\\n', pop: true },
|
|
252
253
|
],
|
|
253
254
|
},
|
|
254
255
|
/**
|
|
255
|
-
* Raw string contents: no escapes, and the closer is a bracket
|
|
256
|
-
*
|
|
257
|
-
* ends the literal early.
|
|
256
|
+
* Raw string contents: no escapes, and the closer is a bracket, the
|
|
257
|
+
* remembered dashes and a quote.
|
|
258
258
|
*/
|
|
259
259
|
'raw-string': {
|
|
260
260
|
default: 'string',
|
|
261
|
-
rules: [{ match: '[)\\]}][
|
|
261
|
+
rules: [{ match: '[)\\]}]{{remembered}}["\']', pop: true }],
|
|
262
262
|
},
|
|
263
263
|
},
|
|
264
264
|
};
|
package/dist/langs/rust.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/langs/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;;GAKG;AACH,QAAA,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/langs/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;;GAKG;AACH,QAAA,MAAM,IAAI,EAAE,OA+HX,CAAA;AAED,eAAe,IAAI,CAAA"}
|
package/dist/langs/rust.js
CHANGED
|
@@ -12,17 +12,15 @@ const rust = {
|
|
|
12
12
|
rules: [
|
|
13
13
|
{ match: '//[/!][^\\n]*', scope: 'comment.doc' },
|
|
14
14
|
{ match: '//[^\\n]*', scope: 'comment' },
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
15
|
+
// Block comments nest in Rust, so the state pushes itself.
|
|
16
|
+
{ match: '/\\*', scope: 'comment', push: 'block-comment' },
|
|
17
|
+
// Raw strings close with a quote and as many hashes as opened them,
|
|
18
|
+
// which the state remembers. No escapes inside.
|
|
18
19
|
{
|
|
19
|
-
match: '(b?r
|
|
20
|
-
scope: ['string.special', 'string'],
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
match: '(b?r)("(?:[^"\\\\]|\\\\.)*")',
|
|
25
|
-
scope: ['string.special', 'string'],
|
|
20
|
+
match: '(b?r)(#*)(")',
|
|
21
|
+
scope: ['string.special', 'string.special', 'string'],
|
|
22
|
+
push: 'raw-string',
|
|
23
|
+
remember: 2,
|
|
26
24
|
},
|
|
27
25
|
{
|
|
28
26
|
match: '(b?)(")',
|
|
@@ -111,6 +109,17 @@ const rust = {
|
|
|
111
109
|
{ match: '"', scope: 'string', pop: true },
|
|
112
110
|
],
|
|
113
111
|
},
|
|
112
|
+
'block-comment': {
|
|
113
|
+
default: 'comment',
|
|
114
|
+
rules: [
|
|
115
|
+
{ match: '/\\*', scope: 'comment', push: 'block-comment' },
|
|
116
|
+
{ match: '\\*/', scope: 'comment', pop: true },
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
'raw-string': {
|
|
120
|
+
default: 'string',
|
|
121
|
+
rules: [{ match: '"{{remembered}}', scope: 'string', pop: true }],
|
|
122
|
+
},
|
|
114
123
|
},
|
|
115
124
|
};
|
|
116
125
|
export default rust;
|
package/dist/langs/sql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/langs/sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,uCAAuC;AACvC,QAAA,MAAM,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/langs/sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,uCAAuC;AACvC,QAAA,MAAM,GAAG,EAAE,OAqEV,CAAA;AAED,eAAe,GAAG,CAAA"}
|
package/dist/langs/sql.js
CHANGED
|
@@ -8,7 +8,9 @@ const sql = {
|
|
|
8
8
|
rules: [
|
|
9
9
|
{ match: '--[^\\n]*', scope: 'comment' },
|
|
10
10
|
{ match: '#[^\\n]*', scope: 'comment' },
|
|
11
|
-
|
|
11
|
+
// A state, not a lazy `[\\s\\S]*?` scan: that form runs to EOF and fails
|
|
12
|
+
// once per opener, which is O(n²) on a run of unterminated `/*`.
|
|
13
|
+
{ match: '/\\*', scope: 'comment', push: 'block-comment' },
|
|
12
14
|
// Doubled quotes are the escape, so a literal never ends early.
|
|
13
15
|
{ match: "'(?:[^']|'')*'", scope: 'string' },
|
|
14
16
|
{ match: '"(?:[^"]|"")*"', scope: 'variable.member' },
|
|
@@ -17,7 +19,7 @@ const sql = {
|
|
|
17
19
|
// and allowing a bare `[` makes a line of brackets cost O(n) each.
|
|
18
20
|
{ match: '\\[[^[\\]]*\\]', scope: 'variable.member' },
|
|
19
21
|
{
|
|
20
|
-
match: '\\b(?:select|from|where|group|by|order|having|limit|offset|join|inner|left|right|full|outer|cross|lateral|on|using|union|intersect|except|with|recursive|case|when|then|else|end|distinct|returning|fetch|next|rows?|only)\\b',
|
|
22
|
+
match: '\\b(?:select|from|where|group|by|order|having|limit|offset|join|inner|left|right|full|outer|cross|lateral|on|using|union|intersect|except|with|recursive|case|when|then|else|end|distinct|returning|fetch|next|rows?|only|declare|print|go|exec|execute|return|returns|while|loop|for|call|connect|prior|merge|matched|raise|exception|elsif|immediate)\\b',
|
|
21
23
|
scope: 'keyword.control',
|
|
22
24
|
},
|
|
23
25
|
{
|
|
@@ -31,7 +33,7 @@ const sql = {
|
|
|
31
33
|
{ match: '\\b(?:null)\\b', scope: 'constant.builtin' },
|
|
32
34
|
{ match: '\\b(?:true|false)\\b', scope: 'boolean' },
|
|
33
35
|
{
|
|
34
|
-
match: '\\b(?:int|integer|bigint|smallint|serial|bigserial|decimal|numeric|real|double|precision|float|money|char|varchar|text|bytea|timestamp|timestamptz|date|time|interval|boolean|bool|uuid|json|jsonb|array|enum|blob)\\b',
|
|
36
|
+
match: '\\b(?:int|integer|bigint|smallint|serial|bigserial|decimal|numeric|real|double|precision|float|money|char|varchar|text|bytea|timestamp|timestamptz|date|time|interval|boolean|bool|uuid|json|jsonb|array|enum|blob|varchar2|nvarchar2?|nchar|number|binary|varbinary|tinyint|datetime2?|bit|clob|nclob|character|dec|xml)\\b',
|
|
35
37
|
scope: 'type.builtin',
|
|
36
38
|
},
|
|
37
39
|
{
|
|
@@ -52,6 +54,10 @@ const sql = {
|
|
|
52
54
|
{ match: '[,;.]', scope: 'punctuation.delimiter' },
|
|
53
55
|
],
|
|
54
56
|
},
|
|
57
|
+
'block-comment': {
|
|
58
|
+
default: 'comment',
|
|
59
|
+
rules: [{ match: '\\*/', scope: 'comment', pop: true }],
|
|
60
|
+
},
|
|
55
61
|
},
|
|
56
62
|
};
|
|
57
63
|
export default sql;
|
package/dist/langs/yaml.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import type { Grammar } from '../core/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* YAML.
|
|
4
|
-
*
|
|
5
|
-
* Keys are the load-bearing thing in a YAML file, so they are matched from the
|
|
6
|
-
* line start and scoped separately from their values. Block scalars (`|`, `>`)
|
|
7
|
-
* switch into a literal state so their contents are not re-parsed as YAML.
|
|
8
|
-
*/
|
|
9
2
|
declare const yaml: Grammar;
|
|
10
3
|
export default yaml;
|
|
11
4
|
//# sourceMappingURL=yaml.d.ts.map
|
package/dist/langs/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../src/langs/yaml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../src/langs/yaml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAuC5C,QAAA,MAAM,IAAI,EAAE,OAiPX,CAAA;AAED,eAAe,IAAI,CAAA"}
|