@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.
Files changed (48) hide show
  1. package/dist/components/Markdown/index.acss +65 -7
  2. package/dist/components/MiniNodeRenderer/index.acss +19 -4
  3. package/dist/components/MiniNodeRenderer/index.axml +109 -29
  4. package/dist/components/MiniNodeRenderer/index.js +12 -0
  5. package/dist/components/MiniNodeRenderer/index.sjs +48 -0
  6. package/dist/es/Markdown/index.acss +65 -7
  7. package/dist/es/MiniNodeRenderer/index.acss +19 -4
  8. package/dist/es/MiniNodeRenderer/index.axml +109 -29
  9. package/dist/es/MiniNodeRenderer/index.js +12 -0
  10. package/dist/es/MiniNodeRenderer/index.sjs +48 -0
  11. package/dist/index.d.mts +39 -1
  12. package/dist/index.d.ts +39 -1
  13. package/dist/index.js +134 -56
  14. package/dist/index.mjs +134 -56
  15. package/dist/miniprogram_dist/components/Markdown/index.json +1 -1
  16. package/dist/miniprogram_dist/components/Markdown/index.wxss +65 -7
  17. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.js +12 -0
  18. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.json +1 -1
  19. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxml +98 -21
  20. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxs +41 -0
  21. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxss +13 -2
  22. package/dist/miniprogram_dist/es/Markdown/index.json +1 -1
  23. package/dist/miniprogram_dist/es/Markdown/index.wxss +65 -7
  24. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.js +12 -0
  25. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.json +1 -1
  26. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxml +98 -21
  27. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxs +41 -0
  28. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxss +13 -2
  29. package/dist/miniprogram_dist/index.js +134 -56
  30. package/dist/miniprogram_dist/plugins/CodeHighlight/index.js +13 -5
  31. package/dist/miniprogram_dist/plugins/CodeHighlight/style.wxss +41 -31
  32. package/dist/miniprogram_dist/plugins/Latex/index.js +44 -23
  33. package/dist/miniprogram_dist/plugins/Latex/style.wxss +11 -11
  34. package/dist/miniprogram_dist/shared/flattenInline.js +33 -5
  35. package/dist/plugins/CodeHighlight/index.d.mts +1 -1
  36. package/dist/plugins/CodeHighlight/index.d.ts +1 -1
  37. package/dist/plugins/CodeHighlight/index.js +13 -5
  38. package/dist/plugins/CodeHighlight/index.mjs +13 -5
  39. package/dist/plugins/CodeHighlight/style.acss +41 -31
  40. package/dist/plugins/Latex/index.d.mts +1 -1
  41. package/dist/plugins/Latex/index.d.ts +1 -1
  42. package/dist/plugins/Latex/index.js +44 -23
  43. package/dist/plugins/Latex/index.mjs +47 -23
  44. package/dist/plugins/Latex/style.acss +11 -6
  45. package/dist/shared/flattenInline.js +33 -5
  46. package/dist/{types-CegkonfJ.d.mts → types-BcxGtbQZ.d.mts} +25 -0
  47. package/dist/{types-CegkonfJ.d.ts → types-BcxGtbQZ.d.ts} +25 -0
  48. package/package.json +3 -2
