ssqch 0.11.0 → 0.13.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/bundled/completions/bash +67 -9
- package/bundled/completions/elvish +24 -4
- package/bundled/completions/fish +37 -25
- package/bundled/completions/powershell +26 -4
- package/bundled/completions/zsh +45 -10
- package/bundled/docs/agents.md +2 -2
- package/bundled/docs/build-summary.md +1 -1
- package/bundled/docs/comparing-builds.md +7 -4
- package/bundled/docs/configuring.md +7 -12
- package/bundled/docs/deploying.md +1 -1
- package/bundled/docs/field-guide.md +4 -4
- package/bundled/docs/github-pages.md +2 -1
- package/bundled/docs/index.md +1 -1
- package/bundled/docs/install.md +1 -1
- package/bundled/docs/known-gaps.md +1 -1
- package/bundled/docs/markdown.md +11 -13
- package/bundled/docs/nav.yml +6 -1
- package/bundled/docs/netlify.md +4 -2
- package/bundled/docs/patrol.md +48 -0
- package/bundled/docs/plugins.md +6 -4
- package/bundled/docs/robots.md +72 -0
- package/bundled/docs/seo.md +2 -38
- package/bundled/docs/serving-markdown.md +142 -0
- package/bundled/docs/template-languages.md +2 -1
- package/bundled/docs/templates.md +2 -1
- package/bundled/docs/trailheads/from-component-frameworks.md +9 -10
- package/bundled/docs/trailheads/from-hugo.md +5 -3
- package/bundled/docs/trailheads/from-jekyll.md +54 -13
- package/bundled/docs/trailheads/from-mkdocs.md +15 -12
- package/bundled/docs/trailheads/from-vitepress.md +142 -0
- package/bundled/docs/trailheads.md +5 -5
- package/bundled/docs/where-values-come-from.md +5 -5
- package/bundled/docs/writing-plugins.md +69 -0
- package/bundled/ssqch.d.ts +150 -34
- package/bundled/starter/engines/index.edge +1 -0
- package/bundled/starter/engines/index.ejs +1 -0
- package/bundled/starter/engines/index.hbs +1 -0
- package/bundled/starter/engines/index.liquid +1 -0
- package/bundled/starter/engines/layout.edge +7 -0
- package/bundled/starter/engines/layout.ejs +4 -0
- package/bundled/starter/engines/layout.hbs +4 -0
- package/bundled/starter/engines/layout.liquid +4 -0
- package/bundled/starter/src/_data/site.json +1 -0
- package/bundled/starter/src/_includes/layout.jinja +4 -0
- package/bundled/starter/src/index.jinja +1 -0
- package/bundled/starter/ssqch.config.js +14 -1
- package/bundled/starter-docs/engines/edge/base.edge +7 -0
- package/bundled/starter-docs/engines/edge/doc.edge +4 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
- package/bundled/starter-docs/src/_data/site.json +1 -0
- package/bundled/starter-docs/src/_includes/base.jinja +4 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
- package/bundled/starter-docs/src/assets/docs.css +4 -0
- package/bundled/starter-docs/src/assets/docs.js +17 -0
- package/bundled/starter-docs/ssqch.config.js +14 -1
- package/lib/assets.js +13 -11
- package/lib/chunk-25WERNDD.js +112 -0
- package/lib/{chunk-H5K2ZE7B.js → chunk-2BJFGKOE.js} +13 -5
- package/lib/chunk-2FKYWYAB.js +268 -0
- package/lib/{chunk-LJOURBYT.js → chunk-3ZTRIO6O.js} +21 -19
- package/lib/{chunk-IOBC665M.js → chunk-4AZFCSGJ.js} +5 -3
- package/lib/{chunk-HWW5NCVJ.js → chunk-4Q6WMTER.js} +1 -1
- package/lib/{chunk-V2FSMOFX.js → chunk-55WXDGO4.js} +3 -3
- package/lib/{chunk-ZR3JYLFB.js → chunk-6FY77I4M.js} +331 -58
- package/lib/{chunk-JC54PHIT.js → chunk-6OUCRDYI.js} +514 -141
- package/lib/{chunk-ERAIEV3O.js → chunk-6U5VIQVY.js} +9 -7
- package/lib/{chunk-Z5OP43HU.js → chunk-7U5GWTEH.js} +455 -94
- package/lib/{chunk-CMJ7X5WW.js → chunk-AIJNG6MJ.js} +3 -2
- package/lib/{chunk-3K237XAX.js → chunk-C2Q7JKFI.js} +12 -10
- package/lib/{chunk-GS5B3CBW.js → chunk-DDV6JEC2.js} +1 -1
- package/lib/{chunk-A75EVUJX.js → chunk-DFJFHULZ.js} +47 -20
- package/lib/{chunk-KZZS4W2V.js → chunk-ENWDM2RW.js} +45 -42
- package/lib/{chunk-I3HYKEEW.js → chunk-ER72RPD6.js} +3 -3
- package/lib/chunk-F3JPNFCZ.js +23 -0
- package/lib/{chunk-B5E27PLU.js → chunk-FENJHLNM.js} +6 -3
- package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
- package/lib/{chunk-KCF2Z6N7.js → chunk-FQZDUDFK.js} +5 -3
- package/lib/{chunk-GJNIQAIH.js → chunk-GSNRAGKQ.js} +13 -6
- package/lib/{chunk-443ZQLVX.js → chunk-GU7BBYWB.js} +5 -4
- package/lib/{chunk-X2GAVYV2.js → chunk-HDKU6LRI.js} +110 -748
- package/lib/chunk-J3C2LEW7.js +121 -0
- package/lib/{chunk-XS4EJSEK.js → chunk-K5WZ2VYK.js} +7 -5
- package/lib/{chunk-3HZZY3Y7.js → chunk-OOKBXQAY.js} +7 -6
- package/lib/chunk-P2WS4RM4.js +707 -0
- package/lib/{chunk-RBNPBTDP.js → chunk-SNQOHNXE.js} +1 -1
- package/lib/{chunk-HFSWUTXX.js → chunk-SPIFZBIW.js} +1 -1
- package/lib/{chunk-QLUTNR37.js → chunk-T5IUI7W7.js} +12 -11
- package/lib/{chunk-ZINLHOX4.js → chunk-TGSVSG2G.js} +3 -2
- package/lib/{chunk-2L3HR67O.js → chunk-U2KEMVXO.js} +24 -16
- package/lib/{chunk-RYIWYWRQ.js → chunk-UHRBPZ4A.js} +7 -5
- package/lib/{chunk-2QTJTEBV.js → chunk-ULCT3PAV.js} +1 -1
- package/lib/{chunk-FCM3NYFR.js → chunk-UZNUS7RP.js} +12 -9
- package/lib/{chunk-GLJQ4C76.js → chunk-V3G2QGL3.js} +13 -106
- package/lib/{chunk-Z44IAMNG.js → chunk-VILOEVK7.js} +60 -28
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/{chunk-5ELAUHRL.js → chunk-WGAIE3DD.js} +23 -19
- package/lib/{chunk-OQGXZYZS.js → chunk-WUCRAV36.js} +13 -7
- package/lib/{chunk-RZYAIX2R.js → chunk-XYAWJTHM.js} +11 -10
- package/lib/{chunk-OSBEH67S.js → chunk-YA23NDMW.js} +5 -3
- package/lib/{chunk-AIMEXBTK.js → chunk-YNJNMQWU.js} +37 -142
- package/lib/{chunk-QJ5ZFTML.js → chunk-ZMG25MXF.js} +20 -18
- package/lib/cli.js +72 -35
- package/lib/elements.js +13 -11
- package/lib/from-hugo.js +36 -0
- package/lib/from-jekyll.js +41 -0
- package/lib/from-mkdocs.js +49 -0
- package/lib/from-vitepress.js +49 -0
- package/lib/image.js +12 -11
- package/lib/links.js +13 -11
- package/lib/llms.js +613 -0
- package/lib/minify.js +14 -12
- package/lib/redirects.js +13 -11
- package/lib/robots.js +87 -0
- package/lib/rss.js +24 -13
- package/lib/sass.js +12 -11
- package/lib/sitemap.js +23 -18
- package/lib/ssqch.js +6 -5
- package/lib/vue.js +400 -0
- package/package.json +29 -1
- package/types/from-hugo.d.ts +5 -0
- package/types/from-jekyll.d.ts +11 -0
- package/types/from-mkdocs.d.ts +11 -0
- package/types/from-vitepress.d.ts +5 -0
- package/types/index.d.ts +51 -31
- package/types/llms.d.ts +27 -0
- package/types/robots.d.ts +13 -0
- package/types/sass.d.ts +1 -1
- package/types/sitemap.d.ts +2 -2
- package/types/vue.d.ts +17 -0
- package/wasm/markdown.wasm +0 -0
- package/lib/chunk-RVXGUMFI.js +0 -21
- /package/lib/{chunk-ZR3JYLFB.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
- /package/lib/{chunk-AIMEXBTK.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
|
@@ -5,23 +5,22 @@ import {
|
|
|
5
5
|
globProblem,
|
|
6
6
|
globToRegExp,
|
|
7
7
|
isGlob
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SPIFZBIW.js";
|
|
9
9
|
import {
|
|
10
10
|
closest
|
|
11
11
|
} from "./chunk-FVZ5JBRI.js";
|
|
12
12
|
import {
|
|
13
13
|
ISSUES_URL,
|
|
14
14
|
SOMETHING_LARGE
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-FJML7INB.js";
|
|
16
16
|
import {
|
|
17
17
|
describeThrown,
|
|
18
18
|
settle
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-4AZFCSGJ.js";
|
|
20
20
|
import {
|
|
21
21
|
BuildError,
|
|
22
22
|
Diagnostics,
|
|
23
23
|
bail,
|
|
24
|
-
comparePaths,
|
|
25
24
|
context,
|
|
26
25
|
isPlainObject,
|
|
27
26
|
loadStaticDataFile,
|
|
@@ -30,7 +29,10 @@ import {
|
|
|
30
29
|
readText,
|
|
31
30
|
warn,
|
|
32
31
|
warning
|
|
33
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-YNJNMQWU.js";
|
|
33
|
+
import {
|
|
34
|
+
comparePaths
|
|
35
|
+
} from "./chunk-VJWQSYEG.js";
|
|
34
36
|
import {
|
|
35
37
|
__commonJS,
|
|
36
38
|
__require,
|
|
@@ -234,11 +236,11 @@ var require_lib = __commonJS({
|
|
|
234
236
|
}
|
|
235
237
|
_exports.without = without;
|
|
236
238
|
function repeat(char_, n) {
|
|
237
|
-
var
|
|
239
|
+
var str2 = "";
|
|
238
240
|
for (var i = 0; i < n; i++) {
|
|
239
|
-
|
|
241
|
+
str2 += char_;
|
|
240
242
|
}
|
|
241
|
-
return
|
|
243
|
+
return str2;
|
|
242
244
|
}
|
|
243
245
|
_exports.repeat = repeat;
|
|
244
246
|
function each(obj, func, context2) {
|
|
@@ -582,10 +584,10 @@ var require_lexer = __commonJS({
|
|
|
582
584
|
};
|
|
583
585
|
}
|
|
584
586
|
var Tokenizer = /* @__PURE__ */ (function() {
|
|
585
|
-
function Tokenizer2(
|
|
586
|
-
this.str =
|
|
587
|
+
function Tokenizer2(str2, opts) {
|
|
588
|
+
this.str = str2;
|
|
587
589
|
this.index = 0;
|
|
588
|
-
this.len =
|
|
590
|
+
this.len = str2.length;
|
|
589
591
|
this.lineno = 0;
|
|
590
592
|
this.colno = 0;
|
|
591
593
|
this.in_code = false;
|
|
@@ -785,20 +787,20 @@ var require_lexer = __commonJS({
|
|
|
785
787
|
};
|
|
786
788
|
_proto._parseString = function _parseString(delimiter) {
|
|
787
789
|
this.forward();
|
|
788
|
-
var
|
|
790
|
+
var str2 = "";
|
|
789
791
|
while (!this.isFinished() && this.current() !== delimiter) {
|
|
790
792
|
var cur = this.current();
|
|
791
793
|
if (cur === "\\") {
|
|
792
794
|
this.forward();
|
|
793
795
|
switch (this.current()) {
|
|
794
796
|
case "n":
|
|
795
|
-
|
|
797
|
+
str2 += "\n";
|
|
796
798
|
break;
|
|
797
799
|
case "t":
|
|
798
|
-
|
|
800
|
+
str2 += " ";
|
|
799
801
|
break;
|
|
800
802
|
case "r":
|
|
801
|
-
|
|
803
|
+
str2 += "\r";
|
|
802
804
|
break;
|
|
803
805
|
// ssqch: Python's (and JavaScript's) code point escapes, so Jinja's "\u003ch1" is "<h1".
|
|
804
806
|
case "x":
|
|
@@ -808,36 +810,36 @@ var require_lexer = __commonJS({
|
|
|
808
810
|
var size = { x: 2, u: 4, U: 8 }[this.current()];
|
|
809
811
|
var hex = this.str.slice(this.index + 1, this.index + 1 + size);
|
|
810
812
|
if (hex.length === size && /^[0-9a-fA-F]+$/.test(hex)) {
|
|
811
|
-
|
|
813
|
+
str2 += String.fromCodePoint(parseInt(hex, 16));
|
|
812
814
|
for (var i = 0; i < size; i++) this.forward();
|
|
813
815
|
} else {
|
|
814
|
-
|
|
816
|
+
str2 += this.current();
|
|
815
817
|
}
|
|
816
818
|
}
|
|
817
819
|
break;
|
|
818
820
|
default:
|
|
819
|
-
|
|
821
|
+
str2 += this.current();
|
|
820
822
|
}
|
|
821
823
|
this.forward();
|
|
822
824
|
} else {
|
|
823
|
-
|
|
825
|
+
str2 += cur;
|
|
824
826
|
this.forward();
|
|
825
827
|
}
|
|
826
828
|
}
|
|
827
829
|
this.forward();
|
|
828
|
-
return
|
|
830
|
+
return str2;
|
|
829
831
|
};
|
|
830
|
-
_proto._matches = function _matches(
|
|
831
|
-
if (this.index +
|
|
832
|
+
_proto._matches = function _matches(str2) {
|
|
833
|
+
if (this.index + str2.length > this.len) {
|
|
832
834
|
return null;
|
|
833
835
|
}
|
|
834
|
-
var m = this.str.slice(this.index, this.index +
|
|
835
|
-
return m ===
|
|
836
|
+
var m = this.str.slice(this.index, this.index + str2.length);
|
|
837
|
+
return m === str2;
|
|
836
838
|
};
|
|
837
|
-
_proto._extractString = function _extractString(
|
|
838
|
-
if (this._matches(
|
|
839
|
-
this.forwardN(
|
|
840
|
-
return
|
|
839
|
+
_proto._extractString = function _extractString(str2) {
|
|
840
|
+
if (this._matches(str2)) {
|
|
841
|
+
this.forwardN(str2.length);
|
|
842
|
+
return str2;
|
|
841
843
|
}
|
|
842
844
|
return null;
|
|
843
845
|
};
|
|
@@ -1364,8 +1366,8 @@ var require_nodes = __commonJS({
|
|
|
1364
1366
|
fields: ["extName", "prop", "args", "contentArgs"]
|
|
1365
1367
|
});
|
|
1366
1368
|
var CallExtensionAsync = CallExtension.extend("CallExtensionAsync");
|
|
1367
|
-
function print(
|
|
1368
|
-
var lines =
|
|
1369
|
+
function print(str2, indent, inline) {
|
|
1370
|
+
var lines = str2.split("\n");
|
|
1369
1371
|
lines.forEach(function(line, i) {
|
|
1370
1372
|
if (line && (inline && i > 0 || !inline)) {
|
|
1371
1373
|
process.stdout.write(" ".repeat(indent));
|
|
@@ -1987,7 +1989,7 @@ var require_parser = __commonJS({
|
|
|
1987
1989
|
var endTagName = "end" + tagName;
|
|
1988
1990
|
var rawBlockRegex = new RegExp("([\\s\\S]*?){%\\s*(" + tagName + "|" + endTagName + ")\\s*(?=%})%}");
|
|
1989
1991
|
var rawLevel = 1;
|
|
1990
|
-
var
|
|
1992
|
+
var str2 = "";
|
|
1991
1993
|
var matches = null;
|
|
1992
1994
|
var begun = this.advanceAfterBlockEnd();
|
|
1993
1995
|
while ((matches = this.tokens._extractRegex(rawBlockRegex)) && rawLevel > 0) {
|
|
@@ -2000,13 +2002,13 @@ var require_parser = __commonJS({
|
|
|
2000
2002
|
rawLevel -= 1;
|
|
2001
2003
|
}
|
|
2002
2004
|
if (rawLevel === 0) {
|
|
2003
|
-
|
|
2005
|
+
str2 += pre;
|
|
2004
2006
|
this.tokens.backN(all.length - pre.length);
|
|
2005
2007
|
} else {
|
|
2006
|
-
|
|
2008
|
+
str2 += all;
|
|
2007
2009
|
}
|
|
2008
2010
|
}
|
|
2009
|
-
return new nodes.Output(begun.lineno, begun.colno, [new nodes.TemplateData(begun.lineno, begun.colno,
|
|
2011
|
+
return new nodes.Output(begun.lineno, begun.colno, [new nodes.TemplateData(begun.lineno, begun.colno, str2)]);
|
|
2010
2012
|
};
|
|
2011
2013
|
_proto.parsePostfix = function parsePostfix(node) {
|
|
2012
2014
|
var lookup;
|
|
@@ -3295,9 +3297,9 @@ var require_compiler = __commonJS({
|
|
|
3295
3297
|
}
|
|
3296
3298
|
this._emit(")) === true");
|
|
3297
3299
|
};
|
|
3298
|
-
_proto._binOpEmitter = function _binOpEmitter(node, frame,
|
|
3300
|
+
_proto._binOpEmitter = function _binOpEmitter(node, frame, str2) {
|
|
3299
3301
|
this.compile(node.left, frame);
|
|
3300
|
-
this._emit(
|
|
3302
|
+
this._emit(str2);
|
|
3301
3303
|
this.compile(node.right, frame);
|
|
3302
3304
|
};
|
|
3303
3305
|
_proto.compileOr = function compileOr(node, frame) {
|
|
@@ -4063,22 +4065,22 @@ var require_filters = __commonJS({
|
|
|
4063
4065
|
return res;
|
|
4064
4066
|
}
|
|
4065
4067
|
_exports.batch = batch;
|
|
4066
|
-
function capitalize(
|
|
4067
|
-
|
|
4068
|
-
var ret =
|
|
4069
|
-
return r.copySafeness(
|
|
4068
|
+
function capitalize(str2) {
|
|
4069
|
+
str2 = normalize(str2, "");
|
|
4070
|
+
var ret = str2.toLowerCase();
|
|
4071
|
+
return r.copySafeness(str2, ret.charAt(0).toUpperCase() + ret.slice(1));
|
|
4070
4072
|
}
|
|
4071
4073
|
_exports.capitalize = capitalize;
|
|
4072
|
-
function center(
|
|
4073
|
-
|
|
4074
|
+
function center(str2, width) {
|
|
4075
|
+
str2 = normalize(str2, "");
|
|
4074
4076
|
width = width || 80;
|
|
4075
|
-
if (
|
|
4076
|
-
return
|
|
4077
|
+
if (str2.length >= width) {
|
|
4078
|
+
return str2;
|
|
4077
4079
|
}
|
|
4078
|
-
var spaces = width -
|
|
4080
|
+
var spaces = width - str2.length;
|
|
4079
4081
|
var pre = lib.repeat(" ", spaces / 2 - spaces % 2);
|
|
4080
4082
|
var post = lib.repeat(" ", spaces / 2);
|
|
4081
|
-
return r.copySafeness(
|
|
4083
|
+
return r.copySafeness(str2, pre + str2 + post);
|
|
4082
4084
|
}
|
|
4083
4085
|
_exports.center = center;
|
|
4084
4086
|
function default_(val, def, bool) {
|
|
@@ -4125,47 +4127,47 @@ var require_filters = __commonJS({
|
|
|
4125
4127
|
return JSON.stringify(obj, null, spaces);
|
|
4126
4128
|
}
|
|
4127
4129
|
_exports.dump = dump;
|
|
4128
|
-
function escape(
|
|
4129
|
-
if (
|
|
4130
|
-
return
|
|
4130
|
+
function escape(str2) {
|
|
4131
|
+
if (str2 instanceof r.SafeString) {
|
|
4132
|
+
return str2;
|
|
4131
4133
|
}
|
|
4132
|
-
|
|
4133
|
-
return r.markSafe(lib.escape(
|
|
4134
|
+
str2 = str2 === null || str2 === void 0 ? "" : str2;
|
|
4135
|
+
return r.markSafe(lib.escape(str2.toString()));
|
|
4134
4136
|
}
|
|
4135
4137
|
_exports.escape = escape;
|
|
4136
|
-
function safe2(
|
|
4137
|
-
if (
|
|
4138
|
-
return
|
|
4138
|
+
function safe2(str2) {
|
|
4139
|
+
if (str2 instanceof r.SafeString) {
|
|
4140
|
+
return str2;
|
|
4139
4141
|
}
|
|
4140
|
-
|
|
4141
|
-
return r.markSafe(
|
|
4142
|
+
str2 = str2 === null || str2 === void 0 ? "" : str2;
|
|
4143
|
+
return r.markSafe(str2.toString());
|
|
4142
4144
|
}
|
|
4143
4145
|
_exports.safe = safe2;
|
|
4144
4146
|
function first(arr) {
|
|
4145
4147
|
return arr[0];
|
|
4146
4148
|
}
|
|
4147
4149
|
_exports.first = first;
|
|
4148
|
-
function forceescape(
|
|
4149
|
-
|
|
4150
|
-
return r.markSafe(lib.escape(
|
|
4150
|
+
function forceescape(str2) {
|
|
4151
|
+
str2 = str2 === null || str2 === void 0 ? "" : str2;
|
|
4152
|
+
return r.markSafe(lib.escape(str2.toString()));
|
|
4151
4153
|
}
|
|
4152
4154
|
_exports.forceescape = forceescape;
|
|
4153
4155
|
function groupby(arr, attr) {
|
|
4154
4156
|
return lib.groupBy(arr, attr, this.env.opts.throwOnUndefined);
|
|
4155
4157
|
}
|
|
4156
4158
|
_exports.groupby = groupby;
|
|
4157
|
-
function indent(
|
|
4158
|
-
|
|
4159
|
-
if (
|
|
4159
|
+
function indent(str2, width, indentfirst) {
|
|
4160
|
+
str2 = normalize(str2, "");
|
|
4161
|
+
if (str2 === "") {
|
|
4160
4162
|
return "";
|
|
4161
4163
|
}
|
|
4162
4164
|
width = width || 4;
|
|
4163
|
-
var lines =
|
|
4165
|
+
var lines = str2.split("\n");
|
|
4164
4166
|
var sp = lib.repeat(" ", width);
|
|
4165
4167
|
var res = lines.map(function(l, i) {
|
|
4166
4168
|
return i === 0 && !indentfirst ? l : "" + sp + l;
|
|
4167
4169
|
}).join("\n");
|
|
4168
|
-
return r.copySafeness(
|
|
4170
|
+
return r.copySafeness(str2, res);
|
|
4169
4171
|
}
|
|
4170
4172
|
_exports.indent = indent;
|
|
4171
4173
|
function join(arr, del, attr) {
|
|
@@ -4214,16 +4216,16 @@ var require_filters = __commonJS({
|
|
|
4214
4216
|
}
|
|
4215
4217
|
}
|
|
4216
4218
|
_exports.list = list;
|
|
4217
|
-
function lower(
|
|
4218
|
-
|
|
4219
|
-
return
|
|
4219
|
+
function lower(str2) {
|
|
4220
|
+
str2 = normalize(str2, "");
|
|
4221
|
+
return str2.toLowerCase();
|
|
4220
4222
|
}
|
|
4221
4223
|
_exports.lower = lower;
|
|
4222
|
-
function nl2br(
|
|
4223
|
-
if (
|
|
4224
|
+
function nl2br(str2) {
|
|
4225
|
+
if (str2 === null || str2 === void 0) {
|
|
4224
4226
|
return "";
|
|
4225
4227
|
}
|
|
4226
|
-
return r.copySafeness(
|
|
4228
|
+
return r.copySafeness(str2, str2.replace(/\r\n|\n/g, "<br />\n"));
|
|
4227
4229
|
}
|
|
4228
4230
|
_exports.nl2br = nl2br;
|
|
4229
4231
|
function random(arr) {
|
|
@@ -4257,10 +4259,10 @@ var require_filters = __commonJS({
|
|
|
4257
4259
|
});
|
|
4258
4260
|
}
|
|
4259
4261
|
_exports.selectattr = selectattr;
|
|
4260
|
-
function replace(
|
|
4261
|
-
var originalStr =
|
|
4262
|
+
function replace(str2, old, new_, maxCount) {
|
|
4263
|
+
var originalStr = str2;
|
|
4262
4264
|
if (old instanceof RegExp) {
|
|
4263
|
-
return
|
|
4265
|
+
return str2.replace(old, new_);
|
|
4264
4266
|
}
|
|
4265
4267
|
if (typeof maxCount === "undefined") {
|
|
4266
4268
|
maxCount = -1;
|
|
@@ -4269,32 +4271,32 @@ var require_filters = __commonJS({
|
|
|
4269
4271
|
if (typeof old === "number") {
|
|
4270
4272
|
old = "" + old;
|
|
4271
4273
|
} else if (typeof old !== "string") {
|
|
4272
|
-
return
|
|
4274
|
+
return str2;
|
|
4273
4275
|
}
|
|
4274
|
-
if (typeof
|
|
4275
|
-
|
|
4276
|
+
if (typeof str2 === "number") {
|
|
4277
|
+
str2 = "" + str2;
|
|
4276
4278
|
}
|
|
4277
|
-
if (typeof
|
|
4278
|
-
return
|
|
4279
|
+
if (typeof str2 !== "string" && !(str2 instanceof r.SafeString)) {
|
|
4280
|
+
return str2;
|
|
4279
4281
|
}
|
|
4280
4282
|
if (old === "") {
|
|
4281
|
-
res = new_ +
|
|
4282
|
-
return r.copySafeness(
|
|
4283
|
+
res = new_ + str2.split("").join(new_) + new_;
|
|
4284
|
+
return r.copySafeness(str2, res);
|
|
4283
4285
|
}
|
|
4284
|
-
var nextIndex =
|
|
4286
|
+
var nextIndex = str2.indexOf(old);
|
|
4285
4287
|
if (maxCount === 0 || nextIndex === -1) {
|
|
4286
|
-
return
|
|
4288
|
+
return str2;
|
|
4287
4289
|
}
|
|
4288
4290
|
var pos = 0;
|
|
4289
4291
|
var count = 0;
|
|
4290
4292
|
while (nextIndex > -1 && (maxCount === -1 || count < maxCount)) {
|
|
4291
|
-
res +=
|
|
4293
|
+
res += str2.substring(pos, nextIndex) + new_;
|
|
4292
4294
|
pos = nextIndex + old.length;
|
|
4293
4295
|
count++;
|
|
4294
|
-
nextIndex =
|
|
4296
|
+
nextIndex = str2.indexOf(old, pos);
|
|
4295
4297
|
}
|
|
4296
|
-
if (pos <
|
|
4297
|
-
res +=
|
|
4298
|
+
if (pos < str2.length) {
|
|
4299
|
+
res += str2.substring(pos);
|
|
4298
4300
|
}
|
|
4299
4301
|
return r.copySafeness(originalStr, res);
|
|
4300
4302
|
}
|
|
@@ -4406,16 +4408,16 @@ var require_filters = __commonJS({
|
|
|
4406
4408
|
return r.copySafeness(input, res);
|
|
4407
4409
|
}
|
|
4408
4410
|
_exports.striptags = striptags;
|
|
4409
|
-
function title(
|
|
4410
|
-
|
|
4411
|
-
var words =
|
|
4411
|
+
function title(str2) {
|
|
4412
|
+
str2 = normalize(str2, "");
|
|
4413
|
+
var words = str2.split(" ").map(function(word) {
|
|
4412
4414
|
return capitalize(word);
|
|
4413
4415
|
});
|
|
4414
|
-
return r.copySafeness(
|
|
4416
|
+
return r.copySafeness(str2, words.join(" "));
|
|
4415
4417
|
}
|
|
4416
4418
|
_exports.title = title;
|
|
4417
|
-
function trim(
|
|
4418
|
-
return r.copySafeness(
|
|
4419
|
+
function trim(str2) {
|
|
4420
|
+
return r.copySafeness(str2, str2.replace(/^\s*|\s*$/g, ""));
|
|
4419
4421
|
}
|
|
4420
4422
|
_exports.trim = trim;
|
|
4421
4423
|
function truncate(input, length, killwords, end) {
|
|
@@ -4438,9 +4440,9 @@ var require_filters = __commonJS({
|
|
|
4438
4440
|
return r.copySafeness(orig, input);
|
|
4439
4441
|
}
|
|
4440
4442
|
_exports.truncate = truncate;
|
|
4441
|
-
function upper(
|
|
4442
|
-
|
|
4443
|
-
return
|
|
4443
|
+
function upper(str2) {
|
|
4444
|
+
str2 = normalize(str2, "");
|
|
4445
|
+
return str2.toUpperCase();
|
|
4444
4446
|
}
|
|
4445
4447
|
_exports.upper = upper;
|
|
4446
4448
|
function urlencode(obj) {
|
|
@@ -4461,12 +4463,12 @@ var require_filters = __commonJS({
|
|
|
4461
4463
|
var httpHttpsRe = /^https?:\/\/.*$/;
|
|
4462
4464
|
var wwwRe = /^www\./;
|
|
4463
4465
|
var tldRe = /\.(?:org|net|com)(?:\:|\/|$)/;
|
|
4464
|
-
function urlize(
|
|
4466
|
+
function urlize(str2, length, nofollow) {
|
|
4465
4467
|
if (isNaN(length)) {
|
|
4466
4468
|
length = Infinity;
|
|
4467
4469
|
}
|
|
4468
4470
|
var noFollowAttr = nofollow === true ? ' rel="nofollow"' : "";
|
|
4469
|
-
var words =
|
|
4471
|
+
var words = str2.split(/(\s+)/).filter(function(word) {
|
|
4470
4472
|
return word && word.length;
|
|
4471
4473
|
}).map(function(word) {
|
|
4472
4474
|
var matches = word.match(puncRe);
|
|
@@ -4489,9 +4491,9 @@ var require_filters = __commonJS({
|
|
|
4489
4491
|
return words.join("");
|
|
4490
4492
|
}
|
|
4491
4493
|
_exports.urlize = urlize;
|
|
4492
|
-
function wordcount(
|
|
4493
|
-
|
|
4494
|
-
var words =
|
|
4494
|
+
function wordcount(str2) {
|
|
4495
|
+
str2 = normalize(str2, "");
|
|
4496
|
+
var words = str2 ? str2.match(/\w+/g) : null;
|
|
4495
4497
|
return words ? words.length : null;
|
|
4496
4498
|
}
|
|
4497
4499
|
_exports.wordcount = wordcount;
|
|
@@ -5508,7 +5510,7 @@ var require_precompile = __commonJS({
|
|
|
5508
5510
|
return filename.match(pattern);
|
|
5509
5511
|
});
|
|
5510
5512
|
}
|
|
5511
|
-
function precompileString(
|
|
5513
|
+
function precompileString(str2, opts) {
|
|
5512
5514
|
opts = opts || {};
|
|
5513
5515
|
opts.isString = true;
|
|
5514
5516
|
var env = opts.env || new Environment([]);
|
|
@@ -5516,7 +5518,7 @@ var require_precompile = __commonJS({
|
|
|
5516
5518
|
if (!opts.name) {
|
|
5517
5519
|
throw new Error('the "name" option is required when compiling a string');
|
|
5518
5520
|
}
|
|
5519
|
-
return wrapper([_precompile(
|
|
5521
|
+
return wrapper([_precompile(str2, opts.name, env)], opts);
|
|
5520
5522
|
}
|
|
5521
5523
|
function precompile(input, opts) {
|
|
5522
5524
|
opts = opts || {};
|
|
@@ -5562,14 +5564,14 @@ var require_precompile = __commonJS({
|
|
|
5562
5564
|
}
|
|
5563
5565
|
return wrapper(precompiled, opts);
|
|
5564
5566
|
}
|
|
5565
|
-
function _precompile(
|
|
5567
|
+
function _precompile(str2, name, env) {
|
|
5566
5568
|
env = env || new Environment([]);
|
|
5567
5569
|
var asyncFilters = env.asyncFilters;
|
|
5568
5570
|
var extensions = env.extensionsList;
|
|
5569
5571
|
var template;
|
|
5570
5572
|
name = name.replace(/\\/g, "/");
|
|
5571
5573
|
try {
|
|
5572
|
-
template = compiler.compile(
|
|
5574
|
+
template = compiler.compile(str2, asyncFilters, extensions, name, env.opts);
|
|
5573
5575
|
} catch (err) {
|
|
5574
5576
|
throw _prettifyError(name, false, err);
|
|
5575
5577
|
}
|
|
@@ -6086,12 +6088,26 @@ var dedent = (lines, by) => trimStart(lines).map((line) => {
|
|
|
6086
6088
|
});
|
|
6087
6089
|
var ADMONITION = /^([ \t]*)(!!!|\?\?\?\+?)[ \t]*([\w-]+(?:[ \t]+[\w-]+)*)?(?:[ \t]+"(.*?)")?[ \t]*$/;
|
|
6088
6090
|
var TAB = /^([ \t]*)===([+!]{0,2})[ \t]+"(.*?)"[ \t]*$/;
|
|
6091
|
+
var REFERENCE = /^ {0,3}\[[^\]]+\]:[ \t]*\S+(?:[ \t]+(?:"[^"]*"|'[^']*'|\([^)]*\)))?[ \t]*$/;
|
|
6089
6092
|
function pythonMarkdownBlocks(source, options) {
|
|
6090
6093
|
if (!(options.admonitions && /^[ \t]*(?:!!!|\?\?\?)/m.test(source)) && !(options.tabs && /^[ \t]*===/m.test(source))) return source;
|
|
6091
6094
|
const counter = { sets: 0 };
|
|
6092
|
-
|
|
6095
|
+
const lines = source.split("\n");
|
|
6096
|
+
let refs;
|
|
6097
|
+
const title = (text) => {
|
|
6098
|
+
if (!options.title) return escapeHtml(text);
|
|
6099
|
+
if (refs === void 0) {
|
|
6100
|
+
const found = [];
|
|
6101
|
+
outsideFences(lines, (line) => {
|
|
6102
|
+
if (REFERENCE.test(line)) found.push(line.trim());
|
|
6103
|
+
});
|
|
6104
|
+
refs = found.join("\n");
|
|
6105
|
+
}
|
|
6106
|
+
return options.title(text, text.includes("[") ? refs : "");
|
|
6107
|
+
};
|
|
6108
|
+
return convertBlocks(lines, options, counter, title).join("\n");
|
|
6093
6109
|
}
|
|
6094
|
-
function convertBlocks(lines, options, counter) {
|
|
6110
|
+
function convertBlocks(lines, options, counter, title) {
|
|
6095
6111
|
const out = [];
|
|
6096
6112
|
let copied = 0;
|
|
6097
6113
|
const flush = (to) => {
|
|
@@ -6105,14 +6121,14 @@ function convertBlocks(lines, options, counter) {
|
|
|
6105
6121
|
flush(i);
|
|
6106
6122
|
const pad = a[1];
|
|
6107
6123
|
const end = blockBody(lines, i + 1, pad.length);
|
|
6108
|
-
const body = convertBlocks(dedent(lines.slice(i + 1, end), pad.length + 4), options, counter);
|
|
6124
|
+
const body = convertBlocks(dedent(lines.slice(i + 1, end), pad.length + 4), options, counter, title);
|
|
6109
6125
|
const classes = (a[3] ?? "note").trim().split(/[ \t]+/).join(" ");
|
|
6110
6126
|
const first = classes.split(" ")[0];
|
|
6111
|
-
const
|
|
6127
|
+
const heading = a[4] ?? first[0].toUpperCase() + first.slice(1);
|
|
6112
6128
|
const details = a[2] !== "!!!";
|
|
6113
|
-
const open = details ? `<details class="${escapeHtml(classes)}"${a[2] === "???+" ? ' open="open"' : ""}>${
|
|
6114
|
-
${pad}<summary>${
|
|
6115
|
-
${pad}<p class="admonition-title">${
|
|
6129
|
+
const open = details ? `<details class="${escapeHtml(classes)}"${a[2] === "???+" ? ' open="open"' : ""}>${heading === "" ? "" : `
|
|
6130
|
+
${pad}<summary>${title(heading)}</summary>`}` : `<div class="admonition ${escapeHtml(classes)}">${heading === "" ? "" : `
|
|
6131
|
+
${pad}<p class="admonition-title">${title(heading)}</p>`}`;
|
|
6116
6132
|
out.push(`${pad}${open}`, "", ...body.map((l) => l === "" ? l : pad + l), "", `${pad}${details ? "</details>" : "</div>"}`);
|
|
6117
6133
|
copied = end;
|
|
6118
6134
|
return end;
|
|
@@ -6127,7 +6143,7 @@ ${pad}<p class="admonition-title">${escapeHtml(title)}</p>`}`;
|
|
|
6127
6143
|
const m = TAB.exec(lines[at] ?? "");
|
|
6128
6144
|
if (!m || m[1] !== pad || tabs.length && m[2].includes("!")) break;
|
|
6129
6145
|
const end = blockBody(lines, at + 1, pad.length);
|
|
6130
|
-
tabs.push({ title: m[3], selected: m[2].includes("+"), body: convertBlocks(dedent(lines.slice(at + 1, end), pad.length + 4), options, counter) });
|
|
6146
|
+
tabs.push({ title: m[3], selected: m[2].includes("+"), body: convertBlocks(dedent(lines.slice(at + 1, end), pad.length + 4), options, counter, title) });
|
|
6131
6147
|
let next = end;
|
|
6132
6148
|
while (next < lines.length && lines[next].trim() === "") next++;
|
|
6133
6149
|
if (!TAB.test(lines[next] ?? "")) {
|
|
@@ -6139,7 +6155,7 @@ ${pad}<p class="admonition-title">${escapeHtml(title)}</p>`}`;
|
|
|
6139
6155
|
const set = ++counter.sets;
|
|
6140
6156
|
const selected = Math.max(0, tabs.findIndex((tab) => tab.selected));
|
|
6141
6157
|
const inputs = tabs.map((_, n) => `<input${n === selected ? ' checked="checked"' : ""} id="__tabbed_${set}_${n + 1}" name="__tabbed_${set}" type="radio" />`).join("");
|
|
6142
|
-
const labels = tabs.map((tab, n) => `<label for="__tabbed_${set}_${n + 1}">${
|
|
6158
|
+
const labels = tabs.map((tab, n) => `<label for="__tabbed_${set}_${n + 1}">${title(tab.title)}</label>`).join("");
|
|
6143
6159
|
out.push(`${pad}<div class="tabbed-set tabbed-alternate" data-tabs="${set}:${tabs.length}">${inputs}<div class="tabbed-labels">${labels}</div>`, `${pad}<div class="tabbed-content">`);
|
|
6144
6160
|
for (const tab of tabs) out.push(`${pad}<div class="tabbed-block">`, "", ...tab.body.map((l) => l === "" ? l : pad + l), "", `${pad}</div>`);
|
|
6145
6161
|
out.push(`${pad}</div>`, `${pad}</div>`);
|
|
@@ -6150,10 +6166,61 @@ ${pad}<p class="admonition-title">${escapeHtml(title)}</p>`}`;
|
|
|
6150
6166
|
flush(lines.length);
|
|
6151
6167
|
return out;
|
|
6152
6168
|
}
|
|
6153
|
-
var SHORTCODE_LINE = /^([ \t]*)\{\{([<%])[ \t]*(\/?)[ \t]*([\w./-]
|
|
6154
|
-
function hugoShortcodes(source) {
|
|
6169
|
+
var SHORTCODE_LINE = /^([ \t]*)\{\{([<%])[ \t]*(\/?)[ \t]*(\w[\w./-]*)((?:[^}]|\}(?!\}))*?)[ \t]*(\/?)[ \t]*[>%]\}\}[ \t]*$/;
|
|
6170
|
+
function hugoShortcodes(source, inline, hasTemplate) {
|
|
6155
6171
|
if (!source.includes("{{<") && !source.includes("{{%")) return source;
|
|
6156
|
-
|
|
6172
|
+
let out = shortcodeContainers(source);
|
|
6173
|
+
if (inline && hasTemplate) out = inlineShortcodes(out, inline, hasTemplate);
|
|
6174
|
+
return unescapeShortcodes(out);
|
|
6175
|
+
}
|
|
6176
|
+
var MARK_OPEN = "\uE020";
|
|
6177
|
+
var MARK_CLOSE = "\uE021";
|
|
6178
|
+
var inlineShortcodeMarker = (n) => MARK_OPEN + [...String(n)].map((d) => String.fromCharCode(57392 + Number(d))).join("") + MARK_CLOSE;
|
|
6179
|
+
var INLINE_SHORTCODE_MARKER = /([-]+)|%EE%80%A0((?:%EE%80%B[0-9])+)%EE%80%A1/gi;
|
|
6180
|
+
function inlineShortcodeNumber(plain, encoded) {
|
|
6181
|
+
if (plain) return Number([...plain].map((c) => c.charCodeAt(0) - 57392).join(""));
|
|
6182
|
+
return Number((encoded ?? "").replace(/%EE%80%B([0-9])/gi, "$1"));
|
|
6183
|
+
}
|
|
6184
|
+
var SHORTCODE_TAG = /\{\{([<%])[ \t]*(\/?)[ \t]*(\w[\w./-]*)((?:[^}]|\}(?!\}))*?)[ \t]*(\/?)[ \t]*[>%]\}\}/g;
|
|
6185
|
+
function inlineShortcodes(source, found, hasTemplate) {
|
|
6186
|
+
const lines = source.split("\n");
|
|
6187
|
+
outsideFences(lines, (line, i) => {
|
|
6188
|
+
if (!line.includes("{{<") && !line.includes("{{%")) return;
|
|
6189
|
+
const tags = [];
|
|
6190
|
+
for (const m of line.matchAll(SHORTCODE_TAG)) tags.push({ start: m.index, end: m.index + m[0].length, name: m[3], args: m[4].trim(), closing: m[2] === "/", self: m[5] === "/" });
|
|
6191
|
+
const spans = [];
|
|
6192
|
+
const open = [];
|
|
6193
|
+
for (const tag of tags) {
|
|
6194
|
+
if (!tag.closing) {
|
|
6195
|
+
if (tag.self) spans.push({ start: tag.start, end: tag.end, call: { name: tag.name, args: tag.args, inner: void 0 } });
|
|
6196
|
+
else open.push(tag);
|
|
6197
|
+
continue;
|
|
6198
|
+
}
|
|
6199
|
+
const k = open.findLastIndex((o2) => o2.name === tag.name);
|
|
6200
|
+
if (k === -1) continue;
|
|
6201
|
+
const o = open[k];
|
|
6202
|
+
open.length = k;
|
|
6203
|
+
spans.push({ start: o.start, end: tag.end, call: { name: o.name, args: o.args, inner: line.slice(o.end, tag.start) } });
|
|
6204
|
+
}
|
|
6205
|
+
for (const o of open) spans.push({ start: o.start, end: o.end, call: { name: o.name, args: o.args, inner: void 0 } });
|
|
6206
|
+
spans.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
6207
|
+
const heading = /^ {0,3}#{1,6}[ \t]+/.exec(line)?.[0].length;
|
|
6208
|
+
let out = "";
|
|
6209
|
+
let at = 0;
|
|
6210
|
+
for (const span of spans) {
|
|
6211
|
+
if (span.start < at || !hasTemplate(span.call.name)) continue;
|
|
6212
|
+
let { start, end } = span;
|
|
6213
|
+
if (heading !== void 0) {
|
|
6214
|
+
while (start > Math.max(at, heading) && /[ \t]/.test(line[start - 1])) start--;
|
|
6215
|
+
if (start === heading) while (end < line.length && /[ \t]/.test(line[end])) end++;
|
|
6216
|
+
if (start !== span.start || end !== span.end) span.call.spaces = [line.slice(start, span.start), line.slice(span.end, end)];
|
|
6217
|
+
}
|
|
6218
|
+
out += line.slice(at, start) + inlineShortcodeMarker(found.push(span.call) - 1);
|
|
6219
|
+
at = end;
|
|
6220
|
+
}
|
|
6221
|
+
if (at) lines[i] = out + line.slice(at);
|
|
6222
|
+
});
|
|
6223
|
+
return lines.join("\n");
|
|
6157
6224
|
}
|
|
6158
6225
|
var unescapeShortcodes = (text) => text.replace(/\{\{([<%])\/\*/g, "{{$1").replace(/\*\/([>%])\}\}/g, "$1}}");
|
|
6159
6226
|
function shortcodeContainers(source) {
|
|
@@ -6336,7 +6403,7 @@ var WebAssembly = globalThis.WebAssembly;
|
|
|
6336
6403
|
// src/engines/markdown.ts
|
|
6337
6404
|
function loadHookTemplates(dir, name, engines, chain) {
|
|
6338
6405
|
const out = /* @__PURE__ */ new Map();
|
|
6339
|
-
for (const kind of ["hooks", "containers"]) {
|
|
6406
|
+
for (const kind of ["hooks", "containers", "components"]) {
|
|
6340
6407
|
let files2;
|
|
6341
6408
|
try {
|
|
6342
6409
|
files2 = fs.readdirSync(path2.join(dir, kind));
|
|
@@ -6447,19 +6514,45 @@ var WasmMarkdown = class {
|
|
|
6447
6514
|
* function or a hook never runs twice. Without functions, it's one render.
|
|
6448
6515
|
*/
|
|
6449
6516
|
render(source, data, _ctx) {
|
|
6517
|
+
const pre = this.#options.preprocess;
|
|
6518
|
+
if (pre) {
|
|
6519
|
+
const check = (out2) => {
|
|
6520
|
+
if (typeof out2 !== "string") throw new BuildError(`markdown.preprocess gave ${out2 === null ? "null" : typeof out2} for ${page ?? pageOf(data) ?? "a page"}: return the page's Markdown as a string`);
|
|
6521
|
+
return out2;
|
|
6522
|
+
};
|
|
6523
|
+
let out;
|
|
6524
|
+
try {
|
|
6525
|
+
out = pre(source, data);
|
|
6526
|
+
} catch (e) {
|
|
6527
|
+
throw context(e, "markdown.preprocess");
|
|
6528
|
+
}
|
|
6529
|
+
if (out instanceof Promise) return out.then((text) => this.#render(check(text), data), (e) => {
|
|
6530
|
+
throw context(e, "markdown.preprocess");
|
|
6531
|
+
});
|
|
6532
|
+
return this.#render(check(out), data);
|
|
6533
|
+
}
|
|
6534
|
+
return this.#render(source, data);
|
|
6535
|
+
}
|
|
6536
|
+
#render(source, data) {
|
|
6450
6537
|
const file = page ?? pageOf(data);
|
|
6451
6538
|
this.#ready();
|
|
6452
6539
|
const python = this.#options.dialect === "python-markdown" ? pythonMarkdownBefore(source) : void 0;
|
|
6453
6540
|
if (python) source = python.source;
|
|
6454
|
-
|
|
6541
|
+
const steps = this.#options.steps;
|
|
6542
|
+
const stepContext = steps.before.length || steps.after.length ? this.#context(data, file) : void 0;
|
|
6543
|
+
for (const [where, step] of steps.before) source = this.#step(step, source, stepContext, where, "before");
|
|
6544
|
+
const shortcodes = [];
|
|
6545
|
+
source = this.#dialects(source, shortcodes, data, file);
|
|
6455
6546
|
const links = this.#options.sourceLinks;
|
|
6456
6547
|
const ids = this.#options.sluggerFn === pythonMarkdownSlug;
|
|
6457
6548
|
const after = (html) => {
|
|
6549
|
+
if (shortcodes.length) html = this.#inlineShortcodes(html, shortcodes, data, file);
|
|
6458
6550
|
if (links) html = sourceLinks(html, data, links, this.#inputRoot);
|
|
6459
6551
|
if (ids) html = pythonMarkdownIds(html);
|
|
6552
|
+
for (const [where, step] of steps.after) html = this.#step(step, html, stepContext, where, "after");
|
|
6460
6553
|
return python ? pythonMarkdownAfter(html, python.raw) : html;
|
|
6461
6554
|
};
|
|
6462
|
-
const changes = Boolean(links || ids || python);
|
|
6555
|
+
const changes = Boolean(links || ids || python || steps.after.length || shortcodes.length);
|
|
6463
6556
|
if (!this.#options.htmlMarkdown) {
|
|
6464
6557
|
const out2 = this.#page(source, data, file);
|
|
6465
6558
|
if (!changes) return out2;
|
|
@@ -6469,12 +6562,37 @@ var WasmMarkdown = class {
|
|
|
6469
6562
|
return typeof out === "string" ? after(restoreBlankLines(out)) : out.then((html) => after(restoreBlankLines(html)));
|
|
6470
6563
|
}
|
|
6471
6564
|
/** Other generators' syntax as ssqch's (markdown-dialects.ts): Hugo's shortcodes as containers, MkDocs' blocks as Python-Markdown's HTML. */
|
|
6472
|
-
#dialects(source) {
|
|
6565
|
+
#dialects(source, inline, data = {}, file = page) {
|
|
6473
6566
|
const o = this.#options;
|
|
6474
|
-
if (o.shortcodes === "hugo") source = hugoShortcodes(source);
|
|
6475
|
-
|
|
6567
|
+
if (o.shortcodes === "hugo") source = hugoShortcodes(source, inline, (name) => this.#hooks.has(`containers/${name}`));
|
|
6568
|
+
const title = (text, refs) => this.#markdown(refs ? `${text}
|
|
6569
|
+
|
|
6570
|
+
${refs}` : text, HOOKS | INLINE2, data, file, void 0, "an admonition's or a tab's title");
|
|
6571
|
+
if (o.admonitions || o.tabs) source = pythonMarkdownBlocks(source, { admonitions: o.admonitions === "mkdocs", tabs: o.tabs === "mkdocs", title });
|
|
6476
6572
|
return source;
|
|
6477
6573
|
}
|
|
6574
|
+
/**
|
|
6575
|
+
* Hugo's shortcodes inside a line of text, each through its container template, in place of
|
|
6576
|
+
* the marker `#dialects` left: `container.content` is what's between its tags as inline
|
|
6577
|
+
* Markdown (its own shortcodes too) and `container.source` that as written, and
|
|
6578
|
+
* `container.inline` is true. What the template writes goes in as it is, as Hugo puts in a
|
|
6579
|
+
* `{{< >}}` shortcode's output.
|
|
6580
|
+
*/
|
|
6581
|
+
#inlineShortcodes(html, calls, data, file) {
|
|
6582
|
+
return html.replace(INLINE_SHORTCODE_MARKER, (whole, plain, encoded) => {
|
|
6583
|
+
const call = calls[inlineShortcodeNumber(plain, encoded)];
|
|
6584
|
+
if (!call) return whole;
|
|
6585
|
+
let content = "";
|
|
6586
|
+
if (call.inner !== void 0) {
|
|
6587
|
+
const inner = [];
|
|
6588
|
+
const text = hugoShortcodes(call.inner, inner, (name) => this.#hooks.has(`containers/${name}`));
|
|
6589
|
+
content = this.#markdown(text, HOOKS | INLINE2, data, file, void 0, `the inside of {{< ${call.name} >}}`);
|
|
6590
|
+
if (inner.length) content = this.#inlineShortcodes(content, inner, data, file);
|
|
6591
|
+
}
|
|
6592
|
+
const out = this.renderHook(`containers/${call.name}`, "container", { name: call.name, args: call.args, content, source: call.inner ?? "", inline: true }, data);
|
|
6593
|
+
return call.spaces ? call.spaces[0] + out + call.spaces[1] : out;
|
|
6594
|
+
});
|
|
6595
|
+
}
|
|
6478
6596
|
#page(source, data, file) {
|
|
6479
6597
|
if (!this.#functions.length) return this.#markdown(source, HOOKS, data, file);
|
|
6480
6598
|
let asked;
|
|
@@ -6486,9 +6604,10 @@ var WasmMarkdown = class {
|
|
|
6486
6604
|
return this.#answer(asked, (answers) => this.#markdown(source, HOOKS, data, file, answers));
|
|
6487
6605
|
}
|
|
6488
6606
|
html(text, inline) {
|
|
6489
|
-
|
|
6490
|
-
if (
|
|
6491
|
-
|
|
6607
|
+
const shortcodes = [];
|
|
6608
|
+
if (!inline) text = this.#dialects(text, shortcodes);
|
|
6609
|
+
const html = this.#options.htmlMarkdown ? restoreBlankLines(this.#markdown(this.#inHtml(text, HOOKS, {}, page, "markdown() in a template"), HOOKS | (inline ? INLINE2 : 0), {}, page, void 0, "markdown() in a template")) : this.#markdown(text, HOOKS | (inline ? INLINE2 : 0), {}, page, void 0, "markdown() in a template");
|
|
6610
|
+
return shortcodes.length ? this.#inlineShortcodes(html, shortcodes, {}, page) : html;
|
|
6492
6611
|
}
|
|
6493
6612
|
plain(text, inline) {
|
|
6494
6613
|
if (this.#options.htmlMarkdown) return restoreBlankLines(this.#markdown(this.#inHtml(text, 0, {}, page, 'markdown() from "ssqch"'), inline ? INLINE2 : 0, {}, page, void 0, 'markdown() from "ssqch"'));
|
|
@@ -6665,18 +6784,18 @@ var WasmMarkdown = class {
|
|
|
6665
6784
|
breaks: o.breaks,
|
|
6666
6785
|
figures: o.figures,
|
|
6667
6786
|
alerts: o.alerts,
|
|
6668
|
-
|
|
6787
|
+
// The wasm's markdown-it reading of a closing `:::`, which is ssqch's own now.
|
|
6788
|
+
containers: o.containers ? "markdown-it" : false,
|
|
6669
6789
|
definitionLists: o.definitionLists,
|
|
6670
6790
|
smartPunctuation: o.smartPunctuation,
|
|
6671
6791
|
indentedCode: o.indentedCode,
|
|
6672
|
-
encodeUrls: o.encodeUrls,
|
|
6673
6792
|
highlight: o.highlight,
|
|
6674
6793
|
highlightCss: o.highlightCss,
|
|
6675
6794
|
highlightClasses: o.highlightClasses,
|
|
6676
6795
|
languages,
|
|
6677
6796
|
headingIdsFunction: o.sluggerFn ? number(o.sluggerFn, "markdown.headingIds", true) : null,
|
|
6678
6797
|
// `slot` is ssqch's container: it always calls back, to be kept for its parent.
|
|
6679
|
-
hooks: [...this.#hooks.keys(), "containers/slot"],
|
|
6798
|
+
hooks: [...this.#hooks.keys(), ...this.#builtinHooks().filter((name) => !this.#hooks.has(name)), "containers/slot"],
|
|
6680
6799
|
languagesKey: JSON.stringify(key)
|
|
6681
6800
|
});
|
|
6682
6801
|
return { json, files: files2 };
|
|
@@ -6684,16 +6803,62 @@ var WasmMarkdown = class {
|
|
|
6684
6803
|
hookFile(name, value, data) {
|
|
6685
6804
|
return this.#hooks.has(`hooks/${name}`) ? this.renderHook(`hooks/${name}`, name, value, data) : void 0;
|
|
6686
6805
|
}
|
|
6806
|
+
component(name, value, data) {
|
|
6807
|
+
const template = `components/${name}`;
|
|
6808
|
+
return this.#hooks.has(template) ? this.renderHook(template, "component", value, data) : void 0;
|
|
6809
|
+
}
|
|
6810
|
+
/** Plugins' render hooks and containers (`markdown: { hooks }`), which a site's own templates replace. */
|
|
6811
|
+
#builtinHooks() {
|
|
6812
|
+
return [...this.#options.steps.hooks.keys()];
|
|
6813
|
+
}
|
|
6814
|
+
/** What a plugin's step or hook gets besides its text. */
|
|
6815
|
+
#context(data, file) {
|
|
6816
|
+
return {
|
|
6817
|
+
data,
|
|
6818
|
+
page: isPlainObject(data.page) ? data.page : void 0,
|
|
6819
|
+
urls: this.#options.htmlUrls ? "html" : "folders",
|
|
6820
|
+
markdown: (text, options) => this.#markdown(String(text ?? ""), HOOKS | (options?.inline ? INLINE2 : 0), data, file, void 0, "a plugin's Markdown step"),
|
|
6821
|
+
hasHook: (name) => this.#hooks.has(name) || this.#options.steps.hooks.has(name),
|
|
6822
|
+
renderHook: (name, key, value) => this.renderHook(name, key, value, data)
|
|
6823
|
+
};
|
|
6824
|
+
}
|
|
6825
|
+
/** One plugin step, which answers at once with text. */
|
|
6826
|
+
#step(step, text, stepContext, where, which) {
|
|
6827
|
+
let out;
|
|
6828
|
+
try {
|
|
6829
|
+
out = step(text, stepContext);
|
|
6830
|
+
} catch (e) {
|
|
6831
|
+
throw context(e, `${where}: markdown.${which}`);
|
|
6832
|
+
}
|
|
6833
|
+
if (typeof out === "string") return out;
|
|
6834
|
+
if (out instanceof Promise) {
|
|
6835
|
+
out.catch(() => {
|
|
6836
|
+
});
|
|
6837
|
+
throw new BuildError(`${where}: markdown.${which} answered with a promise; a plugin's Markdown step answers at once (work out what it needs in beforeBuild or a data file first)`);
|
|
6838
|
+
}
|
|
6839
|
+
throw new BuildError(`${where}: markdown.${which} must return text, not ${out === null ? "null" : typeof out}`);
|
|
6840
|
+
}
|
|
6687
6841
|
/** A render hook for the wasm: the template `name` with the page's data and `value` as `key`. */
|
|
6688
6842
|
renderHook(name, key, value, data) {
|
|
6689
6843
|
if (key === "container" && isPlainObject(value)) {
|
|
6690
6844
|
if (name === "containers/slot") return keepSlot(value);
|
|
6691
|
-
const
|
|
6692
|
-
|
|
6693
|
-
value =
|
|
6845
|
+
const own2 = { ...value, props: containerProps(value.args) };
|
|
6846
|
+
own2.slots = takeSlots(own2);
|
|
6847
|
+
value = own2;
|
|
6694
6848
|
}
|
|
6695
6849
|
const template = this.#hooks.get(name);
|
|
6696
6850
|
const engines = this.#engines;
|
|
6851
|
+
const own = template ? void 0 : this.#options.steps.hooks.get(name);
|
|
6852
|
+
if (own && isPlainObject(value)) {
|
|
6853
|
+
let out;
|
|
6854
|
+
try {
|
|
6855
|
+
out = own[1](value, this.#context(data, pageOf(data)));
|
|
6856
|
+
} catch (e) {
|
|
6857
|
+
throw context(e, `${own[0]}: markdown.hooks["${name.replace(/^hooks\//, "")}"]`);
|
|
6858
|
+
}
|
|
6859
|
+
if (typeof out !== "string") throw new BuildError(`${own[0]}: markdown.hooks["${name.replace(/^hooks\//, "")}"] must return HTML as text, not ${out === null ? "null" : typeof out}`);
|
|
6860
|
+
return out;
|
|
6861
|
+
}
|
|
6697
6862
|
if (!template || !engines) throw new BuildError(`no template for \`${name}\``);
|
|
6698
6863
|
const hookData = { ...isPlainObject(data) ? data : {}, [key]: value };
|
|
6699
6864
|
let text = template.body;
|
|
@@ -7186,6 +7351,164 @@ function safe(html) {
|
|
|
7186
7351
|
}
|
|
7187
7352
|
var isSafe = (value) => value instanceof SafeString;
|
|
7188
7353
|
|
|
7354
|
+
// src/engines/vitepress-dialect.ts
|
|
7355
|
+
import crypto2 from "node:crypto";
|
|
7356
|
+
var escapeHtml2 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
7357
|
+
var str = (v) => v === void 0 || v === null ? "" : String(v);
|
|
7358
|
+
function vitepressSlug(text) {
|
|
7359
|
+
return text.normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[\u0000-\u001f]/g, "").replace(/[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").replace(/^(\d)/, "_$1").toLowerCase();
|
|
7360
|
+
}
|
|
7361
|
+
var FENCE2 = /^(\s*)(`{3,}|~{3,})/;
|
|
7362
|
+
function vitepressBefore(source) {
|
|
7363
|
+
if (!source.includes("<") && !source.includes("-vue")) return source;
|
|
7364
|
+
const lines = source.split("\n");
|
|
7365
|
+
const out = [];
|
|
7366
|
+
let fence;
|
|
7367
|
+
let vueFence = false;
|
|
7368
|
+
for (let i = 0; i < lines.length; i++) {
|
|
7369
|
+
const line = lines[i];
|
|
7370
|
+
if (fence !== void 0) {
|
|
7371
|
+
const m = FENCE2.exec(line);
|
|
7372
|
+
if (m && m[2][0] === fence[0] && m[2].length >= fence.length && line.trim() === m[2]) {
|
|
7373
|
+
fence = void 0;
|
|
7374
|
+
vueFence = false;
|
|
7375
|
+
out.push(line);
|
|
7376
|
+
continue;
|
|
7377
|
+
}
|
|
7378
|
+
out.push(vueFence ? line.replace(/\{\{\s*(['"])((?:(?!\1).)*)\1\s*\}\}/g, "$2") : line);
|
|
7379
|
+
continue;
|
|
7380
|
+
}
|
|
7381
|
+
const open = FENCE2.exec(line);
|
|
7382
|
+
if (open) {
|
|
7383
|
+
fence = open[2];
|
|
7384
|
+
vueFence = /^\s*(?:`{3,}|~{3,})\s*[\w-]+-vue\b/.test(line);
|
|
7385
|
+
out.push(vueFence ? line.replace(/-vue\b/, "") : line);
|
|
7386
|
+
continue;
|
|
7387
|
+
}
|
|
7388
|
+
const block = /^<(script|style)\b/i.exec(line)?.[1].toLowerCase() ?? (/^\s*<ClientOnly>/.test(line) ? "ClientOnly" : void 0);
|
|
7389
|
+
if (block !== void 0) {
|
|
7390
|
+
const end = new RegExp(`</${block}>`, block === "ClientOnly" ? "" : "i");
|
|
7391
|
+
let j = i;
|
|
7392
|
+
while (j < lines.length && !end.test(lines[j])) j++;
|
|
7393
|
+
i = j;
|
|
7394
|
+
continue;
|
|
7395
|
+
}
|
|
7396
|
+
out.push(line);
|
|
7397
|
+
}
|
|
7398
|
+
return out.join("\n");
|
|
7399
|
+
}
|
|
7400
|
+
var EXTERNAL = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
7401
|
+
function vitepressHref(href, htmlUrls) {
|
|
7402
|
+
if (!href || href.startsWith("#") || EXTERNAL.test(href)) return href;
|
|
7403
|
+
const m = /^([^?#]*)(.*)$/.exec(href);
|
|
7404
|
+
let path4 = m[1];
|
|
7405
|
+
const rest = m[2];
|
|
7406
|
+
const index = /(^|.*\/)index\.md$/i.exec(path4);
|
|
7407
|
+
if (index) path4 = index[1];
|
|
7408
|
+
else if (/\.md$/i.test(path4)) path4 = path4.slice(0, -3) + (htmlUrls ? ".html" : "");
|
|
7409
|
+
else if (htmlUrls && path4 && !path4.endsWith("/") && !/\.\w+$/.test(path4)) path4 += ".html";
|
|
7410
|
+
if (path4 && !path4.startsWith("/") && !path4.startsWith("./")) path4 = `./${path4}`;
|
|
7411
|
+
return path4 + rest;
|
|
7412
|
+
}
|
|
7413
|
+
var encodeUrl = (url) => url.replace(/[^\x21-\x7e]+/g, (s) => encodeURIComponent(s));
|
|
7414
|
+
function lineSpans(html) {
|
|
7415
|
+
if (html.startsWith('<span class="line')) return html.replace(/\n$/, "");
|
|
7416
|
+
const open = [];
|
|
7417
|
+
return html.replace(/\n$/, "").split("\n").map((line) => {
|
|
7418
|
+
const start = open.join("");
|
|
7419
|
+
for (const m of line.matchAll(/<span\b[^>]*>|<\/span>/g)) {
|
|
7420
|
+
if (m[0] === "</span>") open.pop();
|
|
7421
|
+
else open.push(m[0]);
|
|
7422
|
+
}
|
|
7423
|
+
return `<span class="line">${start}${line}${"</span>".repeat(open.length)}</span>`;
|
|
7424
|
+
}).join("\n");
|
|
7425
|
+
}
|
|
7426
|
+
var fenceLabel = (lang) => lang === "vue-html" ? "template" : lang.replace(/-vue$/, "");
|
|
7427
|
+
var fenceTitle = (info) => /\[([^\]]+)\]/.exec(info)?.[1] ?? "";
|
|
7428
|
+
function fenceHtml(fence) {
|
|
7429
|
+
const lang = fenceLabel(str(fence.lang));
|
|
7430
|
+
const highlighted = typeof fence.highlighted === "string" && fence.highlighted !== "" ? fence.highlighted : escapeHtml2(str(fence.code));
|
|
7431
|
+
const block = `<div class="language-${escapeHtml2(lang)} vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">${escapeHtml2(lang)}</span><pre class="shiki vp-code" tabindex="0"><code>${lineSpans(highlighted)}</code></pre></div>`;
|
|
7432
|
+
const title = fenceTitle(str(fence.info));
|
|
7433
|
+
return title ? `<div class="vp-code-block-title"><div class="vp-code-block-title-bar"><span class="vp-code-block-title-text" data-title="${escapeHtml2(title)}">${escapeHtml2(title)}</span></div>${block}</div>` : block;
|
|
7434
|
+
}
|
|
7435
|
+
var custom = (kind, title) => (c) => {
|
|
7436
|
+
const args = str(c.args).trim();
|
|
7437
|
+
const head = args ? `<p class="custom-block-title">${args}</p>` : `<p class="custom-block-title custom-block-title-default">${title}</p>`;
|
|
7438
|
+
return `<div class="${kind} custom-block">${head}
|
|
7439
|
+
${str(c.content)}</div>`;
|
|
7440
|
+
};
|
|
7441
|
+
function codeGroup(c) {
|
|
7442
|
+
const source = str(c.source);
|
|
7443
|
+
const labels = [...source.matchAll(/^\s*(?:`{3,}|~{3,})\S*[^\n]*?\[([^\]]+)\]/gm)].map((m) => m[1]);
|
|
7444
|
+
const id = crypto2.createHash("sha1").update(source).digest("hex").slice(0, 5);
|
|
7445
|
+
const tabs = labels.map((label, i) => `<input type="radio" name="group-${id}" id="tab-${id}-${i}"${i === 0 ? " checked" : ""}><label data-title="${escapeHtml2(label)}" for="tab-${id}-${i}">${escapeHtml2(label)}</label>`).join("");
|
|
7446
|
+
const blocks = str(c.content).replace(/<div class="vp-code-block-title"><div class="vp-code-block-title-bar">[\s\S]*?<\/div>(<div class="language-[\s\S]*?<\/pre><\/div>)<\/div>/g, "$1").replace(/<div class="(language-[^"]*)"/, '<div class="$1 active"');
|
|
7447
|
+
return `<div class="vp-code-group"><div class="tabs">${tabs}</div><div class="blocks">${blocks}</div></div>`;
|
|
7448
|
+
}
|
|
7449
|
+
var VITEPRESS_HOOKS = {
|
|
7450
|
+
"hooks/heading": (h) => {
|
|
7451
|
+
const level = str(h.level), id = escapeHtml2(str(h.id));
|
|
7452
|
+
return `<h${level} id="${id}" tabindex="-1">${str(h.content)} <a class="header-anchor" href="#${id}" aria-label="Permalink to \u201C${escapeHtml2(str(h.text).trim())}\u201D">\u200B</a></h${level}>`;
|
|
7453
|
+
},
|
|
7454
|
+
"hooks/link": (l, o) => {
|
|
7455
|
+
const href = str(l.href);
|
|
7456
|
+
const title = l.title ? ` title="${escapeHtml2(str(l.title))}"` : "";
|
|
7457
|
+
if (EXTERNAL.test(href)) return `<a href="${escapeHtml2(encodeUrl(href))}"${title} target="_blank" rel="noreferrer">${str(l.content)}</a>`;
|
|
7458
|
+
return `<a href="${escapeHtml2(encodeUrl(vitepressHref(href, o.htmlUrls)))}"${title}>${str(l.content)}</a>`;
|
|
7459
|
+
},
|
|
7460
|
+
"hooks/fence": (f) => fenceHtml(f),
|
|
7461
|
+
"hooks/table": (t) => `<table tabindex="0">${str(t.content)}</table>`,
|
|
7462
|
+
"containers/tip": custom("tip", "TIP"),
|
|
7463
|
+
"containers/info": custom("info", "INFO"),
|
|
7464
|
+
"containers/warning": custom("warning", "WARNING"),
|
|
7465
|
+
"containers/danger": custom("danger", "DANGER"),
|
|
7466
|
+
"containers/details": (c) => `<details class="details custom-block"><summary>${str(c.args).trim() || "Details"}</summary>
|
|
7467
|
+
${str(c.content)}</details>`,
|
|
7468
|
+
"containers/raw": (c) => `<div class="vp-raw">
|
|
7469
|
+
${str(c.content)}</div>`,
|
|
7470
|
+
"containers/code-group": codeGroup
|
|
7471
|
+
};
|
|
7472
|
+
function vitepressAfter(html) {
|
|
7473
|
+
let out = html.includes("<!--") ? withoutComments(html) : html;
|
|
7474
|
+
out = asVueWritesIt(out);
|
|
7475
|
+
const marker = /<p>\[\[toc\]\]<\/p>/i.exec(out);
|
|
7476
|
+
if (!marker) return out;
|
|
7477
|
+
const heads = [...out.matchAll(/<h([23]) id="([^"]*)"[^>]*>([\s\S]*?)<\/h\1>/g)].map(([, level2, id, inner]) => ({ level: Number(level2), id, text: inner.replace(/<a class="header-anchor"[\s\S]*?<\/a>/, "").replace(/<[^>]+>/g, "").trim() }));
|
|
7478
|
+
let toc = '<nav class="table-of-contents"><ul>';
|
|
7479
|
+
let level = 2;
|
|
7480
|
+
let open = false;
|
|
7481
|
+
for (const h of heads) {
|
|
7482
|
+
if (h.level > level) {
|
|
7483
|
+
toc += "<ul>";
|
|
7484
|
+
level = h.level;
|
|
7485
|
+
} else if (h.level < level) {
|
|
7486
|
+
toc += "</li></ul></li>";
|
|
7487
|
+
level = h.level;
|
|
7488
|
+
} else if (open) toc += "</li>";
|
|
7489
|
+
toc += `<li><a href="#${h.id}">${h.text}</a>`;
|
|
7490
|
+
open = true;
|
|
7491
|
+
}
|
|
7492
|
+
if (open) toc += "</li>";
|
|
7493
|
+
while (level-- > 2) toc += "</ul></li>";
|
|
7494
|
+
toc += "</ul></nav>";
|
|
7495
|
+
out = out.replace(marker[0], toc);
|
|
7496
|
+
return out;
|
|
7497
|
+
}
|
|
7498
|
+
var VOID2 = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
7499
|
+
function asVueWritesIt(html) {
|
|
7500
|
+
if (!/\/>|\sv-pre\b|\s@[\w.-]+=|\sv-on:/.test(html)) return html;
|
|
7501
|
+
return html.replace(/<(pre|code|script|style|textarea)\b[\s\S]*?<\/\1>|<([a-z][\w-]*)((?:\s+[^\s"'>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?)*)\s*(\/?)>/g, (whole, raw, name, attrs, selfClosing) => {
|
|
7502
|
+
if (raw !== void 0) return whole;
|
|
7503
|
+
const kept = attrs.replace(/\s+(?:v-pre|@[\w.:-]+|v-on:[\w.:-]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?/g, "");
|
|
7504
|
+
if (selfClosing && !VOID2.has(name)) return `<${name}${kept}></${name}>`;
|
|
7505
|
+
return kept === attrs ? whole : `<${name}${kept}${selfClosing ? " /" : ""}>`;
|
|
7506
|
+
});
|
|
7507
|
+
}
|
|
7508
|
+
function withoutComments(html) {
|
|
7509
|
+
return html.replace(/<(pre|code|script|style|textarea)\b[\s\S]*?<\/\1>|<!--[\s\S]*?-->/gi, (m, raw) => raw ? m : "");
|
|
7510
|
+
}
|
|
7511
|
+
|
|
7189
7512
|
// src/markdown-options.ts
|
|
7190
7513
|
function defaultMarkdownOptions() {
|
|
7191
7514
|
return {
|
|
@@ -7201,7 +7524,6 @@ function defaultMarkdownOptions() {
|
|
|
7201
7524
|
definitionLists: false,
|
|
7202
7525
|
smartPunctuation: false,
|
|
7203
7526
|
indentedCode: true,
|
|
7204
|
-
encodeUrls: true,
|
|
7205
7527
|
highlight: false,
|
|
7206
7528
|
highlightCss: "/highlight.css",
|
|
7207
7529
|
highlightClasses: null,
|
|
@@ -7212,11 +7534,14 @@ function defaultMarkdownOptions() {
|
|
|
7212
7534
|
tabs: false,
|
|
7213
7535
|
shortcodes: false,
|
|
7214
7536
|
sourceLinks: false,
|
|
7215
|
-
|
|
7537
|
+
preprocess: null,
|
|
7538
|
+
dialect: null,
|
|
7539
|
+
htmlUrls: false,
|
|
7540
|
+
steps: { before: [], after: [], hooks: /* @__PURE__ */ new Map() }
|
|
7216
7541
|
};
|
|
7217
7542
|
}
|
|
7218
|
-
var MARKDOWN_KEYS = ["headingIds", "headingAttributes", "footnotes", "taskLists", "autolinks", "alerts", "containers", "definitionLists", "smartPunctuation", "indentedCode", "highlight", "breaks", "figures", "
|
|
7219
|
-
var FLAGS = ["headingAttributes", "footnotes", "taskLists", "alerts", "
|
|
7543
|
+
var MARKDOWN_KEYS = ["headingIds", "headingAttributes", "footnotes", "taskLists", "autolinks", "alerts", "containers", "definitionLists", "smartPunctuation", "indentedCode", "highlight", "breaks", "figures", "sourceLinks", "preprocess"];
|
|
7544
|
+
var FLAGS = ["headingAttributes", "footnotes", "taskLists", "alerts", "definitionLists", "smartPunctuation", "indentedCode", "breaks", "figures"];
|
|
7220
7545
|
var HIGHLIGHT_KINDS = ["comment", "keyword", "operator", "string", "regexp", "escape", "number", "constant", "builtin", "property", "attribute", "function", "type", "parameter", "tag", "heading", "strong", "emphasis", "link", "inserted", "deleted"];
|
|
7221
7546
|
var PYGMENTS_CLASSES = { comment: "c", keyword: "k", operator: "o", string: "s", regexp: "sr", escape: "se", number: "m", constant: "kc", builtin: "nb", property: "py", attribute: "na", function: "nf", type: "nc", parameter: "nv", tag: "nt", heading: "gh", strong: "gs", emphasis: "ge", link: "nl", inserted: "gi", deleted: "gd" };
|
|
7222
7547
|
var PRISM_CLASSES = { comment: "token comment", keyword: "token keyword", operator: "token operator", string: "token string", regexp: "token regex", escape: "token escape", number: "token number", constant: "token constant", builtin: "token builtin", property: "token property", attribute: "token attr-name", function: "token function", type: "token class-name", parameter: "token parameter", tag: "token tag", heading: "token title", strong: "token bold", emphasis: "token italic", link: "token url", inserted: "token inserted", deleted: "token deleted" };
|
|
@@ -7236,8 +7561,20 @@ function highlightClasses(value) {
|
|
|
7236
7561
|
return { names, prism: false };
|
|
7237
7562
|
}
|
|
7238
7563
|
var typeOf = (v) => typeof v;
|
|
7239
|
-
|
|
7564
|
+
var RETIRED_MARKDOWN = {
|
|
7565
|
+
dialect: (v) => v === "vitepress" ? 'fromVitepress() from "ssqch/from-vitepress"' : 'fromMkdocs() from "ssqch/from-mkdocs"',
|
|
7566
|
+
admonitions: () => 'fromMkdocs() from "ssqch/from-mkdocs"',
|
|
7567
|
+
tabs: () => 'fromMkdocs() from "ssqch/from-mkdocs"',
|
|
7568
|
+
shortcodes: () => 'fromHugo() from "ssqch/from-hugo"',
|
|
7569
|
+
htmlMarkdown: () => 'fromJekyll() from "ssqch/from-jekyll"'
|
|
7570
|
+
};
|
|
7571
|
+
function applyMarkdownOptions(options, value, from = "site") {
|
|
7240
7572
|
if (!isPlainObject(value)) bail(`markdown must be an object, not ${typeOf(value)}`);
|
|
7573
|
+
if (from === "site") {
|
|
7574
|
+
for (const [key, v] of Object.entries(value)) {
|
|
7575
|
+
if (Object.hasOwn(RETIRED_MARKDOWN, key) && v !== false && v !== null && v !== void 0) bail(`markdown.${key} is ${RETIRED_MARKDOWN[key](v)} now: add it to plugins, and leave markdown.${key} out (\`ssqch docs ${RETIRED_MARKDOWN[key](v).split("(")[0]}\`)`);
|
|
7576
|
+
}
|
|
7577
|
+
}
|
|
7241
7578
|
for (const [key, v] of Object.entries(value)) {
|
|
7242
7579
|
if (key === "headingIds") {
|
|
7243
7580
|
if (typeof v === "function") {
|
|
@@ -7251,9 +7588,14 @@ function applyMarkdownOptions(options, value) {
|
|
|
7251
7588
|
options.headingIds = "github";
|
|
7252
7589
|
continue;
|
|
7253
7590
|
}
|
|
7254
|
-
if (
|
|
7591
|
+
if (v === "vitepress") {
|
|
7592
|
+
options.sluggerFn = vitepressSlug;
|
|
7593
|
+
options.headingIds = "github";
|
|
7594
|
+
continue;
|
|
7595
|
+
}
|
|
7596
|
+
if (!["github", "blackfriday", "ascii", "kramdown", "markdown-it-anchor"].includes(v)) bail(`markdown.headingIds: unknown slugger "${v}" (use "github", "blackfriday", "ascii", "kramdown", "markdown-it-anchor", "python-markdown", "vitepress" or false)`);
|
|
7255
7597
|
options.headingIds = v;
|
|
7256
|
-
} else bail(`markdown.headingIds must be "github", "blackfriday", "ascii", "kramdown", "markdown-it-anchor", "python-markdown" or false, not ${typeOf(v)}`);
|
|
7598
|
+
} else bail(`markdown.headingIds must be "github", "blackfriday", "ascii", "kramdown", "markdown-it-anchor", "python-markdown", "vitepress" or false, not ${typeOf(v)}`);
|
|
7257
7599
|
} else if (key === "htmlMarkdown") {
|
|
7258
7600
|
if (v !== false && v !== "kramdown") bail(`markdown.htmlMarkdown must be "kramdown" or false, not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
|
|
7259
7601
|
options.htmlMarkdown = v;
|
|
@@ -7264,8 +7606,11 @@ function applyMarkdownOptions(options, value) {
|
|
|
7264
7606
|
if (v !== false && v !== "hugo") bail(`markdown.shortcodes must be "hugo" or false, not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
|
|
7265
7607
|
options.shortcodes = v;
|
|
7266
7608
|
} else if (key === "dialect") {
|
|
7267
|
-
if (v !== "python-markdown" && v !== null && v !== false) bail(`markdown.dialect: unknown dialect ${typeof v === "string" ? `"${v}"` : typeOf(v)} (use "python-markdown", or false for CommonMark's)`);
|
|
7268
|
-
options.dialect = v === "python-markdown" ? v : null;
|
|
7609
|
+
if (v !== "python-markdown" && v !== "vitepress" && v !== null && v !== false) bail(`markdown.dialect: unknown dialect ${typeof v === "string" ? `"${v}"` : typeOf(v)} (use "python-markdown", "vitepress", or false for CommonMark's)`);
|
|
7610
|
+
options.dialect = v === "python-markdown" || v === "vitepress" ? v : null;
|
|
7611
|
+
} else if (key === "preprocess") {
|
|
7612
|
+
if (v !== null && v !== false && typeof v !== "function") bail(`markdown.preprocess must be a function (source, data) => source, not ${typeOf(v)}`);
|
|
7613
|
+
options.preprocess = typeof v === "function" ? v : null;
|
|
7269
7614
|
} else if (key === "sourceLinks") {
|
|
7270
7615
|
if (typeof v !== "boolean" && v !== "relative") bail(`markdown.sourceLinks must be true, false or "relative", not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
|
|
7271
7616
|
options.sourceLinks = v;
|
|
@@ -7287,17 +7632,41 @@ function applyMarkdownOptions(options, value) {
|
|
|
7287
7632
|
}
|
|
7288
7633
|
} else bail(`markdown.highlight must be true, false or { classes, css, languages }, not ${typeOf(v)}`);
|
|
7289
7634
|
} else if (key === "autolinks") {
|
|
7290
|
-
if (typeof v !== "boolean" && v !== "fuzzy") bail(`markdown.autolinks must be true, false or "fuzzy", not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
|
|
7635
|
+
if (typeof v !== "boolean" && v !== "fuzzy" && v !== "email") bail(`markdown.autolinks must be true, false, "email" or "fuzzy", not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
|
|
7291
7636
|
options.autolinks = v;
|
|
7637
|
+
} else if (key === "containers") {
|
|
7638
|
+
if (v === "markdown-it") bail('markdown.containers: "markdown-it" is what `containers: true` does now (a closing `:::` indented under a list closes its container): write true, or leave it out');
|
|
7639
|
+
if (typeof v !== "boolean") bail(`markdown.containers must be true or false, not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
|
|
7640
|
+
options.containers = v;
|
|
7292
7641
|
} else if (FLAGS.includes(key)) {
|
|
7293
7642
|
if (typeof v !== "boolean") bail(`markdown.${key} must be true or false, not ${typeOf(v)}`);
|
|
7294
7643
|
options[key] = v;
|
|
7644
|
+
} else if (key === "encodeUrls") {
|
|
7645
|
+
bail("markdown.encodeUrls is gone: link and image URLs are percent-encoded, as CommonMark writes them, and browsers go to the same place either way (so does `ssqch diff`). Leave it out");
|
|
7295
7646
|
} else {
|
|
7296
7647
|
const near = closest(key, MARKDOWN_KEYS);
|
|
7297
7648
|
bail(`markdown.${key} isn't an option${near ? ` (did you mean \`${near}\`?)` : ""} (options: ${MARKDOWN_KEYS.join(", ")})`);
|
|
7298
7649
|
}
|
|
7299
7650
|
}
|
|
7300
7651
|
}
|
|
7652
|
+
var STEP_KEYS = ["before", "after", "hooks"];
|
|
7653
|
+
function addMarkdownSteps(steps, where, value) {
|
|
7654
|
+
if (!isPlainObject(value)) bail(`${where}: markdown must be an object of { before, after, hooks }`);
|
|
7655
|
+
for (const key of Object.keys(value)) if (!STEP_KEYS.includes(key)) bail(`${where}: markdown.${key} isn't a plugin's Markdown step${closest(key, STEP_KEYS) ? ` (did you mean \`${closest(key, STEP_KEYS)}\`?)` : ""} (a plugin's markdown has before, after and hooks; the site's own options go in the config's markdown, or in the plugin's defaults)`);
|
|
7656
|
+
for (const key of ["before", "after"]) {
|
|
7657
|
+
const fn = value[key];
|
|
7658
|
+
if (fn === void 0) continue;
|
|
7659
|
+
if (typeof fn !== "function") bail(`${where}: markdown.${key} must be a function, (${key === "before" ? "source" : "html"}, context) => text`);
|
|
7660
|
+
steps[key].push([where, fn]);
|
|
7661
|
+
}
|
|
7662
|
+
if (value.hooks !== void 0) {
|
|
7663
|
+
if (!isPlainObject(value.hooks)) bail(`${where}: markdown.hooks must be an object of { name: (value, context) => html }, like { heading: ..., "containers/tip": ... }`);
|
|
7664
|
+
for (const [name, hook] of Object.entries(value.hooks)) {
|
|
7665
|
+
if (typeof hook !== "function") bail(`${where}: markdown.hooks["${name}"] must be a function, (value, context) => html`);
|
|
7666
|
+
steps.hooks.set(/^(?:hooks|containers)\//.test(name) ? name : `hooks/${name}`, [where, hook]);
|
|
7667
|
+
}
|
|
7668
|
+
}
|
|
7669
|
+
}
|
|
7301
7670
|
function setLanguage(options, name, value) {
|
|
7302
7671
|
let language;
|
|
7303
7672
|
if (typeof value === "function") language = value;
|
|
@@ -7976,8 +8345,12 @@ export {
|
|
|
7976
8345
|
withPage,
|
|
7977
8346
|
safe,
|
|
7978
8347
|
isSafe,
|
|
8348
|
+
vitepressBefore,
|
|
8349
|
+
VITEPRESS_HOOKS,
|
|
8350
|
+
vitepressAfter,
|
|
7979
8351
|
defaultMarkdownOptions,
|
|
7980
8352
|
applyMarkdownOptions,
|
|
8353
|
+
addMarkdownSteps,
|
|
7981
8354
|
slugWith,
|
|
7982
8355
|
slugOptions,
|
|
7983
8356
|
slugText,
|