@speed-highlight/core 2.0.0 → 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.
Files changed (40) hide show
  1. package/README.md +7 -7
  2. package/dist/languages/css.d.ts +2 -2
  3. package/dist/languages/css.js +1 -1
  4. package/dist/languages/html.d.ts +1 -1
  5. package/dist/languages/html.js +1 -1
  6. package/dist/languages/js.d.ts +5 -0
  7. package/dist/languages/js.js +1 -1
  8. package/dist/languages/jsdoc.d.ts +4 -1
  9. package/dist/languages/jsdoc.js +1 -1
  10. package/dist/languages/leanpub-md.d.ts +4 -0
  11. package/dist/languages/leanpub-md.d.ts.map +1 -1
  12. package/dist/languages/leanpub-md.js +2 -2
  13. package/dist/languages/md.d.ts +4 -0
  14. package/dist/languages/md.js +2 -2
  15. package/dist/languages/regex.js +1 -1
  16. package/dist/languages/ts.d.ts +5 -0
  17. package/dist/languages/ts.js +1 -1
  18. package/dist/node/languages/css.d.ts +2 -2
  19. package/dist/node/languages/css.js +1 -1
  20. package/dist/node/languages/html.d.ts +1 -1
  21. package/dist/node/languages/html.js +1 -1
  22. package/dist/node/languages/js.d.ts +5 -0
  23. package/dist/node/languages/js.js +1 -1
  24. package/dist/node/languages/jsdoc.d.ts +4 -1
  25. package/dist/node/languages/jsdoc.js +1 -1
  26. package/dist/node/languages/leanpub-md.d.ts +4 -0
  27. package/dist/node/languages/leanpub-md.d.ts.map +1 -1
  28. package/dist/node/languages/leanpub-md.js +2 -2
  29. package/dist/node/languages/md.d.ts +4 -0
  30. package/dist/node/languages/md.js +2 -2
  31. package/dist/node/languages/regex.js +1 -1
  32. package/dist/node/languages/ts.d.ts +5 -0
  33. package/dist/node/languages/ts.js +1 -1
  34. package/package.json +1 -1
  35. package/src/languages/css.js +15 -6
  36. package/src/languages/html.js +37 -5
  37. package/src/languages/js.js +10 -2
  38. package/src/languages/jsdoc.js +1 -1
  39. package/src/languages/md.js +15 -8
  40. 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.2 kB total) |
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, ... | ✅ | [`343 B`](src/languages/css.js) |
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` | | ✅ | [`627 B`](src/languages/html.js) |
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 | [`758 B`](src/languages/js.js) |
245
- | JSDoc | `shj-lang-jsdoc` | | ❌ | [`247 B`](src/languages/jsdoc.js) |
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, ... | ❌ | [`172 B`](src/languages/regex.js) |
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 | ✅ | [`849 B`](src/languages/ts.js) |
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) |
@@ -9,12 +9,12 @@ declare const _default: ({
9
9
  type?: undefined;
10
10
  sub?: undefined;
11
11
  } | {
12
- type: "kwd";
12
+ type: "var";
13
13
  match: RegExp;
14
14
  sub?: undefined;
15
15
  expand?: undefined;
16
16
  } | {
17
- type: "var";
17
+ type: "kwd";
18
18
  match: RegExp;
19
19
  sub?: undefined;
20
20
  expand?: undefined;
@@ -1 +1 @@
1
- var t=[{match:/\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"kwd",match:/@\w+\b|\b(and|not|only|or)\b|\b(?=([a-z-]+))\2(?=[^{}]*{)/g},{type:"var",match:/\b[\w-]+(?=\s*:)|(::?|\.)[\w-]+(?=[^{}]*{)/g},{type:"func",match:/#[\w-]+(?=[^{}]*{)/g},{type:"num",match:/#[\da-f]{3,8}/g},{type:"num",match:/\d+(\.\d+)?(cm|mm|in|px|pt|pc|em|ex|ch|rem|vm|vh|vmin|vmax|%)?/g,sub:[{type:"var",match:/[a-z]+|%/g}]},{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};
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};
@@ -44,8 +44,8 @@ declare const _default: ({
44
44
  } | {
45
45
  match: RegExp;
46
46
  sub: ({
47
+ sub: import("../tokenize.js").ShjRule[];
47
48
  match: RegExp;
48
- sub: import("../index.js").ShjGrammar;
49
49
  } | {
50
50
  match: RegExp;
51
51
  sub: string;
@@ -1 +1 @@
1
- var p=":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",a=p+"\\-\\.0-9\xB7\u0300-\u036F\u203F-\u2040",t=`[${p}][${a}]*`,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")}]},u=[{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 g=[{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:s.sub},{match:/[^]*(?=<\/style\s*>$)/g,sub:"css"},s]},{match:RegExp(`<script${e}>[^]*?<\/script\\s*>`,"g"),sub:[{match:RegExp(`^<script${e}>`,"g"),sub:s.sub},{match:/[^]*(?=<\/script\s*>$)/g,sub:"js"},s]},...u];export{g as default};
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};
@@ -60,6 +60,11 @@ declare const _default: ({
60
60
  match: RegExp;
61
61
  sub?: undefined;
62
62
  expand?: undefined;
63
+ } | {
64
+ type: "var";
65
+ match: RegExp;
66
+ sub?: undefined;
67
+ expand?: undefined;
63
68
  } | {
64
69
  type: "oper";
65
70
  match: RegExp;
@@ -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:/=>|\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:/\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,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:"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};
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: "class";
19
+ type: "type";
17
20
  match: RegExp;
18
21
  } | {
19
22
  type: "var";
@@ -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:"class",match:/{[\w\s|<>,.@\[\]]+}/g},{type:"var",match:/\[[\w\s="']+\]/g},...t.sub]};export{a as default};
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};
@@ -2,6 +2,10 @@ declare const _default: ({
2
2
  type: "cmnt";
3
3
  match: RegExp;
4
4
  sub?: undefined;
5
+ } | {
6
+ type: "section";
7
+ match: RegExp;
8
+ sub?: undefined;
5
9
  } | {
6
10
  type: "class";
7
11
  match: RegExp;
@@ -1 +1 @@
1
- {"version":3,"file":"leanpub-md.d.ts","sourceRoot":"","sources":["../../src/languages/leanpub-md.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAI+B,cAAc"}
1
+ {"version":3,"file":"leanpub-md.d.ts","sourceRoot":"","sources":["../../src/languages/leanpub-md.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAI+B,cAAc"}
@@ -1,2 +1,2 @@
1
- var r={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function t(a){return Object.entries(r).map(([n,e])=>[n,e.reduce((m,[l,g])=>m+[...a.matchAll(l)].length*g,0)]).filter(([n,e])=>e>20).sort((n,e)=>e[1]-n[1])[0]?.[0]||"plain"}var s=[{type:"cmnt",match:/^>.*|(=|-)\1+/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,})(.*)\n[^]*?^\1[ \t]*$/gm,sub:a=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:a.split(`
2
- `)[0].slice(3)||t(a)}]})},{type:"str",match:/`[^`]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S([^\n]*?\S)?_\b|\*\S([^\n]*?\S)?\*/g},{type:"kwd",match:/^\s*(\*|\d+\.)\s/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];var d=[{type:"insert",match:/(leanpub-start-insert)((?!leanpub-end-insert)[^])*(leanpub-end-insert)?/g,sub:[{type:"insert",match:/leanpub-(start|end)-insert/g},{match:/(?!leanpub-start-insert)((?!leanpub-end-insert)[^])*/g,sub:t}]},{type:"deleted",match:/(leanpub-start-delete)((?!leanpub-end-delete)[^])*(leanpub-end-delete)?/g,sub:[{type:"deleted",match:/leanpub-(start|end)-delete/g},{match:/(?!leanpub-start-delete)((?!leanpub-end-delete)[^])*/g,sub:t}]},...s];export{d as default};
1
+ var r={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function t(a){return Object.entries(r).map(([n,e])=>[n,e.reduce((m,[l,g])=>m+[...a.matchAll(l)].length*g,0)]).filter(([n,e])=>e>20).sort((n,e)=>e[1]-n[1])[0]?.[0]||"plain"}var s=[{type:"cmnt",match:/^>.*|^[ \t]*(=+|-{2,})[ \t]*$/gm},{type:"section",match:/^#{1,6}[ \t]/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,}).*\n[^]*?^\1[ \t]*$/gm,sub:a=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:a.split(`
2
+ `)[0].slice(3)||t(a)}]})},{type:"str",match:/`[^`\n]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S(.*?\S)?_\b|\*\S(.*?\S)?\*|^[ \t]*([*+-]|\d+[.)])([ \t]|$)/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];var d=[{type:"insert",match:/(leanpub-start-insert)((?!leanpub-end-insert)[^])*(leanpub-end-insert)?/g,sub:[{type:"insert",match:/leanpub-(start|end)-insert/g},{match:/(?!leanpub-start-insert)((?!leanpub-end-insert)[^])*/g,sub:t}]},{type:"deleted",match:/(leanpub-start-delete)((?!leanpub-end-delete)[^])*(leanpub-end-delete)?/g,sub:[{type:"deleted",match:/leanpub-(start|end)-delete/g},{match:/(?!leanpub-start-delete)((?!leanpub-end-delete)[^])*/g,sub:t}]},...s];export{d as default};
@@ -2,6 +2,10 @@ declare const _default: ({
2
2
  type: "cmnt";
3
3
  match: RegExp;
4
4
  sub?: undefined;
5
+ } | {
6
+ type: "section";
7
+ match: RegExp;
8
+ sub?: undefined;
5
9
  } | {
6
10
  type: "class";
7
11
  match: RegExp;
@@ -1,2 +1,2 @@
1
- var i={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function m(e){return Object.entries(i).map(([a,t])=>[a,t.reduce((n,[s,g])=>n+[...e.matchAll(s)].length*g,0)]).filter(([a,t])=>t>20).sort((a,t)=>t[1]-a[1])[0]?.[0]||"plain"}var r=[{type:"cmnt",match:/^>.*|(=|-)\1+/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,})(.*)\n[^]*?^\1[ \t]*$/gm,sub:e=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:e.split(`
2
- `)[0].slice(3)||m(e)}]})},{type:"str",match:/`[^`]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S([^\n]*?\S)?_\b|\*\S([^\n]*?\S)?\*/g},{type:"kwd",match:/^\s*(\*|\d+\.)\s/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];export{r as default};
1
+ var i={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function m(e){return Object.entries(i).map(([a,t])=>[a,t.reduce((n,[s,g])=>n+[...e.matchAll(s)].length*g,0)]).filter(([a,t])=>t>20).sort((a,t)=>t[1]-a[1])[0]?.[0]||"plain"}var r=[{type:"cmnt",match:/^>.*|^[ \t]*(=+|-{2,})[ \t]*$/gm},{type:"section",match:/^#{1,6}[ \t]/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,}).*\n[^]*?^\1[ \t]*$/gm,sub:e=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:e.split(`
2
+ `)[0].slice(3)||m(e)}]})},{type:"str",match:/`[^`\n]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S(.*?\S)?_\b|\*\S(.*?\S)?\*|^[ \t]*([*+-]|\d+[.)])([ \t]|$)/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];export{r as default};
@@ -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:/\*|\+|\{\d+,\d+\}/g}]};export{t as default};
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};
@@ -60,6 +60,11 @@ declare const _default: ({
60
60
  match: RegExp;
61
61
  sub?: undefined;
62
62
  expand?: undefined;
63
+ } | {
64
+ type: "var";
65
+ match: RegExp;
66
+ sub?: undefined;
67
+ expand?: undefined;
63
68
  } | {
64
69
  type: "oper";
65
70
  match: RegExp;
@@ -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:/=>|\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:/\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,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:"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 o=[{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{o as default};
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: "kwd";
12
+ type: "var";
13
13
  match: RegExp;
14
14
  sub?: undefined;
15
15
  expand?: undefined;
16
16
  } | {
17
- type: "var";
17
+ type: "kwd";
18
18
  match: RegExp;
19
19
  sub?: undefined;
20
20
  expand?: undefined;
@@ -1 +1 @@
1
- var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var u=(m,t)=>{for(var c in t)e(m,c,{get:t[c],enumerable:!0})},y=(m,t,c,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of n(t))!g.call(m,a)&&a!==c&&e(m,a,{get:()=>t[a],enumerable:!(p=h(t,a))||p.enumerable});return m};var b=m=>y(e({},"__esModule",{value:!0}),m);var d={};u(d,{default:()=>r});module.exports=b(d);var r=[{match:/\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"kwd",match:/@\w+\b|\b(and|not|only|or)\b|\b(?=([a-z-]+))\2(?=[^{}]*{)/g},{type:"var",match:/\b[\w-]+(?=\s*:)|(::?|\.)[\w-]+(?=[^{}]*{)/g},{type:"func",match:/#[\w-]+(?=[^{}]*{)/g},{type:"num",match:/#[\da-f]{3,8}/g},{type:"num",match:/\d+(\.\d+)?(cm|mm|in|px|pt|pc|em|ex|ch|rem|vm|vh|vmin|vmax|%)?/g,sub:[{type:"var",match:/[a-z]+|%/g}]},{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
+ 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}];
@@ -44,8 +44,8 @@ declare const _default: ({
44
44
  } | {
45
45
  match: RegExp;
46
46
  sub: ({
47
+ sub: import("../tokenize.js").ShjRule[];
47
48
  match: RegExp;
48
- sub: import("../index.js").ShjGrammar;
49
49
  } | {
50
50
  match: RegExp;
51
51
  sub: string;
@@ -1 +1 @@
1
- var c=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var m in t)c(e,m,{get:t[m],enumerable:!0})},$=(e,t,m,g)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of y(t))!l.call(e,a)&&a!==m&&c(e,a,{get:()=>t[a],enumerable:!(g=F(t,a))||g.enumerable});return e};var b=e=>$(c({},"__esModule",{value:!0}),e);var i={};x(i,{default:()=>E});module.exports=b(i);var r=":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",o=r+"\\-\\.0-9\xB7\u0300-\u036F\u203F-\u2040",s=`[${r}][${o}]*`,p=`(\\s+${s}\\s*(=\\s*([^"'>\\s][^>\\s]*|("|')(\\\\[^]|(?!\\4)[^])*\\4?)?)?)*\\s*`,u={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")}]},h=[{match:/<!--[^]*?-->/g,type:"cmnt",sub:"todo"},{type:"class",match:/<!\[CDATA\[[\s\S]*?\]\]>/gi},u,{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 E=[{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:u.sub},{match:/[^]*(?=<\/style\s*>$)/g,sub:"css"},u]},{match:RegExp(`<script${p}>[^]*?</script\\s*>`,"g"),sub:[{match:RegExp(`^<script${p}>`,"g"),sub:u.sub},{match:/[^]*(?=<\/script\s*>$)/g,sub:"js"},u]},...h];
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)];
@@ -60,6 +60,11 @@ declare const _default: ({
60
60
  match: RegExp;
61
61
  sub?: undefined;
62
62
  expand?: undefined;
63
+ } | {
64
+ type: "var";
65
+ match: RegExp;
66
+ sub?: undefined;
67
+ expand?: undefined;
63
68
  } | {
64
69
  type: "oper";
65
70
  match: RegExp;
@@ -1 +1 @@
1
- var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var o=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},r=(t,e,a,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!u.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(c=i(e,n))||c.enumerable});return t};var h=t=>r(s({},"__esModule",{value:!0}),t);var m={};o(m,{default:()=>p});module.exports=h(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:/\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,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:"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}];
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: "class";
19
+ type: "type";
17
20
  match: RegExp;
18
21
  } | {
19
22
  type: "var";
@@ -1 +1 @@
1
- var b=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var a in t)b(e,a,{get:t[a],enumerable:!0})},h=(e,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of r(t))!y.call(e,p)&&p!==a&&b(e,p,{get:()=>t[p],enumerable:!(c=s(t,p))||c.enumerable});return e};var o=e=>h(b({},"__esModule",{value:!0}),e);var I={};g(I,{default:()=>E});module.exports=o(I);var m={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:"class",match:/{[\w\s|<>,.@\[\]]+}/g},{type:"var",match:/\[[\w\s="']+\]/g},...m.sub]};
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]};
@@ -2,6 +2,10 @@ declare const _default: ({
2
2
  type: "cmnt";
3
3
  match: RegExp;
4
4
  sub?: undefined;
5
+ } | {
6
+ type: "section";
7
+ match: RegExp;
8
+ sub?: undefined;
5
9
  } | {
6
10
  type: "class";
7
11
  match: RegExp;
@@ -1 +1 @@
1
- {"version":3,"file":"leanpub-md.d.ts","sourceRoot":"","sources":["../../../src/languages/leanpub-md.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAI+B,cAAc"}
1
+ {"version":3,"file":"leanpub-md.d.ts","sourceRoot":"","sources":["../../../src/languages/leanpub-md.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAI+B,cAAc"}
@@ -1,2 +1,2 @@
1
- var l=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var a in t)l(e,a,{get:t[a],enumerable:!0})},d=(e,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of c(t))!b.call(e,s)&&s!==a&&l(e,s,{get:()=>t[s],enumerable:!(n=p(t,s))||n.enumerable});return e};var o=e=>d(l({},"__esModule",{value:!0}),e);var y={};u(y,{default:()=>h});module.exports=o(y);var f={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function m(e){var t;return((t=Object.entries(f).map(([a,n])=>[a,n.reduce((s,[r,i])=>s+[...e.matchAll(r)].length*i,0)]).filter(([a,n])=>n>20).sort((a,n)=>n[1]-a[1])[0])==null?void 0:t[0])||"plain"}var g=[{type:"cmnt",match:/^>.*|(=|-)\1+/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,})(.*)\n[^]*?^\1[ \t]*$/gm,sub:e=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:e.split(`
2
- `)[0].slice(3)||m(e)}]})},{type:"str",match:/`[^`]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S([^\n]*?\S)?_\b|\*\S([^\n]*?\S)?\*/g},{type:"kwd",match:/^\s*(\*|\d+\.)\s/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];var h=[{type:"insert",match:/(leanpub-start-insert)((?!leanpub-end-insert)[^])*(leanpub-end-insert)?/g,sub:[{type:"insert",match:/leanpub-(start|end)-insert/g},{match:/(?!leanpub-start-insert)((?!leanpub-end-insert)[^])*/g,sub:m}]},{type:"deleted",match:/(leanpub-start-delete)((?!leanpub-end-delete)[^])*(leanpub-end-delete)?/g,sub:[{type:"deleted",match:/leanpub-(start|end)-delete/g},{match:/(?!leanpub-start-delete)((?!leanpub-end-delete)[^])*/g,sub:m}]},...g];
1
+ var l=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var a in t)l(e,a,{get:t[a],enumerable:!0})},d=(e,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of c(t))!b.call(e,s)&&s!==a&&l(e,s,{get:()=>t[s],enumerable:!(n=p(t,s))||n.enumerable});return e};var o=e=>d(l({},"__esModule",{value:!0}),e);var y={};u(y,{default:()=>h});module.exports=o(y);var f={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function m(e){var t;return((t=Object.entries(f).map(([a,n])=>[a,n.reduce((s,[r,i])=>s+[...e.matchAll(r)].length*i,0)]).filter(([a,n])=>n>20).sort((a,n)=>n[1]-a[1])[0])==null?void 0:t[0])||"plain"}var g=[{type:"cmnt",match:/^>.*|^[ \t]*(=+|-{2,})[ \t]*$/gm},{type:"section",match:/^#{1,6}[ \t]/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,}).*\n[^]*?^\1[ \t]*$/gm,sub:e=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:e.split(`
2
+ `)[0].slice(3)||m(e)}]})},{type:"str",match:/`[^`\n]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S(.*?\S)?_\b|\*\S(.*?\S)?\*|^[ \t]*([*+-]|\d+[.)])([ \t]|$)/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];var h=[{type:"insert",match:/(leanpub-start-insert)((?!leanpub-end-insert)[^])*(leanpub-end-insert)?/g,sub:[{type:"insert",match:/leanpub-(start|end)-insert/g},{match:/(?!leanpub-start-insert)((?!leanpub-end-insert)[^])*/g,sub:m}]},{type:"deleted",match:/(leanpub-start-delete)((?!leanpub-end-delete)[^])*(leanpub-end-delete)?/g,sub:[{type:"deleted",match:/leanpub-(start|end)-delete/g},{match:/(?!leanpub-start-delete)((?!leanpub-end-delete)[^])*/g,sub:m}]},...g];
@@ -2,6 +2,10 @@ declare const _default: ({
2
2
  type: "cmnt";
3
3
  match: RegExp;
4
4
  sub?: undefined;
5
+ } | {
6
+ type: "section";
7
+ match: RegExp;
8
+ sub?: undefined;
5
9
  } | {
6
10
  type: "class";
7
11
  match: RegExp;
@@ -1,2 +1,2 @@
1
- var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},o=(t,e,a,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of r(e))!p.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(m=l(e,n))||m.enumerable});return t};var u=t=>o(s({},"__esModule",{value:!0}),t);var d={};b(d,{default:()=>h});module.exports=u(d);var f={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function g(t){var e;return((e=Object.entries(f).map(([a,m])=>[a,m.reduce((n,[i,c])=>n+[...t.matchAll(i)].length*c,0)]).filter(([a,m])=>m>20).sort((a,m)=>m[1]-a[1])[0])==null?void 0:e[0])||"plain"}var h=[{type:"cmnt",match:/^>.*|(=|-)\1+/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,})(.*)\n[^]*?^\1[ \t]*$/gm,sub:t=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:t.split(`
2
- `)[0].slice(3)||g(t)}]})},{type:"str",match:/`[^`]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S([^\n]*?\S)?_\b|\*\S([^\n]*?\S)?\*/g},{type:"kwd",match:/^\s*(\*|\d+\.)\s/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];
1
+ var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var o=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},b=(t,e,a,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of r(e))!p.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(m=l(e,n))||m.enumerable});return t};var u=t=>b(s({},"__esModule",{value:!0}),t);var d={};o(d,{default:()=>h});module.exports=u(d);var f={bash:[[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],html:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],http:[[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],ts:[[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace|true|false|null)\b/g,10]],py:[[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],sql:[[/\b(SELECT|INSERT|FROM)\b/g,50]],pl:[[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],lua:[[/#!(\/usr)?\/bin\/lua/g,500]],make:[[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],uri:[[/https?:|mailto:|tel:|ftp:/g,30]],css:[[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],diff:[[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],md:[[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],docker:[[/^(FROM|ENTRYPOINT|RUN)/gm,500]],xml:[[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],c:[[/#include\b|\bprintf\s+\(/g,100]],rs:[[/^\s+(use|fn|mut|match)\b/gm,100]],go:[[/\b(func|fmt|package)\b/g,100]],java:[[/^import\s+java/gm,500]],asm:[[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],yaml:[[/^(\s+)?[a-z][a-z0-9]*:/gmi,10]]};function g(t){var e;return((e=Object.entries(f).map(([a,m])=>[a,m.reduce((n,[i,c])=>n+[...t.matchAll(i)].length*c,0)]).filter(([a,m])=>m>20).sort((a,m)=>m[1]-a[1])[0])==null?void 0:e[0])||"plain"}var h=[{type:"cmnt",match:/^>.*|^[ \t]*(=+|-{2,})[ \t]*$/gm},{type:"section",match:/^#{1,6}[ \t]/gm},{type:"class",match:/\*\*.*?\*\*/g},{match:/^(`{3,}).*\n[^]*?^\1[ \t]*$/gm,sub:t=>({type:"kwd",sub:[{match:/\n[^]*(?=```)/g,sub:t.split(`
2
+ `)[0].slice(3)||g(t)}]})},{type:"str",match:/`[^`\n]*`/g},{type:"var",match:/~~.*?~~/g},{type:"kwd",match:/\b_\S(.*?\S)?_\b|\*\S(.*?\S)?\*|^[ \t]*([*+-]|\d+[.)])([ \t]|$)/gm},{type:"func",match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:"oper",match:/^\[[^\]]*]/g}]}];
@@ -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:/\*|\+|\{\d+,\d+\}/g}]};
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}]};
@@ -60,6 +60,11 @@ declare const _default: ({
60
60
  match: RegExp;
61
61
  sub?: undefined;
62
62
  expand?: undefined;
63
+ } | {
64
+ type: "var";
65
+ match: RegExp;
66
+ sub?: undefined;
67
+ expand?: undefined;
63
68
  } | {
64
69
  type: "oper";
65
70
  match: RegExp;
@@ -1 +1 @@
1
- var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var o=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 p(e))!o.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:/\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,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:"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];
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speed-highlight/core",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "A tiny, fast, simple syntax highlighter for the web and the terminal in JavaScript",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
@@ -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: /@\w+\b|\b(and|not|only|or)\b|\b(?=([a-z-]+))\2(?=[^{}]*{)/g
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
- match: /\b[\w-]+(?=\s*:)|(::?|\.)[\w-]+(?=[^{}]*{)/g
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}/g
38
+ match: /#[\da-f]{3,8}/gi
31
39
  },
32
40
  {
33
41
  type: 'num',
34
- match: /\d+(\.\d+)?(cm|mm|in|px|pt|pc|em|ex|ch|rem|vm|vh|vmin|vmax|%)?/g,
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]+|%/g
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',
@@ -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: xmlElement.sub
62
+ sub: htmlElement.sub
32
63
  },