@@ -1,9 +1,37 @@
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;
6
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, b3) => {
12
+ for (var prop in b3 || (b3 = {}))
13
+ if (__hasOwnProp.call(b3, prop))
14
+ __defNormalProp(a, prop, b3[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b3)) {
17
+ if (__propIsEnum.call(b3, prop))
18
+ __defNormalProp(a, prop, b3[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b3) => __defProps(a, __getOwnPropDescs(b3));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
7
35
  var __export = (target, all) => {
8
36
  for (var name in all)
9
37
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,6 +54,7 @@ __export(src_exports, {
26
54
  StreamingProcessor: () => StreamingProcessor,
27
55
  XMarkdownMini: () => XMarkdownMini,
28
56
  alipayRenderer: () => alipayRenderer,
57
+ copyButton: () => copyButton,
29
58
  flattenInlineTokens: () => flattenInlineTokens,
30
59
  getPlatformRenderer: () => getPlatformRenderer,
31
60
  parse: () => parse,
@@ -86,9 +115,9 @@ var ae = d(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").repla
86
115
  var Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex();
87
116
  var K = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr: I, html: _e, lheading: oe, list: Le, newline: Te, paragraph: ae, table: _, text: Se };
88
117
  var re = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
89
- var ze = { ...K, lheading: Pe, table: re, paragraph: d(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() };
90
- var Ee = { ...K, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(j).replace("hr", I).replace("heading", ` *#{1,6} *[^
91
- ]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
118
+ var ze = __spreadProps(__spreadValues({}, K), { lheading: Pe, table: re, paragraph: d(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() });
119
+ var Ee = __spreadProps(__spreadValues({}, K), { html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(j).replace("hr", I).replace("heading", ` *#{1,6} *[^
120
+ ]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() });
92
121
  var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
93
122
  var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
94
123
  var le = /^( {2,}|\\)\n(?!\s*$)/;
@@ -122,9 +151,9 @@ var ke = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex();
122
151
  var Ye = d("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
123
152
  var se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
124
153
  var X = { _backpedal: _, anyPunctuation: Ke, autolink: We, blockSkip: ve, br: le, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: He, emStrongRDelimAst: Ge, emStrongRDelimUnd: Qe, escape: Ae, link: Ve, nolink: ke, punctuation: Be, reflink: he, reflinkSearch: Ye, tag: Je, text: Ie, url: _ };
125
- var et = { ...X, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
126
- var N = { ...X, emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", se).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", se).getRegex() };
127
- var tt = { ...N, br: d(le).replace("{2,}", "*").getRegex(), text: d(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
154
+ var et = __spreadProps(__spreadValues({}, X), { link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() });
155
+ var N = __spreadProps(__spreadValues({}, X), { emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", se).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", se).getRegex() });
156
+ var tt = __spreadProps(__spreadValues({}, N), { br: d(le).replace("{2,}", "*").getRegex(), text: d(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() });
128
157
  var B = { normal: K, gfm: ze, pedantic: Ee };
129
158
  var A = { normal: X, gfm: N, breaks: tt, pedantic: et };
130
159
  var nt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
@@ -1128,7 +1157,7 @@ var D = class {
1128
1157
  use(...e) {
1129
1158
  let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1130
1159
  return e.forEach((n) => {
1131
- let s = { ...n };
1160
+ let s = __spreadValues({}, n);
1132
1161
  if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
1133
1162
  if (!r.name) throw new Error("extension name required");
1134
1163
  if ("renderer" in r) {
@@ -1201,11 +1230,11 @@ var D = class {
1201
1230
  return u2.push(i.call(this, o)), r && (u2 = u2.concat(r.call(this, o))), u2;
1202
1231
  };
1203
1232
  }
1204
- this.defaults = { ...this.defaults, ...s };
1233
+ this.defaults = __spreadValues(__spreadValues({}, this.defaults), s);
1205
1234
  }), this;
1206
1235
  }
1207
1236
  setOptions(e) {
1208
- return this.defaults = { ...this.defaults, ...e }, this;
1237
+ return this.defaults = __spreadValues(__spreadValues({}, this.defaults), e), this;
1209
1238
  }
1210
1239
  lexer(e, t) {
1211
1240
  return x.lex(e, t != null ? t : this.defaults);
@@ -1215,7 +1244,7 @@ var D = class {
1215
1244
  }
1216
1245
  parseMarkdown(e) {
1217
1246
  return (n, s) => {
1218
- let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
1247
+ let r = __spreadValues({}, s), i = __spreadValues(__spreadValues({}, this.defaults), r), o = this.onError(!!i.silent, !!i.async);
1219
1248
  if (this.defaults.async === true && r.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1220
1249
  if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
1221
1250
  if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
@@ -1282,6 +1311,10 @@ var Jt = b.parse;
1282
1311
  var Vt = x.lex;
1283
1312
 
1284
1313
  // src/plugins/shared/htmlToMiniNodes.ts
1314
+ var CLOSE_TAG_RE = /<\/(\w+)\s*>/y;
1315
+ var OPEN_TAG_RE = /<(\w+)((?:\s+[^>]*?)?)(\/?)>/y;
1316
+ var KATEX_CLOSE_SPAN_RE = /<\/span\s*>/iy;
1317
+ var KATEX_OPEN_SPAN_RE = /<span[\s>]/iy;
1285
1318
  function htmlToMiniNodes(html, escapeText) {
1286
1319
  var _a2;
1287
1320
  const root = { name: "root", children: [] };
@@ -1319,7 +1352,8 @@ function htmlToMiniNodes(html, escapeText) {
1319
1352
  }
1320
1353
  while (i < html.length) {
1321
1354
  if (html[i] === "<") {
1322
- const closeMatch = /^<\/(\w+)\s*>/.exec(html.slice(i));
1355
+ CLOSE_TAG_RE.lastIndex = i;
1356
+ const closeMatch = CLOSE_TAG_RE.exec(html);
1323
1357
  if (closeMatch) {
1324
1358
  const closeTag = closeMatch[1].toLowerCase();
1325
1359
  for (let j3 = stack.length - 1; j3 > 0; j3--) {
@@ -1331,7 +1365,8 @@ function htmlToMiniNodes(html, escapeText) {
1331
1365
  i += closeMatch[0].length;
1332
1366
  continue;
1333
1367
  }
1334
- const tagMatch = /^<(\w+)((?:\s+[^>]*?)?)(\/?)>/.exec(html.slice(i));
1368
+ OPEN_TAG_RE.lastIndex = i;
1369
+ const tagMatch = OPEN_TAG_RE.exec(html);
1335
1370
  if (tagMatch) {
1336
1371
  const rawTag = tagMatch[1].toLowerCase();
1337
1372
  const attrStr = tagMatch[2];
@@ -1342,8 +1377,10 @@ function htmlToMiniNodes(html, escapeText) {
1342
1377
  while (si < html.length && depth > 0) {
1343
1378
  const next = html.indexOf("<", si);
1344
1379
  if (next === -1) break;
1345
- const csm = /^<\/span\s*>/i.exec(html.slice(next));
1346
- const osm = /^<span[\s>]/i.exec(html.slice(next));
1380
+ KATEX_CLOSE_SPAN_RE.lastIndex = next;
1381
+ const csm = KATEX_CLOSE_SPAN_RE.exec(html);
1382
+ KATEX_OPEN_SPAN_RE.lastIndex = next;
1383
+ const osm = KATEX_OPEN_SPAN_RE.exec(html);
1347
1384
  if (csm) {
1348
1385
  depth--;
1349
1386
  si = next + csm[0].length;
@@ -1458,7 +1495,7 @@ function inlineNode(adapter, node, token) {
1458
1495
  }
1459
1496
  function compactNode(node) {
1460
1497
  if (node.attrs && Object.keys(node.attrs).length === 0) {
1461
- const { attrs: _attrs, ...rest } = node;
1498
+ const _a2 = node, { attrs: _attrs } = _a2, rest = __objRest(_a2, ["attrs"]);
1462
1499
  return rest;
1463
1500
  }
1464
1501
  return node;
@@ -1485,10 +1522,41 @@ function collectText(nodes) {
1485
1522
  }
1486
1523
  return out;
1487
1524
  }
1525
+ function copyButton(text) {
1526
+ return { name: "copy-button", attrs: { "data-copy": text, class: "md-copy-icon" } };
1527
+ }
1528
+ function asNodeArray(x3) {
1529
+ if (!x3) return [];
1530
+ return Array.isArray(x3) ? x3 : [x3];
1531
+ }
1532
+ function buildCodeHeader(ctx, lang, text, token) {
1533
+ const cfg = ctx.codeHeader;
1534
+ if (cfg === false) return [];
1535
+ if (typeof cfg === "function") return asNodeArray(cfg({ lang, text, token }));
1536
+ return [
1537
+ { name: "text", attrs: { class: "md-codeblock-lang", value: lang || "code" } },
1538
+ copyButton(text)
1539
+ ];
1540
+ }
1541
+ function buildTableHeader(ctx, token) {
1542
+ var _a2;
1543
+ const cfg = ctx.tableHeader;
1544
+ if (cfg === false) return [];
1545
+ const markdown = (_a2 = token.raw) != null ? _a2 : "";
1546
+ if (typeof cfg === "function") return asNodeArray(cfg({ markdown, token }));
1547
+ return [
1548
+ { name: "text", attrs: { class: "md-tableblock-title", value: "\u8868\u683C" } },
1549
+ copyButton(markdown)
1550
+ ];
1551
+ }
1552
+ function withHeader(node, header) {
1553
+ if (header.length) node.header = header;
1554
+ return node;
1555
+ }
1488
1556
  function renderTokensToMiniNodes(tokens, adapter, ctx = {}) {
1489
1557
  const animate = ctx.animation === true;
1490
1558
  const enc = ctx.escapeText === false ? (s) => s : escapeHtml;
1491
- const localCtx = { ...ctx };
1559
+ const localCtx = __spreadValues({}, ctx);
1492
1560
  localCtx.renderInlineTokens = (inner) => inlineTokens(inner, adapter, enc, localCtx);
1493
1561
  return blockTokens(tokens, adapter, animate, enc, localCtx);
1494
1562
  }
@@ -1501,7 +1569,7 @@ function blockTokens(tokens, adapter, animate, enc, ctx) {
1501
1569
  return out;
1502
1570
  }
1503
1571
  function blockTok(tok, adapter, animate, enc, ctx) {
1504
- var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m;
1572
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p;
1505
1573
  switch (tok.type) {
1506
1574
  case "space":
1507
1575
  return null;
@@ -1515,23 +1583,26 @@ function blockTok(tok, adapter, animate, enc, ctx) {
1515
1583
  return block("p", inlineTokens((_c = t.tokens) != null ? _c : [], adapter, enc, ctx), animate, adapter, tok);
1516
1584
  }
1517
1585
  case "code": {
1518
- const custom = renderCustomToken(tok, ctx);
1519
- if (custom.length) return block("pre", custom, animate, adapter, tok);
1520
1586
  const t = tok;
1587
+ const lang = (_e2 = ((_d = t.lang) != null ? _d : "").trim().split(/\s+/)[0]) != null ? _e2 : "";
1588
+ const preAttrs = lang ? { class: "md-code-block", lang } : { class: "md-code-block" };
1589
+ const header = buildCodeHeader(ctx, lang, (_f = t.text) != null ? _f : "", t);
1590
+ const custom = renderCustomToken(tok, ctx);
1591
+ if (custom.length) return withHeader(block("pre", custom, animate, adapter, tok, preAttrs), header);
1521
1592
  if (!supports(adapter, "supportsPre")) {
1522
- return textBlock(enc((_d = t.text) != null ? _d : ""), animate, adapter, tok);
1593
+ return textBlock(enc((_g = t.text) != null ? _g : ""), animate, adapter, tok);
1523
1594
  }
1524
1595
  const codeChild = {
1525
1596
  name: "code",
1526
- children: [{ name: "text", attrs: { value: enc((_e2 = t.text) != null ? _e2 : "") } }]
1597
+ children: [{ name: "text", attrs: { value: enc((_h = t.text) != null ? _h : "") } }]
1527
1598
  };
1528
- return block("pre", [codeChild], animate, adapter, tok);
1599
+ return withHeader(block("pre", [codeChild], animate, adapter, tok, preAttrs), header);
1529
1600
  }
1530
1601
  case "hr":
1531
1602
  return block("hr", [], animate, adapter, tok);
1532
1603
  case "blockquote": {
1533
1604
  const t = tok;
1534
- const children = blockTokens((_f = t.tokens) != null ? _f : [], adapter, animate, enc, ctx);
1605
+ const children = blockTokens((_i = t.tokens) != null ? _i : [], adapter, animate, enc, ctx);
1535
1606
  if (!supports(adapter, "supportsBlockquote")) {
1536
1607
  return textBlock(collectText(children), animate, adapter, tok);
1537
1608
  }
@@ -1547,15 +1618,15 @@ function blockTok(tok, adapter, animate, enc, ctx) {
1547
1618
  }
1548
1619
  case "html": {
1549
1620
  const t = tok;
1550
- const raw = ((_h = (_g = t.text) != null ? _g : t.raw) != null ? _h : "").replace(/\s+$/, "");
1621
+ const raw = ((_k = (_j = t.text) != null ? _j : t.raw) != null ? _k : "").replace(/\s+$/, "");
1551
1622
  return block("div", raw ? [{ name: "text", attrs: { value: raw } }] : [], animate, adapter, tok);
1552
1623
  }
1553
1624
  case "table": {
1554
1625
  const t = tok;
1555
1626
  if (!supports(adapter, "supportsTable")) {
1556
1627
  const rows = [
1557
- (_i = t.header) != null ? _i : [],
1558
- ...(_j = t.rows) != null ? _j : []
1628
+ (_l = t.header) != null ? _l : [],
1629
+ ...(_m = t.rows) != null ? _m : []
1559
1630
  ];
1560
1631
  const value = rows.map((row) => row.map((cell) => {
1561
1632
  var _a3;
@@ -1563,33 +1634,35 @@ function blockTok(tok, adapter, animate, enc, ctx) {
1563
1634
  }).join(" ")).join("\n");
1564
1635
  return textBlock(value, animate, adapter, tok);
1565
1636
  }
1566
- const headCells = ((_k = t.header) != null ? _k : []).map((cell) => {
1637
+ const headCells = ((_n2 = t.header) != null ? _n2 : []).map((cell) => {
1567
1638
  var _a3;
1568
1639
  return {
1569
1640
  name: "th",
1641
+ attrs: { class: "md-th" },
1570
1642
  children: inlineTokens((_a3 = cell.tokens) != null ? _a3 : [], adapter, enc, ctx)
1571
1643
  };
1572
1644
  });
1573
- const rowNodes = ((_l = t.rows) != null ? _l : []).map((row) => ({
1645
+ const rowNodes = ((_o = t.rows) != null ? _o : []).map((row) => ({
1574
1646
  name: "tr",
1647
+ attrs: { class: "md-tr" },
1575
1648
  children: row.map((cell) => {
1576
1649
  var _a3;
1577
1650
  return {
1578
1651
  name: "td",
1652
+ attrs: { class: "md-td" },
1579
1653
  children: inlineTokens((_a3 = cell.tokens) != null ? _a3 : [], adapter, enc, ctx)
1580
1654
  };
1581
1655
  })
1582
1656
  }));
1583
- const thead = {
1584
- name: "thead",
1585
- children: [{ name: "tr", attrs: {}, children: headCells }]
1586
- };
1587
- const tbody = { name: "tbody", attrs: {}, children: rowNodes };
1588
- return block("table", [compactNode(thead), compactNode(tbody)], animate, adapter, tok);
1657
+ const headerRow = { name: "tr", attrs: { class: "md-tr" }, children: headCells };
1658
+ return withHeader(
1659
+ block("table", [headerRow, ...rowNodes], animate, adapter, tok, { class: "md-table" }),
1660
+ buildTableHeader(ctx, t)
1661
+ );
1589
1662
  }
1590
1663
  case "text": {
1591
1664
  const t = tok;
1592
- const inline = t.tokens ? inlineTokens(t.tokens, adapter, enc, ctx) : [{ name: "text", attrs: { value: enc((_m = t.text) != null ? _m : "") } }];
1665
+ const inline = t.tokens ? inlineTokens(t.tokens, adapter, enc, ctx) : [{ name: "text", attrs: { value: enc((_p = t.text) != null ? _p : "") } }];
1593
1666
  return block("p", inline, animate, adapter, tok);
1594
1667
  }
1595
1668
  case "def":
@@ -1678,6 +1751,7 @@ function inlineTok(tok, adapter, enc, out, ctx) {
1678
1751
  const t = tok;
1679
1752
  const node = inlineNode(adapter, {
1680
1753
  name: "code",
1754
+ attrs: { class: "md-inline-code" },
1681
1755
  children: [{ name: "text", attrs: { value: enc((_f = t.text) != null ? _f : "") } }]
1682
1756
  }, tok);
1683
1757
  if (node) out.push(node);
@@ -1744,7 +1818,7 @@ var alipayAdapter = {
1744
1818
  olAttrs: () => ({})
1745
1819
  };
1746
1820
  function tokensToAlipay(content, opts = {}) {
1747
- const { options, ...ctx } = opts;
1821
+ const _a2 = opts, { options } = _a2, ctx = __objRest(_a2, ["options"]);
1748
1822
  const tokens = x.lex(content, buildMarkedOptions(options != null ? options : {}));
1749
1823
  return tokensToAlipayNodes(tokens, ctx);
1750
1824
  }
@@ -1782,7 +1856,7 @@ var wechatAdapter = {
1782
1856
  }
1783
1857
  };
1784
1858
  function tokensToWechat(content, opts = {}) {
1785
- const { options, ...ctx } = opts;
1859
+ const _a2 = opts, { options } = _a2, ctx = __objRest(_a2, ["options"]);
1786
1860
  const tokens = x.lex(content, buildMarkedOptions2(options != null ? options : {}));
1787
1861
  return tokensToWechatNodes(tokens, ctx);
1788
1862
  }
@@ -1972,6 +2046,7 @@ var StreamingProcessor = class {
1972
2046
  // --- 内部 ---
1973
2047
  /** 按 delimiters + maxChunkSize 把 buffer 切成 chunk 序列;hasNext=false 时 flush 末尾。 */
1974
2048
  splitIntoChunks(hasNextChunk) {
2049
+ var _a2;
1975
2050
  const { semanticEnabled, delimiters = DEFAULT_DELIMITERS, maxChunkSize = DEFAULT_MAX_CHUNK_SIZE } = this.config;
1976
2051
  const pending = [];
1977
2052
  let remaining = this.buffer;
@@ -1979,7 +2054,7 @@ var StreamingProcessor = class {
1979
2054
  let chunk = "";
1980
2055
  if (semanticEnabled) {
1981
2056
  const m3 = remaining.match(delimiters);
1982
- const cut = m3 ? remaining.indexOf(m3[0]) + 1 : -1;
2057
+ const cut = m3 ? ((_a2 = m3.index) != null ? _a2 : 0) + 1 : -1;
1983
2058
  if (cut > 0) {
1984
2059
  chunk = remaining.slice(0, cut);
1985
2060
  remaining = remaining.slice(cut);
@@ -2739,12 +2814,14 @@ var XMarkdownMini = class {
2739
2814
  this.nodeStreamProcessor = null;
2740
2815
  this.activeTokenStreamDefaults = null;
2741
2816
  this.activeNodeStreamDefaults = null;
2742
- var _a2, _b, _c;
2817
+ var _a2, _b, _c, _d, _e2;
2743
2818
  this.escapeText = (_a2 = opts.escapeText) != null ? _a2 : true;
2744
2819
  this.fixup = resolveStreamingFixup((_b = opts.streamingFixup) != null ? _b : "remend");
2745
2820
  this.gfm = opts.gfm;
2746
2821
  this.breaks = opts.breaks;
2747
- const directExtensions = (_c = opts.extensions) != null ? _c : [];
2822
+ this.codeHeader = (_c = opts.codeBlock) == null ? void 0 : _c.header;
2823
+ this.tableHeader = (_d = opts.table) == null ? void 0 : _d.header;
2824
+ const directExtensions = (_e2 = opts.extensions) != null ? _e2 : [];
2748
2825
  this.componentsExtension = opts.components && opts.components.length > 0 ? synthesizeComponentsExtension(opts.components) : void 0;
2749
2826
  const allMarkedExtensions = [
2750
2827
  ...directExtensions,
@@ -2778,7 +2855,7 @@ var XMarkdownMini = class {
2778
2855
  */
2779
2856
  applyPerCallExtensions(perCall) {
2780
2857
  if (!perCall || perCall.length === 0) return null;
2781
- const saved = { ...this.marked.defaults };
2858
+ const saved = __spreadValues({}, this.marked.defaults);
2782
2859
  this.marked.use(...perCall);
2783
2860
  return saved;
2784
2861
  }
@@ -2789,11 +2866,7 @@ var XMarkdownMini = class {
2789
2866
  var _a2, _b;
2790
2867
  const gfm = (_a2 = perCall == null ? void 0 : perCall.gfm) != null ? _a2 : this.gfm;
2791
2868
  const breaks = (_b = perCall == null ? void 0 : perCall.breaks) != null ? _b : this.breaks;
2792
- return {
2793
- ...this.marked.defaults,
2794
- ...gfm !== void 0 ? { gfm: gfm !== false } : {},
2795
- ...breaks !== void 0 ? { breaks: !!breaks } : {}
2796
- };
2869
+ return __spreadValues(__spreadValues(__spreadValues({}, this.marked.defaults), gfm !== void 0 ? { gfm: gfm !== false } : {}), breaks !== void 0 ? { breaks: !!breaks } : {});
2797
2870
  }
2798
2871
  lex(content, opts) {
2799
2872
  const tokens = this.marked.lexer(content, opts != null ? opts : this.buildMarkedOptions());
@@ -2840,11 +2913,11 @@ var XMarkdownMini = class {
2840
2913
  this.activeTokenStreamDefaults = this.applyPerCallExtensions(perCallExts);
2841
2914
  const markedOpts = this.buildMarkedOptions({ gfm, breaks });
2842
2915
  const transform = (md) => this.lex(md, markedOpts);
2843
- this.tokenStreamProcessor = new StreamingProcessor({
2916
+ this.tokenStreamProcessor = new StreamingProcessor(__spreadProps(__spreadValues({
2844
2917
  transform,
2845
2918
  fixup: this.fixup,
2846
- semanticEnabled: stream.semanticEnabled,
2847
- ...stream.semanticConfig,
2919
+ semanticEnabled: stream.semanticEnabled
2920
+ }, stream.semanticConfig), {
2848
2921
  onUpdate: (markdown) => {
2849
2922
  var _a3;
2850
2923
  return (_a3 = props.onRenderProgress) == null ? void 0 : _a3.call(props, { markdown });
@@ -2860,7 +2933,7 @@ var XMarkdownMini = class {
2860
2933
  this.restoreDefaults(this.activeTokenStreamDefaults);
2861
2934
  this.activeTokenStreamDefaults = null;
2862
2935
  }
2863
- });
2936
+ }));
2864
2937
  (_d = props.onRenderStart) == null ? void 0 : _d.call(props);
2865
2938
  }
2866
2939
  this.tokenStreamProcessor.handleContentUpdate(content);
@@ -2889,7 +2962,9 @@ var XMarkdownMini = class {
2889
2962
  animation: false,
2890
2963
  selectable,
2891
2964
  escapeText: this.escapeText,
2892
- extensions: ctxExtensions
2965
+ extensions: ctxExtensions,
2966
+ codeHeader: this.codeHeader,
2967
+ tableHeader: this.tableHeader
2893
2968
  };
2894
2969
  const tokens = this.lex(content, markedOpts);
2895
2970
  const nodes = renderer.renderTokens(tokens, ctx);
@@ -2907,14 +2982,16 @@ var XMarkdownMini = class {
2907
2982
  animation: stream.enableAnimation,
2908
2983
  selectable,
2909
2984
  escapeText: this.escapeText,
2910
- extensions: ctxExtensions
2985
+ extensions: ctxExtensions,
2986
+ codeHeader: this.codeHeader,
2987
+ tableHeader: this.tableHeader
2911
2988
  };
2912
2989
  const transform = (md) => renderer.renderTokens(this.lex(md, markedOpts), ctx);
2913
- this.nodeStreamProcessor = new StreamingProcessor({
2990
+ this.nodeStreamProcessor = new StreamingProcessor(__spreadProps(__spreadValues({
2914
2991
  transform,
2915
2992
  fixup: this.fixup,
2916
- semanticEnabled: stream.semanticEnabled,
2917
- ...stream.semanticConfig,
2993
+ semanticEnabled: stream.semanticEnabled
2994
+ }, stream.semanticConfig), {
2918
2995
  onUpdate: (markdown) => {
2919
2996
  var _a3;
2920
2997
  return (_a3 = props.onRenderProgress) == null ? void 0 : _a3.call(props, { markdown });
@@ -2930,7 +3007,7 @@ var XMarkdownMini = class {
2930
3007
  this.restoreDefaults(this.activeNodeStreamDefaults);
2931
3008
  this.activeNodeStreamDefaults = null;
2932
3009
  }
2933
- });
3010
+ }));
2934
3011
  (_d = props.onRenderStart) == null ? void 0 : _d.call(props);
2935
3012
  }
2936
3013
  this.nodeStreamProcessor.handleContentUpdate(content);
@@ -3136,6 +3213,7 @@ function renderNodes(props) {
3136
3213
  StreamingProcessor,
3137
3214
  XMarkdownMini,
3138
3215
  alipayRenderer,
3216
+ copyButton,
3139
3217
  flattenInlineTokens,
3140
3218
  getPlatformRenderer,
3141
3219
  parse,
@@ -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
- const closeMatch = /^<\/(\w+)\s*>/.exec(html.slice(i));
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
- const tagMatch = /^<(\w+)((?:\s+[^>]*?)?)(\/?)>/.exec(html.slice(i));
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
- const csm = /^<\/span\s*>/i.exec(html.slice(next));
1645
- const osm = /^<span[\s>]/i.exec(html.slice(next));
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 = /[\p{XID_Start}_]\p{XID_Continue}*/u;
3229
+ const IDENT_RE3 = new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*", "u");
3222
3230
  const RESERVED_WORDS = [
3223
3231
  "and",
3224
3232
  "as",
@@ -1,9 +1,30 @@
1
- /* highlight.js GitHub-style light theme for Alipay mini-program.
2
- * Based on highlight.js/styles/github.css. Adapted for mini-program CSS compat. */
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: #24292e;
6
- background: #ffffff;
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: #d73a49;
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: #6f42c1;
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: #005cc5;
57
+ color: #67e8f9;
37
58
  }
38
59
 
39
60
  .hljs-regexp,
40
61
  .hljs-string,
41
62
  .hljs-meta .hljs-string {
42
- color: #032f62;
63
+ color: #86efac;
43
64
  }
44
65
 
45
66
  .hljs-built_in,
46
67
  .hljs-symbol {
47
- color: #e36209;
68
+ color: #fbbf24;
48
69
  }
49
70
 
50
71
  .hljs-comment,
51
72
  .hljs-code,
52
73
  .hljs-formula {
53
- color: #6a737d;
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: #22863a;
81
+ color: #c4b5fd;
61
82
  }
62
83
 
63
84
  .hljs-subst {
64
- color: #24292e;
85
+ color: #dbeafe;
65
86
  }
66
87
 
67
88
  .hljs-section {
68
- color: #005cc5;
89
+ color: #60a5fa;
69
90
  font-weight: bold;
70
91
  }
71
92
 
72
93
  .hljs-bullet {
73
- color: #e36209;
94
+ color: #fbbf24;
74
95
  }
75
96
 
76
97
  .hljs-emphasis {
77
- color: #24292e;
98
+ color: #dbeafe;
78
99
  font-style: italic;
79
100
  }
80
101
 
81
102
  .hljs-strong {
82
- color: #24292e;
103
+ color: #eff6ff;
83
104
  font-weight: bold;
84
105
  }
85
106
 
86
107
  .hljs-addition {
87
- color: #22863a;
88
- background-color: #f0fff4;
108
+ color: #86efac;
109
+ background-color: #052e16;
89
110
  }
90
111
 
91
112
  .hljs-deletion {
92
- color: #b31d28;
93
- background-color: #ffeef0;
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
- }