hexo-util
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -1,1 +0,1 @@ | ||
{"languages":["1c","abnf","accesslog","actionscript","ada","angelscript","apache","applescript","arcade","cpp","arduino","armasm","xml","asciidoc","aspectj","autohotkey","autoit","avrasm","awk","axapta","bash","basic","bnf","brainfuck","cal","capnproto","ceylon","clean","clojure","clojure-repl","cmake","coffeescript","coq","cos","crmsh","crystal","cs","csp","css","d","markdown","dart","delphi","diff","django","dns","dockerfile","dos","dsconfig","dts","dust","ebnf","elixir","elm","ruby","erb","erlang-repl","erlang","excel","fix","flix","fortran","fsharp","gams","gauss","gcode","gherkin","glsl","gml","go","golo","gradle","groovy","haml","handlebars","haskell","haxe","hsp","htmlbars","http","hy","inform7","ini","irpf90","isbl","java","javascript","jboss-cli","json","julia","julia-repl","kotlin","lasso","ldif","leaf","less","lisp","livecodeserver","livescript","llvm","lsl","lua","makefile","mathematica","matlab","maxima","mel","mercury","mipsasm","mizar","perl","mojolicious","monkey","moonscript","n1ql","nginx","nimrod","nix","nsis","objectivec","ocaml","openscad","oxygene","parser3","pf","pgsql","php","plaintext","pony","powershell","processing","profile","prolog","properties","protobuf","puppet","purebasic","python","q","qml","r","reasonml","rib","roboconf","routeros","rsl","ruleslanguage","rust","sas","scala","scheme","scilab","scss","shell","smali","smalltalk","sml","sqf","sql","stan","stata","step21","stylus","subunit","swift","taggerscript","yaml","tap","tcl","tex","thrift","tp","twig","typescript","vala","vbnet","vbscript","vbscript-html","verilog","vhdl","vim","x86asm","xl","xquery","zephir"],"aliases":{"1c":"1c","abnf":"abnf","accesslog":"accesslog","actionscript":"actionscript","as":"actionscript","ada":"ada","angelscript":"angelscript","asc":"angelscript","apache":"apache","apacheconf":"apache","applescript":"applescript","osascript":"applescript","arcade":"arcade","cpp":"cpp","c":"cpp","cc":"cpp","h":"cpp","c++":"cpp","h++":"cpp","hpp":"cpp","arduino":"arduino","armasm":"armasm","arm":"armasm","xml":"xml","html":"xml","xhtml":"xml","rss":"xml","atom":"xml","xjb":"xml","xsd":"xml","xsl":"xml","plist":"xml","asciidoc":"asciidoc","adoc":"asciidoc","aspectj":"aspectj","autohotkey":"autohotkey","ahk":"autohotkey","autoit":"autoit","avrasm":"avrasm","awk":"awk","axapta":"axapta","bash":"bash","sh":"bash","zsh":"bash","basic":"basic","bnf":"bnf","brainfuck":"brainfuck","bf":"brainfuck","cal":"cal","capnproto":"capnproto","capnp":"capnproto","ceylon":"ceylon","clean":"clean","icl":"clean","dcl":"clean","clojure":"clojure","clj":"clojure","clojure-repl":"clojure-repl","cmake":"cmake","cmake.in":"cmake","coffeescript":"coffeescript","coffee":"coffeescript","cson":"coffeescript","iced":"coffeescript","coq":"coq","cos":"cos","cls":"cos","crmsh":"crmsh","crm":"crmsh","pcmk":"crmsh","crystal":"crystal","cr":"crystal","cs":"cs","csharp":"cs","csp":"csp","css":"css","d":"d","markdown":"markdown","md":"markdown","mkdown":"markdown","mkd":"markdown","dart":"dart","delphi":"delphi","dpr":"delphi","dfm":"delphi","pas":"delphi","pascal":"delphi","freepascal":"delphi","lazarus":"delphi","lpr":"delphi","lfm":"delphi","diff":"diff","patch":"diff","django":"django","jinja":"django","dns":"dns","bind":"dns","zone":"dns","dockerfile":"dockerfile","docker":"dockerfile","dos":"dos","bat":"dos","cmd":"dos","dsconfig":"dsconfig","dts":"dts","dust":"dust","dst":"dust","ebnf":"ebnf","elixir":"elixir","elm":"elm","ruby":"ruby","rb":"ruby","gemspec":"ruby","podspec":"ruby","thor":"ruby","irb":"ruby","erb":"erb","erlang-repl":"erlang-repl","erlang":"erlang","erl":"erlang","excel":"excel","xlsx":"excel","xls":"excel","fix":"fix","flix":"flix","fortran":"fortran","f90":"fortran","f95":"fortran","fsharp":"fsharp","fs":"fsharp","gams":"gams","gms":"gams","gauss":"gauss","gss":"gauss","gcode":"gcode","nc":"gcode","gherkin":"gherkin","feature":"gherkin","glsl":"glsl","gml":"gml","GML":"gml","go":"go","golang":"go","golo":"golo","gradle":"gradle","groovy":"groovy","haml":"haml","handlebars":"handlebars","hbs":"handlebars","html.hbs":"handlebars","html.handlebars":"handlebars","haskell":"haskell","hs":"haskell","haxe":"haxe","hx":"haxe","hsp":"hsp","htmlbars":"htmlbars","http":"http","https":"http","hy":"hy","hylang":"hy","inform7":"inform7","i7":"inform7","ini":"ini","toml":"ini","irpf90":"irpf90","isbl":"isbl","java":"java","jsp":"java","javascript":"javascript","js":"javascript","jsx":"javascript","jboss-cli":"jboss-cli","wildfly-cli":"jboss-cli","json":"json","julia":"julia","julia-repl":"julia-repl","kotlin":"kotlin","kt":"kotlin","lasso":"lasso","ls":"livescript","lassoscript":"lasso","ldif":"ldif","leaf":"leaf","less":"less","lisp":"lisp","livecodeserver":"livecodeserver","livescript":"livescript","llvm":"llvm","lsl":"lsl","lua":"lua","makefile":"makefile","mk":"makefile","mak":"makefile","mathematica":"mathematica","mma":"mathematica","matlab":"matlab","maxima":"maxima","mel":"mel","mercury":"mercury","m":"mercury","moo":"mercury","mipsasm":"mipsasm","mips":"mipsasm","mizar":"mizar","perl":"perl","pl":"perl","pm":"perl","mojolicious":"mojolicious","monkey":"monkey","moonscript":"moonscript","moon":"moonscript","n1ql":"n1ql","nginx":"nginx","nginxconf":"nginx","nimrod":"nimrod","nim":"nimrod","nix":"nix","nixos":"nix","nsis":"nsis","objectivec":"objectivec","mm":"objectivec","objc":"objectivec","obj-c":"objectivec","ocaml":"ocaml","ml":"sml","openscad":"openscad","scad":"openscad","oxygene":"oxygene","parser3":"parser3","pf":"pf","pf.conf":"pf","pgsql":"pgsql","postgres":"pgsql","postgresql":"pgsql","php":"php","php3":"php","php4":"php","php5":"php","php6":"php","php7":"php","plaintext":"plaintext","pony":"pony","powershell":"powershell","ps":"powershell","processing":"processing","profile":"profile","prolog":"prolog","properties":"properties","protobuf":"protobuf","puppet":"puppet","pp":"puppet","purebasic":"purebasic","pb":"purebasic","pbi":"purebasic","python":"python","py":"python","gyp":"python","q":"q","k":"q","kdb":"q","qml":"qml","qt":"qml","r":"r","reasonml":"reasonml","re":"reasonml","rib":"rib","roboconf":"roboconf","graph":"roboconf","instances":"roboconf","routeros":"routeros","mikrotik":"routeros","rsl":"rsl","ruleslanguage":"ruleslanguage","rust":"rust","rs":"rust","sas":"sas","SAS":"sas","scala":"scala","scheme":"scheme","scilab":"scilab","sci":"scilab","scss":"scss","shell":"shell","console":"shell","smali":"smali","smalltalk":"smalltalk","st":"smalltalk","sml":"sml","sqf":"sqf","sql":"sql","stan":"stan","stata":"stata","do":"stata","ado":"stata","step21":"step21","p21":"step21","step":"step21","stp":"step21","stylus":"stylus","styl":"stylus","subunit":"subunit","swift":"swift","taggerscript":"taggerscript","yaml":"yaml","yml":"yaml","YAML":"yaml","tap":"tap","tcl":"tcl","tk":"tcl","tex":"tex","thrift":"thrift","tp":"tp","twig":"twig","craftcms":"twig","typescript":"typescript","ts":"typescript","vala":"vala","vbnet":"vbnet","vb":"vbnet","vbscript":"vbscript","vbs":"vbscript","vbscript-html":"vbscript-html","verilog":"verilog","v":"verilog","sv":"verilog","svh":"verilog","vhdl":"vhdl","vim":"vim","x86asm":"x86asm","xl":"xl","tao":"xl","xquery":"xquery","xpath":"xquery","xq":"xquery","zephir":"zephir","zep":"zephir"}} | ||
{"languages":["1c","abnf","accesslog","actionscript","ada","angelscript","apache","applescript","arcade","arduino","armasm","xml","asciidoc","aspectj","autohotkey","autoit","avrasm","awk","axapta","bash","basic","bnf","brainfuck","c","cal","capnproto","ceylon","clean","clojure","clojure-repl","cmake","coffeescript","coq","cos","cpp","crmsh","crystal","csharp","csp","css","d","markdown","dart","delphi","diff","django","dns","dockerfile","dos","dsconfig","dts","dust","ebnf","elixir","elm","ruby","erb","erlang-repl","erlang","excel","fix","flix","fortran","fsharp","gams","gauss","gcode","gherkin","glsl","gml","go","golo","gradle","groovy","haml","handlebars","haskell","haxe","hsp","http","hy","inform7","ini","irpf90","isbl","java","javascript","jboss-cli","json","julia","julia-repl","kotlin","lasso","latex","ldif","leaf","less","lisp","livecodeserver","livescript","llvm","lsl","lua","makefile","mathematica","matlab","maxima","mel","mercury","mipsasm","mizar","perl","mojolicious","monkey","moonscript","n1ql","nestedtext","nginx","nim","nix","node-repl","nsis","objectivec","ocaml","openscad","oxygene","parser3","pf","pgsql","php","php-template","plaintext","pony","powershell","processing","profile","prolog","properties","protobuf","puppet","purebasic","python","python-repl","q","qml","r","reasonml","rib","roboconf","routeros","rsl","ruleslanguage","rust","sas","scala","scheme","scilab","scss","shell","smali","smalltalk","sml","sqf","sql","stan","stata","step21","stylus","subunit","swift","taggerscript","yaml","tap","tcl","thrift","tp","twig","typescript","vala","vbnet","vbscript","vbscript-html","verilog","vhdl","vim","wasm","wren","x86asm","xl","xquery","zephir"],"aliases":{"1c":"1c","abnf":"abnf","accesslog":"accesslog","actionscript":"actionscript","as":"actionscript","ada":"ada","angelscript":"angelscript","asc":"angelscript","apache":"apache","apacheconf":"apache","applescript":"applescript","osascript":"applescript","arcade":"arcade","arduino":"arduino","ino":"arduino","armasm":"armasm","arm":"armasm","xml":"xml","html":"xml","xhtml":"xml","rss":"xml","atom":"xml","xjb":"xml","xsd":"xml","xsl":"xml","plist":"xml","wsf":"xml","svg":"xml","asciidoc":"asciidoc","adoc":"asciidoc","aspectj":"aspectj","autohotkey":"autohotkey","ahk":"autohotkey","autoit":"autoit","avrasm":"avrasm","awk":"awk","axapta":"axapta","x++":"axapta","bash":"bash","sh":"bash","basic":"basic","bnf":"bnf","brainfuck":"brainfuck","bf":"brainfuck","c":"c","h":"c","cal":"cal","capnproto":"capnproto","capnp":"capnproto","ceylon":"ceylon","clean":"clean","icl":"clean","dcl":"clean","clojure":"clojure","clj":"clojure","edn":"clojure","clojure-repl":"clojure-repl","cmake":"cmake","cmake.in":"cmake","coffeescript":"coffeescript","coffee":"coffeescript","cson":"coffeescript","iced":"coffeescript","coq":"coq","cos":"cos","cls":"cos","cpp":"cpp","cc":"cpp","c++":"cpp","h++":"cpp","hpp":"cpp","hh":"cpp","hxx":"cpp","cxx":"cpp","crmsh":"crmsh","crm":"crmsh","pcmk":"crmsh","crystal":"crystal","cr":"crystal","csharp":"csharp","cs":"csharp","c#":"csharp","csp":"csp","css":"css","d":"d","markdown":"markdown","md":"markdown","mkdown":"markdown","mkd":"markdown","dart":"dart","delphi":"delphi","dpr":"delphi","dfm":"delphi","pas":"delphi","pascal":"delphi","diff":"diff","patch":"diff","django":"django","jinja":"django","dns":"dns","bind":"dns","zone":"dns","dockerfile":"dockerfile","docker":"dockerfile","dos":"dos","bat":"dos","cmd":"dos","dsconfig":"dsconfig","dts":"dts","dust":"dust","dst":"dust","ebnf":"ebnf","elixir":"elixir","ex":"elixir","exs":"elixir","elm":"elm","ruby":"ruby","rb":"ruby","gemspec":"ruby","podspec":"ruby","thor":"ruby","irb":"ruby","erb":"erb","erlang-repl":"erlang-repl","erlang":"erlang","erl":"erlang","excel":"excel","xlsx":"excel","xls":"excel","fix":"fix","flix":"flix","fortran":"fortran","f90":"fortran","f95":"fortran","fsharp":"fsharp","fs":"fsharp","f#":"fsharp","gams":"gams","gms":"gams","gauss":"gauss","gss":"gauss","gcode":"gcode","nc":"gcode","gherkin":"gherkin","feature":"gherkin","glsl":"glsl","gml":"gml","go":"go","golang":"go","golo":"golo","gradle":"gradle","groovy":"groovy","haml":"haml","handlebars":"handlebars","hbs":"handlebars","html.hbs":"handlebars","html.handlebars":"handlebars","htmlbars":"handlebars","haskell":"haskell","hs":"haskell","haxe":"haxe","hx":"haxe","hsp":"hsp","http":"http","https":"http","hy":"hy","hylang":"hy","inform7":"inform7","i7":"inform7","ini":"ini","toml":"ini","irpf90":"irpf90","isbl":"isbl","java":"java","jsp":"java","javascript":"javascript","js":"javascript","jsx":"javascript","mjs":"javascript","cjs":"javascript","jboss-cli":"jboss-cli","wildfly-cli":"jboss-cli","json":"json","julia":"julia","julia-repl":"julia-repl","jldoctest":"julia-repl","kotlin":"kotlin","kt":"kotlin","kts":"kotlin","lasso":"lasso","ls":"livescript","lassoscript":"lasso","latex":"latex","tex":"latex","ldif":"ldif","leaf":"leaf","less":"less","lisp":"lisp","livecodeserver":"livecodeserver","livescript":"livescript","llvm":"llvm","lsl":"lsl","lua":"lua","makefile":"makefile","mk":"makefile","mak":"makefile","make":"makefile","mathematica":"mathematica","mma":"mathematica","wl":"mathematica","matlab":"matlab","maxima":"maxima","mel":"mel","mercury":"mercury","m":"mercury","moo":"mercury","mipsasm":"mipsasm","mips":"mipsasm","mizar":"mizar","perl":"perl","pl":"perl","pm":"perl","mojolicious":"mojolicious","monkey":"monkey","moonscript":"moonscript","moon":"moonscript","n1ql":"n1ql","nestedtext":"nestedtext","nt":"nestedtext","nginx":"nginx","nginxconf":"nginx","nim":"nim","nix":"nix","nixos":"nix","node-repl":"node-repl","nsis":"nsis","objectivec":"objectivec","mm":"objectivec","objc":"objectivec","obj-c":"objectivec","obj-c++":"objectivec","objective-c++":"objectivec","ocaml":"ocaml","ml":"sml","openscad":"openscad","scad":"openscad","oxygene":"oxygene","parser3":"parser3","pf":"pf","pf.conf":"pf","pgsql":"pgsql","postgres":"pgsql","postgresql":"pgsql","php":"php","php-template":"php-template","plaintext":"plaintext","text":"plaintext","txt":"plaintext","pony":"pony","powershell":"powershell","pwsh":"powershell","ps":"powershell","ps1":"powershell","processing":"processing","pde":"processing","profile":"profile","prolog":"prolog","properties":"properties","protobuf":"protobuf","puppet":"puppet","pp":"puppet","purebasic":"purebasic","pb":"purebasic","pbi":"purebasic","python":"python","py":"python","gyp":"python","ipython":"python","python-repl":"python-repl","pycon":"python-repl","q":"q","k":"q","kdb":"q","qml":"qml","qt":"qml","r":"r","reasonml":"reasonml","re":"reasonml","rib":"rib","roboconf":"roboconf","graph":"roboconf","instances":"roboconf","routeros":"routeros","mikrotik":"routeros","rsl":"rsl","ruleslanguage":"ruleslanguage","rust":"rust","rs":"rust","sas":"sas","scala":"scala","scheme":"scheme","scilab":"scilab","sci":"scilab","scss":"scss","shell":"shell","console":"shell","shellsession":"shell","smali":"smali","smalltalk":"smalltalk","st":"smalltalk","sml":"sml","sqf":"sqf","sql":"sql","stan":"stan","stanfuncs":"stan","stata":"stata","do":"stata","ado":"stata","step21":"step21","p21":"step21","step":"step21","stp":"step21","stylus":"stylus","styl":"stylus","subunit":"subunit","swift":"swift","taggerscript":"taggerscript","yaml":"yaml","yml":"yaml","tap":"tap","tcl":"tcl","tk":"tcl","thrift":"thrift","tp":"tp","twig":"twig","craftcms":"twig","typescript":"typescript","ts":"typescript","tsx":"typescript","vala":"vala","vbnet":"vbnet","vb":"vbnet","vbscript":"vbscript","vbs":"vbscript","vbscript-html":"vbscript-html","verilog":"verilog","v":"verilog","sv":"verilog","svh":"verilog","vhdl":"vhdl","vim":"vim","wasm":"wasm","wren":"wren","x86asm":"x86asm","xl":"xl","tao":"xl","xquery":"xquery","xpath":"xquery","xq":"xquery","zephir":"zephir","zep":"zephir"}} |
@@ -42,17 +42,4 @@ 'use strict'; | ||
dump() { | ||
// Object#fromEntries supported since Node.js 12 | ||
// eslint-disable-next-line node/no-unsupported-features/es-builtins | ||
if (typeof Object.fromEntries === 'function') { | ||
// eslint-disable-next-line node/no-unsupported-features/es-builtins | ||
return Object.fromEntries(this.cache); | ||
} | ||
// FIXME: A polyfill for Node.js 10 & 11 | ||
const obj = {}; | ||
this.cache.forEach((v, k) => { | ||
obj[k] = v; | ||
}); | ||
return obj; | ||
return Object.fromEntries(this.cache); | ||
} | ||
}; |
@@ -88,11 +88,3 @@ 'use strict'; | ||
function replaceTabs(str, tab) { | ||
return str.replace(/^\t+/, match => { | ||
let result = ''; | ||
for (let i = 0, len = match.length; i < len; i++) { | ||
result += tab; | ||
} | ||
return result; | ||
}); | ||
return str.replace(/\t+/, match => tab.repeat(match.length)); | ||
} | ||
@@ -99,0 +91,0 @@ |
@@ -44,11 +44,3 @@ 'use strict'; | ||
function replaceTabs(str, tab) { | ||
return str.replace(/^\t+/gm, match => { | ||
let result = ''; | ||
for (let i = 0, len = match.length; i < len; i++) { | ||
result += tab; | ||
} | ||
return result; | ||
}); | ||
return str.replace(/^\t+/gm, match => tab.repeat(match.length)); | ||
} | ||
@@ -55,0 +47,0 @@ |
@@ -8,2 +8,7 @@ 'use strict'; | ||
function striptags(html = '') { | ||
// if not string, then safely return an empty string | ||
if (typeof html !== 'string' && !(html instanceof String)) { | ||
return ''; | ||
} | ||
let state = STATE_PLAINTEXT; | ||
@@ -10,0 +15,0 @@ let tag_buffer = ''; |
@@ -16,2 +16,9 @@ 'use strict'; | ||
/** | ||
* Identify a heading that to be unnumbered or not. | ||
*/ | ||
const isUnnumbered = ({ attribs = {} }) => { | ||
return attribs['data-toc-unnumbered'] === 'true'; | ||
}; | ||
function tocObj(str, options = {}) { | ||
@@ -35,2 +42,3 @@ const { min_depth, max_depth } = Object.assign({ | ||
const id = getId(el); | ||
const unnumbered = isUnnumbered(el); | ||
let text = ''; | ||
@@ -48,3 +56,5 @@ for (const element of el.children) { | ||
result.push({ text, id, level }); | ||
const res = { text, id, level }; | ||
if (unnumbered) res.unnumbered = true; | ||
result.push(res); | ||
} | ||
@@ -51,0 +61,0 @@ |
@@ -12,2 +12,4 @@ 'use strict'; | ||
function urlForHelper(path = '/', options) { | ||
if (/^(#|\/\/|http(s)?:)/.test(path)) return path; | ||
const { config } = this; | ||
@@ -32,4 +34,2 @@ | ||
return cache.apply(`${config.url}-${root}-${prettyUrlsOptions.trailing_index}-${prettyUrlsOptions.trailing_html}-${path}`, () => { | ||
if (/^(#|\/\/|http(s)?:)/.test(path)) return path; | ||
const sitehost = parse(config.url).hostname || config.url; | ||
@@ -36,0 +36,0 @@ const data = new URL(path, `http://${sitehost}`); |
{ | ||
"name": "hexo-util", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Utilities for Hexo.", | ||
@@ -37,9 +37,9 @@ "main": "lib/index", | ||
"chai-as-promised": "^7.1.1", | ||
"eslint": "^7.0.0", | ||
"eslint-config-hexo": "^4.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-config-hexo": "^5.0.0", | ||
"html-entities": "^2.1.1", | ||
"html-tag-validator": "^1.5.0", | ||
"mocha": "^8.0.1", | ||
"mocha": "^9.0.3", | ||
"nyc": "^15.0.0", | ||
"rewire": "^5.0.0" | ||
"rewire": "^6.0.0" | ||
}, | ||
@@ -51,4 +51,4 @@ "dependencies": { | ||
"deepmerge": "^4.2.2", | ||
"highlight.js": "^10.7.1", | ||
"htmlparser2": "^6.0.0", | ||
"highlight.js": "^11.0.1", | ||
"htmlparser2": "^7.0.0", | ||
"prismjs": "^1.17.1", | ||
@@ -55,0 +55,0 @@ "strip-indent": "^3.0.0" |
@@ -547,3 +547,3 @@ # hexo-util | ||
Generate a table of contents in JSON format based on the given html string. | ||
Generate a table of contents in JSON format based on the given html string. Headings with attribute `data-toc-unnumbered="true"` will be marked as unnumbered. | ||
@@ -605,2 +605,9 @@ Option | Description | Default | ||
*/ | ||
tocObj('<h1 id="reference" data-toc-unnumbered="true">Reference</h1>') | ||
/* | ||
[ | ||
{ text: 'Reference', id: 'reference', level: 1, unnumbered: true } | ||
] | ||
*/ | ||
``` | ||
@@ -607,0 +614,0 @@ |
82972
757
1417
+ Addedentities@3.0.1(transitive)
+ Addedhighlight.js@11.9.0(transitive)
+ Addedhtmlparser2@7.2.0(transitive)
- Removedhighlight.js@10.7.3(transitive)
- Removedhtmlparser2@6.1.0(transitive)
Updatedhighlight.js@^11.0.1
Updatedhtmlparser2@^7.0.0