@speed-highlight/core 1.1.10 → 1.1.12

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.
Files changed (189) hide show
  1. package/dist/detect.d.ts +8 -0
  2. package/dist/detect.js +1 -1
  3. package/dist/index.d.ts +111 -0
  4. package/dist/index.js +1 -3
  5. package/dist/languages/bash.js +1 -1
  6. package/dist/languages/docker.js +1 -1
  7. package/dist/languages/git.js +1 -1
  8. package/dist/languages/html.js +1 -1
  9. package/dist/languages/http.js +1 -1
  10. package/dist/languages/js_template_literals.js +1 -1
  11. package/dist/languages/jsdoc.js +1 -1
  12. package/dist/languages/json.js +1 -1
  13. package/dist/languages/leanpub-md.js +1 -2
  14. package/dist/languages/md.js +1 -2
  15. package/dist/languages/plain.js +1 -1
  16. package/dist/languages/py.js +1 -1
  17. package/dist/languages/regex.js +1 -1
  18. package/dist/languages/todo.js +1 -1
  19. package/dist/languages/ts.js +1 -1
  20. package/dist/languages/xml.js +1 -1
  21. package/dist/node/common.js +1 -1
  22. package/dist/node/detect.d.ts +8 -0
  23. package/dist/node/detect.js +1 -1
  24. package/dist/node/index.d.ts +111 -0
  25. package/dist/node/index.js +1 -3
  26. package/dist/node/languages/asm.js +1 -1
  27. package/dist/node/languages/bash.js +1 -1
  28. package/dist/node/languages/bf.js +1 -1
  29. package/dist/node/languages/c.js +1 -1
  30. package/dist/node/languages/css.js +1 -1
  31. package/dist/node/languages/csv.js +1 -1
  32. package/dist/node/languages/diff.js +1 -1
  33. package/dist/node/languages/docker.js +1 -1
  34. package/dist/node/languages/git.js +1 -1
  35. package/dist/node/languages/go.js +1 -1
  36. package/dist/node/languages/html.js +1 -1
  37. package/dist/node/languages/http.js +1 -1
  38. package/dist/node/languages/ini.js +1 -1
  39. package/dist/node/languages/java.js +1 -1
  40. package/dist/node/languages/js.js +1 -1
  41. package/dist/node/languages/js_template_literals.js +1 -1
  42. package/dist/node/languages/jsdoc.js +1 -1
  43. package/dist/node/languages/json.js +1 -1
  44. package/dist/node/languages/leanpub-md.js +1 -2
  45. package/dist/node/languages/log.js +1 -1
  46. package/dist/node/languages/lua.js +1 -1
  47. package/dist/node/languages/make.js +1 -1
  48. package/dist/node/languages/md.js +1 -2
  49. package/dist/node/languages/pl.js +1 -1
  50. package/dist/node/languages/plain.js +1 -1
  51. package/dist/node/languages/py.js +1 -1
  52. package/dist/node/languages/regex.js +1 -1
  53. package/dist/node/languages/rs.js +1 -1
  54. package/dist/node/languages/sql.js +1 -1
  55. package/dist/node/languages/todo.js +1 -1
  56. package/dist/node/languages/toml.js +1 -1
  57. package/dist/node/languages/ts.js +1 -1
  58. package/dist/node/languages/uri.js +1 -1
  59. package/dist/node/languages/xml.js +1 -1
  60. package/dist/node/languages/yaml.js +1 -1
  61. package/dist/node/terminal.d.ts +26 -0
  62. package/dist/terminal.d.ts +26 -0
  63. package/package.json +12 -2
  64. package/.gitattributes +0 -2
  65. package/CODE_OF_CONDUCT.md +0 -128
  66. package/CONTRIBUTING.md +0 -34
  67. package/dist/node/terminal.js +0 -1
  68. package/dist/node/themes/atom-dark.js +0 -1
  69. package/dist/node/themes/default.js +0 -1
  70. package/dist/node/themes/termcolor.js +0 -1
  71. package/dist/terminal.js +0 -1
  72. package/dist/themes/atom-dark.css +0 -1
  73. package/dist/themes/atom-dark.js +0 -1
  74. package/dist/themes/dark.css +0 -1
  75. package/dist/themes/default.css +0 -1
  76. package/dist/themes/default.js +0 -1
  77. package/dist/themes/github-dark.css +0 -1
  78. package/dist/themes/github-dim.css +0 -1
  79. package/dist/themes/github-light.css +0 -1
  80. package/dist/themes/termcolor.js +0 -1
  81. package/dist/themes/visual-studio-dark.css +0 -1
  82. package/doc/common.js.html +0 -87
  83. package/doc/css/jsdoc-template.css +0 -1
  84. package/doc/css/tomorrow.min.css +0 -2
  85. package/doc/detect%0ALanguage%20detectormodule_.html +0 -309
  86. package/doc/detect.js.html +0 -113
  87. package/doc/global.html +0 -1826
  88. package/doc/index%0ABase%20scriptmodule_.html +0 -1179
  89. package/doc/index.html +0 -402
  90. package/doc/index.js.html +0 -209
  91. package/doc/js/jsdoc-template.js +0 -2
  92. package/doc/js/jsdoc-template.js.map +0 -1
  93. package/doc/js/prettify.min.js +0 -47
  94. package/doc/term%0ATerminal%20adaptormodule_.html +0 -596
  95. package/doc/term.js.html +0 -108
  96. package/examples/data.js +0 -63
  97. package/examples/deno.js +0 -60
  98. package/examples/index.html +0 -118
  99. package/examples/languages/oneline.bash +0 -1
  100. package/examples/languages/oneline.http +0 -1
  101. package/examples/languages/screenshot.js +0 -18
  102. package/examples/languages/test.asm +0 -17
  103. package/examples/languages/test.bash +0 -32
  104. package/examples/languages/test.bf +0 -21
  105. package/examples/languages/test.c +0 -57
  106. package/examples/languages/test.css +0 -20
  107. package/examples/languages/test.csv +0 -4
  108. package/examples/languages/test.diff +0 -27
  109. package/examples/languages/test.docker +0 -23
  110. package/examples/languages/test.git +0 -10
  111. package/examples/languages/test.go +0 -21
  112. package/examples/languages/test.html +0 -27
  113. package/examples/languages/test.http +0 -17
  114. package/examples/languages/test.ini +0 -6
  115. package/examples/languages/test.java +0 -52
  116. package/examples/languages/test.js +0 -34
  117. package/examples/languages/test.jsdoc +0 -2
  118. package/examples/languages/test.json +0 -24
  119. package/examples/languages/test.leanpub-md +0 -21
  120. package/examples/languages/test.log +0 -32
  121. package/examples/languages/test.lua +0 -62
  122. package/examples/languages/test.make +0 -51
  123. package/examples/languages/test.md +0 -62
  124. package/examples/languages/test.pl +0 -25
  125. package/examples/languages/test.plain +0 -3
  126. package/examples/languages/test.py +0 -38
  127. package/examples/languages/test.regex +0 -2
  128. package/examples/languages/test.rs +0 -38
  129. package/examples/languages/test.sql +0 -6
  130. package/examples/languages/test.todo +0 -18
  131. package/examples/languages/test.toml +0 -16
  132. package/examples/languages/test.ts +0 -43
  133. package/examples/languages/test.uri +0 -9
  134. package/examples/languages/test.xml +0 -44
  135. package/examples/languages/test.yaml +0 -18
  136. package/examples/node.js +0 -11
  137. package/examples/worker.html +0 -20
  138. package/examples/worker.js +0 -6
  139. package/jsdoc.json +0 -16
  140. package/src/common.js +0 -18
  141. package/src/detect.js +0 -49
  142. package/src/index.js +0 -144
  143. package/src/languages/asm.js +0 -30
  144. package/src/languages/bash.js +0 -44
  145. package/src/languages/bf.js +0 -18
  146. package/src/languages/c.js +0 -52
  147. package/src/languages/css.js +0 -56
  148. package/src/languages/csv.js +0 -9
  149. package/src/languages/diff.js +0 -18
  150. package/src/languages/docker.js +0 -9
  151. package/src/languages/git.js +0 -20
  152. package/src/languages/go.js +0 -28
  153. package/src/languages/html.js +0 -51
  154. package/src/languages/http.js +0 -30
  155. package/src/languages/ini.js +0 -22
  156. package/src/languages/java.js +0 -28
  157. package/src/languages/js.js +0 -48
  158. package/src/languages/js_template_literals.js +0 -34
  159. package/src/languages/jsdoc.js +0 -18
  160. package/src/languages/json.js +0 -20
  161. package/src/languages/leanpub-md.js +0 -34
  162. package/src/languages/log.js +0 -28
  163. package/src/languages/lua.js +0 -28
  164. package/src/languages/make.js +0 -36
  165. package/src/languages/md.js +0 -48
  166. package/src/languages/pl.js +0 -25
  167. package/src/languages/plain.js +0 -5
  168. package/src/languages/py.js +0 -52
  169. package/src/languages/regex.js +0 -19
  170. package/src/languages/rs.js +0 -28
  171. package/src/languages/sql.js +0 -33
  172. package/src/languages/todo.js +0 -19
  173. package/src/languages/toml.js +0 -36
  174. package/src/languages/ts.js +0 -13
  175. package/src/languages/uri.js +0 -26
  176. package/src/languages/xml.js +0 -68
  177. package/src/languages/yaml.js +0 -32
  178. package/src/terminal.js +0 -42
  179. package/src/themes/atom-dark.css +0 -23
  180. package/src/themes/atom-dark.js +0 -18
  181. package/src/themes/dark.css +0 -23
  182. package/src/themes/default.css +0 -82
  183. package/src/themes/default.js +0 -18
  184. package/src/themes/github-dark.css +0 -23
  185. package/src/themes/github-dim.css +0 -3
  186. package/src/themes/github-light.css +0 -21
  187. package/src/themes/termcolor.js +0 -11
  188. package/src/themes/visual-studio-dark.css +0 -23
  189. package/typedef.js +0 -34
