@speed-highlight/core 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/languages/css.d.ts +2 -2
- package/dist/languages/css.js +1 -1
- package/dist/languages/html.d.ts +1 -1
- package/dist/languages/html.js +1 -1
- package/dist/languages/js.d.ts +5 -0
- package/dist/languages/js.js +1 -1
- package/dist/languages/jsdoc.d.ts +4 -1
- package/dist/languages/jsdoc.js +1 -1
- package/dist/languages/regex.js +1 -1
- package/dist/languages/ts.d.ts +5 -0
- package/dist/languages/ts.js +1 -1
- package/dist/node/languages/css.d.ts +2 -2
- package/dist/node/languages/css.js +1 -1
- package/dist/node/languages/html.d.ts +1 -1
- package/dist/node/languages/html.js +1 -1
- package/dist/node/languages/js.d.ts +5 -0
- package/dist/node/languages/js.js +1 -1
- package/dist/node/languages/jsdoc.d.ts +4 -1
- package/dist/node/languages/jsdoc.js +1 -1
- package/dist/node/languages/regex.js +1 -1
- package/dist/node/languages/ts.d.ts +5 -0
- package/dist/node/languages/ts.js +1 -1
- package/package.json +1 -1
- package/src/languages/css.js +15 -6
- package/src/languages/html.js +37 -5
- package/src/languages/js.js +10 -2
- package/src/languages/jsdoc.js +1 -1
- package/src/languages/regex.js +1 -1
package/README.md
CHANGED
|
@@ -225,24 +225,24 @@ The main entry covers most apps; reach for `/tokenize` when you want the raw tok
|
|
|
225
225
|
## Languages
|
|
226
226
|
|
|
227
227
|
<!-- AUTOGENERATED:LANGUAGES:START (run `npm run build` to regenerate) -->
|
|
228
|
-
| Name | [CSS Class](#web-usage) | Support | Detection | Size (gzip, 14.
|
|
228
|
+
| Name | [CSS Class](#web-usage) | Support | Detection | Size (gzip, 14.4 kB total) |
|
|
229
229
|
| --- | --- | --- | --- | --- |
|
|
230
230
|
| Assembly | `shj-lang-asm` | | ✅ | [`194 B`](src/languages/asm.js) |
|
|
231
231
|
| Bash | `shj-lang-bash` | | ✅ | [`430 B`](src/languages/bash.js) |
|
|
232
232
|
| Brainfuck | `shj-lang-bf` | increment, operator, print, comment | ❌ | [`137 B`](src/languages/bf.js) |
|
|
233
233
|
| C | `shj-lang-c` | | ✅ | [`429 B`](src/languages/c.js) |
|
|
234
|
-
| CSS | `shj-lang-css` | comment, str, selector, units, function, ... | ✅ | [`
|
|
234
|
+
| CSS | `shj-lang-css` | comment, str, selector, units, function, ... | ✅ | [`332 B`](src/languages/css.js) |
|
|
235
235
|
| CSV | `shj-lang-csv` | punctuation, ... | ❌ | [`96 B`](src/languages/csv.js) |
|
|
236
236
|
| Diff | `shj-lang-diff` | | ✅ | [`144 B`](src/languages/diff.js) |
|
|
237
237
|
| Dockerfile | `shj-lang-docker` | | ✅ | [`566 B`](src/languages/docker.js) |
|
|
238
238
|
| Git | `shj-lang-git` | comment, insert, deleted, string, ... | ❌ | [`222 B`](src/languages/git.js) |
|
|
239
239
|
| Go | `shj-lang-go` | | ✅ | [`329 B`](src/languages/go.js) |
|
|
240
|
-
| HTML | `shj-lang-html` |
|
|
240
|
+
| HTML | `shj-lang-html` | inline style and event handlers | ✅ | [`726 B`](src/languages/html.js) |
|
|
241
241
|
| HTTP | `shj-lang-http` | keywork, string, punctuation, variable, version | ✅ | [`986 B`](src/languages/http.js) |
|
|
242
242
|
| INI | `shj-lang-ini` | | ❌ | [`158 B`](src/languages/ini.js) |
|
|
243
243
|
| Java | `shj-lang-java` | | ✅ | [`457 B`](src/languages/java.js) |
|
|
244
|
-
| JavaScript | `shj-lang-js` | basic syntax, regex, jsdoc, json, template literals | ⛔ reported as TypeScript | [`
|
|
245
|
-
| JSDoc | `shj-lang-jsdoc` | | ❌ | [`
|
|
244
|
+
| JavaScript | `shj-lang-js` | basic syntax, regex, jsdoc, json, template literals | ⛔ reported as TypeScript | [`820 B`](src/languages/js.js) |
|
|
245
|
+
| JSDoc | `shj-lang-jsdoc` | | ❌ | [`251 B`](src/languages/jsdoc.js) |
|
|
246
246
|
| JSON | `shj-lang-json` | string, number, bool, ... | ❌ | [`172 B`](src/languages/json.js) |
|
|
247
247
|
| LeanPub Markdown | `shj-lang-leanpub-md` | | ❌ | [`1.2 kB`](src/languages/leanpub-md.js) |
|
|
248
248
|
| Log | `shj-lang-log` | number, string, comment, errors | ❌ | [`223 B`](src/languages/log.js) |
|
|
@@ -252,12 +252,12 @@ The main entry covers most apps; reach for `/tokenize` when you want the raw tok
|
|
|
252
252
|
| Perl | `shj-lang-pl` | | ✅ | [`329 B`](src/languages/pl.js) |
|
|
253
253
|
| Plain text | `shj-lang-plain` | | ❌ | [`71 B`](src/languages/plain.js) |
|
|
254
254
|
| Python | `shj-lang-py` | | ✅ | [`416 B`](src/languages/py.js) |
|
|
255
|
-
| Regex | `shj-lang-regex` | count, set, ... | ❌ | [`
|
|
255
|
+
| Regex | `shj-lang-regex` | count, set, ... | ❌ | [`176 B`](src/languages/regex.js) |
|
|
256
256
|
| Rust | `shj-lang-rs` | | ✅ | [`414 B`](src/languages/rs.js) |
|
|
257
257
|
| SQL | `shj-lang-sql` | number, string, function, ... | ✅ | [`1.7 kB`](src/languages/sql.js) |
|
|
258
258
|
| TODO | `shj-lang-todo` | | ❌ | [`185 B`](src/languages/todo.js) |
|
|
259
259
|
| TOML | `shj-lang-toml` | comment, table, string, bool, variable | ❌ | [`236 B`](src/languages/toml.js) |
|
|
260
|
-
| TypeScript | `shj-lang-ts` | js syntax, ts keyword, types | ✅ | [`
|
|
260
|
+
| TypeScript | `shj-lang-ts` | js syntax, ts keyword, types | ✅ | [`911 B`](src/languages/ts.js) |
|
|
261
261
|
| URI | `shj-lang-uri` | | ✅ | [`176 B`](src/languages/uri.js) |
|
|
262
262
|
| XML | `shj-lang-xml` | | ✅ | [`511 B`](src/languages/xml.js) |
|
|
263
263
|
| YAML | `shj-lang-yaml` | comment, numbers, variable, string, bool | ✅ | [`208 B`](src/languages/yaml.js) |
|
package/dist/languages/css.d.ts
CHANGED
|
@@ -9,12 +9,12 @@ declare const _default: ({
|
|
|
9
9
|
type?: undefined;
|
|
10
10
|
sub?: undefined;
|
|
11
11
|
} | {
|
|
12
|
-
type: "
|
|
12
|
+
type: "var";
|
|
13
13
|
match: RegExp;
|
|
14
14
|
sub?: undefined;
|
|
15
15
|
expand?: undefined;
|
|
16
16
|
} | {
|
|
17
|
-
type: "
|
|
17
|
+
type: "kwd";
|
|
18
18
|
match: RegExp;
|
|
19
19
|
sub?: undefined;
|
|
20
20
|
expand?: undefined;
|
package/dist/languages/css.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=[{match:/\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"kwd",match
|
|
1
|
+
var t=[{match:/\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"var",match:/--[\w-]+|\b[\w-]+(?=\s*:)/g},{type:"kwd",match:/@[\w-]+\b|!important\b|\b(and|not|only|or)\b|\b(?=([a-z-]+))\2(?=[^{}]*{)/g},{type:"var",match:/(::?|\.)(?!\d)[\w-]+(?=[^{}]*{)/g},{type:"func",match:/#[\w-]+(?=[^{}]*{)/g},{type:"num",match:/#[\da-f]{3,8}/gi},{type:"num",match:/-?\d*\.?\d+([a-z]+|%)?/gi,sub:[{type:"var",match:/[a-z]+|%/gi}]},{match:/url\([^)]*\)/g,sub:[{type:"func",match:/url(?=\()/g},{type:"str",match:/[^()]+/g}]},{type:"func",match:/\b[a-zA-Z][\w-]*(?=\s*\()/g},{type:"num",match:/\b[a-z-]+\b/g}];export{t as default};
|
package/dist/languages/html.d.ts
CHANGED
package/dist/languages/html.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD",r=a+"\\-\\.0-9\xB7\u0300-\u036F\u203F-\u2040",t=`[${a}][${r}]*`,e=`(\\s+${t}\\s*(=\\s*([^"'>\\s][^>\\s]*|("|')(\\\\[^]|(?!\\4)[^])*\\4?)?)?)*\\s*`,s={match:RegExp(`<[/!?]?${t}${e}[/!?]?>`,"g"),sub:[{type:"var",match:RegExp(`^<[/!?]?${t}`,"g"),sub:[{type:"oper",match:/^<[\/!?]?/g}]},{type:"str",match:/=\s*([^"'>\s][^>\s]*|("|')(\\[^]|(?!\2)[^])*\2?)/g,sub:[{type:"oper",match:/^=/g}]},{type:"oper",match:/[\/!?]?>/g},{type:"class",match:RegExp(t,"g")}]},m=[{match:/<!--[^]*?-->/g,type:"cmnt",sub:"todo"},{type:"class",match:/<!\[CDATA\[[\s\S]*?\]\]>/gi},s,{type:"str",match:RegExp(`<\\?${t}([^?]|\\?[^?>])*\\?+>`,"g"),sub:[{type:"var",match:RegExp(`^<\\?${t}`,"g"),sub:[{type:"oper",match:/^<\?/g}]},{type:"oper",match:/\?+>$/g}]},{type:"var",match:/&(#x?)?[\da-z]{1,8};/gi}];var c=(u,g)=>({type:"str",match:RegExp(`(?<=\\s${u}\\s*)=\\s*('[^']*'|"[^"]*")`,"gi"),sub:[{type:"oper",match:/^=/g},{match:/(?<=['"])[^]+(?=['"]$)/g,sub:g}]}),p={...s,sub:[c("style","css"),c("on\\w+","js"),...s.sub]},F=[{type:"class",match:/<!DOCTYPE("[^"]*"|'[^']*'|[^"'>])*>/gi,sub:[{type:"str",match:/"[^"]*"|'[^']*'/g},{type:"oper",match:/^<!|>$/g},{type:"var",match:/DOCTYPE/gi}]},{match:RegExp(`<style${e}>[^]*?</style\\s*>`,"g"),sub:[{match:RegExp(`^<style${e}>`,"g"),sub:p.sub},{match:/[^]*(?=<\/style\s*>$)/g,sub:"css"},p]},{match:RegExp(`<script${e}>[^]*?<\/script\\s*>`,"g"),sub:[{match:RegExp(`^<script${e}>`,"g"),sub:p.sub},{match:/[^]*(?=<\/script\s*>$)/g,sub:"js"},p]},...m.map(u=>u===s?p:u)];export{F as default};
|
package/dist/languages/js.d.ts
CHANGED
package/dist/languages/js.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(t){let e=this.lastIndex,a,n=c=>{for(;++e<t.length-2;)if(t[e]=="{")n();else if(t[e]=="}")return};for(;e<t.length;++e)if(t[e-1]!="\\"&&t[e]=="$"&&t[e+1]=="{")return a=e++,n(e),this.lastIndex=e+1,{index:a,0:t.slice(a,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",match
|
|
1
|
+
var s=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(t){let e=this.lastIndex,a,n=c=>{for(;++e<t.length-2;)if(t[e]=="{")n();else if(t[e]=="}")return};for(;e<t.length;++e)if(t[e-1]!="\\"&&t[e]=="$"&&t[e+1]=="{")return a=e++,n(e),this.lastIndex=e+1,{index:a,0:t.slice(a,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",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},{match:/(?<=[^\w$)\]'"`\s]\s*|\b(case|do|else|in|instanceof|new|of|return|throw|typeof|void|yield|await)\s+|^\s*)\/((?!\/)[^\r\n\\]|\\.)+\/\w*/gm,type:"oper",sub:"regex"},{expand:"num"},{type:"num",match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:"bool",match:/\b(true|false)\b/g},{type:"var",match:/#[\w$]+/g},{type:"oper",match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g},{type:"func",match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}];export{s as default};
|
|
@@ -3,6 +3,9 @@ declare namespace _default {
|
|
|
3
3
|
let sub: ({
|
|
4
4
|
type: "err";
|
|
5
5
|
match: RegExp;
|
|
6
|
+
} | {
|
|
7
|
+
type: "class";
|
|
8
|
+
match: RegExp;
|
|
6
9
|
} | {
|
|
7
10
|
type: "insert";
|
|
8
11
|
match: RegExp;
|
|
@@ -13,7 +16,7 @@ declare namespace _default {
|
|
|
13
16
|
type: "kwd";
|
|
14
17
|
match: RegExp;
|
|
15
18
|
} | {
|
|
16
|
-
type: "
|
|
19
|
+
type: "type";
|
|
17
20
|
match: RegExp;
|
|
18
21
|
} | {
|
|
19
22
|
type: "var";
|
package/dist/languages/jsdoc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={type:"cmnt",sub:[{type:"err",match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:"class",match:/\bIDEA\b/g},{type:"insert",match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:"oper",match:/\bQUESTION\b/g}]};var a={type:"cmnt",sub:[{type:"kwd",match:/@\w+/g},{type:"
|
|
1
|
+
var t={type:"cmnt",sub:[{type:"err",match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:"class",match:/\bIDEA\b/g},{type:"insert",match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:"oper",match:/\bQUESTION\b/g}]};var a={type:"cmnt",sub:[{type:"kwd",match:/@\w+/g},{type:"type",match:/{[\w\s|<>,.@\[\]]+}/g},{type:"var",match:/\[[\w\s="']+\]/g},...t.sub]};export{a as default};
|
package/dist/languages/regex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={type:"oper",sub:[{match:/^(?!\/).*/gm,type:"cmnt",sub:"todo"},{type:"num",match:/\[((?!\])[^\\]|\\.)*\]/g},{type:"kwd",match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:"var",match
|
|
1
|
+
var t={type:"oper",sub:[{match:/^(?!\/).*/gm,type:"cmnt",sub:"todo"},{type:"num",match:/\[((?!\])[^\\]|\\.)*\]/g},{type:"kwd",match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:"var",match:/[*+?.]|\{\d+(,\d*)?\}/g}]};export{t as default};
|
package/dist/languages/ts.d.ts
CHANGED
package/dist/languages/ts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(t){let e=this.lastIndex,a,n=s=>{for(;++e<t.length-2;)if(t[e]=="{")n();else if(t[e]=="}")return};for(;e<t.length;++e)if(t[e-1]!="\\"&&t[e]=="$"&&t[e+1]=="{")return a=e++,n(e),this.lastIndex=e+1,{index:a,0:t.slice(a,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",match
|
|
1
|
+
var c=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(t){let e=this.lastIndex,a,n=s=>{for(;++e<t.length-2;)if(t[e]=="{")n();else if(t[e]=="}")return};for(;e<t.length;++e)if(t[e-1]!="\\"&&t[e]=="$"&&t[e+1]=="{")return a=e++,n(e),this.lastIndex=e+1,{index:a,0:t.slice(a,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",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},{match:/(?<=[^\w$)\]'"`\s]\s*|\b(case|do|else|in|instanceof|new|of|return|throw|typeof|void|yield|await)\s+|^\s*)\/((?!\/)[^\r\n\\]|\\.)+\/\w*/gm,type:"oper",sub:"regex"},{expand:"num"},{type:"num",match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:"bool",match:/\b(true|false)\b/g},{type:"var",match:/#[\w$]+/g},{type:"oper",match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g},{type:"func",match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}];var p=[{type:"type",match:/:\s*(any|void|number|boolean|string|object|never|enum)\b/g},{type:"kwd",match:/\b(type|namespace|typedef|interface|public|private|protected|implements|declare|abstract|readonly)\b/g},...c];export{p as default};
|
|
@@ -9,12 +9,12 @@ declare const _default: ({
|
|
|
9
9
|
type?: undefined;
|
|
10
10
|
sub?: undefined;
|
|
11
11
|
} | {
|
|
12
|
-
type: "
|
|
12
|
+
type: "var";
|
|
13
13
|
match: RegExp;
|
|
14
14
|
sub?: undefined;
|
|
15
15
|
expand?: undefined;
|
|
16
16
|
} | {
|
|
17
|
-
type: "
|
|
17
|
+
type: "kwd";
|
|
18
18
|
match: RegExp;
|
|
19
19
|
sub?: undefined;
|
|
20
20
|
expand?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty;var
|
|
1
|
+
var e=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var b=(a,t)=>{for(var c in t)e(a,c,{get:t[c],enumerable:!0})},n=(a,t,c,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of h(t))!y.call(a,m)&&m!==c&&e(a,m,{get:()=>t[m],enumerable:!(p=g(t,m))||p.enumerable});return a};var u=a=>n(e({},"__esModule",{value:!0}),a);var d={};b(d,{default:()=>r});module.exports=u(d);var r=[{match:/\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"var",match:/--[\w-]+|\b[\w-]+(?=\s*:)/g},{type:"kwd",match:/@[\w-]+\b|!important\b|\b(and|not|only|or)\b|\b(?=([a-z-]+))\2(?=[^{}]*{)/g},{type:"var",match:/(::?|\.)(?!\d)[\w-]+(?=[^{}]*{)/g},{type:"func",match:/#[\w-]+(?=[^{}]*{)/g},{type:"num",match:/#[\da-f]{3,8}/gi},{type:"num",match:/-?\d*\.?\d+([a-z]+|%)?/gi,sub:[{type:"var",match:/[a-z]+|%/gi}]},{match:/url\([^)]*\)/g,sub:[{type:"func",match:/url(?=\()/g},{type:"str",match:/[^()]+/g}]},{type:"func",match:/\b[a-zA-Z][\w-]*(?=\s*\()/g},{type:"num",match:/\b[a-z-]+\b/g}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var o=(t,e)=>{for(var c in e)g(t,c,{get:e[c],enumerable:!0})},x=(t,e,c,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of l(e))!$.call(t,u)&&u!==c&&g(t,u,{get:()=>e[u],enumerable:!(r=b(e,u))||r.enumerable});return t};var E=t=>x(g({},"__esModule",{value:!0}),t);var R={};o(R,{default:()=>D});module.exports=E(R);var h=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD",i=h+"\\-\\.0-9\xB7\u0300-\u036F\u203F-\u2040",s=`[${h}][${i}]*`,p=`(\\s+${s}\\s*(=\\s*([^"'>\\s][^>\\s]*|("|')(\\\\[^]|(?!\\4)[^])*\\4?)?)?)*\\s*`,a={match:RegExp(`<[/!?]?${s}${p}[/!?]?>`,"g"),sub:[{type:"var",match:RegExp(`^<[/!?]?${s}`,"g"),sub:[{type:"oper",match:/^<[\/!?]?/g}]},{type:"str",match:/=\s*([^"'>\s][^>\s]*|("|')(\\[^]|(?!\2)[^])*\2?)/g,sub:[{type:"oper",match:/^=/g}]},{type:"oper",match:/[\/!?]?>/g},{type:"class",match:RegExp(s,"g")}]},y=[{match:/<!--[^]*?-->/g,type:"cmnt",sub:"todo"},{type:"class",match:/<!\[CDATA\[[\s\S]*?\]\]>/gi},a,{type:"str",match:RegExp(`<\\?${s}([^?]|\\?[^?>])*\\?+>`,"g"),sub:[{type:"var",match:RegExp(`^<\\?${s}`,"g"),sub:[{type:"oper",match:/^<\?/g}]},{type:"oper",match:/\?+>$/g}]},{type:"var",match:/&(#x?)?[\da-z]{1,8};/gi}];var F=(t,e)=>({type:"str",match:RegExp(`(?<=\\s${t}\\s*)=\\s*('[^']*'|"[^"]*")`,"gi"),sub:[{type:"oper",match:/^=/g},{match:/(?<=['"])[^]+(?=['"]$)/g,sub:e}]}),m={...a,sub:[F("style","css"),F("on\\w+","js"),...a.sub]},D=[{type:"class",match:/<!DOCTYPE("[^"]*"|'[^']*'|[^"'>])*>/gi,sub:[{type:"str",match:/"[^"]*"|'[^']*'/g},{type:"oper",match:/^<!|>$/g},{type:"var",match:/DOCTYPE/gi}]},{match:RegExp(`<style${p}>[^]*?</style\\s*>`,"g"),sub:[{match:RegExp(`^<style${p}>`,"g"),sub:m.sub},{match:/[^]*(?=<\/style\s*>$)/g,sub:"css"},m]},{match:RegExp(`<script${p}>[^]*?</script\\s*>`,"g"),sub:[{match:RegExp(`^<script${p}>`,"g"),sub:m.sub},{match:/[^]*(?=<\/script\s*>$)/g,sub:"js"},m]},...y.map(t=>t===a?m:t)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},h=(t,e,a,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o(e))!r.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(c=i(e,n))||c.enumerable});return t};var u=t=>h(s({},"__esModule",{value:!0}),t);var m={};l(m,{default:()=>p});module.exports=u(m);var p=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(t){let e=this.lastIndex,a,c=n=>{for(;++e<t.length-2;)if(t[e]=="{")c();else if(t[e]=="}")return};for(;e<t.length;++e)if(t[e-1]!="\\"&&t[e]=="$"&&t[e+1]=="{")return a=e++,c(e),this.lastIndex=e+1,{index:a,0:t.slice(a,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",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},{match:/(?<=[^\w$)\]'"`\s]\s*|\b(case|do|else|in|instanceof|new|of|return|throw|typeof|void|yield|await)\s+|^\s*)\/((?!\/)[^\r\n\\]|\\.)+\/\w*/gm,type:"oper",sub:"regex"},{expand:"num"},{type:"num",match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:"bool",match:/\b(true|false)\b/g},{type:"var",match:/#[\w$]+/g},{type:"oper",match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g},{type:"func",match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}];
|
|
@@ -3,6 +3,9 @@ declare namespace _default {
|
|
|
3
3
|
let sub: ({
|
|
4
4
|
type: "err";
|
|
5
5
|
match: RegExp;
|
|
6
|
+
} | {
|
|
7
|
+
type: "class";
|
|
8
|
+
match: RegExp;
|
|
6
9
|
} | {
|
|
7
10
|
type: "insert";
|
|
8
11
|
match: RegExp;
|
|
@@ -13,7 +16,7 @@ declare namespace _default {
|
|
|
13
16
|
type: "kwd";
|
|
14
17
|
match: RegExp;
|
|
15
18
|
} | {
|
|
16
|
-
type: "
|
|
19
|
+
type: "type";
|
|
17
20
|
match: RegExp;
|
|
18
21
|
} | {
|
|
19
22
|
type: "var";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var b=Object.defineProperty;var
|
|
1
|
+
var b=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var a in t)b(e,a,{get:t[a],enumerable:!0})},h=(e,t,a,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of r(t))!s.call(e,p)&&p!==a&&b(e,p,{get:()=>t[p],enumerable:!(m=y(t,p))||m.enumerable});return e};var o=e=>h(b({},"__esModule",{value:!0}),e);var I={};g(I,{default:()=>E});module.exports=o(I);var c={type:"cmnt",sub:[{type:"err",match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:"class",match:/\bIDEA\b/g},{type:"insert",match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:"oper",match:/\bQUESTION\b/g}]};var E={type:"cmnt",sub:[{type:"kwd",match:/@\w+/g},{type:"type",match:/{[\w\s|<>,.@\[\]]+}/g},{type:"var",match:/\[[\w\s="']+\]/g},...c.sub]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var p in t)a(e,p,{get:t[p],enumerable:!0})},o=(e,t,p,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of y(t))!g.call(e,m)&&m!==p&&a(e,m,{get:()=>t[m],enumerable:!(c=d(t,m))||c.enumerable});return e};var r=e=>o(a({},"__esModule",{value:!0}),e);var n={};h(n,{default:()=>u});module.exports=r(n);var u={type:"oper",sub:[{match:/^(?!\/).*/gm,type:"cmnt",sub:"todo"},{type:"num",match:/\[((?!\])[^\\]|\\.)*\]/g},{type:"kwd",match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:"var",match
|
|
1
|
+
var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var p in t)a(e,p,{get:t[p],enumerable:!0})},o=(e,t,p,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of y(t))!g.call(e,m)&&m!==p&&a(e,m,{get:()=>t[m],enumerable:!(c=d(t,m))||c.enumerable});return e};var r=e=>o(a({},"__esModule",{value:!0}),e);var n={};h(n,{default:()=>u});module.exports=r(n);var u={type:"oper",sub:[{match:/^(?!\/).*/gm,type:"cmnt",sub:"todo"},{type:"num",match:/\[((?!\])[^\\]|\\.)*\]/g},{type:"kwd",match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:"var",match:/[*+?.]|\{\d+(,\d*)?\}/g}]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},m=(t,e,a,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o(e))!p.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(c=i(e,n))||c.enumerable});return t};var u=t=>m(s({},"__esModule",{value:!0}),t);var h={};l(h,{default:()=>d});module.exports=u(h);var r=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(t){let e=this.lastIndex,a,c=n=>{for(;++e<t.length-2;)if(t[e]=="{")c();else if(t[e]=="}")return};for(;e<t.length;++e)if(t[e-1]!="\\"&&t[e]=="$"&&t[e+1]=="{")return a=e++,c(e),this.lastIndex=e+1,{index:a,0:t.slice(a,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",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},{match:/(?<=[^\w$)\]'"`\s]\s*|\b(case|do|else|in|instanceof|new|of|return|throw|typeof|void|yield|await)\s+|^\s*)\/((?!\/)[^\r\n\\]|\\.)+\/\w*/gm,type:"oper",sub:"regex"},{expand:"num"},{type:"num",match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:"bool",match:/\b(true|false)\b/g},{type:"var",match:/#[\w$]+/g},{type:"oper",match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g},{type:"func",match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}];var d=[{type:"type",match:/:\s*(any|void|number|boolean|string|object|never|enum)\b/g},{type:"kwd",match:/\b(type|namespace|typedef|interface|public|private|protected|implements|declare|abstract|readonly)\b/g},...r];
|
package/package.json
CHANGED
package/src/languages/css.js
CHANGED
|
@@ -11,15 +11,23 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
|
11
11
|
{
|
|
12
12
|
expand: 'str'
|
|
13
13
|
},
|
|
14
|
+
{
|
|
15
|
+
type: 'var',
|
|
16
|
+
// a name before a colon is a property, and a custom property is one
|
|
17
|
+
// anywhere, so both win over the selector guessed below, which a
|
|
18
|
+
// nested block would otherwise take them for
|
|
19
|
+
match: /--[\w-]+|\b[\w-]+(?=\s*:)/g
|
|
20
|
+
},
|
|
14
21
|
{
|
|
15
22
|
type: 'kwd',
|
|
16
23
|
// (?=([a-z-]+))\2 fakes an atomic group (JS has none), avoiding
|
|
17
24
|
// catastrophic backtracking a plain [a-z-]+ would have here
|
|
18
|
-
match:
|
|
25
|
+
match: /@[\w-]+\b|!important\b|\b(and|not|only|or)\b|\b(?=([a-z-]+))\2(?=[^{}]*{)/g
|
|
19
26
|
},
|
|
20
27
|
{
|
|
21
28
|
type: 'var',
|
|
22
|
-
|
|
29
|
+
// (?!\d) keeps a number that opens a value (.3s) out of the class selectors
|
|
30
|
+
match: /(::?|\.)(?!\d)[\w-]+(?=[^{}]*{)/g
|
|
23
31
|
},
|
|
24
32
|
{
|
|
25
33
|
type: 'func',
|
|
@@ -27,15 +35,16 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
|
27
35
|
},
|
|
28
36
|
{
|
|
29
37
|
type: 'num',
|
|
30
|
-
match: /#[\da-f]{3,8}/
|
|
38
|
+
match: /#[\da-f]{3,8}/gi
|
|
31
39
|
},
|
|
32
40
|
{
|
|
33
41
|
type: 'num',
|
|
34
|
-
|
|
42
|
+
// any unit rather than a list of them, so the next one css gains needs no edit
|
|
43
|
+
match: /-?\d*\.?\d+([a-z]+|%)?/gi,
|
|
35
44
|
sub: [
|
|
36
45
|
{
|
|
37
46
|
type: 'var',
|
|
38
|
-
match: /[a-z]+|%/
|
|
47
|
+
match: /[a-z]+|%/gi
|
|
39
48
|
}
|
|
40
49
|
]
|
|
41
50
|
},
|
|
@@ -54,7 +63,7 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
|
54
63
|
},
|
|
55
64
|
{
|
|
56
65
|
type: 'func',
|
|
57
|
-
match: /\b[a-zA-Z]\w*(?=\s*\()/g
|
|
66
|
+
match: /\b[a-zA-Z][\w-]*(?=\s*\()/g
|
|
58
67
|
},
|
|
59
68
|
{
|
|
60
69
|
type: 'num',
|
package/src/languages/html.js
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name HTML
|
|
3
|
+
* @support inline style and event handlers
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
6
|
import xml, { properties, xmlElement } from './xml.js';
|
|
6
7
|
|
|
8
|
+
let
|
|
9
|
+
/**
|
|
10
|
+
* An attribute, given by a regex source, whose value is written in another language
|
|
11
|
+
* @type {(name: string, sub: string) => import('../index.js').ShjRule}
|
|
12
|
+
*/
|
|
13
|
+
attribute = (name, sub) => ({
|
|
14
|
+
type: 'str',
|
|
15
|
+
// the name is left to the attribute rule of xml, only its value differs
|
|
16
|
+
match: RegExp(`(?<=\\s${name}\\s*)=\\s*('[^']*'|"[^"]*")`, 'gi'),
|
|
17
|
+
sub: [
|
|
18
|
+
{
|
|
19
|
+
type: 'oper',
|
|
20
|
+
match: /^=/g
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
// the quotes are left to the rule's own type
|
|
24
|
+
match: /(?<=['"])[^]+(?=['"]$)/g,
|
|
25
|
+
sub
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}),
|
|
29
|
+
htmlElement = {
|
|
30
|
+
...xmlElement,
|
|
31
|
+
sub: [
|
|
32
|
+
attribute('style', 'css'),
|
|
33
|
+
attribute('on\\w+', 'js'),
|
|
34
|
+
...xmlElement.sub
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
|
|
7
38
|
export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
8
39
|
{
|
|
9
40
|
type: 'class',
|
|
@@ -28,13 +59,13 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
|
28
59
|
sub: [
|
|
29
60
|
{
|
|
30
61
|
match: RegExp(`^<style${properties}>`, 'g'),
|
|
31
|
-
sub:
|
|
62
|
+
sub: htmlElement.sub
|
|
32
63
|
},
|
|
33
64
|
{
|
|
34
65
|
match: /[^]*(?=<\/style\s*>$)/g,
|
|
35
66
|
sub: 'css'
|
|
36
67
|
},
|
|
37
|
-
|
|
68
|
+
htmlElement
|
|
38
69
|
]
|
|
39
70
|
},
|
|
40
71
|
{
|
|
@@ -42,14 +73,15 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
|
42
73
|
sub: [
|
|
43
74
|
{
|
|
44
75
|
match: RegExp(`^<script${properties}>`, 'g'),
|
|
45
|
-
sub:
|
|
76
|
+
sub: htmlElement.sub
|
|
46
77
|
},
|
|
47
78
|
{
|
|
48
79
|
match: /[^]*(?=<\/script\s*>$)/g,
|
|
49
80
|
sub: 'js'
|
|
50
81
|
},
|
|
51
|
-
|
|
82
|
+
htmlElement
|
|
52
83
|
]
|
|
53
84
|
},
|
|
54
|
-
|
|
85
|
+
// the element rule is the only one html extends, the rest of xml is reused as is
|
|
86
|
+
...xml.map(rule => rule === xmlElement ? htmlElement : rule)
|
|
55
87
|
]);
|
package/src/languages/js.js
CHANGED
|
@@ -59,10 +59,14 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
type: 'kwd',
|
|
62
|
-
|
|
62
|
+
// (?<![^.]\.) is "not after a lone dot", so a property named after a
|
|
63
|
+
// keyword (obj.default) is not one, while a spread (...this) still is
|
|
64
|
+
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
|
|
63
65
|
},
|
|
64
66
|
{
|
|
65
|
-
|
|
67
|
+
// a division can only follow a value, so a slash anywhere else opens a
|
|
68
|
+
// regex, the keywords being spelled out as they too end in a word char
|
|
69
|
+
match: /(?<=[^\w$)\]'"`\s]\s*|\b(case|do|else|in|instanceof|new|of|return|throw|typeof|void|yield|await)\s+|^\s*)\/((?!\/)[^\r\n\\]|\\.)+\/\w*/gm,
|
|
66
70
|
type: 'oper',
|
|
67
71
|
sub: 'regex'
|
|
68
72
|
},
|
|
@@ -77,6 +81,10 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
|
|
|
77
81
|
type: 'bool',
|
|
78
82
|
match: /\b(true|false)\b/g
|
|
79
83
|
},
|
|
84
|
+
{
|
|
85
|
+
type: 'var',
|
|
86
|
+
match: /#[\w$]+/g
|
|
87
|
+
},
|
|
80
88
|
{
|
|
81
89
|
type: 'oper',
|
|
82
90
|
match: /[/*+:?&|%^~=!,<>.^-]+/g
|
package/src/languages/jsdoc.js
CHANGED