33
64
  {
34
65
  match: /[^]*(?=<\/style\s*>$)/g,
35
66
  sub: 'css'
36
67
  },
37
- xmlElement
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: xmlElement.sub
76
+ sub: htmlElement.sub
46
77
  },
47
78
  {
48
79
  match: /[^]*(?=<\/script\s*>$)/g,
49
80
  sub: 'js'
50
81
  },
51
- xmlElement
82
+ htmlElement
52
83
  ]
53
84
  },
54
- ...xml
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
  ]);
@@ -59,10 +59,14 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
59
59
  },
60
60
  {
61
61
  type: 'kwd',
62
- 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
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
- match: /\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,
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
@@ -12,7 +12,7 @@ export default /** @satisfies {import('../index.js').ShjLanguageData} */ ({
12
12
  match: /@\w+/g
13
13
  },
14
14
  {
15
- type: 'class',
15
+ type: 'type',
16
16
  match: /{[\w\s|<>,.@\[\]]+}/g
17
17
  },
18
18
  {
@@ -6,15 +6,22 @@ import { detectLanguage } from '../detect.js';
6
6
 
7
7
  export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
8
8
  {
9
+ // a single = can only underline a heading, while a single - is an empty
10
+ // list item, and the cmnt rule comes first so it would win that tie
9
11
  type: 'cmnt',
10
- match: /^>.*|(=|-)\1+/gm
12
+ match: /^>.*|^[ \t]*(=+|-{2,})[ \t]*$/gm
13
+ },
14
+ {
15
+ type: 'section',
16
+ match: /^#{1,6}[ \t]/gm
11
17
  },
12
18
  {
13
19
  type: 'class',
14
20
  match: /\*\*.*?\*\*/g
15
21
  },
16
22
  {
17
- match: /^(`{3,})(.*)\n[^]*?^\1[ \t]*$/gm,
23
+ // the info string cannot be captured: sub only receives match[0]
24
+ match: /^(`{3,}).*\n[^]*?^\1[ \t]*$/gm,
18
25
  sub: code => ({
19
26
  type: 'kwd',
20
27
  sub: [
@@ -27,21 +34,21 @@ export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
27
34
  },
28
35
  {
29
36
  type: 'str',
30
- match: /`[^`]*`/g
37
+ match: /`[^`\n]*`/g
31
38
  },
32
39
  {
33
40
  type: 'var',
34
41
  match: /~~.*?~~/g
35
42
  },
36
43
  {
44
+ // emphasis, then list markers: sharing a type lets them share a regex,
45
+ // the alternation order keeps emphasis winning an equal start index
37
46
  type: 'kwd',
38
- match: /\b_\S([^\n]*?\S)?_\b|\*\S([^\n]*?\S)?\*/g
39
- },
40
- {
41
- type: 'kwd',
42
- match: /^\s*(\*|\d+\.)\s/gm
47
+ match: /\b_\S(.*?\S)?_\b|\*\S(.*?\S)?\*|^[ \t]*([*+-]|\d+[.)])([ \t]|$)/gm
43
48
  },
44
49
  {
50
+ // the type is not dead: with an array sub the tokenizer keeps the whole
51
+ // rule as data, so this colors what the sub leaves over (the url part)
45
52
  type: 'func',
46
53
  match: /\[[^\]]*]\([^)]*\)|<[^>]*>/g,
47
54
  sub: [
@@ -20,6 +20,6 @@ export default /** @satisfies {import('../index.js').ShjLanguageData} */ ({
20
20
  },
21
21
  {
22
22
  type: 'var',
23
- match: /\*|\+|\{\d+,\d+\}/g
23
+ match: /[*+?.]|\{\d+(,\d*)?\}/g
24
24
  }
25
25
  ]});