package/src/index.js DELETED
@@ -1,144 +0,0 @@
1
- /**
2
- * @module index
3
- * (Base script)
4
- */
5
-
6
- import '../typedef.js'
7
-
8
- import expandData from './common.js';
9
-
10
- const langs = {},
11
- sanitize = (str = '') =>
12
- str.replaceAll('&', '&#38;').replaceAll?.('<', '&lt;').replaceAll?.('>', '&gt;'),
13
- /**
14
- * @function
15
- * @ignore
16
- * Create a HTML element with the right token styling
17
- * @param {String} str The content (need to be sanitized)
18
- * @param {ShjToken} [token] The type of token
19
- * @returns A HMTL string
20
- */
21
- toSpan = (str, token) => token ? `<span class="shj-syn-${token}">${str}</span>` : str;
22
-
23
- /**
24
- * @function tokenize
25
- * Find the tokens in the given code and call the callback
26
- * @param {String} src The code
27
- * @param {ShjLanguage|Array} lang The language of the code
28
- * @param {function(String, ShjToken=):void} token The callback function
29
- * this function will be given
30
- * * the text of the token
31
- * * the type of the token
32
- */
33
- export async function tokenize(src, lang, token) {
34
- try {
35
- let m,
36
- part,
37
- first = {},
38
- match,
39
- cache = [],
40
- i = 0,
41
- data = typeof lang === 'string' ? (await (langs[lang] ??= import(`./languages/${lang}.js`))) : lang,
42
- // make a fast shallow copy to bee able to splice lang without change the original one
43
- arr = [...typeof lang === 'string' ? data.default : lang.sub];
44
-
45
- while (i < src.length) {
46
- first.index = null;
47
- for (m = arr.length; m-- > 0;) {
48
- part = arr[m].expand ? expandData[arr[m].expand] : arr[m];
49
- // do not call again exec if the previous result is sufficient
50
- if (cache[m] === undefined || cache[m].match.index < i) {
51
- part.match.lastIndex = i;
52
- match = part.match.exec(src);
53
- if (match === null) {
54
- // no more match with this regex can be disposed
55
- arr.splice(m, 1);
56
- cache.splice(m, 1);
57
- continue;
58
- }
59
- // save match for later use to decrease performance cost
60
- cache[m] = { match, lastIndex: part.match.lastIndex };
61
- }
62
- // check if it the first match in the string
63
- if (cache[m].match[0] && (cache[m].match.index <= first.index || first.index === null))
64
- first = {
65
- part: part,
66
- index: cache[m].match.index,
67
- match: cache[m].match[0],
68
- end: cache[m].lastIndex
69
- }
70
- }
71
- if (first.index === null)
72
- break;
73
- token(src.slice(i, first.index), data.type);
74
- i = first.end;
75
- if (first.part.sub)
76
- await tokenize(first.match, typeof first.part.sub === 'string' ? first.part.sub : (typeof first.part.sub === 'function' ? first.part.sub(first.match) : first.part), token);
77
- else
78
- token(first.match, first.part.type);
79
- }
80
- token(src.slice(i, src.length), data.type);
81
- }
82
- catch {
83
- token(src);
84
- }
85
- }
86
-
87
- /**
88
- * @function highlightText
89
- * @async
90
- * Highlight a string passed as argument and return it
91
- * @example
92
- * elm.innerHTML = await highlightText(code, 'js');
93
- * @param {String} src The code
94
- * @param {ShjLanguage} lang The language of the code
95
- * @param {Boolean} [multiline=true] If it is multiline, it will add a wrapper for the line numbering and header
96
- * @param {ShjOptions} [opt={}] Customization options
97
- * @returns {Promise<String>} The highlighted string
98
- */
99
- export async function highlightText(src, lang, multiline = true, opt = {}) {
100
- let tmp = ''
101
- await tokenize(src, lang, (str, type) => tmp += toSpan(sanitize(str), type))
102
-
103
- return multiline
104
- ? `<div><div class="shj-numbers">${'<div></div>'.repeat(!opt.hideLineNumbers && src.split('\n').length)}</div><div>${tmp}</div></div>`
105
- : tmp;
106
- }
107
-
108
- /**
109
- * @function highlightElement
110
- * @async
111
- * Highlight a DOM element by getting the new innerHTML with highlightText
112
- * @param {Element} elm The DOM element
113
- * @param {ShjLanguage} [lang] The language of the code (seaching by default on `elm` for a 'shj-lang-' class)
114
- * @param {ShjDisplayMode} [mode] The display mode (guessed by default)
115
- * @param {ShjOptions} [opt={}] Customization options
116
- */
117
- export async function highlightElement(elm, lang = elm.className.match(/shj-lang-([\w-]+)/)?.[1], mode, opt) {
118
- let txt = elm.textContent;
119
- mode ??= `${elm.tagName == 'CODE' ? 'in' : (txt.split('\n').length < 2 ? 'one' : 'multi')}line`;
120
- elm.dataset.lang = lang;
121
- elm.className = `${[...elm.classList].filter(className => !className.startsWith('shj-') || className.startsWith('shj-mode-')).join(' ')} shj-lang-${lang} shj-${mode}`;
122
- elm.innerHTML = await highlightText(txt, lang, mode == 'multiline', opt);
123
- }
124
-
125
- /**
126
- * @function highlightAll
127
- * @async
128
- * Call highlightElement on element with a css class starting with `shj-lang-`
129
- * @param {ShjOptions} [opt={}] Customization options
130
- */
131
- export let highlightAll = async (opt) =>
132
- document
133
- .querySelectorAll('[class*="shj-lang-"]')
134
- .forEach(elm => highlightElement(elm, undefined, undefined, opt))
135
-
136
- /**
137
- * @function loadLanguage
138
- * Load a language and add it to the langs object
139
- * @param {String} languageName The name of the language
140
- * @param {ShjLanguage} language The language
141
- */
142
- export let loadLanguage = (languageName, language) => {
143
- langs[languageName] = language;
144
- }
@@ -1,30 +0,0 @@
1
- export default [
2
- {
3
- type: 'cmnt',
4
- match: /;.*/gm
5
- },
6
- {
7
- expand: 'str'
8
- },
9
- {
10
- expand: 'num'
11
- },
12
- {
13
- type: 'kwd',
14
- match: /^[a-z]+\s+[a-z.]+/gm,
15
- sub: [
16
- {
17
- type: 'func',
18
- match: /^[a-z]+/g
19
- }
20
- ]
21
- },
22
- {
23
- type: 'kwd',
24
- match: /^\t*[a-z]+/gm,
25
- },
26
- {
27
- match: /%|\$/g,
28
- type: 'oper'
29
- }
30
- ]
@@ -1,44 +0,0 @@
1
- let variable = {
2
- type: 'var',
3
- match: /\$\w+|\${[^}]*}|\$\([^)]*\)/g
4
- };
5
-
6
- export default [
7
- {
8
- sub: 'todo',
9
- match: /#.*/g
10
- },
11
- {
12
- type: 'str',
13
- match: /(["'])((?!\1)[^\r\n\\]|\\[^])*\1?/g,
14
- sub: [ variable ]
15
- },
16
- {
17
- type: 'kwd',
18
- match: /-[a-zA-Z]+|$<|[&|;]+|\b(unset|readonly|shift|export|if|fi|else|elif|while|do|done|for|until|case|esac|break|continue|exit|return|trap|wait|eval|exec|then|declare|enable|local|select|typeset|time|add|remove|install|update|delete)\b/g
19
- },
20
- {
21
- expand: 'num'
22
- },
23
- {
24
- type: 'func',
25
- match: /\b(set|alias|bg|bind|builtin|caller|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|set|shift|shopt|source|suspend|test|times|trap|type|ulimit|umask|unalias|unset)\b/g
26
- },
27
- {
28
- type: 'bool',
29
- match: /\b(true|false)\b/g
30
- },
31
- {
32
- type: 'func',
33
- match: /[a-z_]+(?=\s*\()/g
34
- },
35
- {
36
- type: 'oper',
37
- match: /[=(){}<>+*/!?~^-]+/g
38
- },
39
- {
40
- type: 'var',
41
- match: /\w+(?=\s*=)/g
42
- },
43
- variable
44
- ]
@@ -1,18 +0,0 @@
1
- export default [
2
- {
3
- match: /[^\[\->+.<\]\s].*/g,
4
- sub: 'todo'
5
- },
6
- {
7
- type: 'func',
8
- match: /\.+/g
9
- },
10
- {
11
- type: 'kwd',
12
- match: /[<>]+/g
13
- },
14
- {
15
- type: 'oper',
16
- match: /[+-]+/g
17
- }
18
- ]
@@ -1,52 +0,0 @@
1
- export default [
2
- {
3
- match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
4
- sub: 'todo'
5
- },
6
- {
7
- expand: 'str'
8
- },
9
- {
10
- expand: 'num'
11
- },
12
- {
13
- type: 'kwd',
14
- match: /#\s*include (<.*>|".*")/g,
15
- sub: [
16
- {
17
- type: 'str',
18
- match: /(<|").*/g
19
- }
20
- ]
21
- },
22
- {
23
- match: /asm\s*{[^}]*}/g,
24
- sub: [
25
- {
26
- type: 'kwd',
27
- match: /^asm/g
28
- },
29
- {
30
- //type: 'str',
31
- match: /[^{}]*(?=}$)/g,
32
- sub: 'asm'
33
- }
34
- ]
35
- },
36
- {
37
- type: 'kwd',
38
- match: /\*|&|#[a-z]+\b|\b(asm|auto|double|int|struct|break|else|long|switch|case|enum|register|typedef|char|extern|return|union|const|float|short|unsigned|continue|for|signed|void|default|goto|sizeof|volatile|do|if|static|while)\b/g
39
- },
40
- {
41
- type: 'oper',
42
- match: /[/*+:?&|%^~=!,<>.^-]+/g
43
- },
44
- {
45
- type: 'func',
46
- match: /[a-zA-Z_][\w_]*(?=\s*\()/g
47
- },
48
- {
49
- type: 'class',
50
- match: /\b[A-Z][\w_]*\b/g
51
- }
52
- ]
@@ -1,56 +0,0 @@
1
- export default [
2
- {
3
- match: /\/\*((?!\*\/)[^])*(\*\/)?/g,
4
- sub: 'todo'
5
- },
6
- {
7
- expand: 'str'
8
- },
9
- {
10
- type: 'kwd',
11
- match: /@\w+\b|\b(and|not|only|or)\b|\b[a-z-]+(?=[^{}]*{)/g
12
- },
13
- {
14
- type: 'var',
15
- match: /\b[\w-]+(?=\s*:)|(::?|\.)[\w-]+(?=[^{}]*{)/g
16
- },
17
- {
18
- type: 'func',
19
- match: /#[\w-]+(?=[^{}]*{)/g
20
- },
21
- {
22
- type: 'num',
23
- match: /#[\da-f]{3,8}/g
24
- },
25
- {
26
- type: 'num',
27
- match: /\d+(\.\d+)?(cm|mm|in|px|pt|pc|em|ex|ch|rem|vm|vh|vmin|vmax|%)?/g,
28
- sub: [
29
- {
30
- type: 'var',
31
- match: /[a-z]+|%/g
32
- }
33
- ]
34
- },
35
- {
36
- match: /url\([^)]*\)/g,
37
- sub: [
38
- {
39
- type: 'func',
40
- match: /url(?=\()/g
41
- },
42
- {
43
- type: 'str',
44
- match: /[^()]+/g
45
- }
46
- ]
47
- },
48
- {
49
- type: 'func',
50
- match: /\b[a-zA-Z]\w*(?=\s*\()/g
51
- },
52
- {
53
- type: 'num',
54
- match: /\b[a-z-]+\b/g
55
- }
56
- ]
@@ -1,9 +0,0 @@
1
- export default [
2
- {
3
- expand: 'strDouble'
4
- },
5
- {
6
- type: 'oper',
7
- match: /,/g
8
- }
9
- ]
@@ -1,18 +0,0 @@
1
- export default [
2
- {
3
- type: 'deleted',
4
- match: /^[-<].*/gm
5
- },
6
- {
7
- type: 'insert',
8
- match: /^[+>].*/gm
9
- },
10
- {
11
- type: 'kwd',
12
- match: /!.*/gm
13
- },
14
- {
15
- type: 'section',
16
- match: /^@@.*@@$|^\d.*|^([*-+])\1\1.*/gm
17
- }
18
- ]
@@ -1,9 +0,0 @@
1
- import bash from "./bash.js"
2
-
3
- export default [
4
- {
5
- type: 'kwd',
6
- match: /^(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)\b/gmi
7
- },
8
- ...bash
9
- ]
@@ -1,20 +0,0 @@
1
- import diff from './diff.js'
2
-
3
- export default [
4
- {
5
- match: /^#.*/gm,
6
- sub: 'todo'
7
- },
8
- {
9
- expand: 'str'
10
- },
11
- ...diff,
12
- {
13
- type: 'func',
14
- match: /^(\$ )?git(\s.*)?$/gm
15
- },
16
- {
17
- type: 'kwd',
18
- match: /^commit \w+$/gm
19
- }
20
- ]
@@ -1,28 +0,0 @@
1
- export default [
2
- {
3
- match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
4
- sub: 'todo'
5
- },
6
- {
7
- expand: 'str'
8
- },
9
- {
10
- expand: 'num'
11
- },
12
- {
13
- type: 'kwd',
14
- match: /\*|&|\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go|goto|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/g
15
- },
16
- {
17
- type: 'func',
18
- match: /[a-zA-Z_][\w_]*(?=\s*\()/g
19
- },
20
- {
21
- type: 'class',
22
- match: /\b[A-Z][\w_]*\b/g
23
- },
24
- {
25
- type: 'oper',
26
- match: /[+\-*\/%&|^~=!<>.^-]+/g
27
- }
28
- ]
@@ -1,51 +0,0 @@
1
- import xml, { property, xmlElement } from './xml.js'
2
-
3
- export default [
4
- {
5
- type: 'class',
6
- match: /<!DOCTYPE("[^"]*"|'[^']*'|[^"'>])*>/gi,
7
- sub: [
8
- {
9
- type: 'str',
10
- match: /"[^"]*"|'[^']*'/g
11
- },
12
- {
13
- type: 'oper',
14
- match: /^<!|>$/g
15
- },
16
- {
17
- type: 'var',
18
- match: /DOCTYPE/gi
19
- }
20
- ]
21
- },
22
- {
23
- match: RegExp(`<style${property}>((?!</style>)[^])*</style\\s*>`, 'g'),
24
- sub: [
25
- {
26
- match: RegExp(`^<style${property}>`, 'g'),
27
- sub: xmlElement.sub
28
- },
29
- {
30
- match: RegExp(`${xmlElement.match}|[^]*(?=</style\\s*>$)`, 'g'),
31
- sub: 'css'
32
- },
33
- xmlElement
34
- ]
35
- },
36
- {
37
- match: RegExp(`<script${property}>((?!</script>)[^])*</script\\s*>`, 'g'),
38
- sub: [
39
- {
40
- match: RegExp(`^<script${property}>`, 'g'),
41
- sub: xmlElement.sub
42
- },
43
- {
44
- match: RegExp(`${xmlElement.match}|[^]*(?=</script\\s*>$)`, 'g'),
45
- sub: 'js'
46
- },
47
- xmlElement
48
- ]
49
- },
50
- ...xml
51
- ]
@@ -1,30 +0,0 @@
1
- import { detectLanguage } from '../detect.js'
2
-
3
- export default [
4
- {
5
- type: 'kwd',
6
- match: /^(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/gm
7
- },
8
- {
9
- expand: 'str'
10
- },
11
- {
12
- type: 'section',
13
- match: /\bHTTP\/[\d.]+\b/g
14
- },
15
- {
16
- expand: 'num'
17
- },
18
- {
19
- type: 'oper',
20
- match: /[,;:=]/g
21
- },
22
- {
23
- type: 'var',
24
- match: /[a-zA-Z][\w-]*(?=:)/g
25
- },
26
- {
27
- match: /\n\n[^]*/g,
28
- sub: detectLanguage
29
- }
30
- ]
@@ -1,22 +0,0 @@
1
- export default [
2
- {
3
- match: /(^[ \f\t\v]*)[#;].*/gm,
4
- sub: 'todo'
5
- },
6
- {
7
- type: 'str',
8
- match: /.*/g
9
- },
10
- {
11
- type: 'var',
12
- match: /.*(?==)/g
13
- },
14
- {
15
- type: 'section',
16
- match: /^\s*\[.+\]\s*$/gm
17
- },
18
- {
19
- type: 'oper',
20
- match: /=/g
21
- }
22
- ]
@@ -1,28 +0,0 @@
1
- export default [
2
- {
3
- match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
4
- sub: 'todo'
5
- },
6
- {
7
- expand: 'str'
8
- },
9
- {
10
- expand: 'num'
11
- },
12
- {
13
- type: 'kwd',
14
- match: /\b(abstract|assert|boolean|break|byte|case|catch|char|class|continue|const|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|package|private|protected|public|requires|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|transient|try|var|void|volatile|while)\b/g
15
- },
16
- {
17
- type: 'oper',
18
- match: /[/*+:?&|%^~=!,<>.^-]+/g
19
- },
20
- {
21
- type: 'func',
22
- match: /[a-zA-Z_][\w_]*(?=\s*\()/g
23
- },
24
- {
25
- type: 'class',
26
- match: /\b[A-Z][\w_]*\b/g
27
- }
28
- ]
@@ -1,48 +0,0 @@
1
- export default [
2
- {
3
- match: /\/\*\*((?!\*\/)[^])*(\*\/)?/g,
4
- sub: 'jsdoc'
5
- },
6
- {
7
- match: /\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,
8
- sub: 'todo'
9
- },
10
- {
11
- expand: 'str'
12
- },
13
- {
14
- match: /`((?!`)[^]|\\[^])*`?/g,
15
- sub: 'js_template_literals'
16
- },
17
- {
18
- type: 'kwd',
19
- match: /=>|\b(this|set|get|as|async|await|break|case|catch|class|const|constructor|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|if|implements|import|in|instanceof|interface|let|var|of|new|package|private|protected|public|return|static|super|switch|throw|throws|try|typeof|void|while|with|yield)\b/g
20
- },
21
- {
22
- match: /\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,
23
- sub: 'regex'
24
- },
25
- {
26
- expand: 'num'
27
- },
28
- {
29
- type: 'num',
30
- match: /\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g
31
- },
32
- {
33
- type: 'bool',
34
- match: /\b(true|false)\b/g
35
- },
36
- {
37
- type: 'oper',
38
- match: /[/*+:?&|%^~=!,<>.^-]+/g
39
- },
40
- {
41
- type: 'class',
42
- match: /\b[A-Z][\w_]*\b/g
43
- },
44
- {
45
- type: 'func',
46
- match: /[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g
47
- }
48
- ]
@@ -1,34 +0,0 @@
1
- export default [
2
- {
3
- match: new class {
4
- exec(str) {
5
- let i = this.lastIndex,
6
- j,
7
- f = _ => {
8
- while (++i < str.length - 2)
9
- if (str[i] == '{') f();
10
- else if (str[i] == '}') return;
11
- };
12
- for (; i < str.length; i++)
13
- if (str[i - 1] != '\\' && str[i] == '$' && str[i + 1] == '{') {
14
- j = i++;
15
- f(i);
16
- this.lastIndex = i + 1;
17
- return { index: j, 0: str.slice(j, i + 1) };
18
- }
19
- return null;
20
- }
21
- }(),
22
- sub: [
23
- {
24
- type: 'kwd',
25
- match: /^\${|}$/g
26
- },
27
- {
28
- match: /(?!^\$|{)[^]+(?=}$)/g,
29
- sub: 'js'
30
- },
31
- ],
32
- },
33
- ];
34
- export let type = 'str';
@@ -1,18 +0,0 @@
1
- import todo from './todo.js';
2
-
3
- export default [
4
- {
5
- type: 'kwd',
6
- match: /@\w+/g
7
- },
8
- {
9
- type: 'class',
10
- match: /{[\w\s|<>,.@\[\]]+}/g
11
- },
12
- {
13
- type: 'var',
14
- match: /\[[\w\s="']+\]/g
15
- },
16
- ...todo
17
- ];
18
- export let type = 'cmnt';
@@ -1,20 +0,0 @@
1
- export default [
2
- {
3
- type: 'var',
4
- match: /("|')?[a-zA-Z]\w*\1(?=\s*:)/g
5
- },
6
- {
7
- expand: 'str'
8
- },
9
- {
10
- expand: 'num'
11
- },
12
- {
13
- type: 'num',
14
- match: /\bnull\b/g
15
- },
16
- {
17
- type: 'bool',
18
- match: /\b(true|false)\b/g
19
- }
20
- ]