dobo 2.0.1 → 2.2.1
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/.github/FUNDING.yml +0 -0
- package/.github/workflows/repo-lockdown.yml +0 -0
- package/.jsdoc.conf.json +0 -0
- package/LICENSE +0 -0
- package/README.md +2 -2
- package/docs/Dobo.html +0 -0
- package/docs/data/search.json +0 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +0 -0
- package/docs/index.html +0 -0
- package/docs/index.js.html +0 -0
- package/docs/lib_collect-connections.js.html +0 -0
- package/docs/lib_collect-drivers.js.html +0 -0
- package/docs/lib_collect-features.js.html +0 -0
- package/docs/lib_collect-schemas.js.html +0 -0
- package/docs/lib_index.js.html +0 -0
- package/docs/method_model_create.js.html +0 -0
- package/docs/method_model_drop.js.html +0 -0
- package/docs/method_model_exists.js.html +0 -0
- package/docs/method_record_count.js.html +0 -0
- package/docs/method_record_create.js.html +0 -0
- package/docs/method_record_find-all.js.html +0 -0
- package/docs/method_record_find-one.js.html +0 -0
- package/docs/method_record_find.js.html +0 -0
- package/docs/method_record_get.js.html +0 -0
- package/docs/method_record_remove.js.html +0 -0
- package/docs/method_record_update.js.html +0 -0
- package/docs/method_record_upsert.js.html +0 -0
- package/docs/method_sanitize_body.js.html +0 -0
- package/docs/method_sanitize_date.js.html +0 -0
- package/docs/method_sanitize_id.js.html +0 -0
- package/docs/method_validate.js.html +0 -0
- package/docs/module-Lib.html +0 -0
- package/docs/scripts/core.js +476 -477
- package/docs/scripts/core.min.js +0 -0
- package/docs/scripts/resize.js +36 -36
- package/docs/scripts/search.js +105 -105
- package/docs/scripts/search.min.js +0 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
- package/docs/scripts/third-party/fuse.js +1 -1
- package/docs/scripts/third-party/hljs-line-num-original.js +282 -285
- package/docs/scripts/third-party/hljs-line-num.js +1 -1
- package/docs/scripts/third-party/hljs-original.js +1195 -1202
- package/docs/scripts/third-party/hljs.js +1 -1
- package/docs/scripts/third-party/popper.js +1 -1
- package/docs/scripts/third-party/tippy.js +1 -1
- package/docs/scripts/third-party/tocbot.js +508 -509
- package/docs/scripts/third-party/tocbot.min.js +0 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/static/home.md +0 -0
- package/docs/static/logo-ecosystem.png +0 -0
- package/docs/static/logo.png +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +0 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
- package/docs/styles/clean-jsdoc-theme-light.css +0 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
- package/docs/styles/clean-jsdoc-theme.min.css +0 -0
- package/extend/bajo/intl/en-US.json +66 -28
- package/extend/bajo/intl/id.json +55 -27
- package/extend/bajoCli/applet/clear-record.js +22 -0
- package/extend/bajoCli/applet/connection.js +0 -0
- package/extend/bajoCli/applet/count-record.js +27 -0
- package/extend/bajoCli/applet/create-aggregate.js +33 -0
- package/extend/bajoCli/applet/create-histogram.js +33 -0
- package/extend/bajoCli/applet/create-record.js +39 -0
- package/extend/bajoCli/applet/find-record.js +27 -0
- package/extend/bajoCli/applet/get-record.js +27 -0
- package/extend/bajoCli/applet/lib/post-process.js +10 -17
- package/extend/bajoCli/applet/model.js +22 -0
- package/extend/bajoCli/applet/rebuild-model.js +91 -0
- package/extend/bajoCli/applet/remove-record.js +27 -0
- package/extend/bajoCli/applet/update-record.js +44 -0
- package/extend/bajoCli/applet.js +0 -0
- package/extend/dobo/driver/memory.js +170 -0
- package/extend/dobo/feature/created-at.js +9 -7
- package/extend/dobo/feature/dt.js +0 -0
- package/extend/dobo/feature/immutable.js +30 -0
- package/extend/dobo/feature/int-id.js +0 -0
- package/extend/dobo/feature/removed-at.js +32 -54
- package/extend/dobo/feature/updated-at.js +14 -12
- package/extend/waibuMpa/route/attachment/@model/@id/@field/@file.js +2 -6
- package/extend/waibuStatic/virtual.json +0 -0
- package/index.js +284 -371
- package/lib/collect-connections.js +49 -21
- package/lib/collect-drivers.js +19 -33
- package/lib/collect-features.js +24 -17
- package/lib/collect-models.js +321 -0
- package/lib/factory/action.js +161 -0
- package/lib/factory/connection.js +62 -0
- package/lib/factory/driver.js +372 -0
- package/lib/factory/feature.js +33 -0
- package/lib/factory/model/_util.js +402 -0
- package/lib/factory/model/build.js +15 -0
- package/lib/factory/model/clear-record.js +17 -0
- package/lib/factory/model/count-record.js +17 -0
- package/lib/factory/model/create-aggregate.js +17 -0
- package/lib/factory/model/create-attachment.js +29 -0
- package/lib/factory/model/create-histogram.js +17 -0
- package/lib/factory/model/create-record.js +35 -0
- package/lib/factory/model/drop.js +15 -0
- package/lib/factory/model/exists.js +21 -0
- package/lib/factory/model/find-all-record.js +71 -0
- package/lib/factory/model/find-attachment.js +29 -0
- package/lib/factory/model/find-one-record.js +19 -0
- package/{method/record/find.js → lib/factory/model/find-record.js} +103 -115
- package/lib/factory/model/get-attachment.js +15 -0
- package/lib/factory/model/get-record.js +79 -0
- package/lib/factory/model/list-attachment.js +37 -0
- package/lib/{add-fixtures.js → factory/model/load-fixtures.js} +69 -67
- package/lib/factory/model/remove-attachment.js +15 -0
- package/lib/factory/model/remove-record.js +59 -0
- package/lib/factory/model/sanitize-body.js +56 -0
- package/lib/factory/model/sanitize-id.js +7 -0
- package/lib/factory/model/sanitize-record.js +26 -0
- package/lib/factory/model/update-attachment.js +9 -0
- package/lib/factory/model/update-record.js +81 -0
- package/lib/factory/model/upsert-record.js +95 -0
- package/{method → lib/factory/model}/validate.js +38 -52
- package/lib/factory/model.js +150 -0
- package/lib/index.js +0 -0
- package/package.json +8 -4
- package/wiki/APPLETS.md +0 -0
- package/wiki/CHANGES.md +50 -0
- package/wiki/CONFIG.md +0 -0
- package/wiki/CONTRIBUTING.md +0 -0
- package/wiki/DEV-GUIDE.md +0 -0
- package/wiki/ECOSYSTEM.md +0 -0
- package/wiki/GETTING-STARTED.md +10 -10
- package/wiki/QUERY-LANGUAGE.md +0 -0
- package/wiki/USER-GUIDE.md +0 -0
- package/extend/bajoCli/applet/model-clear.js +0 -11
- package/extend/bajoCli/applet/model-rebuild.js +0 -101
- package/extend/bajoCli/applet/record-create.js +0 -43
- package/extend/bajoCli/applet/record-find.js +0 -28
- package/extend/bajoCli/applet/record-get.js +0 -24
- package/extend/bajoCli/applet/record-remove.js +0 -24
- package/extend/bajoCli/applet/record-update.js +0 -47
- package/extend/bajoCli/applet/schema.js +0 -22
- package/extend/bajoCli/applet/stat-count.js +0 -24
- package/lib/build-bulk-action.js +0 -12
- package/lib/check-unique.js +0 -39
- package/lib/collect-schemas.js +0 -91
- package/lib/exec-feature-hook.js +0 -13
- package/lib/exec-validation.js +0 -21
- package/lib/generic-prop-sanitizer.js +0 -32
- package/lib/handle-attachment-upload.js +0 -16
- package/lib/mem-db/conn-sanitizer.js +0 -8
- package/lib/mem-db/instantiate.js +0 -41
- package/lib/mem-db/method/model/clear.js +0 -6
- package/lib/mem-db/method/model/create.js +0 -5
- package/lib/mem-db/method/model/drop.js +0 -5
- package/lib/mem-db/method/model/exists.js +0 -5
- package/lib/mem-db/method/record/create.js +0 -12
- package/lib/mem-db/method/record/find.js +0 -20
- package/lib/mem-db/method/record/get.js +0 -9
- package/lib/mem-db/method/record/remove.js +0 -13
- package/lib/mem-db/method/record/update.js +0 -15
- package/lib/mem-db/method/stat/count.js +0 -11
- package/lib/mem-db/start.js +0 -25
- package/lib/merge-attachment-info.js +0 -16
- package/lib/multi-rel-rows.js +0 -42
- package/lib/resolve-method.js +0 -16
- package/lib/sanitize-schema.js +0 -198
- package/lib/single-rel-rows.js +0 -38
- package/method/attachment/copy-uploaded.js +0 -34
- package/method/attachment/create.js +0 -29
- package/method/attachment/find.js +0 -27
- package/method/attachment/get-path.js +0 -12
- package/method/attachment/get.js +0 -12
- package/method/attachment/pre-check.js +0 -9
- package/method/attachment/remove.js +0 -11
- package/method/attachment/update.js +0 -7
- package/method/bulk/create.js +0 -46
- package/method/model/clear.js +0 -22
- package/method/model/create.js +0 -32
- package/method/model/drop.js +0 -31
- package/method/model/exists.js +0 -37
- package/method/record/clear.js +0 -24
- package/method/record/count.js +0 -66
- package/method/record/create.js +0 -111
- package/method/record/find-all.js +0 -41
- package/method/record/find-one.js +0 -70
- package/method/record/get.js +0 -89
- package/method/record/remove.js +0 -72
- package/method/record/update.js +0 -104
- package/method/record/upsert.js +0 -51
- package/method/sanitize/body.js +0 -85
- package/method/sanitize/date.js +0 -27
- package/method/sanitize/id.js +0 -17
- package/method/stat/aggregate.js +0 -23
- package/method/stat/histogram.js +0 -26
|
@@ -3,42 +3,41 @@
|
|
|
3
3
|
(c) 2006-2021 Ivan Sagalaev and other contributors
|
|
4
4
|
License: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
'use strict'
|
|
6
|
+
const hljs = (function () {
|
|
7
|
+
'use strict'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const deepFreezeEs6 = { exports: {} }
|
|
10
10
|
|
|
11
|
-
function deepFreeze(obj) {
|
|
11
|
+
function deepFreeze (obj) {
|
|
12
12
|
if (obj instanceof Map) {
|
|
13
13
|
obj.clear = obj.delete = obj.set = function () {
|
|
14
|
-
throw new Error('map is read-only')
|
|
15
|
-
}
|
|
14
|
+
throw new Error('map is read-only')
|
|
15
|
+
}
|
|
16
16
|
} else if (obj instanceof Set) {
|
|
17
17
|
obj.add = obj.clear = obj.delete = function () {
|
|
18
|
-
throw new Error('set is read-only')
|
|
19
|
-
}
|
|
18
|
+
throw new Error('set is read-only')
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// Freeze self
|
|
23
|
-
Object.freeze(obj)
|
|
23
|
+
Object.freeze(obj)
|
|
24
24
|
|
|
25
25
|
Object.getOwnPropertyNames(obj).forEach(function (name) {
|
|
26
|
-
|
|
26
|
+
const prop = obj[name]
|
|
27
27
|
|
|
28
28
|
// Freeze prop if it is an object
|
|
29
|
-
if (typeof prop
|
|
30
|
-
deepFreeze(prop)
|
|
29
|
+
if (typeof prop === 'object' && !Object.isFrozen(prop)) {
|
|
30
|
+
deepFreeze(prop)
|
|
31
31
|
}
|
|
32
|
-
})
|
|
32
|
+
})
|
|
33
33
|
|
|
34
|
-
return obj
|
|
34
|
+
return obj
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
deepFreezeEs6.exports = deepFreeze
|
|
38
|
-
deepFreezeEs6.exports.default = deepFreeze
|
|
39
|
-
|
|
40
|
-
var deepFreeze$1 = deepFreezeEs6.exports;
|
|
37
|
+
deepFreezeEs6.exports = deepFreeze
|
|
38
|
+
deepFreezeEs6.exports.default = deepFreeze
|
|
41
39
|
|
|
40
|
+
const deepFreeze$1 = deepFreezeEs6.exports
|
|
42
41
|
|
|
43
42
|
/** @typedef {import('highlight.js').CompiledMode} CompiledMode */
|
|
44
43
|
/** @implements CallbackResponse */
|
|
@@ -47,16 +46,16 @@ var hljs = (function () {
|
|
|
47
46
|
/**
|
|
48
47
|
* @param {CompiledMode} mode
|
|
49
48
|
*/
|
|
50
|
-
constructor(mode) {
|
|
49
|
+
constructor (mode) {
|
|
51
50
|
// eslint-disable-next-line no-undefined
|
|
52
|
-
if (mode.data === undefined) mode.data = {}
|
|
51
|
+
if (mode.data === undefined) mode.data = {}
|
|
53
52
|
|
|
54
|
-
this.data = mode.data
|
|
55
|
-
this.isMatchIgnored = false
|
|
53
|
+
this.data = mode.data
|
|
54
|
+
this.isMatchIgnored = false
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
ignoreMatch() {
|
|
59
|
-
this.isMatchIgnored = true
|
|
57
|
+
ignoreMatch () {
|
|
58
|
+
this.isMatchIgnored = true
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -64,13 +63,13 @@ var hljs = (function () {
|
|
|
64
63
|
* @param {string} value
|
|
65
64
|
* @returns {string}
|
|
66
65
|
*/
|
|
67
|
-
function escapeHTML(value) {
|
|
66
|
+
function escapeHTML (value) {
|
|
68
67
|
return value
|
|
69
68
|
.replace(/&/g, '&')
|
|
70
69
|
.replace(/</g, '<')
|
|
71
70
|
.replace(/>/g, '>')
|
|
72
71
|
.replace(/"/g, '"')
|
|
73
|
-
.replace(/'/g, ''')
|
|
72
|
+
.replace(/'/g, ''')
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
/**
|
|
@@ -81,19 +80,19 @@ var hljs = (function () {
|
|
|
81
80
|
* @param {Record<string,any>[]} objects
|
|
82
81
|
* @returns {T} a single new object
|
|
83
82
|
*/
|
|
84
|
-
function inherit$1(original, ...objects) {
|
|
83
|
+
function inherit$1 (original, ...objects) {
|
|
85
84
|
/** @type Record<string,any> */
|
|
86
|
-
const result = Object.create(null)
|
|
85
|
+
const result = Object.create(null)
|
|
87
86
|
|
|
88
87
|
for (const key in original) {
|
|
89
|
-
result[key] = original[key]
|
|
88
|
+
result[key] = original[key]
|
|
90
89
|
}
|
|
91
90
|
objects.forEach(function (obj) {
|
|
92
91
|
for (const key in obj) {
|
|
93
|
-
result[key] = obj[key]
|
|
92
|
+
result[key] = obj[key]
|
|
94
93
|
}
|
|
95
|
-
})
|
|
96
|
-
return /** @type {T} */ (result)
|
|
94
|
+
})
|
|
95
|
+
return /** @type {T} */ (result)
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
/**
|
|
@@ -108,15 +107,15 @@ var hljs = (function () {
|
|
|
108
107
|
/** @typedef {{walk: (r: Renderer) => void}} Tree */
|
|
109
108
|
/** */
|
|
110
109
|
|
|
111
|
-
const SPAN_CLOSE = '</span>'
|
|
110
|
+
const SPAN_CLOSE = '</span>'
|
|
112
111
|
|
|
113
112
|
/**
|
|
114
113
|
* Determines if a node needs to be wrapped in <span>
|
|
115
114
|
*
|
|
116
115
|
* @param {Node} node */
|
|
117
116
|
const emitsWrappingTags = (node) => {
|
|
118
|
-
return !!node.kind
|
|
119
|
-
}
|
|
117
|
+
return !!node.kind
|
|
118
|
+
}
|
|
120
119
|
|
|
121
120
|
/**
|
|
122
121
|
*
|
|
@@ -124,15 +123,15 @@ var hljs = (function () {
|
|
|
124
123
|
* @param {{prefix:string}} options
|
|
125
124
|
*/
|
|
126
125
|
const expandScopeName = (name, { prefix }) => {
|
|
127
|
-
if (name.includes(
|
|
128
|
-
const pieces = name.split(
|
|
126
|
+
if (name.includes('.')) {
|
|
127
|
+
const pieces = name.split('.')
|
|
129
128
|
return [
|
|
130
129
|
`${prefix}${pieces.shift()}`,
|
|
131
|
-
...(pieces.map((x, i) => `${x}${
|
|
132
|
-
].join(
|
|
130
|
+
...(pieces.map((x, i) => `${x}${'_'.repeat(i + 1)}`))
|
|
131
|
+
].join(' ')
|
|
133
132
|
}
|
|
134
|
-
return `${prefix}${name}
|
|
135
|
-
}
|
|
133
|
+
return `${prefix}${name}`
|
|
134
|
+
}
|
|
136
135
|
|
|
137
136
|
/** @type {Renderer} */
|
|
138
137
|
class HTMLRenderer {
|
|
@@ -142,51 +141,51 @@ var hljs = (function () {
|
|
|
142
141
|
* @param {Tree} parseTree - the parse tree (must support `walk` API)
|
|
143
142
|
* @param {{classPrefix: string}} options
|
|
144
143
|
*/
|
|
145
|
-
constructor(parseTree, options) {
|
|
146
|
-
this.buffer =
|
|
147
|
-
this.classPrefix = options.classPrefix
|
|
148
|
-
parseTree.walk(this)
|
|
144
|
+
constructor (parseTree, options) {
|
|
145
|
+
this.buffer = ''
|
|
146
|
+
this.classPrefix = options.classPrefix
|
|
147
|
+
parseTree.walk(this)
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
/**
|
|
152
151
|
* Adds texts to the output stream
|
|
153
152
|
*
|
|
154
153
|
* @param {string} text */
|
|
155
|
-
addText(text) {
|
|
156
|
-
this.buffer += escapeHTML(text)
|
|
154
|
+
addText (text) {
|
|
155
|
+
this.buffer += escapeHTML(text)
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
/**
|
|
160
159
|
* Adds a node open to the output stream (if needed)
|
|
161
160
|
*
|
|
162
161
|
* @param {Node} node */
|
|
163
|
-
openNode(node) {
|
|
164
|
-
if (!emitsWrappingTags(node)) return
|
|
162
|
+
openNode (node) {
|
|
163
|
+
if (!emitsWrappingTags(node)) return
|
|
165
164
|
|
|
166
|
-
let scope = node.kind
|
|
165
|
+
let scope = node.kind
|
|
167
166
|
if (node.sublanguage) {
|
|
168
|
-
scope = `language-${scope}
|
|
167
|
+
scope = `language-${scope}`
|
|
169
168
|
} else {
|
|
170
|
-
scope = expandScopeName(scope, { prefix: this.classPrefix })
|
|
169
|
+
scope = expandScopeName(scope, { prefix: this.classPrefix })
|
|
171
170
|
}
|
|
172
|
-
this.span(scope)
|
|
171
|
+
this.span(scope)
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
/**
|
|
176
175
|
* Adds a node close to the output stream (if needed)
|
|
177
176
|
*
|
|
178
177
|
* @param {Node} node */
|
|
179
|
-
closeNode(node) {
|
|
180
|
-
if (!emitsWrappingTags(node)) return
|
|
178
|
+
closeNode (node) {
|
|
179
|
+
if (!emitsWrappingTags(node)) return
|
|
181
180
|
|
|
182
|
-
this.buffer += SPAN_CLOSE
|
|
181
|
+
this.buffer += SPAN_CLOSE
|
|
183
182
|
}
|
|
184
183
|
|
|
185
184
|
/**
|
|
186
185
|
* returns the accumulated buffer
|
|
187
186
|
*/
|
|
188
|
-
value() {
|
|
189
|
-
return this.buffer
|
|
187
|
+
value () {
|
|
188
|
+
return this.buffer
|
|
190
189
|
}
|
|
191
190
|
|
|
192
191
|
// helpers
|
|
@@ -195,8 +194,8 @@ var hljs = (function () {
|
|
|
195
194
|
* Builds a span element
|
|
196
195
|
*
|
|
197
196
|
* @param {string} className */
|
|
198
|
-
span(className) {
|
|
199
|
-
this.buffer += `<span class="${className}"
|
|
197
|
+
span (className) {
|
|
198
|
+
this.buffer += `<span class="${className}">`
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
|
|
@@ -206,54 +205,54 @@ var hljs = (function () {
|
|
|
206
205
|
/** */
|
|
207
206
|
|
|
208
207
|
class TokenTree {
|
|
209
|
-
constructor() {
|
|
208
|
+
constructor () {
|
|
210
209
|
/** @type DataNode */
|
|
211
|
-
this.rootNode = { children: [] }
|
|
212
|
-
this.stack = [this.rootNode]
|
|
210
|
+
this.rootNode = { children: [] }
|
|
211
|
+
this.stack = [this.rootNode]
|
|
213
212
|
}
|
|
214
213
|
|
|
215
|
-
get top() {
|
|
216
|
-
return this.stack[this.stack.length - 1]
|
|
214
|
+
get top () {
|
|
215
|
+
return this.stack[this.stack.length - 1]
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
get root() { return this.rootNode
|
|
218
|
+
get root () { return this.rootNode }
|
|
220
219
|
|
|
221
220
|
/** @param {Node} node */
|
|
222
|
-
add(node) {
|
|
223
|
-
this.top.children.push(node)
|
|
221
|
+
add (node) {
|
|
222
|
+
this.top.children.push(node)
|
|
224
223
|
}
|
|
225
224
|
|
|
226
225
|
/** @param {string} kind */
|
|
227
|
-
openNode(kind) {
|
|
226
|
+
openNode (kind) {
|
|
228
227
|
/** @type Node */
|
|
229
|
-
const node = { kind, children: [] }
|
|
230
|
-
this.add(node)
|
|
231
|
-
this.stack.push(node)
|
|
228
|
+
const node = { kind, children: [] }
|
|
229
|
+
this.add(node)
|
|
230
|
+
this.stack.push(node)
|
|
232
231
|
}
|
|
233
232
|
|
|
234
|
-
closeNode() {
|
|
233
|
+
closeNode () {
|
|
235
234
|
if (this.stack.length > 1) {
|
|
236
|
-
return this.stack.pop()
|
|
235
|
+
return this.stack.pop()
|
|
237
236
|
}
|
|
238
237
|
// eslint-disable-next-line no-undefined
|
|
239
|
-
return undefined
|
|
238
|
+
return undefined
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
closeAllNodes() {
|
|
241
|
+
closeAllNodes () {
|
|
243
242
|
while (this.closeNode());
|
|
244
243
|
}
|
|
245
244
|
|
|
246
|
-
toJSON() {
|
|
247
|
-
return JSON.stringify(this.rootNode, null, 4)
|
|
245
|
+
toJSON () {
|
|
246
|
+
return JSON.stringify(this.rootNode, null, 4)
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
/**
|
|
251
250
|
* @typedef { import("./html_renderer").Renderer } Renderer
|
|
252
251
|
* @param {Renderer} builder
|
|
253
252
|
*/
|
|
254
|
-
walk(builder) {
|
|
253
|
+
walk (builder) {
|
|
255
254
|
// this does not
|
|
256
|
-
return this.constructor._walk(builder, this.rootNode)
|
|
255
|
+
return this.constructor._walk(builder, this.rootNode)
|
|
257
256
|
// this works
|
|
258
257
|
// return TokenTree._walk(builder, this.rootNode);
|
|
259
258
|
}
|
|
@@ -262,32 +261,32 @@ var hljs = (function () {
|
|
|
262
261
|
* @param {Renderer} builder
|
|
263
262
|
* @param {Node} node
|
|
264
263
|
*/
|
|
265
|
-
static _walk(builder, node) {
|
|
266
|
-
if (typeof node ===
|
|
267
|
-
builder.addText(node)
|
|
264
|
+
static _walk (builder, node) {
|
|
265
|
+
if (typeof node === 'string') {
|
|
266
|
+
builder.addText(node)
|
|
268
267
|
} else if (node.children) {
|
|
269
|
-
builder.openNode(node)
|
|
270
|
-
node.children.forEach((child) => this._walk(builder, child))
|
|
271
|
-
builder.closeNode(node)
|
|
268
|
+
builder.openNode(node)
|
|
269
|
+
node.children.forEach((child) => this._walk(builder, child))
|
|
270
|
+
builder.closeNode(node)
|
|
272
271
|
}
|
|
273
|
-
return builder
|
|
272
|
+
return builder
|
|
274
273
|
}
|
|
275
274
|
|
|
276
275
|
/**
|
|
277
276
|
* @param {Node} node
|
|
278
277
|
*/
|
|
279
|
-
static _collapse(node) {
|
|
280
|
-
if (typeof node ===
|
|
281
|
-
if (!node.children) return
|
|
278
|
+
static _collapse (node) {
|
|
279
|
+
if (typeof node === 'string') return
|
|
280
|
+
if (!node.children) return
|
|
282
281
|
|
|
283
|
-
if (node.children.every(el => typeof el ===
|
|
282
|
+
if (node.children.every(el => typeof el === 'string')) {
|
|
284
283
|
// node.text = node.children.join("");
|
|
285
284
|
// delete node.children;
|
|
286
|
-
node.children = [node.children.join(
|
|
285
|
+
node.children = [node.children.join('')]
|
|
287
286
|
} else {
|
|
288
287
|
node.children.forEach((child) => {
|
|
289
|
-
TokenTree._collapse(child)
|
|
290
|
-
})
|
|
288
|
+
TokenTree._collapse(child)
|
|
289
|
+
})
|
|
291
290
|
}
|
|
292
291
|
}
|
|
293
292
|
}
|
|
@@ -316,51 +315,51 @@ var hljs = (function () {
|
|
|
316
315
|
/**
|
|
317
316
|
* @param {*} options
|
|
318
317
|
*/
|
|
319
|
-
constructor(options) {
|
|
320
|
-
super()
|
|
321
|
-
this.options = options
|
|
318
|
+
constructor (options) {
|
|
319
|
+
super()
|
|
320
|
+
this.options = options
|
|
322
321
|
}
|
|
323
322
|
|
|
324
323
|
/**
|
|
325
324
|
* @param {string} text
|
|
326
325
|
* @param {string} kind
|
|
327
326
|
*/
|
|
328
|
-
addKeyword(text, kind) {
|
|
329
|
-
if (text ===
|
|
327
|
+
addKeyword (text, kind) {
|
|
328
|
+
if (text === '') { return }
|
|
330
329
|
|
|
331
|
-
this.openNode(kind)
|
|
332
|
-
this.addText(text)
|
|
333
|
-
this.closeNode()
|
|
330
|
+
this.openNode(kind)
|
|
331
|
+
this.addText(text)
|
|
332
|
+
this.closeNode()
|
|
334
333
|
}
|
|
335
334
|
|
|
336
335
|
/**
|
|
337
336
|
* @param {string} text
|
|
338
337
|
*/
|
|
339
|
-
addText(text) {
|
|
340
|
-
if (text ===
|
|
338
|
+
addText (text) {
|
|
339
|
+
if (text === '') { return }
|
|
341
340
|
|
|
342
|
-
this.add(text)
|
|
341
|
+
this.add(text)
|
|
343
342
|
}
|
|
344
343
|
|
|
345
344
|
/**
|
|
346
345
|
* @param {Emitter & {root: DataNode}} emitter
|
|
347
346
|
* @param {string} name
|
|
348
347
|
*/
|
|
349
|
-
addSublanguage(emitter, name) {
|
|
348
|
+
addSublanguage (emitter, name) {
|
|
350
349
|
/** @type DataNode */
|
|
351
|
-
const node = emitter.root
|
|
352
|
-
node.kind = name
|
|
353
|
-
node.sublanguage = true
|
|
354
|
-
this.add(node)
|
|
350
|
+
const node = emitter.root
|
|
351
|
+
node.kind = name
|
|
352
|
+
node.sublanguage = true
|
|
353
|
+
this.add(node)
|
|
355
354
|
}
|
|
356
355
|
|
|
357
|
-
toHTML() {
|
|
358
|
-
const renderer = new HTMLRenderer(this, this.options)
|
|
359
|
-
return renderer.value()
|
|
356
|
+
toHTML () {
|
|
357
|
+
const renderer = new HTMLRenderer(this, this.options)
|
|
358
|
+
return renderer.value()
|
|
360
359
|
}
|
|
361
360
|
|
|
362
|
-
finalize() {
|
|
363
|
-
return true
|
|
361
|
+
finalize () {
|
|
362
|
+
return true
|
|
364
363
|
}
|
|
365
364
|
}
|
|
366
365
|
|
|
@@ -373,46 +372,46 @@ var hljs = (function () {
|
|
|
373
372
|
* @param {RegExp | string } re
|
|
374
373
|
* @returns {string}
|
|
375
374
|
*/
|
|
376
|
-
function source(re) {
|
|
377
|
-
if (!re) return null
|
|
378
|
-
if (typeof re ===
|
|
375
|
+
function source (re) {
|
|
376
|
+
if (!re) return null
|
|
377
|
+
if (typeof re === 'string') return re
|
|
379
378
|
|
|
380
|
-
return re.source
|
|
379
|
+
return re.source
|
|
381
380
|
}
|
|
382
381
|
|
|
383
382
|
/**
|
|
384
383
|
* @param {RegExp | string } re
|
|
385
384
|
* @returns {string}
|
|
386
385
|
*/
|
|
387
|
-
function lookahead(re) {
|
|
388
|
-
return concat('(?=', re, ')')
|
|
386
|
+
function lookahead (re) {
|
|
387
|
+
return concat('(?=', re, ')')
|
|
389
388
|
}
|
|
390
389
|
|
|
391
390
|
/**
|
|
392
391
|
* @param {RegExp | string } re
|
|
393
392
|
* @returns {string}
|
|
394
393
|
*/
|
|
395
|
-
function optional(re) {
|
|
396
|
-
return concat('(?:', re, ')?')
|
|
394
|
+
function optional (re) {
|
|
395
|
+
return concat('(?:', re, ')?')
|
|
397
396
|
}
|
|
398
397
|
|
|
399
398
|
/**
|
|
400
399
|
* @param {...(RegExp | string) } args
|
|
401
400
|
* @returns {string}
|
|
402
401
|
*/
|
|
403
|
-
function concat(...args) {
|
|
404
|
-
const joined = args.map((x) => source(x)).join(
|
|
405
|
-
return joined
|
|
402
|
+
function concat (...args) {
|
|
403
|
+
const joined = args.map((x) => source(x)).join('')
|
|
404
|
+
return joined
|
|
406
405
|
}
|
|
407
406
|
|
|
408
|
-
function stripOptionsFromArgs(args) {
|
|
409
|
-
const opts = args[args.length - 1]
|
|
407
|
+
function stripOptionsFromArgs (args) {
|
|
408
|
+
const opts = args[args.length - 1]
|
|
410
409
|
|
|
411
410
|
if (typeof opts === 'object' && opts.constructor === Object) {
|
|
412
|
-
args.splice(args.length - 1, 1)
|
|
413
|
-
return opts
|
|
411
|
+
args.splice(args.length - 1, 1)
|
|
412
|
+
return opts
|
|
414
413
|
} else {
|
|
415
|
-
return {}
|
|
414
|
+
return {}
|
|
416
415
|
}
|
|
417
416
|
}
|
|
418
417
|
|
|
@@ -423,20 +422,20 @@ var hljs = (function () {
|
|
|
423
422
|
* @param {(RegExp | string)[] } args
|
|
424
423
|
* @returns {string}
|
|
425
424
|
*/
|
|
426
|
-
function either(...args) {
|
|
427
|
-
const opts = stripOptionsFromArgs(args)
|
|
425
|
+
function either (...args) {
|
|
426
|
+
const opts = stripOptionsFromArgs(args)
|
|
428
427
|
const joined = '(' +
|
|
429
|
-
(opts.capture ?
|
|
430
|
-
args.map((x) => source(x)).join(
|
|
431
|
-
return joined
|
|
428
|
+
(opts.capture ? '' : '?:') +
|
|
429
|
+
args.map((x) => source(x)).join('|') + ')'
|
|
430
|
+
return joined
|
|
432
431
|
}
|
|
433
432
|
|
|
434
433
|
/**
|
|
435
434
|
* @param {RegExp} re
|
|
436
435
|
* @returns {number}
|
|
437
436
|
*/
|
|
438
|
-
function countMatchGroups(re) {
|
|
439
|
-
return (new RegExp(re.toString() + '|')).exec('').length - 1
|
|
437
|
+
function countMatchGroups (re) {
|
|
438
|
+
return (new RegExp(re.toString() + '|')).exec('').length - 1
|
|
440
439
|
}
|
|
441
440
|
|
|
442
441
|
/**
|
|
@@ -444,9 +443,9 @@ var hljs = (function () {
|
|
|
444
443
|
* @param {RegExp} re
|
|
445
444
|
* @param {string} lexeme
|
|
446
445
|
*/
|
|
447
|
-
function startsWith(re, lexeme) {
|
|
448
|
-
const match = re && re.exec(lexeme)
|
|
449
|
-
return match && match.index === 0
|
|
446
|
+
function startsWith (re, lexeme) {
|
|
447
|
+
const match = re && re.exec(lexeme)
|
|
448
|
+
return match && match.index === 0
|
|
450
449
|
}
|
|
451
450
|
|
|
452
451
|
// BACKREF_RE matches an open parenthesis or backreference. To avoid
|
|
@@ -456,7 +455,7 @@ var hljs = (function () {
|
|
|
456
455
|
// interesting elements
|
|
457
456
|
// - non-matching or lookahead parentheses, which do not capture. These
|
|
458
457
|
// follow the '(' with a '?'.
|
|
459
|
-
const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)
|
|
458
|
+
const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./
|
|
460
459
|
|
|
461
460
|
// **INTERNAL** Not intended for outside usage
|
|
462
461
|
// join logically computes regexps.join(separator), but fixes the
|
|
@@ -469,60 +468,60 @@ var hljs = (function () {
|
|
|
469
468
|
* @param {{joinWith: string}} opts
|
|
470
469
|
* @returns {string}
|
|
471
470
|
*/
|
|
472
|
-
function _rewriteBackreferences(regexps, { joinWith }) {
|
|
473
|
-
let numCaptures = 0
|
|
471
|
+
function _rewriteBackreferences (regexps, { joinWith }) {
|
|
472
|
+
let numCaptures = 0
|
|
474
473
|
|
|
475
474
|
return regexps.map((regex) => {
|
|
476
|
-
numCaptures += 1
|
|
477
|
-
const offset = numCaptures
|
|
478
|
-
let re = source(regex)
|
|
479
|
-
let out = ''
|
|
475
|
+
numCaptures += 1
|
|
476
|
+
const offset = numCaptures
|
|
477
|
+
let re = source(regex)
|
|
478
|
+
let out = ''
|
|
480
479
|
|
|
481
480
|
while (re.length > 0) {
|
|
482
|
-
const match = BACKREF_RE.exec(re)
|
|
481
|
+
const match = BACKREF_RE.exec(re)
|
|
483
482
|
if (!match) {
|
|
484
|
-
out += re
|
|
485
|
-
break
|
|
483
|
+
out += re
|
|
484
|
+
break
|
|
486
485
|
}
|
|
487
|
-
out += re.substring(0, match.index)
|
|
488
|
-
re = re.substring(match.index + match[0].length)
|
|
486
|
+
out += re.substring(0, match.index)
|
|
487
|
+
re = re.substring(match.index + match[0].length)
|
|
489
488
|
if (match[0][0] === '\\' && match[1]) {
|
|
490
489
|
// Adjust the backreference.
|
|
491
|
-
out += '\\' + String(Number(match[1]) + offset)
|
|
490
|
+
out += '\\' + String(Number(match[1]) + offset)
|
|
492
491
|
} else {
|
|
493
|
-
out += match[0]
|
|
492
|
+
out += match[0]
|
|
494
493
|
if (match[0] === '(') {
|
|
495
|
-
numCaptures
|
|
494
|
+
numCaptures++
|
|
496
495
|
}
|
|
497
496
|
}
|
|
498
497
|
}
|
|
499
|
-
return out
|
|
500
|
-
}).map(re => `(${re})`).join(joinWith)
|
|
498
|
+
return out
|
|
499
|
+
}).map(re => `(${re})`).join(joinWith)
|
|
501
500
|
}
|
|
502
501
|
|
|
503
502
|
/** @typedef {import('highlight.js').Mode} Mode */
|
|
504
503
|
/** @typedef {import('highlight.js').ModeCallback} ModeCallback */
|
|
505
504
|
|
|
506
505
|
// Common regexps
|
|
507
|
-
const MATCH_NOTHING_RE = /\b\B
|
|
508
|
-
const IDENT_RE$1 = '[a-zA-Z]\\w*'
|
|
509
|
-
const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'
|
|
510
|
-
const NUMBER_RE = '\\b\\d+(\\.\\d+)?'
|
|
511
|
-
const C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'
|
|
512
|
-
const BINARY_NUMBER_RE = '\\b(0b[01]+)'
|
|
513
|
-
const RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~'
|
|
506
|
+
const MATCH_NOTHING_RE = /\b\B/
|
|
507
|
+
const IDENT_RE$1 = '[a-zA-Z]\\w*'
|
|
508
|
+
const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'
|
|
509
|
+
const NUMBER_RE = '\\b\\d+(\\.\\d+)?'
|
|
510
|
+
const C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)' // 0x..., 0..., decimal, float
|
|
511
|
+
const BINARY_NUMBER_RE = '\\b(0b[01]+)' // 0b...
|
|
512
|
+
const RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~'
|
|
514
513
|
|
|
515
514
|
/**
|
|
516
515
|
* @param { Partial<Mode> & {binary?: string | RegExp} } opts
|
|
517
516
|
*/
|
|
518
517
|
const SHEBANG = (opts = {}) => {
|
|
519
|
-
const beginShebang = /^#![ ]
|
|
518
|
+
const beginShebang = /^#![ ]*\//
|
|
520
519
|
if (opts.binary) {
|
|
521
520
|
opts.begin = concat(
|
|
522
521
|
beginShebang,
|
|
523
522
|
/.*\b/,
|
|
524
523
|
opts.binary,
|
|
525
|
-
/\b.*/)
|
|
524
|
+
/\b.*/)
|
|
526
525
|
}
|
|
527
526
|
return inherit$1({
|
|
528
527
|
scope: 'meta',
|
|
@@ -530,33 +529,33 @@ var hljs = (function () {
|
|
|
530
529
|
end: /$/,
|
|
531
530
|
relevance: 0,
|
|
532
531
|
/** @type {ModeCallback} */
|
|
533
|
-
|
|
534
|
-
if (m.index !== 0) resp.ignoreMatch()
|
|
532
|
+
'on:begin': (m, resp) => {
|
|
533
|
+
if (m.index !== 0) resp.ignoreMatch()
|
|
535
534
|
}
|
|
536
|
-
}, opts)
|
|
537
|
-
}
|
|
535
|
+
}, opts)
|
|
536
|
+
}
|
|
538
537
|
|
|
539
538
|
// Common modes
|
|
540
539
|
const BACKSLASH_ESCAPE = {
|
|
541
540
|
begin: '\\\\[\\s\\S]', relevance: 0
|
|
542
|
-
}
|
|
541
|
+
}
|
|
543
542
|
const APOS_STRING_MODE = {
|
|
544
543
|
scope: 'string',
|
|
545
544
|
begin: '\'',
|
|
546
545
|
end: '\'',
|
|
547
546
|
illegal: '\\n',
|
|
548
547
|
contains: [BACKSLASH_ESCAPE]
|
|
549
|
-
}
|
|
548
|
+
}
|
|
550
549
|
const QUOTE_STRING_MODE = {
|
|
551
550
|
scope: 'string',
|
|
552
551
|
begin: '"',
|
|
553
552
|
end: '"',
|
|
554
553
|
illegal: '\\n',
|
|
555
554
|
contains: [BACKSLASH_ESCAPE]
|
|
556
|
-
}
|
|
555
|
+
}
|
|
557
556
|
const PHRASAL_WORDS_MODE = {
|
|
558
557
|
begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
|
|
559
|
-
}
|
|
558
|
+
}
|
|
560
559
|
/**
|
|
561
560
|
* Creates a comment mode
|
|
562
561
|
*
|
|
@@ -574,7 +573,7 @@ var hljs = (function () {
|
|
|
574
573
|
contains: []
|
|
575
574
|
},
|
|
576
575
|
modeOptions
|
|
577
|
-
)
|
|
576
|
+
)
|
|
578
577
|
mode.contains.push({
|
|
579
578
|
scope: 'doctag',
|
|
580
579
|
// hack to avoid the space from being included. the space is necessary to
|
|
@@ -583,25 +582,25 @@ var hljs = (function () {
|
|
|
583
582
|
end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
|
|
584
583
|
excludeBegin: true,
|
|
585
584
|
relevance: 0
|
|
586
|
-
})
|
|
585
|
+
})
|
|
587
586
|
const ENGLISH_WORD = either(
|
|
588
587
|
// list of common 1 and 2 letter words in English
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
588
|
+
'I',
|
|
589
|
+
'a',
|
|
590
|
+
'is',
|
|
591
|
+
'so',
|
|
592
|
+
'us',
|
|
593
|
+
'to',
|
|
594
|
+
'at',
|
|
595
|
+
'if',
|
|
596
|
+
'in',
|
|
597
|
+
'it',
|
|
598
|
+
'on',
|
|
600
599
|
// note: this is not an exhaustive list of contractions, just popular ones
|
|
601
600
|
/[A-Za-z]+['](d|ve|re|ll|t|s|n)/, // contractions - can't we'd they're let's, etc
|
|
602
601
|
/[A-Za-z]+[-][a-z]+/, // `no-way`, etc.
|
|
603
602
|
/[A-Za-z][a-z]{2,}/ // allow capitalized words at beginning of sentences
|
|
604
|
-
)
|
|
603
|
+
)
|
|
605
604
|
// looking like plain text, more likely to be a comment
|
|
606
605
|
mode.contains.push(
|
|
607
606
|
{
|
|
@@ -627,27 +626,27 @@ var hljs = (function () {
|
|
|
627
626
|
/[.]?[:]?([.][ ]|[ ])/,
|
|
628
627
|
'){3}') // look for 3 words in a row
|
|
629
628
|
}
|
|
630
|
-
)
|
|
631
|
-
return mode
|
|
632
|
-
}
|
|
633
|
-
const C_LINE_COMMENT_MODE = COMMENT('//', '$')
|
|
634
|
-
const C_BLOCK_COMMENT_MODE = COMMENT('/\\*', '\\*/')
|
|
635
|
-
const HASH_COMMENT_MODE = COMMENT('#', '$')
|
|
629
|
+
)
|
|
630
|
+
return mode
|
|
631
|
+
}
|
|
632
|
+
const C_LINE_COMMENT_MODE = COMMENT('//', '$')
|
|
633
|
+
const C_BLOCK_COMMENT_MODE = COMMENT('/\\*', '\\*/')
|
|
634
|
+
const HASH_COMMENT_MODE = COMMENT('#', '$')
|
|
636
635
|
const NUMBER_MODE = {
|
|
637
636
|
scope: 'number',
|
|
638
637
|
begin: NUMBER_RE,
|
|
639
638
|
relevance: 0
|
|
640
|
-
}
|
|
639
|
+
}
|
|
641
640
|
const C_NUMBER_MODE = {
|
|
642
641
|
scope: 'number',
|
|
643
642
|
begin: C_NUMBER_RE,
|
|
644
643
|
relevance: 0
|
|
645
|
-
}
|
|
644
|
+
}
|
|
646
645
|
const BINARY_NUMBER_MODE = {
|
|
647
646
|
scope: 'number',
|
|
648
647
|
begin: BINARY_NUMBER_RE,
|
|
649
648
|
relevance: 0
|
|
650
|
-
}
|
|
649
|
+
}
|
|
651
650
|
const REGEXP_MODE = {
|
|
652
651
|
// this outer rule makes sure we actually have a WHOLE regex and not simply
|
|
653
652
|
// an expression such as:
|
|
@@ -671,22 +670,22 @@ var hljs = (function () {
|
|
|
671
670
|
}
|
|
672
671
|
]
|
|
673
672
|
}]
|
|
674
|
-
}
|
|
673
|
+
}
|
|
675
674
|
const TITLE_MODE = {
|
|
676
675
|
scope: 'title',
|
|
677
676
|
begin: IDENT_RE$1,
|
|
678
677
|
relevance: 0
|
|
679
|
-
}
|
|
678
|
+
}
|
|
680
679
|
const UNDERSCORE_TITLE_MODE = {
|
|
681
680
|
scope: 'title',
|
|
682
681
|
begin: UNDERSCORE_IDENT_RE,
|
|
683
682
|
relevance: 0
|
|
684
|
-
}
|
|
683
|
+
}
|
|
685
684
|
const METHOD_GUARD = {
|
|
686
685
|
// excludes method names from keyword processing
|
|
687
686
|
begin: '\\.\\s*' + UNDERSCORE_IDENT_RE,
|
|
688
687
|
relevance: 0
|
|
689
|
-
}
|
|
688
|
+
}
|
|
690
689
|
|
|
691
690
|
/**
|
|
692
691
|
* Adds end same as begin mechanics to a mode
|
|
@@ -699,39 +698,39 @@ var hljs = (function () {
|
|
|
699
698
|
return Object.assign(mode,
|
|
700
699
|
{
|
|
701
700
|
/** @type {ModeCallback} */
|
|
702
|
-
'on:begin': (m, resp) => { resp.data._beginMatch = m[1]
|
|
701
|
+
'on:begin': (m, resp) => { resp.data._beginMatch = m[1] },
|
|
703
702
|
/** @type {ModeCallback} */
|
|
704
|
-
'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch()
|
|
705
|
-
})
|
|
706
|
-
}
|
|
703
|
+
'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch() }
|
|
704
|
+
})
|
|
705
|
+
}
|
|
707
706
|
|
|
708
|
-
|
|
707
|
+
const MODES$1 = /* #__PURE__ */Object.freeze({
|
|
709
708
|
__proto__: null,
|
|
710
|
-
MATCH_NOTHING_RE
|
|
709
|
+
MATCH_NOTHING_RE,
|
|
711
710
|
IDENT_RE: IDENT_RE$1,
|
|
712
|
-
UNDERSCORE_IDENT_RE
|
|
713
|
-
NUMBER_RE
|
|
714
|
-
C_NUMBER_RE
|
|
715
|
-
BINARY_NUMBER_RE
|
|
716
|
-
RE_STARTERS_RE
|
|
717
|
-
SHEBANG
|
|
718
|
-
BACKSLASH_ESCAPE
|
|
719
|
-
APOS_STRING_MODE
|
|
720
|
-
QUOTE_STRING_MODE
|
|
721
|
-
PHRASAL_WORDS_MODE
|
|
722
|
-
COMMENT
|
|
723
|
-
C_LINE_COMMENT_MODE
|
|
724
|
-
C_BLOCK_COMMENT_MODE
|
|
725
|
-
HASH_COMMENT_MODE
|
|
726
|
-
NUMBER_MODE
|
|
727
|
-
C_NUMBER_MODE
|
|
728
|
-
BINARY_NUMBER_MODE
|
|
729
|
-
REGEXP_MODE
|
|
730
|
-
TITLE_MODE
|
|
731
|
-
UNDERSCORE_TITLE_MODE
|
|
732
|
-
METHOD_GUARD
|
|
733
|
-
END_SAME_AS_BEGIN
|
|
734
|
-
})
|
|
711
|
+
UNDERSCORE_IDENT_RE,
|
|
712
|
+
NUMBER_RE,
|
|
713
|
+
C_NUMBER_RE,
|
|
714
|
+
BINARY_NUMBER_RE,
|
|
715
|
+
RE_STARTERS_RE,
|
|
716
|
+
SHEBANG,
|
|
717
|
+
BACKSLASH_ESCAPE,
|
|
718
|
+
APOS_STRING_MODE,
|
|
719
|
+
QUOTE_STRING_MODE,
|
|
720
|
+
PHRASAL_WORDS_MODE,
|
|
721
|
+
COMMENT,
|
|
722
|
+
C_LINE_COMMENT_MODE,
|
|
723
|
+
C_BLOCK_COMMENT_MODE,
|
|
724
|
+
HASH_COMMENT_MODE,
|
|
725
|
+
NUMBER_MODE,
|
|
726
|
+
C_NUMBER_MODE,
|
|
727
|
+
BINARY_NUMBER_MODE,
|
|
728
|
+
REGEXP_MODE,
|
|
729
|
+
TITLE_MODE,
|
|
730
|
+
UNDERSCORE_TITLE_MODE,
|
|
731
|
+
METHOD_GUARD,
|
|
732
|
+
END_SAME_AS_BEGIN
|
|
733
|
+
})
|
|
735
734
|
|
|
736
735
|
/**
|
|
737
736
|
@typedef {import('highlight.js').CallbackResponse} CallbackResponse
|
|
@@ -762,10 +761,10 @@ var hljs = (function () {
|
|
|
762
761
|
* @param {RegExpMatchArray} match
|
|
763
762
|
* @param {CallbackResponse} response
|
|
764
763
|
*/
|
|
765
|
-
function skipIfHasPrecedingDot(match, response) {
|
|
766
|
-
const before = match.input[match.index - 1]
|
|
767
|
-
if (before ===
|
|
768
|
-
response.ignoreMatch()
|
|
764
|
+
function skipIfHasPrecedingDot (match, response) {
|
|
765
|
+
const before = match.input[match.index - 1]
|
|
766
|
+
if (before === '.') {
|
|
767
|
+
response.ignoreMatch()
|
|
769
768
|
}
|
|
770
769
|
}
|
|
771
770
|
|
|
@@ -773,11 +772,11 @@ var hljs = (function () {
|
|
|
773
772
|
*
|
|
774
773
|
* @type {CompilerExt}
|
|
775
774
|
*/
|
|
776
|
-
function scopeClassName(mode, _parent) {
|
|
775
|
+
function scopeClassName (mode, _parent) {
|
|
777
776
|
// eslint-disable-next-line no-undefined
|
|
778
777
|
if (mode.className !== undefined) {
|
|
779
|
-
mode.scope = mode.className
|
|
780
|
-
delete mode.className
|
|
778
|
+
mode.scope = mode.className
|
|
779
|
+
delete mode.className
|
|
781
780
|
}
|
|
782
781
|
}
|
|
783
782
|
|
|
@@ -785,80 +784,80 @@ var hljs = (function () {
|
|
|
785
784
|
* `beginKeywords` syntactic sugar
|
|
786
785
|
* @type {CompilerExt}
|
|
787
786
|
*/
|
|
788
|
-
function beginKeywords(mode, parent) {
|
|
789
|
-
if (!parent) return
|
|
790
|
-
if (!mode.beginKeywords) return
|
|
787
|
+
function beginKeywords (mode, parent) {
|
|
788
|
+
if (!parent) return
|
|
789
|
+
if (!mode.beginKeywords) return
|
|
791
790
|
|
|
792
791
|
// for languages with keywords that include non-word characters checking for
|
|
793
792
|
// a word boundary is not sufficient, so instead we check for a word boundary
|
|
794
793
|
// or whitespace - this does no harm in any case since our keyword engine
|
|
795
794
|
// doesn't allow spaces in keywords anyways and we still check for the boundary
|
|
796
795
|
// first
|
|
797
|
-
mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)'
|
|
798
|
-
mode.__beforeBegin = skipIfHasPrecedingDot
|
|
799
|
-
mode.keywords = mode.keywords || mode.beginKeywords
|
|
800
|
-
delete mode.beginKeywords
|
|
796
|
+
mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)'
|
|
797
|
+
mode.__beforeBegin = skipIfHasPrecedingDot
|
|
798
|
+
mode.keywords = mode.keywords || mode.beginKeywords
|
|
799
|
+
delete mode.beginKeywords
|
|
801
800
|
|
|
802
801
|
// prevents double relevance, the keywords themselves provide
|
|
803
802
|
// relevance, the mode doesn't need to double it
|
|
804
803
|
// eslint-disable-next-line no-undefined
|
|
805
|
-
if (mode.relevance === undefined) mode.relevance = 0
|
|
804
|
+
if (mode.relevance === undefined) mode.relevance = 0
|
|
806
805
|
}
|
|
807
806
|
|
|
808
807
|
/**
|
|
809
808
|
* Allow `illegal` to contain an array of illegal values
|
|
810
809
|
* @type {CompilerExt}
|
|
811
810
|
*/
|
|
812
|
-
function compileIllegal(mode, _parent) {
|
|
813
|
-
if (!Array.isArray(mode.illegal)) return
|
|
811
|
+
function compileIllegal (mode, _parent) {
|
|
812
|
+
if (!Array.isArray(mode.illegal)) return
|
|
814
813
|
|
|
815
|
-
mode.illegal = either(...mode.illegal)
|
|
814
|
+
mode.illegal = either(...mode.illegal)
|
|
816
815
|
}
|
|
817
816
|
|
|
818
817
|
/**
|
|
819
818
|
* `match` to match a single expression for readability
|
|
820
819
|
* @type {CompilerExt}
|
|
821
820
|
*/
|
|
822
|
-
function compileMatch(mode, _parent) {
|
|
823
|
-
if (!mode.match) return
|
|
824
|
-
if (mode.begin || mode.end) throw new Error(
|
|
821
|
+
function compileMatch (mode, _parent) {
|
|
822
|
+
if (!mode.match) return
|
|
823
|
+
if (mode.begin || mode.end) throw new Error('begin & end are not supported with match')
|
|
825
824
|
|
|
826
|
-
mode.begin = mode.match
|
|
827
|
-
delete mode.match
|
|
825
|
+
mode.begin = mode.match
|
|
826
|
+
delete mode.match
|
|
828
827
|
}
|
|
829
828
|
|
|
830
829
|
/**
|
|
831
830
|
* provides the default 1 relevance to all modes
|
|
832
831
|
* @type {CompilerExt}
|
|
833
832
|
*/
|
|
834
|
-
function compileRelevance(mode, _parent) {
|
|
833
|
+
function compileRelevance (mode, _parent) {
|
|
835
834
|
// eslint-disable-next-line no-undefined
|
|
836
|
-
if (mode.relevance === undefined) mode.relevance = 1
|
|
835
|
+
if (mode.relevance === undefined) mode.relevance = 1
|
|
837
836
|
}
|
|
838
837
|
|
|
839
838
|
// allow beforeMatch to act as a "qualifier" for the match
|
|
840
839
|
// the full match begin must be [beforeMatch][begin]
|
|
841
840
|
const beforeMatchExt = (mode, parent) => {
|
|
842
|
-
if (!mode.beforeMatch) return
|
|
841
|
+
if (!mode.beforeMatch) return
|
|
843
842
|
// starts conflicts with endsParent which we need to make sure the child
|
|
844
843
|
// rule is not matched multiple times
|
|
845
|
-
if (mode.starts) throw new Error(
|
|
844
|
+
if (mode.starts) throw new Error('beforeMatch cannot be used with starts')
|
|
846
845
|
|
|
847
|
-
const originalMode = Object.assign({}, mode)
|
|
848
|
-
Object.keys(mode).forEach((key) => { delete mode[key]
|
|
846
|
+
const originalMode = Object.assign({}, mode)
|
|
847
|
+
Object.keys(mode).forEach((key) => { delete mode[key] })
|
|
849
848
|
|
|
850
|
-
mode.keywords = originalMode.keywords
|
|
851
|
-
mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin))
|
|
849
|
+
mode.keywords = originalMode.keywords
|
|
850
|
+
mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin))
|
|
852
851
|
mode.starts = {
|
|
853
852
|
relevance: 0,
|
|
854
853
|
contains: [
|
|
855
854
|
Object.assign(originalMode, { endsParent: true })
|
|
856
855
|
]
|
|
857
|
-
}
|
|
858
|
-
mode.relevance = 0
|
|
856
|
+
}
|
|
857
|
+
mode.relevance = 0
|
|
859
858
|
|
|
860
|
-
delete originalMode.beforeMatch
|
|
861
|
-
}
|
|
859
|
+
delete originalMode.beforeMatch
|
|
860
|
+
}
|
|
862
861
|
|
|
863
862
|
// keywords that should have no default relevance value
|
|
864
863
|
const COMMON_KEYWORDS = [
|
|
@@ -873,9 +872,9 @@ var hljs = (function () {
|
|
|
873
872
|
'parent', // common variable name
|
|
874
873
|
'list', // common variable name
|
|
875
874
|
'value' // common variable name
|
|
876
|
-
]
|
|
875
|
+
]
|
|
877
876
|
|
|
878
|
-
const DEFAULT_KEYWORD_SCOPE =
|
|
877
|
+
const DEFAULT_KEYWORD_SCOPE = 'keyword'
|
|
879
878
|
|
|
880
879
|
/**
|
|
881
880
|
* Given raw keywords from a language definition, compile them.
|
|
@@ -883,26 +882,26 @@ var hljs = (function () {
|
|
|
883
882
|
* @param {string | Record<string,string|string[]> | Array<string>} rawKeywords
|
|
884
883
|
* @param {boolean} caseInsensitive
|
|
885
884
|
*/
|
|
886
|
-
function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
|
|
885
|
+
function compileKeywords (rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
|
|
887
886
|
/** @type KeywordDict */
|
|
888
|
-
const compiledKeywords = Object.create(null)
|
|
887
|
+
const compiledKeywords = Object.create(null)
|
|
889
888
|
|
|
890
889
|
// input can be a string of keywords, an array of keywords, or a object with
|
|
891
890
|
// named keys representing scopeName (which can then point to a string or array)
|
|
892
891
|
if (typeof rawKeywords === 'string') {
|
|
893
|
-
compileList(scopeName, rawKeywords.split(
|
|
892
|
+
compileList(scopeName, rawKeywords.split(' '))
|
|
894
893
|
} else if (Array.isArray(rawKeywords)) {
|
|
895
|
-
compileList(scopeName, rawKeywords)
|
|
894
|
+
compileList(scopeName, rawKeywords)
|
|
896
895
|
} else {
|
|
897
896
|
Object.keys(rawKeywords).forEach(function (scopeName) {
|
|
898
897
|
// collapse all our objects back into the parent object
|
|
899
898
|
Object.assign(
|
|
900
899
|
compiledKeywords,
|
|
901
900
|
compileKeywords(rawKeywords[scopeName], caseInsensitive, scopeName)
|
|
902
|
-
)
|
|
903
|
-
})
|
|
901
|
+
)
|
|
902
|
+
})
|
|
904
903
|
}
|
|
905
|
-
return compiledKeywords
|
|
904
|
+
return compiledKeywords
|
|
906
905
|
|
|
907
906
|
// ---
|
|
908
907
|
|
|
@@ -914,14 +913,14 @@ var hljs = (function () {
|
|
|
914
913
|
* @param {string} scopeName
|
|
915
914
|
* @param {Array<string>} keywordList
|
|
916
915
|
*/
|
|
917
|
-
function compileList(scopeName, keywordList) {
|
|
916
|
+
function compileList (scopeName, keywordList) {
|
|
918
917
|
if (caseInsensitive) {
|
|
919
|
-
keywordList = keywordList.map(x => x.toLowerCase())
|
|
918
|
+
keywordList = keywordList.map(x => x.toLowerCase())
|
|
920
919
|
}
|
|
921
920
|
keywordList.forEach(function (keyword) {
|
|
922
|
-
const pair = keyword.split('|')
|
|
923
|
-
compiledKeywords[pair[0]] = [scopeName, scoreForKeyword(pair[0], pair[1])]
|
|
924
|
-
})
|
|
921
|
+
const pair = keyword.split('|')
|
|
922
|
+
compiledKeywords[pair[0]] = [scopeName, scoreForKeyword(pair[0], pair[1])]
|
|
923
|
+
})
|
|
925
924
|
}
|
|
926
925
|
}
|
|
927
926
|
|
|
@@ -933,22 +932,22 @@ var hljs = (function () {
|
|
|
933
932
|
* @param {string} keyword
|
|
934
933
|
* @param {string} [providedScore]
|
|
935
934
|
*/
|
|
936
|
-
function scoreForKeyword(keyword, providedScore) {
|
|
935
|
+
function scoreForKeyword (keyword, providedScore) {
|
|
937
936
|
// manual scores always win over common keywords
|
|
938
937
|
// so you can force a score of 1 if you really insist
|
|
939
938
|
if (providedScore) {
|
|
940
|
-
return Number(providedScore)
|
|
939
|
+
return Number(providedScore)
|
|
941
940
|
}
|
|
942
941
|
|
|
943
|
-
return commonKeyword(keyword) ? 0 : 1
|
|
942
|
+
return commonKeyword(keyword) ? 0 : 1
|
|
944
943
|
}
|
|
945
944
|
|
|
946
945
|
/**
|
|
947
946
|
* Determines if a given keyword is common or not
|
|
948
947
|
*
|
|
949
948
|
* @param {string} keyword */
|
|
950
|
-
function commonKeyword(keyword) {
|
|
951
|
-
return COMMON_KEYWORDS.includes(keyword.toLowerCase())
|
|
949
|
+
function commonKeyword (keyword) {
|
|
950
|
+
return COMMON_KEYWORDS.includes(keyword.toLowerCase())
|
|
952
951
|
}
|
|
953
952
|
|
|
954
953
|
/*
|
|
@@ -961,33 +960,33 @@ var hljs = (function () {
|
|
|
961
960
|
/**
|
|
962
961
|
* @type {Record<string, boolean>}
|
|
963
962
|
*/
|
|
964
|
-
const seenDeprecations = {}
|
|
963
|
+
const seenDeprecations = {}
|
|
965
964
|
|
|
966
965
|
/**
|
|
967
966
|
* @param {string} message
|
|
968
967
|
*/
|
|
969
968
|
const error = (message) => {
|
|
970
|
-
console.error(message)
|
|
971
|
-
}
|
|
969
|
+
console.error(message)
|
|
970
|
+
}
|
|
972
971
|
|
|
973
972
|
/**
|
|
974
973
|
* @param {string} message
|
|
975
974
|
* @param {any} args
|
|
976
975
|
*/
|
|
977
976
|
const warn = (message, ...args) => {
|
|
978
|
-
console.log(`WARN: ${message}`, ...args)
|
|
979
|
-
}
|
|
977
|
+
console.log(`WARN: ${message}`, ...args)
|
|
978
|
+
}
|
|
980
979
|
|
|
981
980
|
/**
|
|
982
981
|
* @param {string} version
|
|
983
982
|
* @param {string} message
|
|
984
983
|
*/
|
|
985
984
|
const deprecated = (version, message) => {
|
|
986
|
-
if (seenDeprecations[`${version}/${message}`]) return
|
|
985
|
+
if (seenDeprecations[`${version}/${message}`]) return
|
|
987
986
|
|
|
988
|
-
console.log(`Deprecated as of ${version}. ${message}`)
|
|
989
|
-
seenDeprecations[`${version}/${message}`] = true
|
|
990
|
-
}
|
|
987
|
+
console.log(`Deprecated as of ${version}. ${message}`)
|
|
988
|
+
seenDeprecations[`${version}/${message}`] = true
|
|
989
|
+
}
|
|
991
990
|
|
|
992
991
|
/* eslint-disable no-throw-literal */
|
|
993
992
|
|
|
@@ -995,7 +994,7 @@ var hljs = (function () {
|
|
|
995
994
|
@typedef {import('highlight.js').CompiledMode} CompiledMode
|
|
996
995
|
*/
|
|
997
996
|
|
|
998
|
-
const MultiClassError = new Error()
|
|
997
|
+
const MultiClassError = new Error()
|
|
999
998
|
|
|
1000
999
|
/**
|
|
1001
1000
|
* Renumbers labeled scope names to account for additional inner match
|
|
@@ -1025,64 +1024,64 @@ var hljs = (function () {
|
|
|
1025
1024
|
* @param {Array<RegExp>} regexes
|
|
1026
1025
|
* @param {{key: "beginScope"|"endScope"}} opts
|
|
1027
1026
|
*/
|
|
1028
|
-
function remapScopeNames(mode, regexes, { key }) {
|
|
1029
|
-
let offset = 0
|
|
1030
|
-
const scopeNames = mode[key]
|
|
1027
|
+
function remapScopeNames (mode, regexes, { key }) {
|
|
1028
|
+
let offset = 0
|
|
1029
|
+
const scopeNames = mode[key]
|
|
1031
1030
|
/** @type Record<number,boolean> */
|
|
1032
|
-
const emit = {}
|
|
1031
|
+
const emit = {}
|
|
1033
1032
|
/** @type Record<number,string> */
|
|
1034
|
-
const positions = {}
|
|
1033
|
+
const positions = {}
|
|
1035
1034
|
|
|
1036
1035
|
for (let i = 1; i <= regexes.length; i++) {
|
|
1037
|
-
positions[i + offset] = scopeNames[i]
|
|
1038
|
-
emit[i + offset] = true
|
|
1039
|
-
offset += countMatchGroups(regexes[i - 1])
|
|
1036
|
+
positions[i + offset] = scopeNames[i]
|
|
1037
|
+
emit[i + offset] = true
|
|
1038
|
+
offset += countMatchGroups(regexes[i - 1])
|
|
1040
1039
|
}
|
|
1041
1040
|
// we use _emit to keep track of which match groups are "top-level" to avoid double
|
|
1042
1041
|
// output from inside match groups
|
|
1043
|
-
mode[key] = positions
|
|
1044
|
-
mode[key]._emit = emit
|
|
1045
|
-
mode[key]._multi = true
|
|
1042
|
+
mode[key] = positions
|
|
1043
|
+
mode[key]._emit = emit
|
|
1044
|
+
mode[key]._multi = true
|
|
1046
1045
|
}
|
|
1047
1046
|
|
|
1048
1047
|
/**
|
|
1049
1048
|
* @param {CompiledMode} mode
|
|
1050
1049
|
*/
|
|
1051
|
-
function beginMultiClass(mode) {
|
|
1052
|
-
if (!Array.isArray(mode.begin)) return
|
|
1050
|
+
function beginMultiClass (mode) {
|
|
1051
|
+
if (!Array.isArray(mode.begin)) return
|
|
1053
1052
|
|
|
1054
1053
|
if (mode.skip || mode.excludeBegin || mode.returnBegin) {
|
|
1055
|
-
error(
|
|
1056
|
-
throw MultiClassError
|
|
1054
|
+
error('skip, excludeBegin, returnBegin not compatible with beginScope: {}')
|
|
1055
|
+
throw MultiClassError
|
|
1057
1056
|
}
|
|
1058
1057
|
|
|
1059
|
-
if (typeof mode.beginScope !==
|
|
1060
|
-
error(
|
|
1061
|
-
throw MultiClassError
|
|
1058
|
+
if (typeof mode.beginScope !== 'object' || mode.beginScope === null) {
|
|
1059
|
+
error('beginScope must be object')
|
|
1060
|
+
throw MultiClassError
|
|
1062
1061
|
}
|
|
1063
1062
|
|
|
1064
|
-
remapScopeNames(mode, mode.begin, { key:
|
|
1065
|
-
mode.begin = _rewriteBackreferences(mode.begin, { joinWith:
|
|
1063
|
+
remapScopeNames(mode, mode.begin, { key: 'beginScope' })
|
|
1064
|
+
mode.begin = _rewriteBackreferences(mode.begin, { joinWith: '' })
|
|
1066
1065
|
}
|
|
1067
1066
|
|
|
1068
1067
|
/**
|
|
1069
1068
|
* @param {CompiledMode} mode
|
|
1070
1069
|
*/
|
|
1071
|
-
function endMultiClass(mode) {
|
|
1072
|
-
if (!Array.isArray(mode.end)) return
|
|
1070
|
+
function endMultiClass (mode) {
|
|
1071
|
+
if (!Array.isArray(mode.end)) return
|
|
1073
1072
|
|
|
1074
1073
|
if (mode.skip || mode.excludeEnd || mode.returnEnd) {
|
|
1075
|
-
error(
|
|
1076
|
-
throw MultiClassError
|
|
1074
|
+
error('skip, excludeEnd, returnEnd not compatible with endScope: {}')
|
|
1075
|
+
throw MultiClassError
|
|
1077
1076
|
}
|
|
1078
1077
|
|
|
1079
|
-
if (typeof mode.endScope !==
|
|
1080
|
-
error(
|
|
1081
|
-
throw MultiClassError
|
|
1078
|
+
if (typeof mode.endScope !== 'object' || mode.endScope === null) {
|
|
1079
|
+
error('endScope must be object')
|
|
1080
|
+
throw MultiClassError
|
|
1082
1081
|
}
|
|
1083
1082
|
|
|
1084
|
-
remapScopeNames(mode, mode.end, { key:
|
|
1085
|
-
mode.end = _rewriteBackreferences(mode.end, { joinWith:
|
|
1083
|
+
remapScopeNames(mode, mode.end, { key: 'endScope' })
|
|
1084
|
+
mode.end = _rewriteBackreferences(mode.end, { joinWith: '' })
|
|
1086
1085
|
}
|
|
1087
1086
|
|
|
1088
1087
|
/**
|
|
@@ -1096,28 +1095,28 @@ var hljs = (function () {
|
|
|
1096
1095
|
|
|
1097
1096
|
* @param {CompiledMode} mode
|
|
1098
1097
|
*/
|
|
1099
|
-
function scopeSugar(mode) {
|
|
1100
|
-
if (mode.scope && typeof mode.scope ===
|
|
1101
|
-
mode.beginScope = mode.scope
|
|
1102
|
-
delete mode.scope
|
|
1098
|
+
function scopeSugar (mode) {
|
|
1099
|
+
if (mode.scope && typeof mode.scope === 'object' && mode.scope !== null) {
|
|
1100
|
+
mode.beginScope = mode.scope
|
|
1101
|
+
delete mode.scope
|
|
1103
1102
|
}
|
|
1104
1103
|
}
|
|
1105
1104
|
|
|
1106
1105
|
/**
|
|
1107
1106
|
* @param {CompiledMode} mode
|
|
1108
1107
|
*/
|
|
1109
|
-
function MultiClass(mode) {
|
|
1110
|
-
scopeSugar(mode)
|
|
1108
|
+
function MultiClass (mode) {
|
|
1109
|
+
scopeSugar(mode)
|
|
1111
1110
|
|
|
1112
|
-
if (typeof mode.beginScope ===
|
|
1113
|
-
mode.beginScope = { _wrap: mode.beginScope }
|
|
1111
|
+
if (typeof mode.beginScope === 'string') {
|
|
1112
|
+
mode.beginScope = { _wrap: mode.beginScope }
|
|
1114
1113
|
}
|
|
1115
|
-
if (typeof mode.endScope ===
|
|
1116
|
-
mode.endScope = { _wrap: mode.endScope }
|
|
1114
|
+
if (typeof mode.endScope === 'string') {
|
|
1115
|
+
mode.endScope = { _wrap: mode.endScope }
|
|
1117
1116
|
}
|
|
1118
1117
|
|
|
1119
|
-
beginMultiClass(mode)
|
|
1120
|
-
endMultiClass(mode)
|
|
1118
|
+
beginMultiClass(mode)
|
|
1119
|
+
endMultiClass(mode)
|
|
1121
1120
|
}
|
|
1122
1121
|
|
|
1123
1122
|
/**
|
|
@@ -1138,18 +1137,18 @@ var hljs = (function () {
|
|
|
1138
1137
|
* @param {Language} language
|
|
1139
1138
|
* @returns {CompiledLanguage}
|
|
1140
1139
|
*/
|
|
1141
|
-
function compileLanguage(language) {
|
|
1140
|
+
function compileLanguage (language) {
|
|
1142
1141
|
/**
|
|
1143
1142
|
* Builds a regex with the case sensitivity of the current language
|
|
1144
1143
|
*
|
|
1145
1144
|
* @param {RegExp | string} value
|
|
1146
1145
|
* @param {boolean} [global]
|
|
1147
1146
|
*/
|
|
1148
|
-
function langRe(value, global) {
|
|
1147
|
+
function langRe (value, global) {
|
|
1149
1148
|
return new RegExp(
|
|
1150
1149
|
source(value),
|
|
1151
1150
|
'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '')
|
|
1152
|
-
)
|
|
1151
|
+
)
|
|
1153
1152
|
}
|
|
1154
1153
|
|
|
1155
1154
|
/**
|
|
@@ -1166,49 +1165,49 @@ var hljs = (function () {
|
|
|
1166
1165
|
(`illegal`, `begin`, end, etc).
|
|
1167
1166
|
*/
|
|
1168
1167
|
class MultiRegex {
|
|
1169
|
-
constructor() {
|
|
1170
|
-
this.matchIndexes = {}
|
|
1168
|
+
constructor () {
|
|
1169
|
+
this.matchIndexes = {}
|
|
1171
1170
|
// @ts-ignore
|
|
1172
|
-
this.regexes = []
|
|
1173
|
-
this.matchAt = 1
|
|
1174
|
-
this.position = 0
|
|
1171
|
+
this.regexes = []
|
|
1172
|
+
this.matchAt = 1
|
|
1173
|
+
this.position = 0
|
|
1175
1174
|
}
|
|
1176
1175
|
|
|
1177
1176
|
// @ts-ignore
|
|
1178
|
-
addRule(re, opts) {
|
|
1179
|
-
opts.position = this.position
|
|
1177
|
+
addRule (re, opts) {
|
|
1178
|
+
opts.position = this.position++
|
|
1180
1179
|
// @ts-ignore
|
|
1181
|
-
this.matchIndexes[this.matchAt] = opts
|
|
1182
|
-
this.regexes.push([opts, re])
|
|
1183
|
-
this.matchAt += countMatchGroups(re) + 1
|
|
1180
|
+
this.matchIndexes[this.matchAt] = opts
|
|
1181
|
+
this.regexes.push([opts, re])
|
|
1182
|
+
this.matchAt += countMatchGroups(re) + 1
|
|
1184
1183
|
}
|
|
1185
1184
|
|
|
1186
|
-
compile() {
|
|
1185
|
+
compile () {
|
|
1187
1186
|
if (this.regexes.length === 0) {
|
|
1188
1187
|
// avoids the need to check length every time exec is called
|
|
1189
1188
|
// @ts-ignore
|
|
1190
|
-
this.exec = () => null
|
|
1189
|
+
this.exec = () => null
|
|
1191
1190
|
}
|
|
1192
|
-
const terminators = this.regexes.map(el => el[1])
|
|
1193
|
-
this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: '|' }), true)
|
|
1194
|
-
this.lastIndex = 0
|
|
1191
|
+
const terminators = this.regexes.map(el => el[1])
|
|
1192
|
+
this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: '|' }), true)
|
|
1193
|
+
this.lastIndex = 0
|
|
1195
1194
|
}
|
|
1196
1195
|
|
|
1197
1196
|
/** @param {string} s */
|
|
1198
|
-
exec(s) {
|
|
1199
|
-
this.matcherRe.lastIndex = this.lastIndex
|
|
1200
|
-
const match = this.matcherRe.exec(s)
|
|
1201
|
-
if (!match) { return null
|
|
1197
|
+
exec (s) {
|
|
1198
|
+
this.matcherRe.lastIndex = this.lastIndex
|
|
1199
|
+
const match = this.matcherRe.exec(s)
|
|
1200
|
+
if (!match) { return null }
|
|
1202
1201
|
|
|
1203
1202
|
// eslint-disable-next-line no-undefined
|
|
1204
|
-
const i = match.findIndex((el, i) => i > 0 && el !== undefined)
|
|
1203
|
+
const i = match.findIndex((el, i) => i > 0 && el !== undefined)
|
|
1205
1204
|
// @ts-ignore
|
|
1206
|
-
const matchData = this.matchIndexes[i]
|
|
1205
|
+
const matchData = this.matchIndexes[i]
|
|
1207
1206
|
// trim off any earlier non-relevant match groups (ie, the other regex
|
|
1208
1207
|
// match groups that make up the multi-matcher)
|
|
1209
|
-
match.splice(0, i)
|
|
1208
|
+
match.splice(0, i)
|
|
1210
1209
|
|
|
1211
|
-
return Object.assign(match, matchData)
|
|
1210
|
+
return Object.assign(match, matchData)
|
|
1212
1211
|
}
|
|
1213
1212
|
}
|
|
1214
1213
|
|
|
@@ -1244,47 +1243,47 @@ var hljs = (function () {
|
|
|
1244
1243
|
MOST of the time the parser will be setting startAt manually to 0.
|
|
1245
1244
|
*/
|
|
1246
1245
|
class ResumableMultiRegex {
|
|
1247
|
-
constructor() {
|
|
1246
|
+
constructor () {
|
|
1248
1247
|
// @ts-ignore
|
|
1249
|
-
this.rules = []
|
|
1248
|
+
this.rules = []
|
|
1250
1249
|
// @ts-ignore
|
|
1251
|
-
this.multiRegexes = []
|
|
1252
|
-
this.count = 0
|
|
1250
|
+
this.multiRegexes = []
|
|
1251
|
+
this.count = 0
|
|
1253
1252
|
|
|
1254
|
-
this.lastIndex = 0
|
|
1255
|
-
this.regexIndex = 0
|
|
1253
|
+
this.lastIndex = 0
|
|
1254
|
+
this.regexIndex = 0
|
|
1256
1255
|
}
|
|
1257
1256
|
|
|
1258
1257
|
// @ts-ignore
|
|
1259
|
-
getMatcher(index) {
|
|
1260
|
-
if (this.multiRegexes[index]) return this.multiRegexes[index]
|
|
1261
|
-
|
|
1262
|
-
const matcher = new MultiRegex()
|
|
1263
|
-
this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts))
|
|
1264
|
-
matcher.compile()
|
|
1265
|
-
this.multiRegexes[index] = matcher
|
|
1266
|
-
return matcher
|
|
1258
|
+
getMatcher (index) {
|
|
1259
|
+
if (this.multiRegexes[index]) return this.multiRegexes[index]
|
|
1260
|
+
|
|
1261
|
+
const matcher = new MultiRegex()
|
|
1262
|
+
this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts))
|
|
1263
|
+
matcher.compile()
|
|
1264
|
+
this.multiRegexes[index] = matcher
|
|
1265
|
+
return matcher
|
|
1267
1266
|
}
|
|
1268
1267
|
|
|
1269
|
-
resumingScanAtSamePosition() {
|
|
1270
|
-
return this.regexIndex !== 0
|
|
1268
|
+
resumingScanAtSamePosition () {
|
|
1269
|
+
return this.regexIndex !== 0
|
|
1271
1270
|
}
|
|
1272
1271
|
|
|
1273
|
-
considerAll() {
|
|
1274
|
-
this.regexIndex = 0
|
|
1272
|
+
considerAll () {
|
|
1273
|
+
this.regexIndex = 0
|
|
1275
1274
|
}
|
|
1276
1275
|
|
|
1277
1276
|
// @ts-ignore
|
|
1278
|
-
addRule(re, opts) {
|
|
1279
|
-
this.rules.push([re, opts])
|
|
1280
|
-
if (opts.type ===
|
|
1277
|
+
addRule (re, opts) {
|
|
1278
|
+
this.rules.push([re, opts])
|
|
1279
|
+
if (opts.type === 'begin') this.count++
|
|
1281
1280
|
}
|
|
1282
1281
|
|
|
1283
1282
|
/** @param {string} s */
|
|
1284
|
-
exec(s) {
|
|
1285
|
-
const m = this.getMatcher(this.regexIndex)
|
|
1286
|
-
m.lastIndex = this.lastIndex
|
|
1287
|
-
let result = m.exec(s)
|
|
1283
|
+
exec (s) {
|
|
1284
|
+
const m = this.getMatcher(this.regexIndex)
|
|
1285
|
+
m.lastIndex = this.lastIndex
|
|
1286
|
+
let result = m.exec(s)
|
|
1288
1287
|
|
|
1289
1288
|
// The following is because we have no easy way to say "resume scanning at the
|
|
1290
1289
|
// existing position but also skip the current rule ONLY". What happens is
|
|
@@ -1319,21 +1318,21 @@ var hljs = (function () {
|
|
|
1319
1318
|
// 4. If #2 and #3 result in matches, which came first?
|
|
1320
1319
|
if (this.resumingScanAtSamePosition()) {
|
|
1321
1320
|
if (result && result.index === this.lastIndex); else { // use the second matcher result
|
|
1322
|
-
const m2 = this.getMatcher(0)
|
|
1323
|
-
m2.lastIndex = this.lastIndex + 1
|
|
1324
|
-
result = m2.exec(s)
|
|
1321
|
+
const m2 = this.getMatcher(0)
|
|
1322
|
+
m2.lastIndex = this.lastIndex + 1
|
|
1323
|
+
result = m2.exec(s)
|
|
1325
1324
|
}
|
|
1326
1325
|
}
|
|
1327
1326
|
|
|
1328
1327
|
if (result) {
|
|
1329
|
-
this.regexIndex += result.position + 1
|
|
1328
|
+
this.regexIndex += result.position + 1
|
|
1330
1329
|
if (this.regexIndex === this.count) {
|
|
1331
1330
|
// wrap-around to considering all matches again
|
|
1332
|
-
this.considerAll()
|
|
1331
|
+
this.considerAll()
|
|
1333
1332
|
}
|
|
1334
1333
|
}
|
|
1335
1334
|
|
|
1336
|
-
return result
|
|
1335
|
+
return result
|
|
1337
1336
|
}
|
|
1338
1337
|
}
|
|
1339
1338
|
|
|
@@ -1344,19 +1343,19 @@ var hljs = (function () {
|
|
|
1344
1343
|
* @param {CompiledMode} mode
|
|
1345
1344
|
* @returns {ResumableMultiRegex}
|
|
1346
1345
|
*/
|
|
1347
|
-
function buildModeRegex(mode) {
|
|
1348
|
-
const mm = new ResumableMultiRegex()
|
|
1346
|
+
function buildModeRegex (mode) {
|
|
1347
|
+
const mm = new ResumableMultiRegex()
|
|
1349
1348
|
|
|
1350
|
-
mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type:
|
|
1349
|
+
mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type: 'begin' }))
|
|
1351
1350
|
|
|
1352
1351
|
if (mode.terminatorEnd) {
|
|
1353
|
-
mm.addRule(mode.terminatorEnd, { type:
|
|
1352
|
+
mm.addRule(mode.terminatorEnd, { type: 'end' })
|
|
1354
1353
|
}
|
|
1355
1354
|
if (mode.illegal) {
|
|
1356
|
-
mm.addRule(mode.illegal, { type:
|
|
1355
|
+
mm.addRule(mode.illegal, { type: 'illegal' })
|
|
1357
1356
|
}
|
|
1358
1357
|
|
|
1359
|
-
return mm
|
|
1358
|
+
return mm
|
|
1360
1359
|
}
|
|
1361
1360
|
|
|
1362
1361
|
/** skip vs abort vs ignore
|
|
@@ -1398,8 +1397,8 @@ var hljs = (function () {
|
|
|
1398
1397
|
* @param {CompiledMode | null} [parent]
|
|
1399
1398
|
* @returns {CompiledMode | never}
|
|
1400
1399
|
*/
|
|
1401
|
-
function compileMode(mode, parent) {
|
|
1402
|
-
const cmode = /** @type CompiledMode */ (mode)
|
|
1400
|
+
function compileMode (mode, parent) {
|
|
1401
|
+
const cmode = /** @type CompiledMode */ (mode)
|
|
1403
1402
|
if (mode.isCompiled) return cmode;
|
|
1404
1403
|
|
|
1405
1404
|
[
|
|
@@ -1409,9 +1408,9 @@ var hljs = (function () {
|
|
|
1409
1408
|
compileMatch,
|
|
1410
1409
|
MultiClass,
|
|
1411
1410
|
beforeMatchExt
|
|
1412
|
-
].forEach(ext => ext(mode, parent))
|
|
1411
|
+
].forEach(ext => ext(mode, parent))
|
|
1413
1412
|
|
|
1414
|
-
language.compilerExtensions.forEach(ext => ext(mode, parent))
|
|
1413
|
+
language.compilerExtensions.forEach(ext => ext(mode, parent))
|
|
1415
1414
|
|
|
1416
1415
|
// __beforeBegin is considered private API, internal use only
|
|
1417
1416
|
mode.__beforeBegin = null;
|
|
@@ -1423,64 +1422,64 @@ var hljs = (function () {
|
|
|
1423
1422
|
compileIllegal,
|
|
1424
1423
|
// default to 1 relevance if not specified
|
|
1425
1424
|
compileRelevance
|
|
1426
|
-
].forEach(ext => ext(mode, parent))
|
|
1425
|
+
].forEach(ext => ext(mode, parent))
|
|
1427
1426
|
|
|
1428
|
-
mode.isCompiled = true
|
|
1427
|
+
mode.isCompiled = true
|
|
1429
1428
|
|
|
1430
|
-
let keywordPattern = null
|
|
1431
|
-
if (typeof mode.keywords ===
|
|
1429
|
+
let keywordPattern = null
|
|
1430
|
+
if (typeof mode.keywords === 'object' && mode.keywords.$pattern) {
|
|
1432
1431
|
// we need a copy because keywords might be compiled multiple times
|
|
1433
1432
|
// so we can't go deleting $pattern from the original on the first
|
|
1434
1433
|
// pass
|
|
1435
|
-
mode.keywords = Object.assign({}, mode.keywords)
|
|
1436
|
-
keywordPattern = mode.keywords.$pattern
|
|
1437
|
-
delete mode.keywords.$pattern
|
|
1434
|
+
mode.keywords = Object.assign({}, mode.keywords)
|
|
1435
|
+
keywordPattern = mode.keywords.$pattern
|
|
1436
|
+
delete mode.keywords.$pattern
|
|
1438
1437
|
}
|
|
1439
|
-
keywordPattern = keywordPattern || /\w
|
|
1438
|
+
keywordPattern = keywordPattern || /\w+/
|
|
1440
1439
|
|
|
1441
1440
|
if (mode.keywords) {
|
|
1442
|
-
mode.keywords = compileKeywords(mode.keywords, language.case_insensitive)
|
|
1441
|
+
mode.keywords = compileKeywords(mode.keywords, language.case_insensitive)
|
|
1443
1442
|
}
|
|
1444
1443
|
|
|
1445
|
-
cmode.keywordPatternRe = langRe(keywordPattern, true)
|
|
1444
|
+
cmode.keywordPatternRe = langRe(keywordPattern, true)
|
|
1446
1445
|
|
|
1447
1446
|
if (parent) {
|
|
1448
|
-
if (!mode.begin) mode.begin = /\B|\b
|
|
1449
|
-
cmode.beginRe = langRe(mode.begin)
|
|
1450
|
-
if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b
|
|
1451
|
-
if (mode.end) cmode.endRe = langRe(mode.end)
|
|
1452
|
-
cmode.terminatorEnd = source(mode.end) || ''
|
|
1447
|
+
if (!mode.begin) mode.begin = /\B|\b/
|
|
1448
|
+
cmode.beginRe = langRe(mode.begin)
|
|
1449
|
+
if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/
|
|
1450
|
+
if (mode.end) cmode.endRe = langRe(mode.end)
|
|
1451
|
+
cmode.terminatorEnd = source(mode.end) || ''
|
|
1453
1452
|
if (mode.endsWithParent && parent.terminatorEnd) {
|
|
1454
|
-
cmode.terminatorEnd += (mode.end ? '|' : '') + parent.terminatorEnd
|
|
1453
|
+
cmode.terminatorEnd += (mode.end ? '|' : '') + parent.terminatorEnd
|
|
1455
1454
|
}
|
|
1456
1455
|
}
|
|
1457
|
-
if (mode.illegal) cmode.illegalRe = langRe(/** @type {RegExp | string} */(mode.illegal))
|
|
1458
|
-
if (!mode.contains) mode.contains = []
|
|
1456
|
+
if (mode.illegal) cmode.illegalRe = langRe(/** @type {RegExp | string} */(mode.illegal))
|
|
1457
|
+
if (!mode.contains) mode.contains = []
|
|
1459
1458
|
|
|
1460
1459
|
mode.contains = [].concat(...mode.contains.map(function (c) {
|
|
1461
|
-
return expandOrCloneMode(c === 'self' ? mode : c)
|
|
1462
|
-
}))
|
|
1463
|
-
mode.contains.forEach(function (c) { compileMode(/** @type Mode */(c), cmode)
|
|
1460
|
+
return expandOrCloneMode(c === 'self' ? mode : c)
|
|
1461
|
+
}))
|
|
1462
|
+
mode.contains.forEach(function (c) { compileMode(/** @type Mode */(c), cmode) })
|
|
1464
1463
|
|
|
1465
1464
|
if (mode.starts) {
|
|
1466
|
-
compileMode(mode.starts, parent)
|
|
1465
|
+
compileMode(mode.starts, parent)
|
|
1467
1466
|
}
|
|
1468
1467
|
|
|
1469
|
-
cmode.matcher = buildModeRegex(cmode)
|
|
1470
|
-
return cmode
|
|
1468
|
+
cmode.matcher = buildModeRegex(cmode)
|
|
1469
|
+
return cmode
|
|
1471
1470
|
}
|
|
1472
1471
|
|
|
1473
|
-
if (!language.compilerExtensions) language.compilerExtensions = []
|
|
1472
|
+
if (!language.compilerExtensions) language.compilerExtensions = []
|
|
1474
1473
|
|
|
1475
1474
|
// self is not valid at the top-level
|
|
1476
1475
|
if (language.contains && language.contains.includes('self')) {
|
|
1477
|
-
throw new Error(
|
|
1476
|
+
throw new Error('ERR: contains `self` is not supported at the top-level of a language. See documentation.')
|
|
1478
1477
|
}
|
|
1479
1478
|
|
|
1480
1479
|
// we need a null object, which inherit will guarantee
|
|
1481
|
-
language.classNameAliases = inherit$1(language.classNameAliases || {})
|
|
1480
|
+
language.classNameAliases = inherit$1(language.classNameAliases || {})
|
|
1482
1481
|
|
|
1483
|
-
return compileMode(/** @type Mode */(language))
|
|
1482
|
+
return compileMode(/** @type Mode */(language))
|
|
1484
1483
|
}
|
|
1485
1484
|
|
|
1486
1485
|
/**
|
|
@@ -1494,10 +1493,10 @@ var hljs = (function () {
|
|
|
1494
1493
|
* @param {Mode | null} mode
|
|
1495
1494
|
* @returns {boolean} - is there a dependency on the parent?
|
|
1496
1495
|
* */
|
|
1497
|
-
function dependencyOnParent(mode) {
|
|
1498
|
-
if (!mode) return false
|
|
1496
|
+
function dependencyOnParent (mode) {
|
|
1497
|
+
if (!mode) return false
|
|
1499
1498
|
|
|
1500
|
-
return mode.endsWithParent || dependencyOnParent(mode.starts)
|
|
1499
|
+
return mode.endsWithParent || dependencyOnParent(mode.starts)
|
|
1501
1500
|
}
|
|
1502
1501
|
|
|
1503
1502
|
/**
|
|
@@ -1510,18 +1509,18 @@ var hljs = (function () {
|
|
|
1510
1509
|
* @param {Mode} mode
|
|
1511
1510
|
* @returns {Mode | Mode[]}
|
|
1512
1511
|
* */
|
|
1513
|
-
function expandOrCloneMode(mode) {
|
|
1512
|
+
function expandOrCloneMode (mode) {
|
|
1514
1513
|
if (mode.variants && !mode.cachedVariants) {
|
|
1515
1514
|
mode.cachedVariants = mode.variants.map(function (variant) {
|
|
1516
|
-
return inherit$1(mode, { variants: null }, variant)
|
|
1517
|
-
})
|
|
1515
|
+
return inherit$1(mode, { variants: null }, variant)
|
|
1516
|
+
})
|
|
1518
1517
|
}
|
|
1519
1518
|
|
|
1520
1519
|
// EXPAND
|
|
1521
1520
|
// if we have variants then essentially "replace" the mode with the variants
|
|
1522
1521
|
// this happens in compileMode, where this function is called from
|
|
1523
1522
|
if (mode.cachedVariants) {
|
|
1524
|
-
return mode.cachedVariants
|
|
1523
|
+
return mode.cachedVariants
|
|
1525
1524
|
}
|
|
1526
1525
|
|
|
1527
1526
|
// CLONE
|
|
@@ -1529,18 +1528,18 @@ var hljs = (function () {
|
|
|
1529
1528
|
// instance of ourselves, so we can be reused with many
|
|
1530
1529
|
// different parents without issue
|
|
1531
1530
|
if (dependencyOnParent(mode)) {
|
|
1532
|
-
return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null })
|
|
1531
|
+
return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null })
|
|
1533
1532
|
}
|
|
1534
1533
|
|
|
1535
1534
|
if (Object.isFrozen(mode)) {
|
|
1536
|
-
return inherit$1(mode)
|
|
1535
|
+
return inherit$1(mode)
|
|
1537
1536
|
}
|
|
1538
1537
|
|
|
1539
1538
|
// no special dependency issues, just return ourselves
|
|
1540
|
-
return mode
|
|
1539
|
+
return mode
|
|
1541
1540
|
}
|
|
1542
1541
|
|
|
1543
|
-
|
|
1542
|
+
const version = '11.0.0-beta1'
|
|
1544
1543
|
|
|
1545
1544
|
/*
|
|
1546
1545
|
Syntax highlighting with language autodetection.
|
|
@@ -1567,11 +1566,10 @@ var hljs = (function () {
|
|
|
1567
1566
|
@typedef {import('highlight.js').HighlightResult} HighlightResult
|
|
1568
1567
|
*/
|
|
1569
1568
|
|
|
1570
|
-
|
|
1571
|
-
const
|
|
1572
|
-
const
|
|
1573
|
-
const
|
|
1574
|
-
const MAX_KEYWORD_HITS = 7;
|
|
1569
|
+
const escape = escapeHTML
|
|
1570
|
+
const inherit = inherit$1
|
|
1571
|
+
const NO_MATCH = Symbol('nomatch')
|
|
1572
|
+
const MAX_KEYWORD_HITS = 7
|
|
1575
1573
|
|
|
1576
1574
|
/**
|
|
1577
1575
|
* @param {any} hljs - object that is extended (legacy)
|
|
@@ -1580,18 +1578,18 @@ var hljs = (function () {
|
|
|
1580
1578
|
const HLJS = function (hljs) {
|
|
1581
1579
|
// Global internal variables used within the highlight.js library.
|
|
1582
1580
|
/** @type {Record<string, Language>} */
|
|
1583
|
-
const languages = Object.create(null)
|
|
1581
|
+
const languages = Object.create(null)
|
|
1584
1582
|
/** @type {Record<string, string>} */
|
|
1585
|
-
const aliases = Object.create(null)
|
|
1583
|
+
const aliases = Object.create(null)
|
|
1586
1584
|
/** @type {HLJSPlugin[]} */
|
|
1587
|
-
const plugins = []
|
|
1585
|
+
const plugins = []
|
|
1588
1586
|
|
|
1589
1587
|
// safe/production mode - swallows more errors, tries to keep running
|
|
1590
1588
|
// even if a single syntax or parse hits a fatal error
|
|
1591
|
-
let SAFE_MODE = true
|
|
1592
|
-
const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?"
|
|
1589
|
+
let SAFE_MODE = true
|
|
1590
|
+
const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?"
|
|
1593
1591
|
/** @type {Language} */
|
|
1594
|
-
const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] }
|
|
1592
|
+
const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] }
|
|
1595
1593
|
|
|
1596
1594
|
// Global options used when within external APIs. This is modified when
|
|
1597
1595
|
// calling the `hljs.configure` function.
|
|
@@ -1606,7 +1604,7 @@ var hljs = (function () {
|
|
|
1606
1604
|
// beta configuration options, subject to change, welcome to discuss
|
|
1607
1605
|
// https://github.com/highlightjs/highlight.js/issues/1086
|
|
1608
1606
|
__emitter: TokenTreeEmitter
|
|
1609
|
-
}
|
|
1607
|
+
}
|
|
1610
1608
|
|
|
1611
1609
|
/* Utility functions */
|
|
1612
1610
|
|
|
@@ -1614,32 +1612,32 @@ var hljs = (function () {
|
|
|
1614
1612
|
* Tests a language name to see if highlighting should be skipped
|
|
1615
1613
|
* @param {string} languageName
|
|
1616
1614
|
*/
|
|
1617
|
-
function shouldNotHighlight(languageName) {
|
|
1618
|
-
return options.noHighlightRe.test(languageName)
|
|
1615
|
+
function shouldNotHighlight (languageName) {
|
|
1616
|
+
return options.noHighlightRe.test(languageName)
|
|
1619
1617
|
}
|
|
1620
1618
|
|
|
1621
1619
|
/**
|
|
1622
1620
|
* @param {HighlightedHTMLElement} block - the HTML element to determine language for
|
|
1623
1621
|
*/
|
|
1624
|
-
function blockLanguage(block) {
|
|
1625
|
-
let classes = block.className + ' '
|
|
1622
|
+
function blockLanguage (block) {
|
|
1623
|
+
let classes = block.className + ' '
|
|
1626
1624
|
|
|
1627
|
-
classes += block.parentNode ? block.parentNode.className : ''
|
|
1625
|
+
classes += block.parentNode ? block.parentNode.className : ''
|
|
1628
1626
|
|
|
1629
1627
|
// language-* takes precedence over non-prefixed class names.
|
|
1630
|
-
const match = options.languageDetectRe.exec(classes)
|
|
1628
|
+
const match = options.languageDetectRe.exec(classes)
|
|
1631
1629
|
if (match) {
|
|
1632
|
-
const language = getLanguage(match[1])
|
|
1630
|
+
const language = getLanguage(match[1])
|
|
1633
1631
|
if (!language) {
|
|
1634
|
-
warn(LANGUAGE_NOT_FOUND.replace(
|
|
1635
|
-
warn(
|
|
1632
|
+
warn(LANGUAGE_NOT_FOUND.replace('{}', match[1]))
|
|
1633
|
+
warn('Falling back to no-highlight mode for this block.', block)
|
|
1636
1634
|
}
|
|
1637
|
-
return language ? match[1] : 'no-highlight'
|
|
1635
|
+
return language ? match[1] : 'no-highlight'
|
|
1638
1636
|
}
|
|
1639
1637
|
|
|
1640
1638
|
return classes
|
|
1641
1639
|
.split(/\s+/)
|
|
1642
|
-
.find((_class) => shouldNotHighlight(_class) || getLanguage(_class))
|
|
1640
|
+
.find((_class) => shouldNotHighlight(_class) || getLanguage(_class))
|
|
1643
1641
|
}
|
|
1644
1642
|
|
|
1645
1643
|
/**
|
|
@@ -1664,48 +1662,48 @@ var hljs = (function () {
|
|
|
1664
1662
|
* @property {CompiledMode} top - top of the current mode stack
|
|
1665
1663
|
* @property {boolean} illegal - indicates whether any illegal matches were found
|
|
1666
1664
|
*/
|
|
1667
|
-
function highlight(codeOrLanguageName, optionsOrCode, ignoreIllegals, continuation) {
|
|
1668
|
-
let code =
|
|
1669
|
-
let languageName =
|
|
1670
|
-
if (typeof optionsOrCode ===
|
|
1671
|
-
code = codeOrLanguageName
|
|
1672
|
-
ignoreIllegals = optionsOrCode.ignoreIllegals
|
|
1673
|
-
languageName = optionsOrCode.language
|
|
1665
|
+
function highlight (codeOrLanguageName, optionsOrCode, ignoreIllegals, continuation) {
|
|
1666
|
+
let code = ''
|
|
1667
|
+
let languageName = ''
|
|
1668
|
+
if (typeof optionsOrCode === 'object') {
|
|
1669
|
+
code = codeOrLanguageName
|
|
1670
|
+
ignoreIllegals = optionsOrCode.ignoreIllegals
|
|
1671
|
+
languageName = optionsOrCode.language
|
|
1674
1672
|
// continuation not supported at all via the new API
|
|
1675
1673
|
// eslint-disable-next-line no-undefined
|
|
1676
|
-
continuation = undefined
|
|
1674
|
+
continuation = undefined
|
|
1677
1675
|
} else {
|
|
1678
1676
|
// old API
|
|
1679
|
-
deprecated(
|
|
1680
|
-
deprecated(
|
|
1681
|
-
languageName = codeOrLanguageName
|
|
1682
|
-
code = optionsOrCode
|
|
1677
|
+
deprecated('10.7.0', 'highlight(lang, code, ...args) has been deprecated.')
|
|
1678
|
+
deprecated('10.7.0', 'Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277')
|
|
1679
|
+
languageName = codeOrLanguageName
|
|
1680
|
+
code = optionsOrCode
|
|
1683
1681
|
}
|
|
1684
1682
|
|
|
1685
1683
|
// https://github.com/highlightjs/highlight.js/issues/3149
|
|
1686
1684
|
// eslint-disable-next-line no-undefined
|
|
1687
|
-
if (ignoreIllegals === undefined) { ignoreIllegals = true
|
|
1685
|
+
if (ignoreIllegals === undefined) { ignoreIllegals = true }
|
|
1688
1686
|
|
|
1689
1687
|
/** @type {BeforeHighlightContext} */
|
|
1690
1688
|
const context = {
|
|
1691
1689
|
code,
|
|
1692
1690
|
language: languageName
|
|
1693
|
-
}
|
|
1691
|
+
}
|
|
1694
1692
|
// the plugin can change the desired language or the code to be highlighted
|
|
1695
1693
|
// just be changing the object it was passed
|
|
1696
|
-
fire(
|
|
1694
|
+
fire('before:highlight', context)
|
|
1697
1695
|
|
|
1698
1696
|
// a before plugin can usurp the result completely by providing it's own
|
|
1699
1697
|
// in which case we don't even need to call highlight
|
|
1700
1698
|
const result = context.result
|
|
1701
1699
|
? context.result
|
|
1702
|
-
: _highlight(context.language, context.code, ignoreIllegals, continuation)
|
|
1700
|
+
: _highlight(context.language, context.code, ignoreIllegals, continuation)
|
|
1703
1701
|
|
|
1704
|
-
result.code = context.code
|
|
1702
|
+
result.code = context.code
|
|
1705
1703
|
// the plugin can change anything in result to suite it
|
|
1706
|
-
fire(
|
|
1704
|
+
fire('after:highlight', result)
|
|
1707
1705
|
|
|
1708
|
-
return result
|
|
1706
|
+
return result
|
|
1709
1707
|
}
|
|
1710
1708
|
|
|
1711
1709
|
/**
|
|
@@ -1717,8 +1715,8 @@ var hljs = (function () {
|
|
|
1717
1715
|
* @param {CompiledMode?} [continuation] - current continuation mode, if any
|
|
1718
1716
|
* @returns {HighlightResult} - result of the highlight operation
|
|
1719
1717
|
*/
|
|
1720
|
-
function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
|
|
1721
|
-
const keywordHits = Object.create(null)
|
|
1718
|
+
function _highlight (languageName, codeToHighlight, ignoreIllegals, continuation) {
|
|
1719
|
+
const keywordHits = Object.create(null)
|
|
1722
1720
|
|
|
1723
1721
|
/**
|
|
1724
1722
|
* Return keyword data if a match is a keyword
|
|
@@ -1726,64 +1724,64 @@ var hljs = (function () {
|
|
|
1726
1724
|
* @param {string} matchText - the textual match
|
|
1727
1725
|
* @returns {KeywordData | false}
|
|
1728
1726
|
*/
|
|
1729
|
-
function keywordData(mode, matchText) {
|
|
1730
|
-
return mode.keywords[matchText]
|
|
1727
|
+
function keywordData (mode, matchText) {
|
|
1728
|
+
return mode.keywords[matchText]
|
|
1731
1729
|
}
|
|
1732
1730
|
|
|
1733
|
-
function processKeywords() {
|
|
1731
|
+
function processKeywords () {
|
|
1734
1732
|
if (!top.keywords) {
|
|
1735
|
-
emitter.addText(modeBuffer)
|
|
1736
|
-
return
|
|
1733
|
+
emitter.addText(modeBuffer)
|
|
1734
|
+
return
|
|
1737
1735
|
}
|
|
1738
1736
|
|
|
1739
|
-
let lastIndex = 0
|
|
1740
|
-
top.keywordPatternRe.lastIndex = 0
|
|
1741
|
-
let match = top.keywordPatternRe.exec(modeBuffer)
|
|
1742
|
-
let buf =
|
|
1737
|
+
let lastIndex = 0
|
|
1738
|
+
top.keywordPatternRe.lastIndex = 0
|
|
1739
|
+
let match = top.keywordPatternRe.exec(modeBuffer)
|
|
1740
|
+
let buf = ''
|
|
1743
1741
|
|
|
1744
1742
|
while (match) {
|
|
1745
|
-
buf += modeBuffer.substring(lastIndex, match.index)
|
|
1746
|
-
const word = language.case_insensitive ? match[0].toLowerCase() : match[0]
|
|
1747
|
-
const data = keywordData(top, word)
|
|
1743
|
+
buf += modeBuffer.substring(lastIndex, match.index)
|
|
1744
|
+
const word = language.case_insensitive ? match[0].toLowerCase() : match[0]
|
|
1745
|
+
const data = keywordData(top, word)
|
|
1748
1746
|
if (data) {
|
|
1749
|
-
const [kind, keywordRelevance] = data
|
|
1750
|
-
emitter.addText(buf)
|
|
1751
|
-
buf =
|
|
1747
|
+
const [kind, keywordRelevance] = data
|
|
1748
|
+
emitter.addText(buf)
|
|
1749
|
+
buf = ''
|
|
1752
1750
|
|
|
1753
|
-
keywordHits[word] = (keywordHits[word] || 0) + 1
|
|
1754
|
-
if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance
|
|
1755
|
-
if (kind.startsWith(
|
|
1751
|
+
keywordHits[word] = (keywordHits[word] || 0) + 1
|
|
1752
|
+
if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance
|
|
1753
|
+
if (kind.startsWith('_')) {
|
|
1756
1754
|
// _ implied for relevance only, do not highlight
|
|
1757
1755
|
// by applying a class name
|
|
1758
|
-
buf += match[0]
|
|
1756
|
+
buf += match[0]
|
|
1759
1757
|
} else {
|
|
1760
|
-
const cssClass = language.classNameAliases[kind] || kind
|
|
1761
|
-
emitter.addKeyword(match[0], cssClass)
|
|
1758
|
+
const cssClass = language.classNameAliases[kind] || kind
|
|
1759
|
+
emitter.addKeyword(match[0], cssClass)
|
|
1762
1760
|
}
|
|
1763
1761
|
} else {
|
|
1764
|
-
buf += match[0]
|
|
1762
|
+
buf += match[0]
|
|
1765
1763
|
}
|
|
1766
|
-
lastIndex = top.keywordPatternRe.lastIndex
|
|
1767
|
-
match = top.keywordPatternRe.exec(modeBuffer)
|
|
1764
|
+
lastIndex = top.keywordPatternRe.lastIndex
|
|
1765
|
+
match = top.keywordPatternRe.exec(modeBuffer)
|
|
1768
1766
|
}
|
|
1769
|
-
buf += modeBuffer.substr(lastIndex)
|
|
1770
|
-
emitter.addText(buf)
|
|
1767
|
+
buf += modeBuffer.substr(lastIndex)
|
|
1768
|
+
emitter.addText(buf)
|
|
1771
1769
|
}
|
|
1772
1770
|
|
|
1773
|
-
function processSubLanguage() {
|
|
1774
|
-
if (modeBuffer ===
|
|
1771
|
+
function processSubLanguage () {
|
|
1772
|
+
if (modeBuffer === '') return
|
|
1775
1773
|
/** @type HighlightResult */
|
|
1776
|
-
let result = null
|
|
1774
|
+
let result = null
|
|
1777
1775
|
|
|
1778
1776
|
if (typeof top.subLanguage === 'string') {
|
|
1779
1777
|
if (!languages[top.subLanguage]) {
|
|
1780
|
-
emitter.addText(modeBuffer)
|
|
1781
|
-
return
|
|
1778
|
+
emitter.addText(modeBuffer)
|
|
1779
|
+
return
|
|
1782
1780
|
}
|
|
1783
|
-
result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage])
|
|
1784
|
-
continuations[top.subLanguage] = /** @type {CompiledMode} */ (result._top)
|
|
1781
|
+
result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage])
|
|
1782
|
+
continuations[top.subLanguage] = /** @type {CompiledMode} */ (result._top)
|
|
1785
1783
|
} else {
|
|
1786
|
-
result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null)
|
|
1784
|
+
result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null)
|
|
1787
1785
|
}
|
|
1788
1786
|
|
|
1789
1787
|
// Counting embedded language score towards the host language may be disabled
|
|
@@ -1791,39 +1789,39 @@ var hljs = (function () {
|
|
|
1791
1789
|
// allows XML everywhere and makes every XML snippet to have a much larger Markdown
|
|
1792
1790
|
// score.
|
|
1793
1791
|
if (top.relevance > 0) {
|
|
1794
|
-
relevance += result.relevance
|
|
1792
|
+
relevance += result.relevance
|
|
1795
1793
|
}
|
|
1796
|
-
emitter.addSublanguage(result._emitter, result.language)
|
|
1794
|
+
emitter.addSublanguage(result._emitter, result.language)
|
|
1797
1795
|
}
|
|
1798
1796
|
|
|
1799
|
-
function processBuffer() {
|
|
1797
|
+
function processBuffer () {
|
|
1800
1798
|
if (top.subLanguage != null) {
|
|
1801
|
-
processSubLanguage()
|
|
1799
|
+
processSubLanguage()
|
|
1802
1800
|
} else {
|
|
1803
|
-
processKeywords()
|
|
1801
|
+
processKeywords()
|
|
1804
1802
|
}
|
|
1805
|
-
modeBuffer = ''
|
|
1803
|
+
modeBuffer = ''
|
|
1806
1804
|
}
|
|
1807
1805
|
|
|
1808
1806
|
/**
|
|
1809
1807
|
* @param {CompiledMode} mode
|
|
1810
1808
|
* @param {RegExpMatchArray} match
|
|
1811
1809
|
*/
|
|
1812
|
-
function emitMultiClass(scope, match) {
|
|
1813
|
-
let i = 1
|
|
1810
|
+
function emitMultiClass (scope, match) {
|
|
1811
|
+
let i = 1
|
|
1814
1812
|
// eslint-disable-next-line no-undefined
|
|
1815
1813
|
while (match[i] !== undefined) {
|
|
1816
|
-
if (!scope._emit[i]) { i++; continue
|
|
1817
|
-
const klass = language.classNameAliases[scope[i]] || scope[i]
|
|
1818
|
-
const text = match[i]
|
|
1814
|
+
if (!scope._emit[i]) { i++; continue }
|
|
1815
|
+
const klass = language.classNameAliases[scope[i]] || scope[i]
|
|
1816
|
+
const text = match[i]
|
|
1819
1817
|
if (klass) {
|
|
1820
|
-
emitter.addKeyword(text, klass)
|
|
1818
|
+
emitter.addKeyword(text, klass)
|
|
1821
1819
|
} else {
|
|
1822
|
-
modeBuffer = text
|
|
1823
|
-
processKeywords()
|
|
1824
|
-
modeBuffer =
|
|
1820
|
+
modeBuffer = text
|
|
1821
|
+
processKeywords()
|
|
1822
|
+
modeBuffer = ''
|
|
1825
1823
|
}
|
|
1826
|
-
i
|
|
1824
|
+
i++
|
|
1827
1825
|
}
|
|
1828
1826
|
}
|
|
1829
1827
|
|
|
@@ -1831,24 +1829,24 @@ var hljs = (function () {
|
|
|
1831
1829
|
* @param {CompiledMode} mode - new mode to start
|
|
1832
1830
|
* @param {RegExpMatchArray} match
|
|
1833
1831
|
*/
|
|
1834
|
-
function startNewMode(mode, match) {
|
|
1835
|
-
if (mode.scope && typeof mode.scope ===
|
|
1836
|
-
emitter.openNode(language.classNameAliases[mode.scope] || mode.scope)
|
|
1832
|
+
function startNewMode (mode, match) {
|
|
1833
|
+
if (mode.scope && typeof mode.scope === 'string') {
|
|
1834
|
+
emitter.openNode(language.classNameAliases[mode.scope] || mode.scope)
|
|
1837
1835
|
}
|
|
1838
1836
|
if (mode.beginScope) {
|
|
1839
1837
|
// beginScope just wraps the begin match itself in a scope
|
|
1840
1838
|
if (mode.beginScope._wrap) {
|
|
1841
|
-
emitter.addKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap)
|
|
1842
|
-
modeBuffer =
|
|
1839
|
+
emitter.addKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap)
|
|
1840
|
+
modeBuffer = ''
|
|
1843
1841
|
} else if (mode.beginScope._multi) {
|
|
1844
1842
|
// at this point modeBuffer should just be the match
|
|
1845
|
-
emitMultiClass(mode.beginScope, match)
|
|
1846
|
-
modeBuffer =
|
|
1843
|
+
emitMultiClass(mode.beginScope, match)
|
|
1844
|
+
modeBuffer = ''
|
|
1847
1845
|
}
|
|
1848
1846
|
}
|
|
1849
1847
|
|
|
1850
|
-
top = Object.create(mode, { parent: { value: top } })
|
|
1851
|
-
return top
|
|
1848
|
+
top = Object.create(mode, { parent: { value: top } })
|
|
1849
|
+
return top
|
|
1852
1850
|
}
|
|
1853
1851
|
|
|
1854
1852
|
/**
|
|
@@ -1857,27 +1855,27 @@ var hljs = (function () {
|
|
|
1857
1855
|
* @param {string} matchPlusRemainder - match plus remainder of content
|
|
1858
1856
|
* @returns {CompiledMode | void} - the next mode, or if void continue on in current mode
|
|
1859
1857
|
*/
|
|
1860
|
-
function endOfMode(mode, match, matchPlusRemainder) {
|
|
1861
|
-
let matched = startsWith(mode.endRe, matchPlusRemainder)
|
|
1858
|
+
function endOfMode (mode, match, matchPlusRemainder) {
|
|
1859
|
+
let matched = startsWith(mode.endRe, matchPlusRemainder)
|
|
1862
1860
|
|
|
1863
1861
|
if (matched) {
|
|
1864
|
-
if (mode[
|
|
1865
|
-
const resp = new Response(mode)
|
|
1866
|
-
mode[
|
|
1867
|
-
if (resp.isMatchIgnored) matched = false
|
|
1862
|
+
if (mode['on:end']) {
|
|
1863
|
+
const resp = new Response(mode)
|
|
1864
|
+
mode['on:end'](match, resp)
|
|
1865
|
+
if (resp.isMatchIgnored) matched = false
|
|
1868
1866
|
}
|
|
1869
1867
|
|
|
1870
1868
|
if (matched) {
|
|
1871
1869
|
while (mode.endsParent && mode.parent) {
|
|
1872
|
-
mode = mode.parent
|
|
1870
|
+
mode = mode.parent
|
|
1873
1871
|
}
|
|
1874
|
-
return mode
|
|
1872
|
+
return mode
|
|
1875
1873
|
}
|
|
1876
1874
|
}
|
|
1877
1875
|
// even if on:end fires an `ignore` it's still possible
|
|
1878
1876
|
// that we might trigger the end node because of a parent mode
|
|
1879
1877
|
if (mode.endsWithParent) {
|
|
1880
|
-
return endOfMode(mode.parent, match, matchPlusRemainder)
|
|
1878
|
+
return endOfMode(mode.parent, match, matchPlusRemainder)
|
|
1881
1879
|
}
|
|
1882
1880
|
}
|
|
1883
1881
|
|
|
@@ -1886,17 +1884,17 @@ var hljs = (function () {
|
|
|
1886
1884
|
*
|
|
1887
1885
|
* @param {string} lexeme - string containing full match text
|
|
1888
1886
|
*/
|
|
1889
|
-
function doIgnore(lexeme) {
|
|
1887
|
+
function doIgnore (lexeme) {
|
|
1890
1888
|
if (top.matcher.regexIndex === 0) {
|
|
1891
1889
|
// no more regexes to potentially match here, so we move the cursor forward one
|
|
1892
1890
|
// space
|
|
1893
|
-
modeBuffer += lexeme[0]
|
|
1894
|
-
return 1
|
|
1891
|
+
modeBuffer += lexeme[0]
|
|
1892
|
+
return 1
|
|
1895
1893
|
} else {
|
|
1896
1894
|
// no need to move the cursor, we still have additional regexes to try and
|
|
1897
1895
|
// match at this very spot
|
|
1898
|
-
resumeScanAtSamePosition = true
|
|
1899
|
-
return 0
|
|
1896
|
+
resumeScanAtSamePosition = true
|
|
1897
|
+
return 0
|
|
1900
1898
|
}
|
|
1901
1899
|
}
|
|
1902
1900
|
|
|
@@ -1906,32 +1904,32 @@ var hljs = (function () {
|
|
|
1906
1904
|
* @param {EnhancedMatch} match - the current match
|
|
1907
1905
|
* @returns {number} how far to advance the parse cursor
|
|
1908
1906
|
*/
|
|
1909
|
-
function doBeginMatch(match) {
|
|
1910
|
-
const lexeme = match[0]
|
|
1911
|
-
const newMode = match.rule
|
|
1907
|
+
function doBeginMatch (match) {
|
|
1908
|
+
const lexeme = match[0]
|
|
1909
|
+
const newMode = match.rule
|
|
1912
1910
|
|
|
1913
|
-
const resp = new Response(newMode)
|
|
1911
|
+
const resp = new Response(newMode)
|
|
1914
1912
|
// first internal before callbacks, then the public ones
|
|
1915
|
-
const beforeCallbacks = [newMode.__beforeBegin, newMode[
|
|
1913
|
+
const beforeCallbacks = [newMode.__beforeBegin, newMode['on:begin']]
|
|
1916
1914
|
for (const cb of beforeCallbacks) {
|
|
1917
|
-
if (!cb) continue
|
|
1918
|
-
cb(match, resp)
|
|
1919
|
-
if (resp.isMatchIgnored) return doIgnore(lexeme)
|
|
1915
|
+
if (!cb) continue
|
|
1916
|
+
cb(match, resp)
|
|
1917
|
+
if (resp.isMatchIgnored) return doIgnore(lexeme)
|
|
1920
1918
|
}
|
|
1921
1919
|
|
|
1922
1920
|
if (newMode.skip) {
|
|
1923
|
-
modeBuffer += lexeme
|
|
1921
|
+
modeBuffer += lexeme
|
|
1924
1922
|
} else {
|
|
1925
1923
|
if (newMode.excludeBegin) {
|
|
1926
|
-
modeBuffer += lexeme
|
|
1924
|
+
modeBuffer += lexeme
|
|
1927
1925
|
}
|
|
1928
|
-
processBuffer()
|
|
1926
|
+
processBuffer()
|
|
1929
1927
|
if (!newMode.returnBegin && !newMode.excludeBegin) {
|
|
1930
|
-
modeBuffer = lexeme
|
|
1928
|
+
modeBuffer = lexeme
|
|
1931
1929
|
}
|
|
1932
1930
|
}
|
|
1933
|
-
startNewMode(newMode, match)
|
|
1934
|
-
return newMode.returnBegin ? 0 : lexeme.length
|
|
1931
|
+
startNewMode(newMode, match)
|
|
1932
|
+
return newMode.returnBegin ? 0 : lexeme.length
|
|
1935
1933
|
}
|
|
1936
1934
|
|
|
1937
1935
|
/**
|
|
@@ -1939,58 +1937,58 @@ var hljs = (function () {
|
|
|
1939
1937
|
*
|
|
1940
1938
|
* @param {RegExpMatchArray} match - the current match
|
|
1941
1939
|
*/
|
|
1942
|
-
function doEndMatch(match) {
|
|
1943
|
-
const lexeme = match[0]
|
|
1944
|
-
const matchPlusRemainder = codeToHighlight.substr(match.index)
|
|
1940
|
+
function doEndMatch (match) {
|
|
1941
|
+
const lexeme = match[0]
|
|
1942
|
+
const matchPlusRemainder = codeToHighlight.substr(match.index)
|
|
1945
1943
|
|
|
1946
|
-
const endMode = endOfMode(top, match, matchPlusRemainder)
|
|
1947
|
-
if (!endMode) { return NO_MATCH
|
|
1944
|
+
const endMode = endOfMode(top, match, matchPlusRemainder)
|
|
1945
|
+
if (!endMode) { return NO_MATCH }
|
|
1948
1946
|
|
|
1949
|
-
const origin = top
|
|
1947
|
+
const origin = top
|
|
1950
1948
|
if (top.endScope && top.endScope._wrap) {
|
|
1951
|
-
processBuffer()
|
|
1952
|
-
emitter.addKeyword(lexeme, top.endScope._wrap)
|
|
1949
|
+
processBuffer()
|
|
1950
|
+
emitter.addKeyword(lexeme, top.endScope._wrap)
|
|
1953
1951
|
} else if (top.endScope && top.endScope._multi) {
|
|
1954
|
-
processBuffer()
|
|
1955
|
-
emitMultiClass(top.endScope, match)
|
|
1952
|
+
processBuffer()
|
|
1953
|
+
emitMultiClass(top.endScope, match)
|
|
1956
1954
|
} else if (origin.skip) {
|
|
1957
|
-
modeBuffer += lexeme
|
|
1955
|
+
modeBuffer += lexeme
|
|
1958
1956
|
} else {
|
|
1959
1957
|
if (!(origin.returnEnd || origin.excludeEnd)) {
|
|
1960
|
-
modeBuffer += lexeme
|
|
1958
|
+
modeBuffer += lexeme
|
|
1961
1959
|
}
|
|
1962
|
-
processBuffer()
|
|
1960
|
+
processBuffer()
|
|
1963
1961
|
if (origin.excludeEnd) {
|
|
1964
|
-
modeBuffer = lexeme
|
|
1962
|
+
modeBuffer = lexeme
|
|
1965
1963
|
}
|
|
1966
1964
|
}
|
|
1967
1965
|
do {
|
|
1968
1966
|
if (top.scope && !top.isMultiClass) {
|
|
1969
|
-
emitter.closeNode()
|
|
1967
|
+
emitter.closeNode()
|
|
1970
1968
|
}
|
|
1971
1969
|
if (!top.skip && !top.subLanguage) {
|
|
1972
|
-
relevance += top.relevance
|
|
1970
|
+
relevance += top.relevance
|
|
1973
1971
|
}
|
|
1974
|
-
top = top.parent
|
|
1975
|
-
} while (top !== endMode.parent)
|
|
1972
|
+
top = top.parent
|
|
1973
|
+
} while (top !== endMode.parent)
|
|
1976
1974
|
if (endMode.starts) {
|
|
1977
|
-
startNewMode(endMode.starts, match)
|
|
1975
|
+
startNewMode(endMode.starts, match)
|
|
1978
1976
|
}
|
|
1979
|
-
return origin.returnEnd ? 0 : lexeme.length
|
|
1977
|
+
return origin.returnEnd ? 0 : lexeme.length
|
|
1980
1978
|
}
|
|
1981
1979
|
|
|
1982
|
-
function processContinuations() {
|
|
1983
|
-
const list = []
|
|
1980
|
+
function processContinuations () {
|
|
1981
|
+
const list = []
|
|
1984
1982
|
for (let current = top; current !== language; current = current.parent) {
|
|
1985
1983
|
if (current.scope) {
|
|
1986
|
-
list.unshift(current.scope)
|
|
1984
|
+
list.unshift(current.scope)
|
|
1987
1985
|
}
|
|
1988
1986
|
}
|
|
1989
|
-
list.forEach(item => emitter.openNode(item))
|
|
1987
|
+
list.forEach(item => emitter.openNode(item))
|
|
1990
1988
|
}
|
|
1991
1989
|
|
|
1992
1990
|
/** @type {{type?: MatchType, index?: number, rule?: Mode}}} */
|
|
1993
|
-
let lastMatch = {}
|
|
1991
|
+
let lastMatch = {}
|
|
1994
1992
|
|
|
1995
1993
|
/**
|
|
1996
1994
|
* Process an individual match
|
|
@@ -1998,56 +1996,56 @@ var hljs = (function () {
|
|
|
1998
1996
|
* @param {string} textBeforeMatch - text preceding the match (since the last match)
|
|
1999
1997
|
* @param {EnhancedMatch} [match] - the match itself
|
|
2000
1998
|
*/
|
|
2001
|
-
function processLexeme(textBeforeMatch, match) {
|
|
2002
|
-
const lexeme = match && match[0]
|
|
1999
|
+
function processLexeme (textBeforeMatch, match) {
|
|
2000
|
+
const lexeme = match && match[0]
|
|
2003
2001
|
|
|
2004
2002
|
// add non-matched text to the current mode buffer
|
|
2005
|
-
modeBuffer += textBeforeMatch
|
|
2003
|
+
modeBuffer += textBeforeMatch
|
|
2006
2004
|
|
|
2007
2005
|
if (lexeme == null) {
|
|
2008
|
-
processBuffer()
|
|
2009
|
-
return 0
|
|
2006
|
+
processBuffer()
|
|
2007
|
+
return 0
|
|
2010
2008
|
}
|
|
2011
2009
|
|
|
2012
2010
|
// we've found a 0 width match and we're stuck, so we need to advance
|
|
2013
2011
|
// this happens when we have badly behaved rules that have optional matchers to the degree that
|
|
2014
2012
|
// sometimes they can end up matching nothing at all
|
|
2015
2013
|
// Ref: https://github.com/highlightjs/highlight.js/issues/2140
|
|
2016
|
-
if (lastMatch.type ===
|
|
2014
|
+
if (lastMatch.type === 'begin' && match.type === 'end' && lastMatch.index === match.index && lexeme === '') {
|
|
2017
2015
|
// spit the "skipped" character that our regex choked on back into the output sequence
|
|
2018
|
-
modeBuffer += codeToHighlight.slice(match.index, match.index + 1)
|
|
2016
|
+
modeBuffer += codeToHighlight.slice(match.index, match.index + 1)
|
|
2019
2017
|
if (!SAFE_MODE) {
|
|
2020
2018
|
/** @type {AnnotatedError} */
|
|
2021
|
-
const err = new Error(`0 width match regex (${languageName})`)
|
|
2022
|
-
err.languageName = languageName
|
|
2023
|
-
err.badRule = lastMatch.rule
|
|
2024
|
-
throw err
|
|
2019
|
+
const err = new Error(`0 width match regex (${languageName})`)
|
|
2020
|
+
err.languageName = languageName
|
|
2021
|
+
err.badRule = lastMatch.rule
|
|
2022
|
+
throw err
|
|
2025
2023
|
}
|
|
2026
|
-
return 1
|
|
2024
|
+
return 1
|
|
2027
2025
|
}
|
|
2028
|
-
lastMatch = match
|
|
2026
|
+
lastMatch = match
|
|
2029
2027
|
|
|
2030
|
-
if (match.type ===
|
|
2031
|
-
return doBeginMatch(match)
|
|
2032
|
-
} else if (match.type ===
|
|
2028
|
+
if (match.type === 'begin') {
|
|
2029
|
+
return doBeginMatch(match)
|
|
2030
|
+
} else if (match.type === 'illegal' && !ignoreIllegals) {
|
|
2033
2031
|
// illegal match, we do not continue processing
|
|
2034
2032
|
/** @type {AnnotatedError} */
|
|
2035
|
-
const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || '<unnamed>') + '"')
|
|
2036
|
-
err.mode = top
|
|
2037
|
-
throw err
|
|
2038
|
-
} else if (match.type ===
|
|
2039
|
-
const processed = doEndMatch(match)
|
|
2033
|
+
const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || '<unnamed>') + '"')
|
|
2034
|
+
err.mode = top
|
|
2035
|
+
throw err
|
|
2036
|
+
} else if (match.type === 'end') {
|
|
2037
|
+
const processed = doEndMatch(match)
|
|
2040
2038
|
if (processed !== NO_MATCH) {
|
|
2041
|
-
return processed
|
|
2039
|
+
return processed
|
|
2042
2040
|
}
|
|
2043
2041
|
}
|
|
2044
2042
|
|
|
2045
2043
|
// edge case for when illegal matches $ (end of line) which is technically
|
|
2046
2044
|
// a 0 width match but not a begin/end match so it's not caught by the
|
|
2047
2045
|
// first handler (when ignoreIllegals is true)
|
|
2048
|
-
if (match.type ===
|
|
2046
|
+
if (match.type === 'illegal' && lexeme === '') {
|
|
2049
2047
|
// advance so we aren't stuck in an infinite loop
|
|
2050
|
-
return 1
|
|
2048
|
+
return 1
|
|
2051
2049
|
}
|
|
2052
2050
|
|
|
2053
2051
|
// infinite loops are BAD, this is a last ditch catch all. if we have a
|
|
@@ -2055,8 +2053,8 @@ var hljs = (function () {
|
|
|
2055
2053
|
// parsing) still 3x behind our index then something is very wrong
|
|
2056
2054
|
// so we bail
|
|
2057
2055
|
if (iterations > 100000 && iterations > match.index * 3) {
|
|
2058
|
-
const err = new Error('potential infinite loop, way more iterations than matches')
|
|
2059
|
-
throw err
|
|
2056
|
+
const err = new Error('potential infinite loop, way more iterations than matches')
|
|
2057
|
+
throw err
|
|
2060
2058
|
}
|
|
2061
2059
|
|
|
2062
2060
|
/*
|
|
@@ -2067,66 +2065,66 @@ var hljs = (function () {
|
|
|
2067
2065
|
This causes no real harm other than stopping a few times too many.
|
|
2068
2066
|
*/
|
|
2069
2067
|
|
|
2070
|
-
modeBuffer += lexeme
|
|
2071
|
-
return lexeme.length
|
|
2068
|
+
modeBuffer += lexeme
|
|
2069
|
+
return lexeme.length
|
|
2072
2070
|
}
|
|
2073
2071
|
|
|
2074
|
-
const language = getLanguage(languageName)
|
|
2072
|
+
const language = getLanguage(languageName)
|
|
2075
2073
|
if (!language) {
|
|
2076
|
-
error(LANGUAGE_NOT_FOUND.replace(
|
|
2077
|
-
throw new Error('Unknown language: "' + languageName + '"')
|
|
2074
|
+
error(LANGUAGE_NOT_FOUND.replace('{}', languageName))
|
|
2075
|
+
throw new Error('Unknown language: "' + languageName + '"')
|
|
2078
2076
|
}
|
|
2079
2077
|
|
|
2080
|
-
const md = compileLanguage(language)
|
|
2081
|
-
let result = ''
|
|
2078
|
+
const md = compileLanguage(language)
|
|
2079
|
+
let result = ''
|
|
2082
2080
|
/** @type {CompiledMode} */
|
|
2083
|
-
let top = continuation || md
|
|
2081
|
+
let top = continuation || md
|
|
2084
2082
|
/** @type Record<string,CompiledMode> */
|
|
2085
|
-
const continuations = {}
|
|
2086
|
-
const emitter = new options.__emitter(options)
|
|
2087
|
-
processContinuations()
|
|
2088
|
-
let modeBuffer = ''
|
|
2089
|
-
let relevance = 0
|
|
2090
|
-
let index = 0
|
|
2091
|
-
let iterations = 0
|
|
2092
|
-
let resumeScanAtSamePosition = false
|
|
2083
|
+
const continuations = {} // keep continuations for sub-languages
|
|
2084
|
+
const emitter = new options.__emitter(options)
|
|
2085
|
+
processContinuations()
|
|
2086
|
+
let modeBuffer = ''
|
|
2087
|
+
let relevance = 0
|
|
2088
|
+
let index = 0
|
|
2089
|
+
let iterations = 0
|
|
2090
|
+
let resumeScanAtSamePosition = false
|
|
2093
2091
|
|
|
2094
2092
|
try {
|
|
2095
|
-
top.matcher.considerAll()
|
|
2093
|
+
top.matcher.considerAll()
|
|
2096
2094
|
|
|
2097
2095
|
for (; ;) {
|
|
2098
|
-
iterations
|
|
2096
|
+
iterations++
|
|
2099
2097
|
if (resumeScanAtSamePosition) {
|
|
2100
2098
|
// only regexes not matched previously will now be
|
|
2101
2099
|
// considered for a potential match
|
|
2102
|
-
resumeScanAtSamePosition = false
|
|
2100
|
+
resumeScanAtSamePosition = false
|
|
2103
2101
|
} else {
|
|
2104
|
-
top.matcher.considerAll()
|
|
2102
|
+
top.matcher.considerAll()
|
|
2105
2103
|
}
|
|
2106
|
-
top.matcher.lastIndex = index
|
|
2104
|
+
top.matcher.lastIndex = index
|
|
2107
2105
|
|
|
2108
|
-
const match = top.matcher.exec(codeToHighlight)
|
|
2106
|
+
const match = top.matcher.exec(codeToHighlight)
|
|
2109
2107
|
// console.log("match", match[0], match.rule && match.rule.begin)
|
|
2110
2108
|
|
|
2111
|
-
if (!match) break
|
|
2109
|
+
if (!match) break
|
|
2112
2110
|
|
|
2113
|
-
const beforeMatch = codeToHighlight.substring(index, match.index)
|
|
2114
|
-
const processedCount = processLexeme(beforeMatch, match)
|
|
2115
|
-
index = match.index + processedCount
|
|
2111
|
+
const beforeMatch = codeToHighlight.substring(index, match.index)
|
|
2112
|
+
const processedCount = processLexeme(beforeMatch, match)
|
|
2113
|
+
index = match.index + processedCount
|
|
2116
2114
|
}
|
|
2117
|
-
processLexeme(codeToHighlight.substr(index))
|
|
2118
|
-
emitter.closeAllNodes()
|
|
2119
|
-
emitter.finalize()
|
|
2120
|
-
result = emitter.toHTML()
|
|
2115
|
+
processLexeme(codeToHighlight.substr(index))
|
|
2116
|
+
emitter.closeAllNodes()
|
|
2117
|
+
emitter.finalize()
|
|
2118
|
+
result = emitter.toHTML()
|
|
2121
2119
|
|
|
2122
2120
|
return {
|
|
2123
2121
|
language: languageName,
|
|
2124
2122
|
value: result,
|
|
2125
|
-
relevance
|
|
2123
|
+
relevance,
|
|
2126
2124
|
illegal: false,
|
|
2127
2125
|
_emitter: emitter,
|
|
2128
2126
|
_top: top
|
|
2129
|
-
}
|
|
2127
|
+
}
|
|
2130
2128
|
} catch (err) {
|
|
2131
2129
|
if (err.message && err.message.includes('Illegal')) {
|
|
2132
2130
|
return {
|
|
@@ -2136,13 +2134,13 @@ var hljs = (function () {
|
|
|
2136
2134
|
relevance: 0,
|
|
2137
2135
|
_illegalBy: {
|
|
2138
2136
|
message: err.message,
|
|
2139
|
-
index
|
|
2137
|
+
index,
|
|
2140
2138
|
context: codeToHighlight.slice(index - 100, index + 100),
|
|
2141
2139
|
mode: err.mode,
|
|
2142
2140
|
resultSoFar: result
|
|
2143
2141
|
},
|
|
2144
2142
|
_emitter: emitter
|
|
2145
|
-
}
|
|
2143
|
+
}
|
|
2146
2144
|
} else if (SAFE_MODE) {
|
|
2147
2145
|
return {
|
|
2148
2146
|
language: languageName,
|
|
@@ -2152,9 +2150,9 @@ var hljs = (function () {
|
|
|
2152
2150
|
errorRaised: err,
|
|
2153
2151
|
_emitter: emitter,
|
|
2154
2152
|
_top: top
|
|
2155
|
-
}
|
|
2153
|
+
}
|
|
2156
2154
|
} else {
|
|
2157
|
-
throw err
|
|
2155
|
+
throw err
|
|
2158
2156
|
}
|
|
2159
2157
|
}
|
|
2160
2158
|
}
|
|
@@ -2166,16 +2164,16 @@ var hljs = (function () {
|
|
|
2166
2164
|
* @param {string} code
|
|
2167
2165
|
* @returns {HighlightResult}
|
|
2168
2166
|
*/
|
|
2169
|
-
function justTextHighlightResult(code) {
|
|
2167
|
+
function justTextHighlightResult (code) {
|
|
2170
2168
|
const result = {
|
|
2171
2169
|
value: escape(code),
|
|
2172
2170
|
illegal: false,
|
|
2173
2171
|
relevance: 0,
|
|
2174
2172
|
_top: PLAINTEXT_LANGUAGE,
|
|
2175
2173
|
_emitter: new options.__emitter(options)
|
|
2176
|
-
}
|
|
2177
|
-
result._emitter.addText(code)
|
|
2178
|
-
return result
|
|
2174
|
+
}
|
|
2175
|
+
result._emitter.addText(code)
|
|
2176
|
+
return result
|
|
2179
2177
|
}
|
|
2180
2178
|
|
|
2181
2179
|
/**
|
|
@@ -2192,26 +2190,26 @@ var hljs = (function () {
|
|
|
2192
2190
|
@param {Array<string>} [languageSubset]
|
|
2193
2191
|
@returns {AutoHighlightResult}
|
|
2194
2192
|
*/
|
|
2195
|
-
function highlightAuto(code, languageSubset) {
|
|
2196
|
-
languageSubset = languageSubset || options.languages || Object.keys(languages)
|
|
2197
|
-
const plaintext = justTextHighlightResult(code)
|
|
2193
|
+
function highlightAuto (code, languageSubset) {
|
|
2194
|
+
languageSubset = languageSubset || options.languages || Object.keys(languages)
|
|
2195
|
+
const plaintext = justTextHighlightResult(code)
|
|
2198
2196
|
|
|
2199
2197
|
const results = languageSubset.filter(getLanguage).filter(autoDetection).map(name =>
|
|
2200
2198
|
_highlight(name, code, false)
|
|
2201
|
-
)
|
|
2202
|
-
results.unshift(plaintext)
|
|
2199
|
+
)
|
|
2200
|
+
results.unshift(plaintext) // plaintext is always an option
|
|
2203
2201
|
|
|
2204
2202
|
const sorted = results.sort((a, b) => {
|
|
2205
2203
|
// sort base on relevance
|
|
2206
|
-
if (a.relevance !== b.relevance) return b.relevance - a.relevance
|
|
2204
|
+
if (a.relevance !== b.relevance) return b.relevance - a.relevance
|
|
2207
2205
|
|
|
2208
2206
|
// always award the tie to the base language
|
|
2209
2207
|
// ie if C++ and Arduino are tied, it's more likely to be C++
|
|
2210
2208
|
if (a.language && b.language) {
|
|
2211
2209
|
if (getLanguage(a.language).supersetOf === b.language) {
|
|
2212
|
-
return 1
|
|
2210
|
+
return 1
|
|
2213
2211
|
} else if (getLanguage(b.language).supersetOf === a.language) {
|
|
2214
|
-
return -1
|
|
2212
|
+
return -1
|
|
2215
2213
|
}
|
|
2216
2214
|
}
|
|
2217
2215
|
|
|
@@ -2219,16 +2217,16 @@ var hljs = (function () {
|
|
|
2219
2217
|
// relevance while preserving the original ordering - which is how ties
|
|
2220
2218
|
// have historically been settled, ie the language that comes first always
|
|
2221
2219
|
// wins in the case of a tie
|
|
2222
|
-
return 0
|
|
2223
|
-
})
|
|
2220
|
+
return 0
|
|
2221
|
+
})
|
|
2224
2222
|
|
|
2225
|
-
const [best, secondBest] = sorted
|
|
2223
|
+
const [best, secondBest] = sorted
|
|
2226
2224
|
|
|
2227
2225
|
/** @type {AutoHighlightResult} */
|
|
2228
|
-
const result = best
|
|
2229
|
-
result.secondBest = secondBest
|
|
2226
|
+
const result = best
|
|
2227
|
+
result.secondBest = secondBest
|
|
2230
2228
|
|
|
2231
|
-
return result
|
|
2229
|
+
return result
|
|
2232
2230
|
}
|
|
2233
2231
|
|
|
2234
2232
|
/**
|
|
@@ -2238,11 +2236,11 @@ var hljs = (function () {
|
|
|
2238
2236
|
* @param {string} [currentLang]
|
|
2239
2237
|
* @param {string} [resultLang]
|
|
2240
2238
|
*/
|
|
2241
|
-
function updateClassName(element, currentLang, resultLang) {
|
|
2242
|
-
const language = (currentLang && aliases[currentLang]) || resultLang
|
|
2239
|
+
function updateClassName (element, currentLang, resultLang) {
|
|
2240
|
+
const language = (currentLang && aliases[currentLang]) || resultLang
|
|
2243
2241
|
|
|
2244
|
-
element.classList.add(
|
|
2245
|
-
element.classList.add(`language-${language}`)
|
|
2242
|
+
element.classList.add('hljs')
|
|
2243
|
+
element.classList.add(`language-${language}`)
|
|
2246
2244
|
}
|
|
2247
2245
|
|
|
2248
2246
|
/**
|
|
@@ -2250,42 +2248,42 @@ var hljs = (function () {
|
|
|
2250
2248
|
*
|
|
2251
2249
|
* @param {HighlightedHTMLElement} element - the HTML element to highlight
|
|
2252
2250
|
*/
|
|
2253
|
-
function highlightElement(element) {
|
|
2251
|
+
function highlightElement (element) {
|
|
2254
2252
|
/** @type HTMLElement */
|
|
2255
|
-
let node = null
|
|
2256
|
-
const language = blockLanguage(element)
|
|
2253
|
+
let node = null
|
|
2254
|
+
const language = blockLanguage(element)
|
|
2257
2255
|
|
|
2258
|
-
if (shouldNotHighlight(language)) return
|
|
2256
|
+
if (shouldNotHighlight(language)) return
|
|
2259
2257
|
|
|
2260
|
-
fire(
|
|
2261
|
-
{ el: element, language
|
|
2258
|
+
fire('before:highlightElement',
|
|
2259
|
+
{ el: element, language })
|
|
2262
2260
|
|
|
2263
2261
|
// we should be all text, no child nodes
|
|
2264
2262
|
if (!options.ignoreUnescapedHTML && element.children.length > 0) {
|
|
2265
|
-
console.warn(
|
|
2266
|
-
console.warn(
|
|
2267
|
-
console.warn(element)
|
|
2263
|
+
console.warn('One of your code blocks includes unescaped HTML. This is a potentially serious security risk.')
|
|
2264
|
+
console.warn('https://github.com/highlightjs/highlight.js/issues/2886')
|
|
2265
|
+
console.warn(element)
|
|
2268
2266
|
}
|
|
2269
2267
|
|
|
2270
|
-
node = element
|
|
2271
|
-
const text = node.textContent
|
|
2272
|
-
const result = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text)
|
|
2268
|
+
node = element
|
|
2269
|
+
const text = node.textContent
|
|
2270
|
+
const result = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text)
|
|
2273
2271
|
|
|
2274
|
-
fire(
|
|
2272
|
+
fire('after:highlightElement', { el: element, result, text })
|
|
2275
2273
|
|
|
2276
|
-
element.innerHTML = result.value
|
|
2277
|
-
updateClassName(element, language, result.language)
|
|
2274
|
+
element.innerHTML = result.value
|
|
2275
|
+
updateClassName(element, language, result.language)
|
|
2278
2276
|
element.result = {
|
|
2279
2277
|
language: result.language,
|
|
2280
2278
|
// TODO: remove with version 11.0
|
|
2281
2279
|
re: result.relevance,
|
|
2282
2280
|
relevance: result.relevance
|
|
2283
|
-
}
|
|
2281
|
+
}
|
|
2284
2282
|
if (result.secondBest) {
|
|
2285
2283
|
element.secondBest = {
|
|
2286
2284
|
language: result.secondBest.language,
|
|
2287
2285
|
relevance: result.secondBest.relevance
|
|
2288
|
-
}
|
|
2286
|
+
}
|
|
2289
2287
|
}
|
|
2290
2288
|
}
|
|
2291
2289
|
|
|
@@ -2294,46 +2292,46 @@ var hljs = (function () {
|
|
|
2294
2292
|
*
|
|
2295
2293
|
* @param {Partial<HLJSOptions>} userOptions
|
|
2296
2294
|
*/
|
|
2297
|
-
function configure(userOptions) {
|
|
2298
|
-
options = inherit(options, userOptions)
|
|
2295
|
+
function configure (userOptions) {
|
|
2296
|
+
options = inherit(options, userOptions)
|
|
2299
2297
|
}
|
|
2300
2298
|
|
|
2301
2299
|
// TODO: remove v12, deprecated
|
|
2302
2300
|
const initHighlighting = () => {
|
|
2303
|
-
highlightAll()
|
|
2304
|
-
deprecated(
|
|
2305
|
-
}
|
|
2301
|
+
highlightAll()
|
|
2302
|
+
deprecated('10.6.0', 'initHighlighting() deprecated. Use highlightAll() now.')
|
|
2303
|
+
}
|
|
2306
2304
|
|
|
2307
2305
|
// TODO: remove v12, deprecated
|
|
2308
|
-
function initHighlightingOnLoad() {
|
|
2309
|
-
highlightAll()
|
|
2310
|
-
deprecated(
|
|
2306
|
+
function initHighlightingOnLoad () {
|
|
2307
|
+
highlightAll()
|
|
2308
|
+
deprecated('10.6.0', 'initHighlightingOnLoad() deprecated. Use highlightAll() now.')
|
|
2311
2309
|
}
|
|
2312
2310
|
|
|
2313
|
-
let wantsHighlight = false
|
|
2311
|
+
let wantsHighlight = false
|
|
2314
2312
|
|
|
2315
2313
|
/**
|
|
2316
2314
|
* auto-highlights all pre>code elements on the page
|
|
2317
2315
|
*/
|
|
2318
|
-
function highlightAll() {
|
|
2316
|
+
function highlightAll () {
|
|
2319
2317
|
// if we are called too early in the loading process
|
|
2320
|
-
if (document.readyState ===
|
|
2321
|
-
wantsHighlight = true
|
|
2322
|
-
return
|
|
2318
|
+
if (document.readyState === 'loading') {
|
|
2319
|
+
wantsHighlight = true
|
|
2320
|
+
return
|
|
2323
2321
|
}
|
|
2324
2322
|
|
|
2325
|
-
const blocks = document.querySelectorAll(options.cssSelector)
|
|
2326
|
-
blocks.forEach(highlightElement)
|
|
2323
|
+
const blocks = document.querySelectorAll(options.cssSelector)
|
|
2324
|
+
blocks.forEach(highlightElement)
|
|
2327
2325
|
}
|
|
2328
2326
|
|
|
2329
|
-
function boot() {
|
|
2327
|
+
function boot () {
|
|
2330
2328
|
// if a highlight was requested before DOM was loaded, do now
|
|
2331
|
-
if (wantsHighlight) highlightAll()
|
|
2329
|
+
if (wantsHighlight) highlightAll()
|
|
2332
2330
|
}
|
|
2333
2331
|
|
|
2334
2332
|
// make sure we are in the browser environment
|
|
2335
2333
|
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
2336
|
-
window.addEventListener('DOMContentLoaded', boot, false)
|
|
2334
|
+
window.addEventListener('DOMContentLoaded', boot, false)
|
|
2337
2335
|
}
|
|
2338
2336
|
|
|
2339
2337
|
/**
|
|
@@ -2342,27 +2340,27 @@ var hljs = (function () {
|
|
|
2342
2340
|
* @param {string} languageName
|
|
2343
2341
|
* @param {LanguageFn} languageDefinition
|
|
2344
2342
|
*/
|
|
2345
|
-
function registerLanguage(languageName, languageDefinition) {
|
|
2346
|
-
let lang = null
|
|
2343
|
+
function registerLanguage (languageName, languageDefinition) {
|
|
2344
|
+
let lang = null
|
|
2347
2345
|
try {
|
|
2348
|
-
lang = languageDefinition(hljs)
|
|
2346
|
+
lang = languageDefinition(hljs)
|
|
2349
2347
|
} catch (error$1) {
|
|
2350
|
-
error("Language definition for '{}' could not be registered.".replace(
|
|
2348
|
+
error("Language definition for '{}' could not be registered.".replace('{}', languageName))
|
|
2351
2349
|
// hard or soft error
|
|
2352
|
-
if (!SAFE_MODE) { throw error$1
|
|
2350
|
+
if (!SAFE_MODE) { throw error$1 } else { error(error$1) }
|
|
2353
2351
|
// languages that have serious errors are replaced with essentially a
|
|
2354
2352
|
// "plaintext" stand-in so that the code blocks will still get normal
|
|
2355
2353
|
// css classes applied to them - and one bad language won't break the
|
|
2356
2354
|
// entire highlighter
|
|
2357
|
-
lang = PLAINTEXT_LANGUAGE
|
|
2355
|
+
lang = PLAINTEXT_LANGUAGE
|
|
2358
2356
|
}
|
|
2359
2357
|
// give it a temporary name if it doesn't have one in the meta-data
|
|
2360
|
-
if (!lang.name) lang.name = languageName
|
|
2361
|
-
languages[languageName] = lang
|
|
2362
|
-
lang.rawDefinition = languageDefinition.bind(null, hljs)
|
|
2358
|
+
if (!lang.name) lang.name = languageName
|
|
2359
|
+
languages[languageName] = lang
|
|
2360
|
+
lang.rawDefinition = languageDefinition.bind(null, hljs)
|
|
2363
2361
|
|
|
2364
2362
|
if (lang.aliases) {
|
|
2365
|
-
registerAliases(lang.aliases, { languageName })
|
|
2363
|
+
registerAliases(lang.aliases, { languageName })
|
|
2366
2364
|
}
|
|
2367
2365
|
}
|
|
2368
2366
|
|
|
@@ -2371,11 +2369,11 @@ var hljs = (function () {
|
|
|
2371
2369
|
*
|
|
2372
2370
|
* @param {string} languageName
|
|
2373
2371
|
*/
|
|
2374
|
-
function unregisterLanguage(languageName) {
|
|
2375
|
-
delete languages[languageName]
|
|
2372
|
+
function unregisterLanguage (languageName) {
|
|
2373
|
+
delete languages[languageName]
|
|
2376
2374
|
for (const alias of Object.keys(aliases)) {
|
|
2377
2375
|
if (aliases[alias] === languageName) {
|
|
2378
|
-
delete aliases[alias]
|
|
2376
|
+
delete aliases[alias]
|
|
2379
2377
|
}
|
|
2380
2378
|
}
|
|
2381
2379
|
}
|
|
@@ -2383,17 +2381,17 @@ var hljs = (function () {
|
|
|
2383
2381
|
/**
|
|
2384
2382
|
* @returns {string[]} List of language internal names
|
|
2385
2383
|
*/
|
|
2386
|
-
function listLanguages() {
|
|
2387
|
-
return Object.keys(languages)
|
|
2384
|
+
function listLanguages () {
|
|
2385
|
+
return Object.keys(languages)
|
|
2388
2386
|
}
|
|
2389
2387
|
|
|
2390
2388
|
/**
|
|
2391
2389
|
* @param {string} name - name of the language to retrieve
|
|
2392
2390
|
* @returns {Language | undefined}
|
|
2393
2391
|
*/
|
|
2394
|
-
function getLanguage(name) {
|
|
2395
|
-
name = (name || '').toLowerCase()
|
|
2396
|
-
return languages[name] || languages[aliases[name]]
|
|
2392
|
+
function getLanguage (name) {
|
|
2393
|
+
name = (name || '').toLowerCase()
|
|
2394
|
+
return languages[name] || languages[aliases[name]]
|
|
2397
2395
|
}
|
|
2398
2396
|
|
|
2399
2397
|
/**
|
|
@@ -2401,20 +2399,20 @@ var hljs = (function () {
|
|
|
2401
2399
|
* @param {string|string[]} aliasList - single alias or list of aliases
|
|
2402
2400
|
* @param {{languageName: string}} opts
|
|
2403
2401
|
*/
|
|
2404
|
-
function registerAliases(aliasList, { languageName }) {
|
|
2402
|
+
function registerAliases (aliasList, { languageName }) {
|
|
2405
2403
|
if (typeof aliasList === 'string') {
|
|
2406
|
-
aliasList = [aliasList]
|
|
2404
|
+
aliasList = [aliasList]
|
|
2407
2405
|
}
|
|
2408
|
-
aliasList.forEach(alias => { aliases[alias.toLowerCase()] = languageName
|
|
2406
|
+
aliasList.forEach(alias => { aliases[alias.toLowerCase()] = languageName })
|
|
2409
2407
|
}
|
|
2410
2408
|
|
|
2411
2409
|
/**
|
|
2412
2410
|
* Determines if a given language has auto-detection enabled
|
|
2413
2411
|
* @param {string} name - name of the language
|
|
2414
2412
|
*/
|
|
2415
|
-
function autoDetection(name) {
|
|
2416
|
-
const lang = getLanguage(name)
|
|
2417
|
-
return lang && !lang.disableAutodetect
|
|
2413
|
+
function autoDetection (name) {
|
|
2414
|
+
const lang = getLanguage(name)
|
|
2415
|
+
return lang && !lang.disableAutodetect
|
|
2418
2416
|
}
|
|
2419
2417
|
|
|
2420
2418
|
/**
|
|
@@ -2422,30 +2420,30 @@ var hljs = (function () {
|
|
|
2422
2420
|
* highlightElement API
|
|
2423
2421
|
* @param {HLJSPlugin} plugin
|
|
2424
2422
|
*/
|
|
2425
|
-
function upgradePluginAPI(plugin) {
|
|
2423
|
+
function upgradePluginAPI (plugin) {
|
|
2426
2424
|
// TODO: remove with v12
|
|
2427
|
-
if (plugin[
|
|
2428
|
-
plugin[
|
|
2429
|
-
plugin[
|
|
2425
|
+
if (plugin['before:highlightBlock'] && !plugin['before:highlightElement']) {
|
|
2426
|
+
plugin['before:highlightElement'] = (data) => {
|
|
2427
|
+
plugin['before:highlightBlock'](
|
|
2430
2428
|
Object.assign({ block: data.el }, data)
|
|
2431
|
-
)
|
|
2432
|
-
}
|
|
2429
|
+
)
|
|
2430
|
+
}
|
|
2433
2431
|
}
|
|
2434
|
-
if (plugin[
|
|
2435
|
-
plugin[
|
|
2436
|
-
plugin[
|
|
2432
|
+
if (plugin['after:highlightBlock'] && !plugin['after:highlightElement']) {
|
|
2433
|
+
plugin['after:highlightElement'] = (data) => {
|
|
2434
|
+
plugin['after:highlightBlock'](
|
|
2437
2435
|
Object.assign({ block: data.el }, data)
|
|
2438
|
-
)
|
|
2439
|
-
}
|
|
2436
|
+
)
|
|
2437
|
+
}
|
|
2440
2438
|
}
|
|
2441
2439
|
}
|
|
2442
2440
|
|
|
2443
2441
|
/**
|
|
2444
2442
|
* @param {HLJSPlugin} plugin
|
|
2445
2443
|
*/
|
|
2446
|
-
function addPlugin(plugin) {
|
|
2447
|
-
upgradePluginAPI(plugin)
|
|
2448
|
-
plugins.push(plugin)
|
|
2444
|
+
function addPlugin (plugin) {
|
|
2445
|
+
upgradePluginAPI(plugin)
|
|
2446
|
+
plugins.push(plugin)
|
|
2449
2447
|
}
|
|
2450
2448
|
|
|
2451
2449
|
/**
|
|
@@ -2453,24 +2451,24 @@ var hljs = (function () {
|
|
|
2453
2451
|
* @param {PluginEvent} event
|
|
2454
2452
|
* @param {any} args
|
|
2455
2453
|
*/
|
|
2456
|
-
function fire(event, args) {
|
|
2457
|
-
const cb = event
|
|
2454
|
+
function fire (event, args) {
|
|
2455
|
+
const cb = event
|
|
2458
2456
|
plugins.forEach(function (plugin) {
|
|
2459
2457
|
if (plugin[cb]) {
|
|
2460
|
-
plugin[cb](args)
|
|
2458
|
+
plugin[cb](args)
|
|
2461
2459
|
}
|
|
2462
|
-
})
|
|
2460
|
+
})
|
|
2463
2461
|
}
|
|
2464
2462
|
|
|
2465
2463
|
/**
|
|
2466
2464
|
*
|
|
2467
2465
|
* @param {HighlightedHTMLElement} el
|
|
2468
2466
|
*/
|
|
2469
|
-
function deprecateHighlightBlock(el) {
|
|
2470
|
-
deprecated(
|
|
2471
|
-
deprecated(
|
|
2467
|
+
function deprecateHighlightBlock (el) {
|
|
2468
|
+
deprecated('10.7.0', 'highlightBlock will be removed entirely in v12.0')
|
|
2469
|
+
deprecated('10.7.0', 'Please use highlightElement now.')
|
|
2472
2470
|
|
|
2473
|
-
return highlightElement(el)
|
|
2471
|
+
return highlightElement(el)
|
|
2474
2472
|
}
|
|
2475
2473
|
|
|
2476
2474
|
/* Interface definition */
|
|
@@ -2492,28 +2490,28 @@ var hljs = (function () {
|
|
|
2492
2490
|
autoDetection,
|
|
2493
2491
|
inherit,
|
|
2494
2492
|
addPlugin
|
|
2495
|
-
})
|
|
2493
|
+
})
|
|
2496
2494
|
|
|
2497
|
-
hljs.debugMode = function () { SAFE_MODE = false
|
|
2498
|
-
hljs.safeMode = function () { SAFE_MODE = true
|
|
2499
|
-
hljs.versionString = version
|
|
2495
|
+
hljs.debugMode = function () { SAFE_MODE = false }
|
|
2496
|
+
hljs.safeMode = function () { SAFE_MODE = true }
|
|
2497
|
+
hljs.versionString = version
|
|
2500
2498
|
|
|
2501
2499
|
for (const key in MODES$1) {
|
|
2502
2500
|
// @ts-ignore
|
|
2503
|
-
if (typeof MODES$1[key] ===
|
|
2501
|
+
if (typeof MODES$1[key] === 'object') {
|
|
2504
2502
|
// @ts-ignore
|
|
2505
|
-
deepFreeze$1(MODES$1[key])
|
|
2503
|
+
deepFreeze$1(MODES$1[key])
|
|
2506
2504
|
}
|
|
2507
2505
|
}
|
|
2508
2506
|
|
|
2509
2507
|
// merge all the modes/regexes into our main object
|
|
2510
|
-
Object.assign(hljs, MODES$1)
|
|
2508
|
+
Object.assign(hljs, MODES$1)
|
|
2511
2509
|
|
|
2512
|
-
return hljs
|
|
2513
|
-
}
|
|
2510
|
+
return hljs
|
|
2511
|
+
}
|
|
2514
2512
|
|
|
2515
2513
|
// export an "instance" of the highlighter
|
|
2516
|
-
|
|
2514
|
+
const HighlightJS = HLJS({})
|
|
2517
2515
|
|
|
2518
2516
|
/*
|
|
2519
2517
|
Language: Bash
|
|
@@ -2524,19 +2522,19 @@ var hljs = (function () {
|
|
|
2524
2522
|
*/
|
|
2525
2523
|
|
|
2526
2524
|
/** @type LanguageFn */
|
|
2527
|
-
function bash(hljs) {
|
|
2528
|
-
const VAR = {}
|
|
2525
|
+
function bash (hljs) {
|
|
2526
|
+
const VAR = {}
|
|
2529
2527
|
const BRACED_VAR = {
|
|
2530
2528
|
begin: /\$\{/,
|
|
2531
2529
|
end: /\}/,
|
|
2532
2530
|
contains: [
|
|
2533
|
-
|
|
2531
|
+
'self',
|
|
2534
2532
|
{
|
|
2535
2533
|
begin: /:-/,
|
|
2536
2534
|
contains: [VAR]
|
|
2537
2535
|
} // default values
|
|
2538
2536
|
]
|
|
2539
|
-
}
|
|
2537
|
+
}
|
|
2540
2538
|
Object.assign(VAR, {
|
|
2541
2539
|
className: 'variable',
|
|
2542
2540
|
variants: [
|
|
@@ -2544,17 +2542,18 @@ var hljs = (function () {
|
|
|
2544
2542
|
begin: concat(/\$[\w\d#@][\w\d_]*/,
|
|
2545
2543
|
// negative look-ahead tries to avoid matching patterns that are not
|
|
2546
2544
|
// Perl at all like $ident$, @ident@, etc.
|
|
2547
|
-
|
|
2545
|
+
'(?![\\w\\d])(?![$])')
|
|
2548
2546
|
},
|
|
2549
2547
|
BRACED_VAR
|
|
2550
2548
|
]
|
|
2551
|
-
})
|
|
2549
|
+
})
|
|
2552
2550
|
|
|
2553
2551
|
const SUBST = {
|
|
2554
2552
|
className: 'subst',
|
|
2555
|
-
begin: /\$\(/,
|
|
2553
|
+
begin: /\$\(/,
|
|
2554
|
+
end: /\)/,
|
|
2556
2555
|
contains: [hljs.BACKSLASH_ESCAPE]
|
|
2557
|
-
}
|
|
2556
|
+
}
|
|
2558
2557
|
const HERE_DOC = {
|
|
2559
2558
|
begin: /<<-?\s*(?=\w+)/,
|
|
2560
2559
|
starts: {
|
|
@@ -2566,78 +2565,80 @@ var hljs = (function () {
|
|
|
2566
2565
|
})
|
|
2567
2566
|
]
|
|
2568
2567
|
}
|
|
2569
|
-
}
|
|
2568
|
+
}
|
|
2570
2569
|
const QUOTE_STRING = {
|
|
2571
2570
|
className: 'string',
|
|
2572
|
-
begin: /"/,
|
|
2571
|
+
begin: /"/,
|
|
2572
|
+
end: /"/,
|
|
2573
2573
|
contains: [
|
|
2574
2574
|
hljs.BACKSLASH_ESCAPE,
|
|
2575
2575
|
VAR,
|
|
2576
2576
|
SUBST
|
|
2577
2577
|
]
|
|
2578
|
-
}
|
|
2579
|
-
SUBST.contains.push(QUOTE_STRING)
|
|
2578
|
+
}
|
|
2579
|
+
SUBST.contains.push(QUOTE_STRING)
|
|
2580
2580
|
const ESCAPED_QUOTE = {
|
|
2581
2581
|
className: '',
|
|
2582
2582
|
begin: /\\"/
|
|
2583
2583
|
|
|
2584
|
-
}
|
|
2584
|
+
}
|
|
2585
2585
|
const APOS_STRING = {
|
|
2586
2586
|
className: 'string',
|
|
2587
|
-
begin: /'/,
|
|
2588
|
-
|
|
2587
|
+
begin: /'/,
|
|
2588
|
+
end: /'/
|
|
2589
|
+
}
|
|
2589
2590
|
const ARITHMETIC = {
|
|
2590
2591
|
begin: /\$\(\(/,
|
|
2591
2592
|
end: /\)\)/,
|
|
2592
2593
|
contains: [
|
|
2593
|
-
{ begin: /\d+#[0-9a-f]+/, className:
|
|
2594
|
+
{ begin: /\d+#[0-9a-f]+/, className: 'number' },
|
|
2594
2595
|
hljs.NUMBER_MODE,
|
|
2595
2596
|
VAR
|
|
2596
2597
|
]
|
|
2597
|
-
}
|
|
2598
|
+
}
|
|
2598
2599
|
const SH_LIKE_SHELLS = [
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
]
|
|
2600
|
+
'fish',
|
|
2601
|
+
'bash',
|
|
2602
|
+
'zsh',
|
|
2603
|
+
'sh',
|
|
2604
|
+
'csh',
|
|
2605
|
+
'ksh',
|
|
2606
|
+
'tcsh',
|
|
2607
|
+
'dash',
|
|
2608
|
+
'scsh'
|
|
2609
|
+
]
|
|
2609
2610
|
const KNOWN_SHEBANG = hljs.SHEBANG({
|
|
2610
|
-
binary: `(${SH_LIKE_SHELLS.join(
|
|
2611
|
+
binary: `(${SH_LIKE_SHELLS.join('|')})`,
|
|
2611
2612
|
relevance: 10
|
|
2612
|
-
})
|
|
2613
|
+
})
|
|
2613
2614
|
const FUNCTION = {
|
|
2614
2615
|
className: 'function',
|
|
2615
2616
|
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
|
|
2616
2617
|
returnBegin: true,
|
|
2617
2618
|
contains: [hljs.inherit(hljs.TITLE_MODE, { begin: /\w[\w\d_]*/ })],
|
|
2618
2619
|
relevance: 0
|
|
2619
|
-
}
|
|
2620
|
+
}
|
|
2620
2621
|
|
|
2621
2622
|
const KEYWORDS = [
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
]
|
|
2623
|
+
'if',
|
|
2624
|
+
'then',
|
|
2625
|
+
'else',
|
|
2626
|
+
'elif',
|
|
2627
|
+
'fi',
|
|
2628
|
+
'for',
|
|
2629
|
+
'while',
|
|
2630
|
+
'in',
|
|
2631
|
+
'do',
|
|
2632
|
+
'done',
|
|
2633
|
+
'case',
|
|
2634
|
+
'esac',
|
|
2635
|
+
'function'
|
|
2636
|
+
]
|
|
2636
2637
|
|
|
2637
2638
|
const LITERALS = [
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
]
|
|
2639
|
+
'true',
|
|
2640
|
+
'false'
|
|
2641
|
+
]
|
|
2641
2642
|
|
|
2642
2643
|
return {
|
|
2643
2644
|
name: 'Bash',
|
|
@@ -2676,10 +2677,9 @@ var hljs = (function () {
|
|
|
2676
2677
|
APOS_STRING,
|
|
2677
2678
|
VAR
|
|
2678
2679
|
]
|
|
2679
|
-
}
|
|
2680
|
+
}
|
|
2680
2681
|
}
|
|
2681
2682
|
|
|
2682
|
-
|
|
2683
2683
|
const MODES = (hljs) => {
|
|
2684
2684
|
return {
|
|
2685
2685
|
IMPORTANT: {
|
|
@@ -2713,8 +2713,8 @@ var hljs = (function () {
|
|
|
2713
2713
|
')?',
|
|
2714
2714
|
relevance: 0
|
|
2715
2715
|
}
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
2718
|
|
|
2719
2719
|
const TAGS = [
|
|
2720
2720
|
'a',
|
|
@@ -2789,7 +2789,7 @@ var hljs = (function () {
|
|
|
2789
2789
|
'ul',
|
|
2790
2790
|
'var',
|
|
2791
2791
|
'video'
|
|
2792
|
-
]
|
|
2792
|
+
]
|
|
2793
2793
|
|
|
2794
2794
|
const MEDIA_FEATURES = [
|
|
2795
2795
|
'any-hover',
|
|
@@ -2826,7 +2826,7 @@ var hljs = (function () {
|
|
|
2826
2826
|
'max-width',
|
|
2827
2827
|
'min-height',
|
|
2828
2828
|
'max-height'
|
|
2829
|
-
]
|
|
2829
|
+
]
|
|
2830
2830
|
|
|
2831
2831
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
|
|
2832
2832
|
const PSEUDO_CLASSES = [
|
|
@@ -2869,8 +2869,8 @@ var hljs = (function () {
|
|
|
2869
2869
|
'nth-col', // nth-col()
|
|
2870
2870
|
'nth-last-child', // nth-last-child()
|
|
2871
2871
|
'nth-last-col', // nth-last-col()
|
|
2872
|
-
'nth-last-of-type', //nth-last-of-type()
|
|
2873
|
-
'nth-of-type', //nth-of-type()
|
|
2872
|
+
'nth-last-of-type', // nth-last-of-type()
|
|
2873
|
+
'nth-of-type', // nth-of-type()
|
|
2874
2874
|
'only-child',
|
|
2875
2875
|
'only-of-type',
|
|
2876
2876
|
'optional',
|
|
@@ -2889,7 +2889,7 @@ var hljs = (function () {
|
|
|
2889
2889
|
'valid',
|
|
2890
2890
|
'visited',
|
|
2891
2891
|
'where' // where()
|
|
2892
|
-
]
|
|
2892
|
+
]
|
|
2893
2893
|
|
|
2894
2894
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
|
|
2895
2895
|
const PSEUDO_ELEMENTS = [
|
|
@@ -2907,7 +2907,7 @@ var hljs = (function () {
|
|
|
2907
2907
|
'selection',
|
|
2908
2908
|
'slotted',
|
|
2909
2909
|
'spelling-error'
|
|
2910
|
-
]
|
|
2910
|
+
]
|
|
2911
2911
|
|
|
2912
2912
|
const ATTRIBUTES = [
|
|
2913
2913
|
'align-content',
|
|
@@ -3119,17 +3119,16 @@ var hljs = (function () {
|
|
|
3119
3119
|
'z-index'
|
|
3120
3120
|
// reverse makes sure longer attributes `font-weight` are matched fully
|
|
3121
3121
|
// instead of getting false positives on say `font`
|
|
3122
|
-
].reverse()
|
|
3122
|
+
].reverse()
|
|
3123
3123
|
|
|
3124
3124
|
// some grammars use them all as a single group
|
|
3125
|
-
const PSEUDO_SELECTORS = PSEUDO_CLASSES.concat(PSEUDO_ELEMENTS)
|
|
3126
|
-
|
|
3125
|
+
const PSEUDO_SELECTORS = PSEUDO_CLASSES.concat(PSEUDO_ELEMENTS)
|
|
3127
3126
|
|
|
3128
3127
|
// https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3128
|
+
const decimalDigits = '[0-9](_*[0-9])*'
|
|
3129
|
+
const frac = `\\.(${decimalDigits})`
|
|
3130
|
+
const hexDigits = '[0-9a-fA-F](_*[0-9a-fA-F])*'
|
|
3131
|
+
const NUMERIC = {
|
|
3133
3132
|
className: 'number',
|
|
3134
3133
|
variants: [
|
|
3135
3134
|
// DecimalFloatingPointLiteral
|
|
@@ -3159,11 +3158,10 @@ var hljs = (function () {
|
|
|
3159
3158
|
{ begin: '\\b0(_*[0-7])*[lL]?\\b' },
|
|
3160
3159
|
|
|
3161
3160
|
// BinaryIntegerLiteral
|
|
3162
|
-
{ begin: '\\b0[bB][01](_*[01])*[lL]?\\b' }
|
|
3161
|
+
{ begin: '\\b0[bB][01](_*[01])*[lL]?\\b' }
|
|
3163
3162
|
],
|
|
3164
3163
|
relevance: 0
|
|
3165
|
-
}
|
|
3166
|
-
|
|
3164
|
+
}
|
|
3167
3165
|
|
|
3168
3166
|
/**
|
|
3169
3167
|
* Allows recursive regex expressions to a given depth
|
|
@@ -3176,153 +3174,153 @@ var hljs = (function () {
|
|
|
3176
3174
|
* @param {number} depth
|
|
3177
3175
|
* @returns {string}``
|
|
3178
3176
|
*/
|
|
3179
|
-
function recurRegex(re, substitution, depth) {
|
|
3180
|
-
if (depth === -1) return
|
|
3177
|
+
function recurRegex (re, substitution, depth) {
|
|
3178
|
+
if (depth === -1) return ''
|
|
3181
3179
|
|
|
3182
3180
|
return re.replace(substitution, _ => {
|
|
3183
|
-
return recurRegex(re, substitution, depth - 1)
|
|
3184
|
-
})
|
|
3181
|
+
return recurRegex(re, substitution, depth - 1)
|
|
3182
|
+
})
|
|
3185
3183
|
}
|
|
3186
3184
|
|
|
3187
|
-
const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'
|
|
3185
|
+
const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'
|
|
3188
3186
|
const KEYWORDS = [
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3187
|
+
'as', // for exports
|
|
3188
|
+
'in',
|
|
3189
|
+
'of',
|
|
3190
|
+
'if',
|
|
3191
|
+
'for',
|
|
3192
|
+
'while',
|
|
3193
|
+
'finally',
|
|
3194
|
+
'var',
|
|
3195
|
+
'new',
|
|
3196
|
+
'function',
|
|
3197
|
+
'do',
|
|
3198
|
+
'return',
|
|
3199
|
+
'void',
|
|
3200
|
+
'else',
|
|
3201
|
+
'break',
|
|
3202
|
+
'catch',
|
|
3203
|
+
'instanceof',
|
|
3204
|
+
'with',
|
|
3205
|
+
'throw',
|
|
3206
|
+
'case',
|
|
3207
|
+
'default',
|
|
3208
|
+
'try',
|
|
3209
|
+
'switch',
|
|
3210
|
+
'continue',
|
|
3211
|
+
'typeof',
|
|
3212
|
+
'delete',
|
|
3213
|
+
'let',
|
|
3214
|
+
'yield',
|
|
3215
|
+
'const',
|
|
3216
|
+
'class',
|
|
3219
3217
|
// JS handles these with a special rule
|
|
3220
3218
|
// "get",
|
|
3221
3219
|
// "set",
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
]
|
|
3220
|
+
'debugger',
|
|
3221
|
+
'async',
|
|
3222
|
+
'await',
|
|
3223
|
+
'static',
|
|
3224
|
+
'import',
|
|
3225
|
+
'from',
|
|
3226
|
+
'export',
|
|
3227
|
+
'extends'
|
|
3228
|
+
]
|
|
3231
3229
|
const LITERALS = [
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
]
|
|
3230
|
+
'true',
|
|
3231
|
+
'false',
|
|
3232
|
+
'null',
|
|
3233
|
+
'undefined',
|
|
3234
|
+
'NaN',
|
|
3235
|
+
'Infinity'
|
|
3236
|
+
]
|
|
3239
3237
|
|
|
3240
3238
|
const TYPES = [
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
]
|
|
3239
|
+
'Intl',
|
|
3240
|
+
'DataView',
|
|
3241
|
+
'Number',
|
|
3242
|
+
'Math',
|
|
3243
|
+
'Date',
|
|
3244
|
+
'String',
|
|
3245
|
+
'RegExp',
|
|
3246
|
+
'Object',
|
|
3247
|
+
'Function',
|
|
3248
|
+
'Boolean',
|
|
3249
|
+
'Error',
|
|
3250
|
+
'Symbol',
|
|
3251
|
+
'Set',
|
|
3252
|
+
'Map',
|
|
3253
|
+
'WeakSet',
|
|
3254
|
+
'WeakMap',
|
|
3255
|
+
'Proxy',
|
|
3256
|
+
'Reflect',
|
|
3257
|
+
'JSON',
|
|
3258
|
+
'Promise',
|
|
3259
|
+
'Float64Array',
|
|
3260
|
+
'Int16Array',
|
|
3261
|
+
'Int32Array',
|
|
3262
|
+
'Int8Array',
|
|
3263
|
+
'Uint16Array',
|
|
3264
|
+
'Uint32Array',
|
|
3265
|
+
'Float32Array',
|
|
3266
|
+
'Array',
|
|
3267
|
+
'Uint8Array',
|
|
3268
|
+
'Uint8ClampedArray',
|
|
3269
|
+
'ArrayBuffer',
|
|
3270
|
+
'BigInt64Array',
|
|
3271
|
+
'BigUint64Array',
|
|
3272
|
+
'BigInt'
|
|
3273
|
+
]
|
|
3276
3274
|
|
|
3277
3275
|
const ERROR_TYPES = [
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
]
|
|
3276
|
+
'EvalError',
|
|
3277
|
+
'InternalError',
|
|
3278
|
+
'RangeError',
|
|
3279
|
+
'ReferenceError',
|
|
3280
|
+
'SyntaxError',
|
|
3281
|
+
'TypeError',
|
|
3282
|
+
'URIError'
|
|
3283
|
+
]
|
|
3286
3284
|
|
|
3287
3285
|
const BUILT_IN_GLOBALS = [
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
]
|
|
3286
|
+
'setInterval',
|
|
3287
|
+
'setTimeout',
|
|
3288
|
+
'clearInterval',
|
|
3289
|
+
'clearTimeout',
|
|
3290
|
+
|
|
3291
|
+
'require',
|
|
3292
|
+
'exports',
|
|
3293
|
+
|
|
3294
|
+
'eval',
|
|
3295
|
+
'isFinite',
|
|
3296
|
+
'isNaN',
|
|
3297
|
+
'parseFloat',
|
|
3298
|
+
'parseInt',
|
|
3299
|
+
'decodeURI',
|
|
3300
|
+
'decodeURIComponent',
|
|
3301
|
+
'encodeURI',
|
|
3302
|
+
'encodeURIComponent',
|
|
3303
|
+
'escape',
|
|
3304
|
+
'unescape'
|
|
3305
|
+
]
|
|
3308
3306
|
|
|
3309
3307
|
const BUILT_IN_VARIABLES = [
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
]
|
|
3308
|
+
'arguments',
|
|
3309
|
+
'this',
|
|
3310
|
+
'super',
|
|
3311
|
+
'console',
|
|
3312
|
+
'window',
|
|
3313
|
+
'document',
|
|
3314
|
+
'localStorage',
|
|
3315
|
+
'module',
|
|
3316
|
+
'global' // Node.js
|
|
3317
|
+
]
|
|
3320
3318
|
|
|
3321
3319
|
const BUILT_INS = [].concat(
|
|
3322
3320
|
BUILT_IN_GLOBALS,
|
|
3323
3321
|
TYPES,
|
|
3324
3322
|
ERROR_TYPES
|
|
3325
|
-
)
|
|
3323
|
+
)
|
|
3326
3324
|
|
|
3327
3325
|
/*
|
|
3328
3326
|
Language: JavaScript
|
|
@@ -3332,7 +3330,7 @@ var hljs = (function () {
|
|
|
3332
3330
|
*/
|
|
3333
3331
|
|
|
3334
3332
|
/** @type LanguageFn */
|
|
3335
|
-
function javascript(hljs) {
|
|
3333
|
+
function javascript (hljs) {
|
|
3336
3334
|
/**
|
|
3337
3335
|
* Takes a string like "<Booger" and checks to see
|
|
3338
3336
|
* if we can find a matching "</Booger" later in the
|
|
@@ -3341,16 +3339,16 @@ var hljs = (function () {
|
|
|
3341
3339
|
* @param {{after:number}} param1
|
|
3342
3340
|
*/
|
|
3343
3341
|
const hasClosingTag = (match, { after }) => {
|
|
3344
|
-
const tag =
|
|
3345
|
-
const pos = match.input.indexOf(tag, after)
|
|
3346
|
-
return pos !== -1
|
|
3347
|
-
}
|
|
3342
|
+
const tag = '</' + match[0].slice(1)
|
|
3343
|
+
const pos = match.input.indexOf(tag, after)
|
|
3344
|
+
return pos !== -1
|
|
3345
|
+
}
|
|
3348
3346
|
|
|
3349
|
-
const IDENT_RE$1 = IDENT_RE
|
|
3347
|
+
const IDENT_RE$1 = IDENT_RE
|
|
3350
3348
|
const FRAGMENT = {
|
|
3351
3349
|
begin: '<>',
|
|
3352
3350
|
end: '</>'
|
|
3353
|
-
}
|
|
3351
|
+
}
|
|
3354
3352
|
const XML_TAG = {
|
|
3355
3353
|
begin: /<[A-Za-z0-9\\._:-]+/,
|
|
3356
3354
|
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
|
|
@@ -3359,40 +3357,40 @@ var hljs = (function () {
|
|
|
3359
3357
|
* @param {CallbackResponse} response
|
|
3360
3358
|
*/
|
|
3361
3359
|
isTrulyOpeningTag: (match, response) => {
|
|
3362
|
-
const afterMatchIndex = match[0].length + match.index
|
|
3363
|
-
const nextChar = match.input[afterMatchIndex]
|
|
3360
|
+
const afterMatchIndex = match[0].length + match.index
|
|
3361
|
+
const nextChar = match.input[afterMatchIndex]
|
|
3364
3362
|
// nested type?
|
|
3365
3363
|
// HTML should not include another raw `<` inside a tag
|
|
3366
3364
|
// But a type might: `<Array<Array<number>>`, etc.
|
|
3367
|
-
if (nextChar ===
|
|
3368
|
-
response.ignoreMatch()
|
|
3369
|
-
return
|
|
3365
|
+
if (nextChar === '<') {
|
|
3366
|
+
response.ignoreMatch()
|
|
3367
|
+
return
|
|
3370
3368
|
}
|
|
3371
3369
|
// <something>
|
|
3372
3370
|
// This is now either a tag or a type.
|
|
3373
|
-
if (nextChar ===
|
|
3371
|
+
if (nextChar === '>') {
|
|
3374
3372
|
// if we cannot find a matching closing tag, then we
|
|
3375
3373
|
// will ignore it
|
|
3376
3374
|
if (!hasClosingTag(match, { after: afterMatchIndex })) {
|
|
3377
|
-
response.ignoreMatch()
|
|
3375
|
+
response.ignoreMatch()
|
|
3378
3376
|
}
|
|
3379
3377
|
}
|
|
3380
3378
|
}
|
|
3381
|
-
}
|
|
3379
|
+
}
|
|
3382
3380
|
const KEYWORDS$1 = {
|
|
3383
3381
|
$pattern: IDENT_RE,
|
|
3384
3382
|
keyword: KEYWORDS,
|
|
3385
3383
|
literal: LITERALS,
|
|
3386
3384
|
built_in: BUILT_INS,
|
|
3387
|
-
|
|
3388
|
-
}
|
|
3385
|
+
'variable.language': BUILT_IN_VARIABLES
|
|
3386
|
+
}
|
|
3389
3387
|
|
|
3390
3388
|
// https://tc39.es/ecma262/#sec-literals-numeric-literals
|
|
3391
|
-
const decimalDigits = '[0-9](_?[0-9])*'
|
|
3392
|
-
const frac = `\\.(${decimalDigits})
|
|
3389
|
+
const decimalDigits = '[0-9](_?[0-9])*'
|
|
3390
|
+
const frac = `\\.(${decimalDigits})`
|
|
3393
3391
|
// DecimalIntegerLiteral, including Annex B NonOctalDecimalIntegerLiteral
|
|
3394
3392
|
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
|
|
3395
|
-
const decimalInteger =
|
|
3393
|
+
const decimalInteger = '0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*'
|
|
3396
3394
|
const NUMBER = {
|
|
3397
3395
|
className: 'number',
|
|
3398
3396
|
variants: [
|
|
@@ -3404,19 +3402,19 @@ var hljs = (function () {
|
|
|
3404
3402
|
{ begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
|
|
3405
3403
|
|
|
3406
3404
|
// DecimalBigIntegerLiteral
|
|
3407
|
-
{ begin:
|
|
3405
|
+
{ begin: '\\b(0|[1-9](_?[0-9])*)n\\b' },
|
|
3408
3406
|
|
|
3409
3407
|
// NonDecimalIntegerLiteral
|
|
3410
|
-
{ begin:
|
|
3411
|
-
{ begin:
|
|
3412
|
-
{ begin:
|
|
3408
|
+
{ begin: '\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b' },
|
|
3409
|
+
{ begin: '\\b0[bB][0-1](_?[0-1])*n?\\b' },
|
|
3410
|
+
{ begin: '\\b0[oO][0-7](_?[0-7])*n?\\b' },
|
|
3413
3411
|
|
|
3414
3412
|
// LegacyOctalIntegerLiteral (does not include underscore separators)
|
|
3415
3413
|
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
|
|
3416
|
-
{ begin:
|
|
3414
|
+
{ begin: '\\b0[0-7]+n?\\b' }
|
|
3417
3415
|
],
|
|
3418
3416
|
relevance: 0
|
|
3419
|
-
}
|
|
3417
|
+
}
|
|
3420
3418
|
|
|
3421
3419
|
const SUBST = {
|
|
3422
3420
|
className: 'subst',
|
|
@@ -3424,7 +3422,7 @@ var hljs = (function () {
|
|
|
3424
3422
|
end: '\\}',
|
|
3425
3423
|
keywords: KEYWORDS$1,
|
|
3426
3424
|
contains: [] // defined later
|
|
3427
|
-
}
|
|
3425
|
+
}
|
|
3428
3426
|
const HTML_TEMPLATE = {
|
|
3429
3427
|
begin: 'html`',
|
|
3430
3428
|
end: '',
|
|
@@ -3437,7 +3435,7 @@ var hljs = (function () {
|
|
|
3437
3435
|
],
|
|
3438
3436
|
subLanguage: 'xml'
|
|
3439
3437
|
}
|
|
3440
|
-
}
|
|
3438
|
+
}
|
|
3441
3439
|
const CSS_TEMPLATE = {
|
|
3442
3440
|
begin: 'css`',
|
|
3443
3441
|
end: '',
|
|
@@ -3450,7 +3448,7 @@ var hljs = (function () {
|
|
|
3450
3448
|
],
|
|
3451
3449
|
subLanguage: 'css'
|
|
3452
3450
|
}
|
|
3453
|
-
}
|
|
3451
|
+
}
|
|
3454
3452
|
const TEMPLATE_STRING = {
|
|
3455
3453
|
className: 'string',
|
|
3456
3454
|
begin: '`',
|
|
@@ -3459,7 +3457,7 @@ var hljs = (function () {
|
|
|
3459
3457
|
hljs.BACKSLASH_ESCAPE,
|
|
3460
3458
|
SUBST
|
|
3461
3459
|
]
|
|
3462
|
-
}
|
|
3460
|
+
}
|
|
3463
3461
|
const JSDOC_COMMENT = hljs.COMMENT(
|
|
3464
3462
|
/\/\*\*(?!\/)/,
|
|
3465
3463
|
'\\*/',
|
|
@@ -3498,15 +3496,15 @@ var hljs = (function () {
|
|
|
3498
3496
|
}
|
|
3499
3497
|
]
|
|
3500
3498
|
}
|
|
3501
|
-
)
|
|
3499
|
+
)
|
|
3502
3500
|
const COMMENT = {
|
|
3503
|
-
className:
|
|
3501
|
+
className: 'comment',
|
|
3504
3502
|
variants: [
|
|
3505
3503
|
JSDOC_COMMENT,
|
|
3506
3504
|
hljs.C_BLOCK_COMMENT_MODE,
|
|
3507
3505
|
hljs.C_LINE_COMMENT_MODE
|
|
3508
3506
|
]
|
|
3509
|
-
}
|
|
3507
|
+
}
|
|
3510
3508
|
const SUBST_INTERNALS = [
|
|
3511
3509
|
hljs.APOS_STRING_MODE,
|
|
3512
3510
|
hljs.QUOTE_STRING_MODE,
|
|
@@ -3515,7 +3513,7 @@ var hljs = (function () {
|
|
|
3515
3513
|
TEMPLATE_STRING,
|
|
3516
3514
|
NUMBER,
|
|
3517
3515
|
hljs.REGEXP_MODE
|
|
3518
|
-
]
|
|
3516
|
+
]
|
|
3519
3517
|
SUBST.contains = SUBST_INTERNALS
|
|
3520
3518
|
.concat({
|
|
3521
3519
|
// we need to pair up {} inside our subst to prevent
|
|
@@ -3524,19 +3522,19 @@ var hljs = (function () {
|
|
|
3524
3522
|
end: /\}/,
|
|
3525
3523
|
keywords: KEYWORDS$1,
|
|
3526
3524
|
contains: [
|
|
3527
|
-
|
|
3525
|
+
'self'
|
|
3528
3526
|
].concat(SUBST_INTERNALS)
|
|
3529
|
-
})
|
|
3530
|
-
const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains)
|
|
3527
|
+
})
|
|
3528
|
+
const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains)
|
|
3531
3529
|
const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
|
|
3532
3530
|
// eat recursive parens in sub expressions
|
|
3533
3531
|
{
|
|
3534
3532
|
begin: /\(/,
|
|
3535
3533
|
end: /\)/,
|
|
3536
3534
|
keywords: KEYWORDS$1,
|
|
3537
|
-
contains: [
|
|
3535
|
+
contains: ['self'].concat(SUBST_AND_COMMENTS)
|
|
3538
3536
|
}
|
|
3539
|
-
])
|
|
3537
|
+
])
|
|
3540
3538
|
const PARAMS = {
|
|
3541
3539
|
className: 'params',
|
|
3542
3540
|
begin: /\(/,
|
|
@@ -3545,7 +3543,7 @@ var hljs = (function () {
|
|
|
3545
3543
|
excludeEnd: true,
|
|
3546
3544
|
keywords: KEYWORDS$1,
|
|
3547
3545
|
contains: PARAMS_CONTAINS
|
|
3548
|
-
}
|
|
3546
|
+
}
|
|
3549
3547
|
|
|
3550
3548
|
// ES6 classes
|
|
3551
3549
|
const CLASS_OR_EXTENDS = {
|
|
@@ -3557,28 +3555,28 @@ var hljs = (function () {
|
|
|
3557
3555
|
IDENT_RE$1
|
|
3558
3556
|
],
|
|
3559
3557
|
scope: {
|
|
3560
|
-
1:
|
|
3561
|
-
3:
|
|
3558
|
+
1: 'keyword',
|
|
3559
|
+
3: 'title.class'
|
|
3562
3560
|
}
|
|
3563
3561
|
},
|
|
3564
3562
|
{
|
|
3565
3563
|
match: [
|
|
3566
3564
|
/extends/,
|
|
3567
3565
|
/\s+/,
|
|
3568
|
-
concat(IDENT_RE$1,
|
|
3566
|
+
concat(IDENT_RE$1, '(', concat(/\./, IDENT_RE$1), ')*')
|
|
3569
3567
|
],
|
|
3570
3568
|
scope: {
|
|
3571
|
-
1:
|
|
3572
|
-
3:
|
|
3569
|
+
1: 'keyword',
|
|
3570
|
+
3: 'title.class.inherited'
|
|
3573
3571
|
}
|
|
3574
3572
|
}
|
|
3575
3573
|
]
|
|
3576
|
-
}
|
|
3574
|
+
}
|
|
3577
3575
|
|
|
3578
3576
|
const CLASS_REFERENCE = {
|
|
3579
3577
|
relevance: 0,
|
|
3580
3578
|
match: /\b[A-Z][a-z]+([A-Z][a-z]+)*/,
|
|
3581
|
-
className:
|
|
3579
|
+
className: 'title.class',
|
|
3582
3580
|
keywords: {
|
|
3583
3581
|
_: [
|
|
3584
3582
|
// se we still get relevance credit for JS library classes
|
|
@@ -3586,14 +3584,14 @@ var hljs = (function () {
|
|
|
3586
3584
|
...ERROR_TYPES
|
|
3587
3585
|
]
|
|
3588
3586
|
}
|
|
3589
|
-
}
|
|
3587
|
+
}
|
|
3590
3588
|
|
|
3591
3589
|
const USE_STRICT = {
|
|
3592
|
-
label:
|
|
3590
|
+
label: 'use_strict',
|
|
3593
3591
|
className: 'meta',
|
|
3594
3592
|
relevance: 10,
|
|
3595
3593
|
begin: /^\s*['"]use (strict|asm)['"]/
|
|
3596
|
-
}
|
|
3594
|
+
}
|
|
3597
3595
|
|
|
3598
3596
|
const FUNCTION_DEFINITION = {
|
|
3599
3597
|
variants: [
|
|
@@ -3614,22 +3612,22 @@ var hljs = (function () {
|
|
|
3614
3612
|
}
|
|
3615
3613
|
],
|
|
3616
3614
|
className: {
|
|
3617
|
-
1:
|
|
3618
|
-
3:
|
|
3615
|
+
1: 'keyword',
|
|
3616
|
+
3: 'title.function'
|
|
3619
3617
|
},
|
|
3620
|
-
label:
|
|
3618
|
+
label: 'func.def',
|
|
3621
3619
|
contains: [PARAMS],
|
|
3622
3620
|
illegal: /%/
|
|
3623
|
-
}
|
|
3621
|
+
}
|
|
3624
3622
|
|
|
3625
3623
|
const UPPER_CASE_CONSTANT = {
|
|
3626
3624
|
relevance: 0,
|
|
3627
3625
|
match: /\b[A-Z][A-Z_]+\b/,
|
|
3628
|
-
className:
|
|
3629
|
-
}
|
|
3626
|
+
className: 'variable.constant'
|
|
3627
|
+
}
|
|
3630
3628
|
|
|
3631
|
-
function noneOf(list) {
|
|
3632
|
-
return concat(
|
|
3629
|
+
function noneOf (list) {
|
|
3630
|
+
return concat('(?!', list.join('|'), ')')
|
|
3633
3631
|
}
|
|
3634
3632
|
|
|
3635
3633
|
const FUNCTION_CALL = {
|
|
@@ -3637,12 +3635,12 @@ var hljs = (function () {
|
|
|
3637
3635
|
/\b/,
|
|
3638
3636
|
noneOf([
|
|
3639
3637
|
...BUILT_IN_GLOBALS,
|
|
3640
|
-
|
|
3638
|
+
'super'
|
|
3641
3639
|
]),
|
|
3642
3640
|
IDENT_RE$1, lookahead(/\(/)),
|
|
3643
|
-
className:
|
|
3641
|
+
className: 'title.function',
|
|
3644
3642
|
relevance: 0
|
|
3645
|
-
}
|
|
3643
|
+
}
|
|
3646
3644
|
|
|
3647
3645
|
const PROPERTY_ACCESS = {
|
|
3648
3646
|
begin: concat(/\./, lookahead(
|
|
@@ -3650,10 +3648,10 @@ var hljs = (function () {
|
|
|
3650
3648
|
)),
|
|
3651
3649
|
end: IDENT_RE$1,
|
|
3652
3650
|
excludeBegin: true,
|
|
3653
|
-
keywords:
|
|
3654
|
-
className:
|
|
3651
|
+
keywords: 'prototype',
|
|
3652
|
+
className: 'property',
|
|
3655
3653
|
relevance: 0
|
|
3656
|
-
}
|
|
3654
|
+
}
|
|
3657
3655
|
|
|
3658
3656
|
const GETTER_OR_SETTER = {
|
|
3659
3657
|
match: [
|
|
@@ -3663,8 +3661,8 @@ var hljs = (function () {
|
|
|
3663
3661
|
/(?=\()/
|
|
3664
3662
|
],
|
|
3665
3663
|
className: {
|
|
3666
|
-
1:
|
|
3667
|
-
3:
|
|
3664
|
+
1: 'keyword',
|
|
3665
|
+
3: 'title.function'
|
|
3668
3666
|
},
|
|
3669
3667
|
contains: [
|
|
3670
3668
|
{ // eat to avoid empty params
|
|
@@ -3672,7 +3670,7 @@ var hljs = (function () {
|
|
|
3672
3670
|
},
|
|
3673
3671
|
PARAMS
|
|
3674
3672
|
]
|
|
3675
|
-
}
|
|
3673
|
+
}
|
|
3676
3674
|
|
|
3677
3675
|
const FUNC_LEAD_IN_RE = '(\\(' +
|
|
3678
3676
|
'[^()]*(\\(' +
|
|
@@ -3680,7 +3678,7 @@ var hljs = (function () {
|
|
|
3680
3678
|
'[^()]*' +
|
|
3681
3679
|
'\\)[^()]*)*' +
|
|
3682
3680
|
'\\)[^()]*)*' +
|
|
3683
|
-
'\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>'
|
|
3681
|
+
'\\)|' + hljs.UNDERSCORE_IDENT_RE + ')\\s*=>'
|
|
3684
3682
|
|
|
3685
3683
|
const FUNCTION_VARIABLE = {
|
|
3686
3684
|
match: [
|
|
@@ -3690,13 +3688,13 @@ var hljs = (function () {
|
|
|
3690
3688
|
lookahead(FUNC_LEAD_IN_RE)
|
|
3691
3689
|
],
|
|
3692
3690
|
className: {
|
|
3693
|
-
1:
|
|
3694
|
-
3:
|
|
3691
|
+
1: 'keyword',
|
|
3692
|
+
3: 'title.function'
|
|
3695
3693
|
},
|
|
3696
3694
|
contains: [
|
|
3697
3695
|
PARAMS
|
|
3698
3696
|
]
|
|
3699
|
-
}
|
|
3697
|
+
}
|
|
3700
3698
|
|
|
3701
3699
|
return {
|
|
3702
3700
|
name: 'Javascript',
|
|
@@ -3707,8 +3705,8 @@ var hljs = (function () {
|
|
|
3707
3705
|
illegal: /#(?![$_A-z])/,
|
|
3708
3706
|
contains: [
|
|
3709
3707
|
hljs.SHEBANG({
|
|
3710
|
-
label:
|
|
3711
|
-
binary:
|
|
3708
|
+
label: 'shebang',
|
|
3709
|
+
binary: 'node',
|
|
3712
3710
|
relevance: 5
|
|
3713
3711
|
}),
|
|
3714
3712
|
USE_STRICT,
|
|
@@ -3795,13 +3793,13 @@ var hljs = (function () {
|
|
|
3795
3793
|
}
|
|
3796
3794
|
]
|
|
3797
3795
|
}
|
|
3798
|
-
]
|
|
3796
|
+
]
|
|
3799
3797
|
},
|
|
3800
3798
|
FUNCTION_DEFINITION,
|
|
3801
3799
|
{
|
|
3802
3800
|
// prevent this from getting swallowed up by function
|
|
3803
3801
|
// since they appear "function like"
|
|
3804
|
-
beginKeywords:
|
|
3802
|
+
beginKeywords: 'while if switch catch for'
|
|
3805
3803
|
},
|
|
3806
3804
|
{
|
|
3807
3805
|
// we have to count the parens to make sure we actually have the correct
|
|
@@ -3816,10 +3814,10 @@ var hljs = (function () {
|
|
|
3816
3814
|
'\\)[^()]*)*' +
|
|
3817
3815
|
'\\)\\s*\\{', // end parens
|
|
3818
3816
|
returnBegin: true,
|
|
3819
|
-
label:
|
|
3817
|
+
label: 'func.def',
|
|
3820
3818
|
contains: [
|
|
3821
3819
|
PARAMS,
|
|
3822
|
-
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1, className:
|
|
3820
|
+
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1, className: 'title.function' })
|
|
3823
3821
|
]
|
|
3824
3822
|
},
|
|
3825
3823
|
// catch ... so it won't trigger the property rule below
|
|
@@ -3837,7 +3835,7 @@ var hljs = (function () {
|
|
|
3837
3835
|
},
|
|
3838
3836
|
{
|
|
3839
3837
|
match: [/\bconstructor(?=\s*\()/],
|
|
3840
|
-
className: { 1:
|
|
3838
|
+
className: { 1: 'title.function' },
|
|
3841
3839
|
contains: [PARAMS]
|
|
3842
3840
|
},
|
|
3843
3841
|
FUNCTION_CALL,
|
|
@@ -3848,7 +3846,7 @@ var hljs = (function () {
|
|
|
3848
3846
|
match: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
|
|
3849
3847
|
}
|
|
3850
3848
|
]
|
|
3851
|
-
}
|
|
3849
|
+
}
|
|
3852
3850
|
}
|
|
3853
3851
|
|
|
3854
3852
|
/*
|
|
@@ -3859,17 +3857,17 @@ var hljs = (function () {
|
|
|
3859
3857
|
Category: common, protocols, web
|
|
3860
3858
|
*/
|
|
3861
3859
|
|
|
3862
|
-
function json(hljs) {
|
|
3860
|
+
function json (hljs) {
|
|
3863
3861
|
const ATTRIBUTE = {
|
|
3864
3862
|
className: 'attr',
|
|
3865
3863
|
begin: /"(\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
3866
3864
|
relevance: 1.01
|
|
3867
|
-
}
|
|
3865
|
+
}
|
|
3868
3866
|
const PUNCTUATION = {
|
|
3869
3867
|
match: /[{}[\],:]/,
|
|
3870
|
-
className:
|
|
3868
|
+
className: 'punctuation',
|
|
3871
3869
|
relevance: 0
|
|
3872
|
-
}
|
|
3870
|
+
}
|
|
3873
3871
|
// normally we would rely on `keywords` for this but using a mode here allows us
|
|
3874
3872
|
// to use the very tight `illegal: \S` rule later to flag any other character
|
|
3875
3873
|
// as illegal indicating that despite looking like JSON we do not truly have
|
|
@@ -3877,11 +3875,11 @@ var hljs = (function () {
|
|
|
3877
3875
|
// all sorts of JSON looking stuff
|
|
3878
3876
|
const LITERALS = {
|
|
3879
3877
|
beginKeywords: [
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
].join(
|
|
3884
|
-
}
|
|
3878
|
+
'true',
|
|
3879
|
+
'false',
|
|
3880
|
+
'null'
|
|
3881
|
+
].join(' ')
|
|
3882
|
+
}
|
|
3885
3883
|
|
|
3886
3884
|
return {
|
|
3887
3885
|
name: 'JSON',
|
|
@@ -3895,19 +3893,18 @@ var hljs = (function () {
|
|
|
3895
3893
|
hljs.C_BLOCK_COMMENT_MODE
|
|
3896
3894
|
],
|
|
3897
3895
|
illegal: '\\S'
|
|
3898
|
-
}
|
|
3896
|
+
}
|
|
3899
3897
|
}
|
|
3900
3898
|
|
|
3901
|
-
|
|
3902
3899
|
/** @type LanguageFn */
|
|
3903
|
-
function xml(hljs) {
|
|
3900
|
+
function xml (hljs) {
|
|
3904
3901
|
// Element names can contain letters, digits, hyphens, underscores, and periods
|
|
3905
|
-
const TAG_NAME_RE = concat(/[A-Z_]/, optional(/[A-Z0-9_.-]*:/), /[A-Z0-9_.-]*/)
|
|
3906
|
-
const XML_IDENT_RE = /[A-Za-z0-9._:-]
|
|
3902
|
+
const TAG_NAME_RE = concat(/[A-Z_]/, optional(/[A-Z0-9_.-]*:/), /[A-Z0-9_.-]*/)
|
|
3903
|
+
const XML_IDENT_RE = /[A-Za-z0-9._:-]+/
|
|
3907
3904
|
const XML_ENTITIES = {
|
|
3908
3905
|
className: 'symbol',
|
|
3909
3906
|
begin: /&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/
|
|
3910
|
-
}
|
|
3907
|
+
}
|
|
3911
3908
|
const XML_META_KEYWORDS = {
|
|
3912
3909
|
begin: /\s/,
|
|
3913
3910
|
contains: [
|
|
@@ -3917,17 +3914,17 @@ var hljs = (function () {
|
|
|
3917
3914
|
illegal: /\n/
|
|
3918
3915
|
}
|
|
3919
3916
|
]
|
|
3920
|
-
}
|
|
3917
|
+
}
|
|
3921
3918
|
const XML_META_PAR_KEYWORDS = hljs.inherit(XML_META_KEYWORDS, {
|
|
3922
3919
|
begin: /\(/,
|
|
3923
3920
|
end: /\)/
|
|
3924
|
-
})
|
|
3921
|
+
})
|
|
3925
3922
|
const APOS_META_STRING_MODE = hljs.inherit(hljs.APOS_STRING_MODE, {
|
|
3926
3923
|
className: 'string'
|
|
3927
|
-
})
|
|
3924
|
+
})
|
|
3928
3925
|
const QUOTE_META_STRING_MODE = hljs.inherit(hljs.QUOTE_STRING_MODE, {
|
|
3929
3926
|
className: 'string'
|
|
3930
|
-
})
|
|
3927
|
+
})
|
|
3931
3928
|
const TAG_INTERNALS = {
|
|
3932
3929
|
endsWithParent: true,
|
|
3933
3930
|
illegal: /</,
|
|
@@ -3964,7 +3961,7 @@ var hljs = (function () {
|
|
|
3964
3961
|
]
|
|
3965
3962
|
}
|
|
3966
3963
|
]
|
|
3967
|
-
}
|
|
3964
|
+
}
|
|
3968
3965
|
return {
|
|
3969
3966
|
name: 'HTML, XML',
|
|
3970
3967
|
aliases: [
|
|
@@ -4121,7 +4118,7 @@ var hljs = (function () {
|
|
|
4121
4118
|
]
|
|
4122
4119
|
}
|
|
4123
4120
|
]
|
|
4124
|
-
}
|
|
4121
|
+
}
|
|
4125
4122
|
}
|
|
4126
4123
|
|
|
4127
4124
|
/*
|
|
@@ -4132,17 +4129,17 @@ var hljs = (function () {
|
|
|
4132
4129
|
Category: common, markup
|
|
4133
4130
|
*/
|
|
4134
4131
|
|
|
4135
|
-
function markdown(hljs) {
|
|
4132
|
+
function markdown (hljs) {
|
|
4136
4133
|
const INLINE_HTML = {
|
|
4137
4134
|
begin: /<\/?[A-Za-z_]/,
|
|
4138
4135
|
end: '>',
|
|
4139
4136
|
subLanguage: 'xml',
|
|
4140
4137
|
relevance: 0
|
|
4141
|
-
}
|
|
4138
|
+
}
|
|
4142
4139
|
const HORIZONTAL_RULE = {
|
|
4143
4140
|
begin: '^[-\\*]{3,}',
|
|
4144
4141
|
end: '$'
|
|
4145
|
-
}
|
|
4142
|
+
}
|
|
4146
4143
|
const CODE = {
|
|
4147
4144
|
className: 'code',
|
|
4148
4145
|
variants: [
|
|
@@ -4178,13 +4175,13 @@ var hljs = (function () {
|
|
|
4178
4175
|
relevance: 0
|
|
4179
4176
|
}
|
|
4180
4177
|
]
|
|
4181
|
-
}
|
|
4178
|
+
}
|
|
4182
4179
|
const LIST = {
|
|
4183
4180
|
className: 'bullet',
|
|
4184
4181
|
begin: '^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)',
|
|
4185
4182
|
end: '\\s+',
|
|
4186
4183
|
excludeEnd: true
|
|
4187
|
-
}
|
|
4184
|
+
}
|
|
4188
4185
|
const LINK_REFERENCE = {
|
|
4189
4186
|
begin: /^\[[^\n]+\]:/,
|
|
4190
4187
|
returnBegin: true,
|
|
@@ -4203,8 +4200,8 @@ var hljs = (function () {
|
|
|
4203
4200
|
excludeBegin: true
|
|
4204
4201
|
}
|
|
4205
4202
|
]
|
|
4206
|
-
}
|
|
4207
|
-
const URL_SCHEME = /[A-Za-z][A-Za-z0-9+.-]
|
|
4203
|
+
}
|
|
4204
|
+
const URL_SCHEME = /[A-Za-z][A-Za-z0-9+.-]*/
|
|
4208
4205
|
const LINK = {
|
|
4209
4206
|
variants: [
|
|
4210
4207
|
// too much like nested array access in so many languages
|
|
@@ -4260,7 +4257,7 @@ var hljs = (function () {
|
|
|
4260
4257
|
excludeEnd: true
|
|
4261
4258
|
}
|
|
4262
4259
|
]
|
|
4263
|
-
}
|
|
4260
|
+
}
|
|
4264
4261
|
const BOLD = {
|
|
4265
4262
|
className: 'strong',
|
|
4266
4263
|
contains: [], // defined later
|
|
@@ -4274,7 +4271,7 @@ var hljs = (function () {
|
|
|
4274
4271
|
end: /\*{2}/
|
|
4275
4272
|
}
|
|
4276
4273
|
]
|
|
4277
|
-
}
|
|
4274
|
+
}
|
|
4278
4275
|
const ITALIC = {
|
|
4279
4276
|
className: 'emphasis',
|
|
4280
4277
|
contains: [], // defined later
|
|
@@ -4289,19 +4286,19 @@ var hljs = (function () {
|
|
|
4289
4286
|
relevance: 0
|
|
4290
4287
|
}
|
|
4291
4288
|
]
|
|
4292
|
-
}
|
|
4293
|
-
BOLD.contains.push(ITALIC)
|
|
4294
|
-
ITALIC.contains.push(BOLD)
|
|
4289
|
+
}
|
|
4290
|
+
BOLD.contains.push(ITALIC)
|
|
4291
|
+
ITALIC.contains.push(BOLD)
|
|
4295
4292
|
|
|
4296
4293
|
let CONTAINABLE = [
|
|
4297
4294
|
INLINE_HTML,
|
|
4298
4295
|
LINK
|
|
4299
|
-
]
|
|
4296
|
+
]
|
|
4300
4297
|
|
|
4301
|
-
BOLD.contains = BOLD.contains.concat(CONTAINABLE)
|
|
4302
|
-
ITALIC.contains = ITALIC.contains.concat(CONTAINABLE)
|
|
4298
|
+
BOLD.contains = BOLD.contains.concat(CONTAINABLE)
|
|
4299
|
+
ITALIC.contains = ITALIC.contains.concat(CONTAINABLE)
|
|
4303
4300
|
|
|
4304
|
-
CONTAINABLE = CONTAINABLE.concat(BOLD, ITALIC)
|
|
4301
|
+
CONTAINABLE = CONTAINABLE.concat(BOLD, ITALIC)
|
|
4305
4302
|
|
|
4306
4303
|
const HEADER = {
|
|
4307
4304
|
className: 'section',
|
|
@@ -4319,20 +4316,20 @@ var hljs = (function () {
|
|
|
4319
4316
|
},
|
|
4320
4317
|
{
|
|
4321
4318
|
begin: '^',
|
|
4322
|
-
end:
|
|
4319
|
+
end: '\\n',
|
|
4323
4320
|
contains: CONTAINABLE
|
|
4324
4321
|
}
|
|
4325
4322
|
]
|
|
4326
4323
|
}
|
|
4327
4324
|
]
|
|
4328
|
-
}
|
|
4325
|
+
}
|
|
4329
4326
|
|
|
4330
4327
|
const BLOCKQUOTE = {
|
|
4331
4328
|
className: 'quote',
|
|
4332
4329
|
begin: '^>\\s+',
|
|
4333
4330
|
contains: CONTAINABLE,
|
|
4334
4331
|
end: '$'
|
|
4335
|
-
}
|
|
4332
|
+
}
|
|
4336
4333
|
|
|
4337
4334
|
return {
|
|
4338
4335
|
name: 'Markdown',
|
|
@@ -4353,10 +4350,9 @@ var hljs = (function () {
|
|
|
4353
4350
|
LINK,
|
|
4354
4351
|
LINK_REFERENCE
|
|
4355
4352
|
]
|
|
4356
|
-
}
|
|
4353
|
+
}
|
|
4357
4354
|
}
|
|
4358
4355
|
|
|
4359
|
-
|
|
4360
4356
|
/*
|
|
4361
4357
|
Language: Plain text
|
|
4362
4358
|
Author: Egor Rogov (e.rogov@postgrespro.ru)
|
|
@@ -4364,7 +4360,7 @@ var hljs = (function () {
|
|
|
4364
4360
|
Category: common
|
|
4365
4361
|
*/
|
|
4366
4362
|
|
|
4367
|
-
function plaintext(hljs) {
|
|
4363
|
+
function plaintext (hljs) {
|
|
4368
4364
|
return {
|
|
4369
4365
|
name: 'Plain text',
|
|
4370
4366
|
aliases: [
|
|
@@ -4372,10 +4368,9 @@ var hljs = (function () {
|
|
|
4372
4368
|
'txt'
|
|
4373
4369
|
],
|
|
4374
4370
|
disableAutodetect: true
|
|
4375
|
-
}
|
|
4371
|
+
}
|
|
4376
4372
|
}
|
|
4377
4373
|
|
|
4378
|
-
|
|
4379
4374
|
/*
|
|
4380
4375
|
Language: SCSS
|
|
4381
4376
|
Description: Scss is an extension of the syntax of CSS.
|
|
@@ -4385,18 +4380,18 @@ var hljs = (function () {
|
|
|
4385
4380
|
*/
|
|
4386
4381
|
|
|
4387
4382
|
/** @type LanguageFn */
|
|
4388
|
-
function scss(hljs) {
|
|
4389
|
-
const modes = MODES(hljs)
|
|
4390
|
-
const PSEUDO_ELEMENTS$1 = PSEUDO_ELEMENTS
|
|
4391
|
-
const PSEUDO_CLASSES$1 = PSEUDO_CLASSES
|
|
4392
|
-
|
|
4393
|
-
const AT_IDENTIFIER = '@[a-z-]+'
|
|
4394
|
-
const AT_MODIFIERS =
|
|
4395
|
-
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*'
|
|
4383
|
+
function scss (hljs) {
|
|
4384
|
+
const modes = MODES(hljs)
|
|
4385
|
+
const PSEUDO_ELEMENTS$1 = PSEUDO_ELEMENTS
|
|
4386
|
+
const PSEUDO_CLASSES$1 = PSEUDO_CLASSES
|
|
4387
|
+
|
|
4388
|
+
const AT_IDENTIFIER = '@[a-z-]+' // @font-face
|
|
4389
|
+
const AT_MODIFIERS = 'and or not only'
|
|
4390
|
+
const IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*'
|
|
4396
4391
|
const VARIABLE = {
|
|
4397
4392
|
className: 'variable',
|
|
4398
4393
|
begin: '(\\$' + IDENT_RE + ')\\b'
|
|
4399
|
-
}
|
|
4394
|
+
}
|
|
4400
4395
|
|
|
4401
4396
|
return {
|
|
4402
4397
|
name: 'SCSS',
|
|
@@ -4472,16 +4467,16 @@ var hljs = (function () {
|
|
|
4472
4467
|
keywords: {
|
|
4473
4468
|
$pattern: /[a-z-]+/,
|
|
4474
4469
|
keyword: AT_MODIFIERS,
|
|
4475
|
-
attribute: MEDIA_FEATURES.join(
|
|
4470
|
+
attribute: MEDIA_FEATURES.join(' ')
|
|
4476
4471
|
},
|
|
4477
4472
|
contains: [
|
|
4478
4473
|
{
|
|
4479
4474
|
begin: AT_IDENTIFIER,
|
|
4480
|
-
className:
|
|
4475
|
+
className: 'keyword'
|
|
4481
4476
|
},
|
|
4482
4477
|
{
|
|
4483
4478
|
begin: /[a-z-]+(?=:)/,
|
|
4484
|
-
className:
|
|
4479
|
+
className: 'attribute'
|
|
4485
4480
|
},
|
|
4486
4481
|
VARIABLE,
|
|
4487
4482
|
hljs.QUOTE_STRING_MODE,
|
|
@@ -4491,7 +4486,7 @@ var hljs = (function () {
|
|
|
4491
4486
|
]
|
|
4492
4487
|
}
|
|
4493
4488
|
]
|
|
4494
|
-
}
|
|
4489
|
+
}
|
|
4495
4490
|
}
|
|
4496
4491
|
|
|
4497
4492
|
/*
|
|
@@ -4503,7 +4498,7 @@ var hljs = (function () {
|
|
|
4503
4498
|
*/
|
|
4504
4499
|
|
|
4505
4500
|
/** @type LanguageFn */
|
|
4506
|
-
function shell(hljs) {
|
|
4501
|
+
function shell (hljs) {
|
|
4507
4502
|
return {
|
|
4508
4503
|
name: 'Shell Session',
|
|
4509
4504
|
aliases: ['console', 'shellsession'],
|
|
@@ -4520,33 +4515,32 @@ var hljs = (function () {
|
|
|
4520
4515
|
}
|
|
4521
4516
|
}
|
|
4522
4517
|
]
|
|
4523
|
-
}
|
|
4518
|
+
}
|
|
4524
4519
|
}
|
|
4525
4520
|
|
|
4526
|
-
|
|
4527
4521
|
const keywordWrapper = keyword => concat(
|
|
4528
4522
|
/\b/,
|
|
4529
4523
|
keyword,
|
|
4530
4524
|
/\w$/.test(keyword) ? /\b/ : /\B/
|
|
4531
|
-
)
|
|
4525
|
+
)
|
|
4532
4526
|
|
|
4533
4527
|
// Keywords that require a leading dot.
|
|
4534
4528
|
const dotKeywords = [
|
|
4535
4529
|
'Protocol', // contextual
|
|
4536
4530
|
'Type' // contextual
|
|
4537
|
-
].map(keywordWrapper)
|
|
4531
|
+
].map(keywordWrapper)
|
|
4538
4532
|
|
|
4539
4533
|
// Keywords that may have a leading dot.
|
|
4540
4534
|
const optionalDotKeywords = [
|
|
4541
4535
|
'init',
|
|
4542
4536
|
'self'
|
|
4543
|
-
].map(keywordWrapper)
|
|
4537
|
+
].map(keywordWrapper)
|
|
4544
4538
|
|
|
4545
4539
|
// should register as keyword, not type
|
|
4546
4540
|
const keywordTypes = [
|
|
4547
4541
|
'Any',
|
|
4548
4542
|
'Self'
|
|
4549
|
-
]
|
|
4543
|
+
]
|
|
4550
4544
|
|
|
4551
4545
|
// Regular keywords and literals.
|
|
4552
4546
|
const keywords = [
|
|
@@ -4636,7 +4630,7 @@ var hljs = (function () {
|
|
|
4636
4630
|
'where',
|
|
4637
4631
|
'while',
|
|
4638
4632
|
'willSet' // contextual
|
|
4639
|
-
]
|
|
4633
|
+
]
|
|
4640
4634
|
|
|
4641
4635
|
// NOTE: Contextual keywords are reserved only in specific contexts.
|
|
4642
4636
|
// Ideally, these should be matched using modes to avoid false positives.
|
|
@@ -4646,7 +4640,7 @@ var hljs = (function () {
|
|
|
4646
4640
|
'false',
|
|
4647
4641
|
'nil',
|
|
4648
4642
|
'true'
|
|
4649
|
-
]
|
|
4643
|
+
]
|
|
4650
4644
|
|
|
4651
4645
|
// Keywords used in precedence groups.
|
|
4652
4646
|
const precedencegroupKeywords = [
|
|
@@ -4657,7 +4651,7 @@ var hljs = (function () {
|
|
|
4657
4651
|
'lowerThan',
|
|
4658
4652
|
'none',
|
|
4659
4653
|
'right'
|
|
4660
|
-
]
|
|
4654
|
+
]
|
|
4661
4655
|
|
|
4662
4656
|
// Keywords that start with a number sign (#).
|
|
4663
4657
|
// #available is handled separately.
|
|
@@ -4682,7 +4676,7 @@ var hljs = (function () {
|
|
|
4682
4676
|
'#sourceLocation',
|
|
4683
4677
|
'#warn_unqualified_access',
|
|
4684
4678
|
'#warning'
|
|
4685
|
-
]
|
|
4679
|
+
]
|
|
4686
4680
|
|
|
4687
4681
|
// Global functions in the Standard Library.
|
|
4688
4682
|
const builtIns$1 = [
|
|
@@ -4720,7 +4714,7 @@ var hljs = (function () {
|
|
|
4720
4714
|
'withVaList',
|
|
4721
4715
|
'withoutActuallyEscaping',
|
|
4722
4716
|
'zip'
|
|
4723
|
-
]
|
|
4717
|
+
]
|
|
4724
4718
|
|
|
4725
4719
|
// Valid first characters for operators.
|
|
4726
4720
|
const operatorHead = either(
|
|
@@ -4742,7 +4736,7 @@ var hljs = (function () {
|
|
|
4742
4736
|
/[\u3001-\u3003]/,
|
|
4743
4737
|
/[\u3008-\u3020]/,
|
|
4744
4738
|
/[\u3030]/
|
|
4745
|
-
)
|
|
4739
|
+
)
|
|
4746
4740
|
|
|
4747
4741
|
// Valid characters for operators.
|
|
4748
4742
|
const operatorCharacter = either(
|
|
@@ -4754,10 +4748,10 @@ var hljs = (function () {
|
|
|
4754
4748
|
/[\uFE20-\uFE2F]/
|
|
4755
4749
|
// TODO: The following characters are also allowed, but the regex isn't supported yet.
|
|
4756
4750
|
// /[\u{E0100}-\u{E01EF}]/u
|
|
4757
|
-
)
|
|
4751
|
+
)
|
|
4758
4752
|
|
|
4759
4753
|
// Valid operator.
|
|
4760
|
-
const operator = concat(operatorHead, operatorCharacter, '*')
|
|
4754
|
+
const operator = concat(operatorHead, operatorCharacter, '*')
|
|
4761
4755
|
|
|
4762
4756
|
// Valid first characters for identifiers.
|
|
4763
4757
|
const identifierHead = either(
|
|
@@ -4777,20 +4771,20 @@ var hljs = (function () {
|
|
|
4777
4771
|
// /[\u{50000}-\u{5FFFD}\u{60000-\u{6FFFD}\u{70000}-\u{7FFFD}\u{80000}-\u{8FFFD}]/u,
|
|
4778
4772
|
// /[\u{90000}-\u{9FFFD}\u{A0000-\u{AFFFD}\u{B0000}-\u{BFFFD}\u{C0000}-\u{CFFFD}]/u,
|
|
4779
4773
|
// /[\u{D0000}-\u{DFFFD}\u{E0000-\u{EFFFD}]/u
|
|
4780
|
-
)
|
|
4774
|
+
)
|
|
4781
4775
|
|
|
4782
4776
|
// Valid characters for identifiers.
|
|
4783
4777
|
const identifierCharacter = either(
|
|
4784
4778
|
identifierHead,
|
|
4785
4779
|
/\d/,
|
|
4786
4780
|
/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/
|
|
4787
|
-
)
|
|
4781
|
+
)
|
|
4788
4782
|
|
|
4789
4783
|
// Valid identifier.
|
|
4790
|
-
const identifier = concat(identifierHead, identifierCharacter, '*')
|
|
4784
|
+
const identifier = concat(identifierHead, identifierCharacter, '*')
|
|
4791
4785
|
|
|
4792
4786
|
// Valid type identifier.
|
|
4793
|
-
const typeIdentifier = concat(/[A-Z]/, identifierCharacter, '*')
|
|
4787
|
+
const typeIdentifier = concat(/[A-Z]/, identifierCharacter, '*')
|
|
4794
4788
|
|
|
4795
4789
|
// Built-in attributes, which are highlighted as keywords.
|
|
4796
4790
|
// @available is handled separately.
|
|
@@ -4824,7 +4818,7 @@ var hljs = (function () {
|
|
|
4824
4818
|
'UIApplicationMain',
|
|
4825
4819
|
'unknown',
|
|
4826
4820
|
'usableFromInline'
|
|
4827
|
-
]
|
|
4821
|
+
]
|
|
4828
4822
|
|
|
4829
4823
|
// Contextual keywords used in @available and #available.
|
|
4830
4824
|
const availabilityKeywords = [
|
|
@@ -4839,8 +4833,7 @@ var hljs = (function () {
|
|
|
4839
4833
|
'tvOS',
|
|
4840
4834
|
'tvOSApplicationExtension',
|
|
4841
4835
|
'swift'
|
|
4842
|
-
]
|
|
4843
|
-
|
|
4836
|
+
]
|
|
4844
4837
|
|
|
4845
4838
|
/*
|
|
4846
4839
|
Language: TypeScript
|
|
@@ -4852,91 +4845,92 @@ var hljs = (function () {
|
|
|
4852
4845
|
*/
|
|
4853
4846
|
|
|
4854
4847
|
/** @type LanguageFn */
|
|
4855
|
-
function typescript(hljs) {
|
|
4856
|
-
const IDENT_RE$1 = IDENT_RE
|
|
4848
|
+
function typescript (hljs) {
|
|
4849
|
+
const IDENT_RE$1 = IDENT_RE
|
|
4857
4850
|
const NAMESPACE = {
|
|
4858
4851
|
beginKeywords: 'namespace', end: /\{/, excludeEnd: true
|
|
4859
|
-
}
|
|
4852
|
+
}
|
|
4860
4853
|
const INTERFACE = {
|
|
4861
|
-
beginKeywords: 'interface',
|
|
4854
|
+
beginKeywords: 'interface',
|
|
4855
|
+
end: /\{/,
|
|
4856
|
+
excludeEnd: true,
|
|
4862
4857
|
keywords: 'interface extends'
|
|
4863
|
-
}
|
|
4858
|
+
}
|
|
4864
4859
|
const USE_STRICT = {
|
|
4865
4860
|
className: 'meta',
|
|
4866
4861
|
relevance: 10,
|
|
4867
4862
|
begin: /^\s*['"]use strict['"]/
|
|
4868
|
-
}
|
|
4863
|
+
}
|
|
4869
4864
|
const TYPES = [
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
]
|
|
4865
|
+
'any',
|
|
4866
|
+
'void',
|
|
4867
|
+
'number',
|
|
4868
|
+
'boolean',
|
|
4869
|
+
'string',
|
|
4870
|
+
'object',
|
|
4871
|
+
'never',
|
|
4872
|
+
'enum'
|
|
4873
|
+
]
|
|
4879
4874
|
const TS_SPECIFIC_KEYWORDS = [
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
]
|
|
4875
|
+
'type',
|
|
4876
|
+
'namespace',
|
|
4877
|
+
'typedef',
|
|
4878
|
+
'interface',
|
|
4879
|
+
'public',
|
|
4880
|
+
'private',
|
|
4881
|
+
'protected',
|
|
4882
|
+
'implements',
|
|
4883
|
+
'declare',
|
|
4884
|
+
'abstract',
|
|
4885
|
+
'readonly'
|
|
4886
|
+
]
|
|
4892
4887
|
const KEYWORDS$1 = {
|
|
4893
4888
|
$pattern: IDENT_RE,
|
|
4894
4889
|
keyword: KEYWORDS.concat(TS_SPECIFIC_KEYWORDS),
|
|
4895
4890
|
literal: LITERALS,
|
|
4896
4891
|
built_in: BUILT_INS.concat(TYPES),
|
|
4897
|
-
|
|
4898
|
-
}
|
|
4892
|
+
'variable.language': BUILT_IN_VARIABLES
|
|
4893
|
+
}
|
|
4899
4894
|
const DECORATOR = {
|
|
4900
4895
|
className: 'meta',
|
|
4901
|
-
begin: '@' + IDENT_RE$1
|
|
4902
|
-
}
|
|
4896
|
+
begin: '@' + IDENT_RE$1
|
|
4897
|
+
}
|
|
4903
4898
|
|
|
4904
4899
|
const swapMode = (mode, label, replacement) => {
|
|
4905
|
-
const indx = mode.contains.findIndex(m => m.label === label)
|
|
4906
|
-
if (indx === -1) { throw new Error(
|
|
4907
|
-
mode.contains.splice(indx, 1, replacement)
|
|
4908
|
-
}
|
|
4900
|
+
const indx = mode.contains.findIndex(m => m.label === label)
|
|
4901
|
+
if (indx === -1) { throw new Error('can not find mode to replace') }
|
|
4902
|
+
mode.contains.splice(indx, 1, replacement)
|
|
4903
|
+
}
|
|
4909
4904
|
|
|
4910
|
-
const tsLanguage = javascript(hljs)
|
|
4905
|
+
const tsLanguage = javascript(hljs)
|
|
4911
4906
|
|
|
4912
4907
|
// this should update anywhere keywords is used since
|
|
4913
4908
|
// it will be the same actual JS object
|
|
4914
|
-
Object.assign(tsLanguage.keywords, KEYWORDS$1)
|
|
4909
|
+
Object.assign(tsLanguage.keywords, KEYWORDS$1)
|
|
4915
4910
|
|
|
4916
|
-
tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR)
|
|
4911
|
+
tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR)
|
|
4917
4912
|
tsLanguage.contains = tsLanguage.contains.concat([
|
|
4918
4913
|
DECORATOR,
|
|
4919
4914
|
NAMESPACE,
|
|
4920
|
-
INTERFACE
|
|
4921
|
-
])
|
|
4915
|
+
INTERFACE
|
|
4916
|
+
])
|
|
4922
4917
|
|
|
4923
4918
|
// TS gets a simpler shebang rule than JS
|
|
4924
|
-
swapMode(tsLanguage,
|
|
4919
|
+
swapMode(tsLanguage, 'shebang', hljs.SHEBANG())
|
|
4925
4920
|
// JS use strict rule purposely excludes `asm` which makes no sense
|
|
4926
|
-
swapMode(tsLanguage,
|
|
4921
|
+
swapMode(tsLanguage, 'use_strict', USE_STRICT)
|
|
4927
4922
|
|
|
4928
|
-
const functionDeclaration = tsLanguage.contains.find(m => m.label ===
|
|
4929
|
-
functionDeclaration.relevance = 0
|
|
4923
|
+
const functionDeclaration = tsLanguage.contains.find(m => m.label === 'func.def')
|
|
4924
|
+
functionDeclaration.relevance = 0 // () => {} is more typical in TypeScript
|
|
4930
4925
|
|
|
4931
4926
|
Object.assign(tsLanguage, {
|
|
4932
4927
|
name: 'TypeScript',
|
|
4933
4928
|
aliases: ['ts', 'tsx']
|
|
4934
|
-
})
|
|
4929
|
+
})
|
|
4935
4930
|
|
|
4936
|
-
return tsLanguage
|
|
4931
|
+
return tsLanguage
|
|
4937
4932
|
}
|
|
4938
4933
|
|
|
4939
|
-
|
|
4940
4934
|
/*
|
|
4941
4935
|
Language: YAML
|
|
4942
4936
|
Description: Yet Another Markdown Language
|
|
@@ -4946,11 +4940,11 @@ var hljs = (function () {
|
|
|
4946
4940
|
Website: https://yaml.org
|
|
4947
4941
|
Category: common, config
|
|
4948
4942
|
*/
|
|
4949
|
-
function yaml(hljs) {
|
|
4950
|
-
const LITERALS = 'true false yes no null'
|
|
4943
|
+
function yaml (hljs) {
|
|
4944
|
+
const LITERALS = 'true false yes no null'
|
|
4951
4945
|
|
|
4952
4946
|
// YAML spec allows non-reserved URI characters in tags.
|
|
4953
|
-
const URI_CHARACTERS = '[\\w#;/?:@&=+$,.~*\'()[\\]]+'
|
|
4947
|
+
const URI_CHARACTERS = '[\\w#;/?:@&=+$,.~*\'()[\\]]+'
|
|
4954
4948
|
|
|
4955
4949
|
// Define keys as starting with a word character
|
|
4956
4950
|
// ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
|
|
@@ -4969,7 +4963,7 @@ var hljs = (function () {
|
|
|
4969
4963
|
begin: '\'\\w[\\w :\\/.-]*\':(?=[ \t]|$)'
|
|
4970
4964
|
}
|
|
4971
4965
|
]
|
|
4972
|
-
}
|
|
4966
|
+
}
|
|
4973
4967
|
|
|
4974
4968
|
const TEMPLATE_VARIABLES = {
|
|
4975
4969
|
className: 'template-variable',
|
|
@@ -4983,7 +4977,7 @@ var hljs = (function () {
|
|
|
4983
4977
|
end: /\}/
|
|
4984
4978
|
}
|
|
4985
4979
|
]
|
|
4986
|
-
}
|
|
4980
|
+
}
|
|
4987
4981
|
const STRING = {
|
|
4988
4982
|
className: 'string',
|
|
4989
4983
|
relevance: 0,
|
|
@@ -5004,7 +4998,7 @@ var hljs = (function () {
|
|
|
5004
4998
|
hljs.BACKSLASH_ESCAPE,
|
|
5005
4999
|
TEMPLATE_VARIABLES
|
|
5006
5000
|
]
|
|
5007
|
-
}
|
|
5001
|
+
}
|
|
5008
5002
|
|
|
5009
5003
|
// Strings inside of value containers (objects) can't contain braces,
|
|
5010
5004
|
// brackets, or commas
|
|
@@ -5022,16 +5016,16 @@ var hljs = (function () {
|
|
|
5022
5016
|
begin: /[^\s,{}[\]]+/
|
|
5023
5017
|
}
|
|
5024
5018
|
]
|
|
5025
|
-
})
|
|
5019
|
+
})
|
|
5026
5020
|
|
|
5027
|
-
const DATE_RE = '[0-9]{4}(-[0-9][0-9]){0,2}'
|
|
5028
|
-
const TIME_RE = '([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?'
|
|
5029
|
-
const FRACTION_RE = '(\\.[0-9]*)?'
|
|
5030
|
-
const ZONE_RE = '([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?'
|
|
5021
|
+
const DATE_RE = '[0-9]{4}(-[0-9][0-9]){0,2}'
|
|
5022
|
+
const TIME_RE = '([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?'
|
|
5023
|
+
const FRACTION_RE = '(\\.[0-9]*)?'
|
|
5024
|
+
const ZONE_RE = '([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?'
|
|
5031
5025
|
const TIMESTAMP = {
|
|
5032
5026
|
className: 'number',
|
|
5033
5027
|
begin: '\\b' + DATE_RE + TIME_RE + FRACTION_RE + ZONE_RE + '\\b'
|
|
5034
|
-
}
|
|
5028
|
+
}
|
|
5035
5029
|
|
|
5036
5030
|
const VALUE_CONTAINER = {
|
|
5037
5031
|
end: ',',
|
|
@@ -5039,21 +5033,21 @@ var hljs = (function () {
|
|
|
5039
5033
|
excludeEnd: true,
|
|
5040
5034
|
keywords: LITERALS,
|
|
5041
5035
|
relevance: 0
|
|
5042
|
-
}
|
|
5036
|
+
}
|
|
5043
5037
|
const OBJECT = {
|
|
5044
5038
|
begin: /\{/,
|
|
5045
5039
|
end: /\}/,
|
|
5046
5040
|
contains: [VALUE_CONTAINER],
|
|
5047
5041
|
illegal: '\\n',
|
|
5048
5042
|
relevance: 0
|
|
5049
|
-
}
|
|
5043
|
+
}
|
|
5050
5044
|
const ARRAY = {
|
|
5051
5045
|
begin: '\\[',
|
|
5052
5046
|
end: '\\]',
|
|
5053
5047
|
contains: [VALUE_CONTAINER],
|
|
5054
5048
|
illegal: '\\n',
|
|
5055
5049
|
relevance: 0
|
|
5056
|
-
}
|
|
5050
|
+
}
|
|
5057
5051
|
|
|
5058
5052
|
const MODES = [
|
|
5059
5053
|
KEY,
|
|
@@ -5085,7 +5079,7 @@ var hljs = (function () {
|
|
|
5085
5079
|
// https://yaml.org/spec/1.2/spec.html#id2784064
|
|
5086
5080
|
{ // verbatim tags
|
|
5087
5081
|
className: 'type',
|
|
5088
|
-
begin: '!<' + URI_CHARACTERS +
|
|
5082
|
+
begin: '!<' + URI_CHARACTERS + '>'
|
|
5089
5083
|
},
|
|
5090
5084
|
{ // primary tags
|
|
5091
5085
|
className: 'type',
|
|
@@ -5127,22 +5121,22 @@ var hljs = (function () {
|
|
|
5127
5121
|
OBJECT,
|
|
5128
5122
|
ARRAY,
|
|
5129
5123
|
STRING
|
|
5130
|
-
]
|
|
5124
|
+
]
|
|
5131
5125
|
|
|
5132
|
-
const VALUE_MODES = [...MODES]
|
|
5133
|
-
VALUE_MODES.pop()
|
|
5134
|
-
VALUE_MODES.push(CONTAINER_STRING)
|
|
5135
|
-
VALUE_CONTAINER.contains = VALUE_MODES
|
|
5126
|
+
const VALUE_MODES = [...MODES]
|
|
5127
|
+
VALUE_MODES.pop()
|
|
5128
|
+
VALUE_MODES.push(CONTAINER_STRING)
|
|
5129
|
+
VALUE_CONTAINER.contains = VALUE_MODES
|
|
5136
5130
|
|
|
5137
5131
|
return {
|
|
5138
5132
|
name: 'YAML',
|
|
5139
5133
|
case_insensitive: true,
|
|
5140
5134
|
aliases: ['yml'],
|
|
5141
5135
|
contains: MODES
|
|
5142
|
-
}
|
|
5136
|
+
}
|
|
5143
5137
|
}
|
|
5144
5138
|
|
|
5145
|
-
|
|
5139
|
+
const builtIns = /* #__PURE__ */Object.freeze({
|
|
5146
5140
|
__proto__: null,
|
|
5147
5141
|
grmr_bash: bash,
|
|
5148
5142
|
grmr_scss: scss,
|
|
@@ -5156,16 +5150,15 @@ var hljs = (function () {
|
|
|
5156
5150
|
grmr_shell: shell,
|
|
5157
5151
|
grmr_typescript: typescript,
|
|
5158
5152
|
grmr_yaml: yaml
|
|
5159
|
-
})
|
|
5153
|
+
})
|
|
5160
5154
|
|
|
5161
|
-
const hljs = HighlightJS
|
|
5155
|
+
const hljs = HighlightJS
|
|
5162
5156
|
|
|
5163
5157
|
for (const key of Object.keys(builtIns)) {
|
|
5164
|
-
const languageName = key.replace(
|
|
5165
|
-
hljs.registerLanguage(languageName, builtIns[key])
|
|
5158
|
+
const languageName = key.replace('grmr_', '')
|
|
5159
|
+
hljs.registerLanguage(languageName, builtIns[key])
|
|
5166
5160
|
}
|
|
5167
5161
|
|
|
5168
|
-
return hljs
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = hljs; }
|
|
5162
|
+
return hljs
|
|
5163
|
+
}())
|
|
5164
|
+
if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = hljs }
|