@ant-design/x-markdown-mini 0.1.0-beta.0 → 0.1.0-beta.1
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/dist/components/Markdown/index.acss +65 -7
- package/dist/components/MiniNodeRenderer/index.acss +19 -4
- package/dist/components/MiniNodeRenderer/index.axml +109 -29
- package/dist/components/MiniNodeRenderer/index.js +12 -0
- package/dist/components/MiniNodeRenderer/index.sjs +48 -0
- package/dist/es/Markdown/index.acss +65 -7
- package/dist/es/MiniNodeRenderer/index.acss +19 -4
- package/dist/es/MiniNodeRenderer/index.axml +109 -29
- package/dist/es/MiniNodeRenderer/index.js +12 -0
- package/dist/es/MiniNodeRenderer/index.sjs +48 -0
- package/dist/index.d.mts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.js +134 -56
- package/dist/index.mjs +134 -56
- package/dist/miniprogram_dist/components/Markdown/index.json +1 -1
- package/dist/miniprogram_dist/components/Markdown/index.wxss +65 -7
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.js +12 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.json +1 -1
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxml +98 -21
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxs +41 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxss +13 -2
- package/dist/miniprogram_dist/es/Markdown/index.json +1 -1
- package/dist/miniprogram_dist/es/Markdown/index.wxss +65 -7
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.js +12 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.json +1 -1
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxml +98 -21
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxs +41 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxss +13 -2
- package/dist/miniprogram_dist/index.js +134 -56
- package/dist/miniprogram_dist/plugins/CodeHighlight/index.js +13 -5
- package/dist/miniprogram_dist/plugins/CodeHighlight/style.wxss +41 -31
- package/dist/miniprogram_dist/plugins/Latex/index.js +44 -23
- package/dist/miniprogram_dist/plugins/Latex/style.wxss +11 -11
- package/dist/miniprogram_dist/shared/flattenInline.js +33 -5
- package/dist/plugins/CodeHighlight/index.d.mts +1 -1
- package/dist/plugins/CodeHighlight/index.d.ts +1 -1
- package/dist/plugins/CodeHighlight/index.js +13 -5
- package/dist/plugins/CodeHighlight/index.mjs +13 -5
- package/dist/plugins/CodeHighlight/style.acss +41 -31
- package/dist/plugins/Latex/index.d.mts +1 -1
- package/dist/plugins/Latex/index.d.ts +1 -1
- package/dist/plugins/Latex/index.js +44 -23
- package/dist/plugins/Latex/index.mjs +47 -23
- package/dist/plugins/Latex/style.acss +11 -6
- package/dist/shared/flattenInline.js +33 -5
- package/dist/{types-CegkonfJ.d.mts → types-BcxGtbQZ.d.mts} +25 -0
- package/dist/{types-CegkonfJ.d.ts → types-BcxGtbQZ.d.ts} +25 -0
- package/package.json +3 -2
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
6
23
|
var __export = (target, all) => {
|
|
7
24
|
for (var name in all)
|
|
8
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -14523,6 +14540,10 @@ var katex = {
|
|
|
14523
14540
|
};
|
|
14524
14541
|
|
|
14525
14542
|
// src/plugins/shared/htmlToMiniNodes.ts
|
|
14543
|
+
var CLOSE_TAG_RE = /<\/(\w+)\s*>/y;
|
|
14544
|
+
var OPEN_TAG_RE = /<(\w+)((?:\s+[^>]*?)?)(\/?)>/y;
|
|
14545
|
+
var KATEX_CLOSE_SPAN_RE = /<\/span\s*>/iy;
|
|
14546
|
+
var KATEX_OPEN_SPAN_RE = /<span[\s>]/iy;
|
|
14526
14547
|
function htmlToMiniNodes(html, escapeText) {
|
|
14527
14548
|
var _a;
|
|
14528
14549
|
const root = { name: "root", children: [] };
|
|
@@ -14560,7 +14581,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
14560
14581
|
}
|
|
14561
14582
|
while (i < html.length) {
|
|
14562
14583
|
if (html[i] === "<") {
|
|
14563
|
-
|
|
14584
|
+
CLOSE_TAG_RE.lastIndex = i;
|
|
14585
|
+
const closeMatch = CLOSE_TAG_RE.exec(html);
|
|
14564
14586
|
if (closeMatch) {
|
|
14565
14587
|
const closeTag = closeMatch[1].toLowerCase();
|
|
14566
14588
|
for (let j = stack.length - 1; j > 0; j--) {
|
|
@@ -14572,7 +14594,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
14572
14594
|
i += closeMatch[0].length;
|
|
14573
14595
|
continue;
|
|
14574
14596
|
}
|
|
14575
|
-
|
|
14597
|
+
OPEN_TAG_RE.lastIndex = i;
|
|
14598
|
+
const tagMatch = OPEN_TAG_RE.exec(html);
|
|
14576
14599
|
if (tagMatch) {
|
|
14577
14600
|
const rawTag = tagMatch[1].toLowerCase();
|
|
14578
14601
|
const attrStr = tagMatch[2];
|
|
@@ -14583,8 +14606,10 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
14583
14606
|
while (si < html.length && depth > 0) {
|
|
14584
14607
|
const next = html.indexOf("<", si);
|
|
14585
14608
|
if (next === -1) break;
|
|
14586
|
-
|
|
14587
|
-
const
|
|
14609
|
+
KATEX_CLOSE_SPAN_RE.lastIndex = next;
|
|
14610
|
+
const csm = KATEX_CLOSE_SPAN_RE.exec(html);
|
|
14611
|
+
KATEX_OPEN_SPAN_RE.lastIndex = next;
|
|
14612
|
+
const osm = KATEX_OPEN_SPAN_RE.exec(html);
|
|
14588
14613
|
if (csm) {
|
|
14589
14614
|
depth--;
|
|
14590
14615
|
si = next + csm[0].length;
|
|
@@ -14683,29 +14708,25 @@ function inlineStart(src) {
|
|
|
14683
14708
|
return void 0;
|
|
14684
14709
|
}
|
|
14685
14710
|
function renderKatex(tex, displayMode, options) {
|
|
14711
|
+
let html;
|
|
14686
14712
|
try {
|
|
14687
|
-
|
|
14713
|
+
html = katex.renderToString(tex, __spreadProps(__spreadValues({
|
|
14688
14714
|
displayMode,
|
|
14689
|
-
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
|
-
|
|
14695
|
-
|
|
14696
|
-
|
|
14715
|
+
output: "html"
|
|
14716
|
+
}, options.katexOptions), {
|
|
14717
|
+
// The plugin owns error handling: force KaTeX to throw on invalid input
|
|
14718
|
+
// so we never emit its red `.katex-error` markup. This is intentionally
|
|
14719
|
+
// set after the spread so a caller's `throwOnError: false` cannot re-enable
|
|
14720
|
+
// the broken-formula output (common during streaming of partial formulas).
|
|
14721
|
+
throwOnError: true
|
|
14722
|
+
}));
|
|
14697
14723
|
} catch (err) {
|
|
14698
|
-
|
|
14699
|
-
return options.onError(tex, err);
|
|
14700
|
-
}
|
|
14701
|
-
return [
|
|
14702
|
-
{
|
|
14703
|
-
name: "span",
|
|
14704
|
-
attrs: { class: "katex-error" },
|
|
14705
|
-
children: [{ name: "text", attrs: { value: err.message } }]
|
|
14706
|
-
}
|
|
14707
|
-
];
|
|
14724
|
+
return options.onError ? options.onError(tex, err) : [];
|
|
14708
14725
|
}
|
|
14726
|
+
const nodes = htmlToMiniNodes(html, false);
|
|
14727
|
+
const wrapper = displayMode ? "div" : "span";
|
|
14728
|
+
const className = displayMode ? "katex-display" : "katex-inline";
|
|
14729
|
+
return [{ name: wrapper, attrs: { class: className }, children: nodes }];
|
|
14709
14730
|
}
|
|
14710
14731
|
function Latex(options = {}) {
|
|
14711
14732
|
return {
|
|
@@ -209,6 +209,7 @@
|
|
|
209
209
|
/* Note: '>' child combinators replaced with ' ' (descendant) for mini-program compat */
|
|
210
210
|
|
|
211
211
|
.katex {
|
|
212
|
+
display: inline-block;
|
|
212
213
|
font-family: KaTeX_Main, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
213
214
|
font-size: 1em;
|
|
214
215
|
font-weight: normal;
|
|
@@ -218,10 +219,9 @@
|
|
|
218
219
|
-webkit-font-smoothing: antialiased;
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
222
|
+
/* mini-program 无原生 <span>,KaTeX 节点渲染为 <view>/<text>;未带显式 display
|
|
223
|
+
的原子默认 inline-block,结构性 class 规则(.base/.vlist* 等)按特异性覆盖。 */
|
|
224
|
+
.katex view { display: inline-block; vertical-align: baseline; }
|
|
225
225
|
|
|
226
226
|
.katex .katex-mathml {
|
|
227
227
|
position: absolute;
|
|
@@ -281,13 +281,13 @@
|
|
|
281
281
|
position: relative;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
.katex .vlist
|
|
284
|
+
.katex .vlist view {
|
|
285
285
|
display: block;
|
|
286
286
|
height: 0;
|
|
287
287
|
position: relative;
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
.katex .vlist
|
|
290
|
+
.katex .vlist view view { display: inline-block; }
|
|
291
291
|
|
|
292
292
|
.katex .vlist .pstrut {
|
|
293
293
|
overflow: hidden;
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
|
|
327
327
|
.katex .msupsub { text-align: left; }
|
|
328
328
|
|
|
329
|
-
.katex .mfrac
|
|
329
|
+
.katex .mfrac view view { text-align: center; }
|
|
330
330
|
|
|
331
331
|
.katex .mfrac .frac-line {
|
|
332
332
|
display: inline-block;
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
.katex .llap .fix, .katex .rlap .fix, .katex .clap .fix { display: inline-block; }
|
|
355
355
|
.katex .llap .inner { right: 0; }
|
|
356
356
|
.katex .rlap .inner, .katex .clap .inner { left: 0; }
|
|
357
|
-
.katex .clap .inner
|
|
357
|
+
.katex .clap .inner view { margin-left: -50%; margin-right: 50%; }
|
|
358
358
|
|
|
359
359
|
.katex .rule {
|
|
360
360
|
display: inline-block;
|
|
@@ -529,8 +529,8 @@
|
|
|
529
529
|
.katex .delimsizing.size3 { font-family: KaTeX_Size3; }
|
|
530
530
|
.katex .delimsizing.size4 { font-family: KaTeX_Size4; }
|
|
531
531
|
|
|
532
|
-
.katex .delimsizing.mult .delim-size1
|
|
533
|
-
.katex .delimsizing.mult .delim-size4
|
|
532
|
+
.katex .delimsizing.mult .delim-size1 view { font-family: KaTeX_Size1; }
|
|
533
|
+
.katex .delimsizing.mult .delim-size4 view { font-family: KaTeX_Size4; }
|
|
534
534
|
|
|
535
535
|
.katex .nulldelimiter { display: inline-block; width: 0.12em; }
|
|
536
536
|
.katex .delimcenter { position: relative; }
|
|
@@ -645,4 +645,4 @@
|
|
|
645
645
|
/* --- Inline math wrapper --- */
|
|
646
646
|
.katex-inline {
|
|
647
647
|
display: inline;
|
|
648
|
-
}
|
|
648
|
+
}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
6
23
|
var __export = (target, all) => {
|
|
7
24
|
for (var name in all)
|
|
8
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,16 +51,23 @@ const INLINE_TAGS = {
|
|
|
34
51
|
const TAG_CLASS = {
|
|
35
52
|
strong: "md-strong",
|
|
36
53
|
em: "md-em",
|
|
37
|
-
del: "md-del"
|
|
38
|
-
code
|
|
54
|
+
del: "md-del"
|
|
55
|
+
// 'code' 不在此处加类:行内 codespan 由 transformer 直接打 md-inline-code,
|
|
56
|
+
// 而代码块内的 <code>(在 <pre> 中)不应带行内药丸底色。
|
|
39
57
|
// 'span' 不附加额外 class
|
|
40
58
|
};
|
|
59
|
+
function isKatex(node) {
|
|
60
|
+
var _a;
|
|
61
|
+
const cls = (_a = node.attrs) == null ? void 0 : _a.class;
|
|
62
|
+
return typeof cls === "string" && cls.indexOf("katex") > -1;
|
|
63
|
+
}
|
|
41
64
|
function walk(node) {
|
|
65
|
+
if (isKatex(node)) return node;
|
|
42
66
|
if (!node.children || node.children.length === 0) return node;
|
|
43
67
|
if (node.name === "a") {
|
|
44
|
-
return {
|
|
68
|
+
return __spreadProps(__spreadValues({}, node), { children: flattenChildren(node.children) });
|
|
45
69
|
}
|
|
46
|
-
return {
|
|
70
|
+
return __spreadProps(__spreadValues({}, node), { children: flattenChildren(node.children) });
|
|
47
71
|
}
|
|
48
72
|
function flattenChildren(children) {
|
|
49
73
|
const out = [];
|
|
@@ -65,8 +89,12 @@ function flattenOne(n, classChain, out) {
|
|
|
65
89
|
out.push({ name: "br", attrs: {} });
|
|
66
90
|
return;
|
|
67
91
|
}
|
|
92
|
+
if (isKatex(n)) {
|
|
93
|
+
out.push(n);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
68
96
|
if (n.name === "a") {
|
|
69
|
-
out.push({
|
|
97
|
+
out.push(__spreadProps(__spreadValues({}, n), { children: flattenChildren((_d = n.children) != null ? _d : []) }));
|
|
70
98
|
return;
|
|
71
99
|
}
|
|
72
100
|
if (n.name === "img") {
|
|
@@ -1581,6 +1581,10 @@ var import_core = __toESM(require_core(), 1);
|
|
|
1581
1581
|
var core_default = import_core.default;
|
|
1582
1582
|
|
|
1583
1583
|
// src/plugins/shared/htmlToMiniNodes.ts
|
|
1584
|
+
var CLOSE_TAG_RE = /<\/(\w+)\s*>/y;
|
|
1585
|
+
var OPEN_TAG_RE = /<(\w+)((?:\s+[^>]*?)?)(\/?)>/y;
|
|
1586
|
+
var KATEX_CLOSE_SPAN_RE = /<\/span\s*>/iy;
|
|
1587
|
+
var KATEX_OPEN_SPAN_RE = /<span[\s>]/iy;
|
|
1584
1588
|
function htmlToMiniNodes(html, escapeText) {
|
|
1585
1589
|
var _a;
|
|
1586
1590
|
const root = { name: "root", children: [] };
|
|
@@ -1618,7 +1622,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1618
1622
|
}
|
|
1619
1623
|
while (i < html.length) {
|
|
1620
1624
|
if (html[i] === "<") {
|
|
1621
|
-
|
|
1625
|
+
CLOSE_TAG_RE.lastIndex = i;
|
|
1626
|
+
const closeMatch = CLOSE_TAG_RE.exec(html);
|
|
1622
1627
|
if (closeMatch) {
|
|
1623
1628
|
const closeTag = closeMatch[1].toLowerCase();
|
|
1624
1629
|
for (let j = stack.length - 1; j > 0; j--) {
|
|
@@ -1630,7 +1635,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1630
1635
|
i += closeMatch[0].length;
|
|
1631
1636
|
continue;
|
|
1632
1637
|
}
|
|
1633
|
-
|
|
1638
|
+
OPEN_TAG_RE.lastIndex = i;
|
|
1639
|
+
const tagMatch = OPEN_TAG_RE.exec(html);
|
|
1634
1640
|
if (tagMatch) {
|
|
1635
1641
|
const rawTag = tagMatch[1].toLowerCase();
|
|
1636
1642
|
const attrStr = tagMatch[2];
|
|
@@ -1641,8 +1647,10 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1641
1647
|
while (si < html.length && depth > 0) {
|
|
1642
1648
|
const next = html.indexOf("<", si);
|
|
1643
1649
|
if (next === -1) break;
|
|
1644
|
-
|
|
1645
|
-
const
|
|
1650
|
+
KATEX_CLOSE_SPAN_RE.lastIndex = next;
|
|
1651
|
+
const csm = KATEX_CLOSE_SPAN_RE.exec(html);
|
|
1652
|
+
KATEX_OPEN_SPAN_RE.lastIndex = next;
|
|
1653
|
+
const osm = KATEX_OPEN_SPAN_RE.exec(html);
|
|
1646
1654
|
if (csm) {
|
|
1647
1655
|
depth--;
|
|
1648
1656
|
si = next + csm[0].length;
|
|
@@ -3218,7 +3226,7 @@ function typescript(hljs) {
|
|
|
3218
3226
|
// node_modules/highlight.js/es/languages/python.js
|
|
3219
3227
|
function python(hljs) {
|
|
3220
3228
|
const regex = hljs.regex;
|
|
3221
|
-
const IDENT_RE3 =
|
|
3229
|
+
const IDENT_RE3 = new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*", "u");
|
|
3222
3230
|
const RESERVED_WORDS = [
|
|
3223
3231
|
"and",
|
|
3224
3232
|
"as",
|
|
@@ -1568,6 +1568,10 @@ var import_core = __toESM(require_core(), 1);
|
|
|
1568
1568
|
var core_default = import_core.default;
|
|
1569
1569
|
|
|
1570
1570
|
// src/plugins/shared/htmlToMiniNodes.ts
|
|
1571
|
+
var CLOSE_TAG_RE = /<\/(\w+)\s*>/y;
|
|
1572
|
+
var OPEN_TAG_RE = /<(\w+)((?:\s+[^>]*?)?)(\/?)>/y;
|
|
1573
|
+
var KATEX_CLOSE_SPAN_RE = /<\/span\s*>/iy;
|
|
1574
|
+
var KATEX_OPEN_SPAN_RE = /<span[\s>]/iy;
|
|
1571
1575
|
function htmlToMiniNodes(html, escapeText) {
|
|
1572
1576
|
var _a;
|
|
1573
1577
|
const root = { name: "root", children: [] };
|
|
@@ -1605,7 +1609,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1605
1609
|
}
|
|
1606
1610
|
while (i < html.length) {
|
|
1607
1611
|
if (html[i] === "<") {
|
|
1608
|
-
|
|
1612
|
+
CLOSE_TAG_RE.lastIndex = i;
|
|
1613
|
+
const closeMatch = CLOSE_TAG_RE.exec(html);
|
|
1609
1614
|
if (closeMatch) {
|
|
1610
1615
|
const closeTag = closeMatch[1].toLowerCase();
|
|
1611
1616
|
for (let j = stack.length - 1; j > 0; j--) {
|
|
@@ -1617,7 +1622,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1617
1622
|
i += closeMatch[0].length;
|
|
1618
1623
|
continue;
|
|
1619
1624
|
}
|
|
1620
|
-
|
|
1625
|
+
OPEN_TAG_RE.lastIndex = i;
|
|
1626
|
+
const tagMatch = OPEN_TAG_RE.exec(html);
|
|
1621
1627
|
if (tagMatch) {
|
|
1622
1628
|
const rawTag = tagMatch[1].toLowerCase();
|
|
1623
1629
|
const attrStr = tagMatch[2];
|
|
@@ -1628,8 +1634,10 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
1628
1634
|
while (si < html.length && depth > 0) {
|
|
1629
1635
|
const next = html.indexOf("<", si);
|
|
1630
1636
|
if (next === -1) break;
|
|
1631
|
-
|
|
1632
|
-
const
|
|
1637
|
+
KATEX_CLOSE_SPAN_RE.lastIndex = next;
|
|
1638
|
+
const csm = KATEX_CLOSE_SPAN_RE.exec(html);
|
|
1639
|
+
KATEX_OPEN_SPAN_RE.lastIndex = next;
|
|
1640
|
+
const osm = KATEX_OPEN_SPAN_RE.exec(html);
|
|
1633
1641
|
if (csm) {
|
|
1634
1642
|
depth--;
|
|
1635
1643
|
si = next + csm[0].length;
|
|
@@ -3205,7 +3213,7 @@ function typescript(hljs) {
|
|
|
3205
3213
|
// node_modules/highlight.js/es/languages/python.js
|
|
3206
3214
|
function python(hljs) {
|
|
3207
3215
|
const regex = hljs.regex;
|
|
3208
|
-
const IDENT_RE3 =
|
|
3216
|
+
const IDENT_RE3 = new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*", "u");
|
|
3209
3217
|
const RESERVED_WORDS = [
|
|
3210
3218
|
"and",
|
|
3211
3219
|
"as",
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
1
|
+
/* Dark syntax theme for mini-program code blocks. */
|
|
2
|
+
.md-codeblock {
|
|
3
|
+
background: #111827;
|
|
4
|
+
border: 1px solid #263244;
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.md-codeblock-bar {
|
|
10
|
+
background: #172033;
|
|
11
|
+
border-bottom: 1px solid #263244;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.md-codeblock-lang {
|
|
15
|
+
color: #93c5fd;
|
|
16
|
+
letter-spacing: 0;
|
|
17
|
+
text-transform: uppercase;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.md-code-block {
|
|
21
|
+
background: #111827;
|
|
22
|
+
color: #dbeafe;
|
|
23
|
+
}
|
|
3
24
|
|
|
4
25
|
.hljs {
|
|
5
|
-
color: #
|
|
6
|
-
background:
|
|
26
|
+
color: #dbeafe;
|
|
27
|
+
background: transparent;
|
|
7
28
|
}
|
|
8
29
|
|
|
9
30
|
.hljs-doctag,
|
|
@@ -13,14 +34,14 @@
|
|
|
13
34
|
.hljs-template-variable,
|
|
14
35
|
.hljs-type,
|
|
15
36
|
.hljs-variable.language_ {
|
|
16
|
-
color: #
|
|
37
|
+
color: #f472b6;
|
|
17
38
|
}
|
|
18
39
|
|
|
19
40
|
.hljs-title,
|
|
20
41
|
.hljs-title.class_,
|
|
21
42
|
.hljs-title.class_.inherited__,
|
|
22
43
|
.hljs-title.function_ {
|
|
23
|
-
color: #
|
|
44
|
+
color: #93c5fd;
|
|
24
45
|
}
|
|
25
46
|
|
|
26
47
|
.hljs-attr,
|
|
@@ -33,73 +54,62 @@
|
|
|
33
54
|
.hljs-selector-attr,
|
|
34
55
|
.hljs-selector-class,
|
|
35
56
|
.hljs-selector-id {
|
|
36
|
-
color: #
|
|
57
|
+
color: #67e8f9;
|
|
37
58
|
}
|
|
38
59
|
|
|
39
60
|
.hljs-regexp,
|
|
40
61
|
.hljs-string,
|
|
41
62
|
.hljs-meta .hljs-string {
|
|
42
|
-
color: #
|
|
63
|
+
color: #86efac;
|
|
43
64
|
}
|
|
44
65
|
|
|
45
66
|
.hljs-built_in,
|
|
46
67
|
.hljs-symbol {
|
|
47
|
-
color: #
|
|
68
|
+
color: #fbbf24;
|
|
48
69
|
}
|
|
49
70
|
|
|
50
71
|
.hljs-comment,
|
|
51
72
|
.hljs-code,
|
|
52
73
|
.hljs-formula {
|
|
53
|
-
color: #
|
|
74
|
+
color: #94a3b8;
|
|
54
75
|
}
|
|
55
76
|
|
|
56
77
|
.hljs-name,
|
|
57
78
|
.hljs-quote,
|
|
58
79
|
.hljs-selector-tag,
|
|
59
80
|
.hljs-selector-pseudo {
|
|
60
|
-
color: #
|
|
81
|
+
color: #c4b5fd;
|
|
61
82
|
}
|
|
62
83
|
|
|
63
84
|
.hljs-subst {
|
|
64
|
-
color: #
|
|
85
|
+
color: #dbeafe;
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
.hljs-section {
|
|
68
|
-
color: #
|
|
89
|
+
color: #60a5fa;
|
|
69
90
|
font-weight: bold;
|
|
70
91
|
}
|
|
71
92
|
|
|
72
93
|
.hljs-bullet {
|
|
73
|
-
color: #
|
|
94
|
+
color: #fbbf24;
|
|
74
95
|
}
|
|
75
96
|
|
|
76
97
|
.hljs-emphasis {
|
|
77
|
-
color: #
|
|
98
|
+
color: #dbeafe;
|
|
78
99
|
font-style: italic;
|
|
79
100
|
}
|
|
80
101
|
|
|
81
102
|
.hljs-strong {
|
|
82
|
-
color: #
|
|
103
|
+
color: #eff6ff;
|
|
83
104
|
font-weight: bold;
|
|
84
105
|
}
|
|
85
106
|
|
|
86
107
|
.hljs-addition {
|
|
87
|
-
color: #
|
|
88
|
-
background-color: #
|
|
108
|
+
color: #86efac;
|
|
109
|
+
background-color: #052e16;
|
|
89
110
|
}
|
|
90
111
|
|
|
91
112
|
.hljs-deletion {
|
|
92
|
-
color: #
|
|
93
|
-
background-color: #
|
|
113
|
+
color: #fca5a5;
|
|
114
|
+
background-color: #450a0a;
|
|
94
115
|
}
|
|
95
|
-
|
|
96
|
-
/* Code block wrapper */
|
|
97
|
-
pre .hljs {
|
|
98
|
-
display: block;
|
|
99
|
-
overflow-x: auto;
|
|
100
|
-
padding: 1em;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
code .hljs {
|
|
104
|
-
padding: 3px 5px;
|
|
105
|
-
}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
6
23
|
var __export = (target, all) => {
|
|
7
24
|
for (var name in all)
|
|
8
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -14523,6 +14540,10 @@ var katex = {
|
|
|
14523
14540
|
};
|
|
14524
14541
|
|
|
14525
14542
|
// src/plugins/shared/htmlToMiniNodes.ts
|
|
14543
|
+
var CLOSE_TAG_RE = /<\/(\w+)\s*>/y;
|
|
14544
|
+
var OPEN_TAG_RE = /<(\w+)((?:\s+[^>]*?)?)(\/?)>/y;
|
|
14545
|
+
var KATEX_CLOSE_SPAN_RE = /<\/span\s*>/iy;
|
|
14546
|
+
var KATEX_OPEN_SPAN_RE = /<span[\s>]/iy;
|
|
14526
14547
|
function htmlToMiniNodes(html, escapeText) {
|
|
14527
14548
|
var _a;
|
|
14528
14549
|
const root = { name: "root", children: [] };
|
|
@@ -14560,7 +14581,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
14560
14581
|
}
|
|
14561
14582
|
while (i < html.length) {
|
|
14562
14583
|
if (html[i] === "<") {
|
|
14563
|
-
|
|
14584
|
+
CLOSE_TAG_RE.lastIndex = i;
|
|
14585
|
+
const closeMatch = CLOSE_TAG_RE.exec(html);
|
|
14564
14586
|
if (closeMatch) {
|
|
14565
14587
|
const closeTag = closeMatch[1].toLowerCase();
|
|
14566
14588
|
for (let j = stack.length - 1; j > 0; j--) {
|
|
@@ -14572,7 +14594,8 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
14572
14594
|
i += closeMatch[0].length;
|
|
14573
14595
|
continue;
|
|
14574
14596
|
}
|
|
14575
|
-
|
|
14597
|
+
OPEN_TAG_RE.lastIndex = i;
|
|
14598
|
+
const tagMatch = OPEN_TAG_RE.exec(html);
|
|
14576
14599
|
if (tagMatch) {
|
|
14577
14600
|
const rawTag = tagMatch[1].toLowerCase();
|
|
14578
14601
|
const attrStr = tagMatch[2];
|
|
@@ -14583,8 +14606,10 @@ function htmlToMiniNodes(html, escapeText) {
|
|
|
14583
14606
|
while (si < html.length && depth > 0) {
|
|
14584
14607
|
const next = html.indexOf("<", si);
|
|
14585
14608
|
if (next === -1) break;
|
|
14586
|
-
|
|
14587
|
-
const
|
|
14609
|
+
KATEX_CLOSE_SPAN_RE.lastIndex = next;
|
|
14610
|
+
const csm = KATEX_CLOSE_SPAN_RE.exec(html);
|
|
14611
|
+
KATEX_OPEN_SPAN_RE.lastIndex = next;
|
|
14612
|
+
const osm = KATEX_OPEN_SPAN_RE.exec(html);
|
|
14588
14613
|
if (csm) {
|
|
14589
14614
|
depth--;
|
|
14590
14615
|
si = next + csm[0].length;
|
|
@@ -14683,29 +14708,25 @@ function inlineStart(src) {
|
|
|
14683
14708
|
return void 0;
|
|
14684
14709
|
}
|
|
14685
14710
|
function renderKatex(tex, displayMode, options) {
|
|
14711
|
+
let html;
|
|
14686
14712
|
try {
|
|
14687
|
-
|
|
14713
|
+
html = katex.renderToString(tex, __spreadProps(__spreadValues({
|
|
14688
14714
|
displayMode,
|
|
14689
|
-
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
|
-
|
|
14695
|
-
|
|
14696
|
-
|
|
14715
|
+
output: "html"
|
|
14716
|
+
}, options.katexOptions), {
|
|
14717
|
+
// The plugin owns error handling: force KaTeX to throw on invalid input
|
|
14718
|
+
// so we never emit its red `.katex-error` markup. This is intentionally
|
|
14719
|
+
// set after the spread so a caller's `throwOnError: false` cannot re-enable
|
|
14720
|
+
// the broken-formula output (common during streaming of partial formulas).
|
|
14721
|
+
throwOnError: true
|
|
14722
|
+
}));
|
|
14697
14723
|
} catch (err) {
|
|
14698
|
-
|
|
14699
|
-
return options.onError(tex, err);
|
|
14700
|
-
}
|
|
14701
|
-
return [
|
|
14702
|
-
{
|
|
14703
|
-
name: "span",
|
|
14704
|
-
attrs: { class: "katex-error" },
|
|
14705
|
-
children: [{ name: "text", attrs: { value: err.message } }]
|
|
14706
|
-
}
|
|
14707
|
-
];
|
|
14724
|
+
return options.onError ? options.onError(tex, err) : [];
|
|
14708
14725
|
}
|
|
14726
|
+
const nodes = htmlToMiniNodes(html, false);
|
|
14727
|
+
const wrapper = displayMode ? "div" : "span";
|
|
14728
|
+
const className = displayMode ? "katex-display" : "katex-inline";
|
|
14729
|
+
return [{ name: wrapper, attrs: { class: className }, children: nodes }];
|
|
14709
14730
|
}
|
|
14710
14731
|
function Latex(options = {}) {
|
|
14711
14732
|
return {
|