@wsxjs/wsx-press 0.0.25 → 0.0.27

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/node.js CHANGED
@@ -119,10 +119,10 @@ async function Pe(a) {
119
119
  publicPath: l
120
120
  });
121
121
  o.options.addReader(new Ae()), o.options.addReader(new Ie());
122
- const p = await o.convert();
123
- if (!p)
122
+ const h = await o.convert();
123
+ if (!h)
124
124
  throw new Error("Failed to convert TypeScript project");
125
- await o.generateDocs(p, t);
125
+ await o.generateDocs(h, t);
126
126
  } catch (o) {
127
127
  throw new Error(
128
128
  `Failed to generate API documentation: ${o instanceof Error ? o.message : String(o)}`
@@ -144,7 +144,7 @@ function J() {
144
144
  };
145
145
  }
146
146
  let A = J();
147
- function pe(a) {
147
+ function he(a) {
148
148
  A = a;
149
149
  }
150
150
  const ue = /[&<>"']/, ve = new RegExp(ue.source, "g"), fe = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, Oe = new RegExp(fe.source, "g"), Le = {
@@ -190,8 +190,8 @@ function oe(a) {
190
190
  const E = { exec: () => null };
191
191
  function le(a, n) {
192
192
  const e = a.replace(/\|/g, (r, s, l) => {
193
- let o = !1, p = s;
194
- for (; --p >= 0 && l[p] === "\\"; )
193
+ let o = !1, h = s;
194
+ for (; --h >= 0 && l[h] === "\\"; )
195
195
  o = !o;
196
196
  return o ? "|" : " |";
197
197
  }), t = e.split(/ \|/);
@@ -364,39 +364,39 @@ class N {
364
364
  };
365
365
  t = i ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = i ? t : "[*+-]");
366
366
  const s = new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`);
367
- let l = "", o = "", p = !1;
367
+ let l = "", o = "", h = !1;
368
368
  for (; n; ) {
369
369
  let c = !1;
370
370
  if (!(e = s.exec(n)) || this.rules.block.hr.test(n))
371
371
  break;
372
372
  l = e[0], n = n.substring(l.length);
373
373
  let u = e[2].split(`
374
- `, 1)[0].replace(/^\t+/, (M) => " ".repeat(3 * M.length)), h = n.split(`
374
+ `, 1)[0].replace(/^\t+/, (M) => " ".repeat(3 * M.length)), p = n.split(`
375
375
  `, 1)[0], f = 0;
376
376
  this.options.pedantic ? (f = 2, o = u.trimStart()) : (f = e[2].search(/[^ ]/), f = f > 4 ? 1 : f, o = u.slice(f), f += e[1].length);
377
377
  let w = !1;
378
- if (!u && /^ *$/.test(h) && (l += h + `
379
- `, n = n.substring(h.length + 1), c = !0), !c) {
378
+ if (!u && /^ *$/.test(p) && (l += p + `
379
+ `, n = n.substring(p.length + 1), c = !0), !c) {
380
380
  const M = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), Y = new RegExp(`^ {0,${Math.min(3, f - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), ee = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:\`\`\`|~~~)`), te = new RegExp(`^ {0,${Math.min(3, f - 1)}}#`);
381
381
  for (; n; ) {
382
382
  const F = n.split(`
383
383
  `, 1)[0];
384
- if (h = F, this.options.pedantic && (h = h.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), ee.test(h) || te.test(h) || M.test(h) || Y.test(n))
384
+ if (p = F, this.options.pedantic && (p = p.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), ee.test(p) || te.test(p) || M.test(p) || Y.test(n))
385
385
  break;
386
- if (h.search(/[^ ]/) >= f || !h.trim())
386
+ if (p.search(/[^ ]/) >= f || !p.trim())
387
387
  o += `
388
- ` + h.slice(f);
388
+ ` + p.slice(f);
389
389
  else {
390
390
  if (w || u.search(/[^ ]/) >= 4 || ee.test(u) || te.test(u) || Y.test(u))
391
391
  break;
392
392
  o += `
393
- ` + h;
393
+ ` + p;
394
394
  }
395
- !w && !h.trim() && (w = !0), l += F + `
396
- `, n = n.substring(F.length + 1), u = h.slice(f);
395
+ !w && !p.trim() && (w = !0), l += F + `
396
+ `, n = n.substring(F.length + 1), u = p.slice(f);
397
397
  }
398
398
  }
399
- r.loose || (p ? r.loose = !0 : /\n *\n *$/.test(l) && (p = !0));
399
+ r.loose || (h ? r.loose = !0 : /\n *\n *$/.test(l) && (h = !0));
400
400
  let y = null, R;
401
401
  this.options.gfm && (y = /^\[[ xX]\] /.exec(o), y && (R = y[0] !== "[ ] ", o = o.replace(/^\[[ xX]\] +/, ""))), r.items.push({
402
402
  type: "list_item",
@@ -411,8 +411,8 @@ class N {
411
411
  r.items[r.items.length - 1].raw = l.trimEnd(), r.items[r.items.length - 1].text = o.trimEnd(), r.raw = r.raw.trimEnd();
412
412
  for (let c = 0; c < r.items.length; c++)
413
413
  if (this.lexer.state.top = !1, r.items[c].tokens = this.lexer.blockTokens(r.items[c].text, []), !r.loose) {
414
- const u = r.items[c].tokens.filter((f) => f.type === "space"), h = u.length > 0 && u.some((f) => /\n.*\n/.test(f.raw));
415
- r.loose = h;
414
+ const u = r.items[c].tokens.filter((f) => f.type === "space"), p = u.length > 0 && u.some((f) => /\n.*\n/.test(f.raw));
415
+ r.loose = p;
416
416
  }
417
417
  if (r.loose)
418
418
  for (let c = 0; c < r.items.length; c++)
@@ -577,22 +577,22 @@ class N {
577
577
  return;
578
578
  if (!(i[1] || i[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
579
579
  const s = [...i[0]].length - 1;
580
- let l, o, p = s, c = 0;
580
+ let l, o, h = s, c = 0;
581
581
  const u = i[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
582
582
  for (u.lastIndex = 0, e = e.slice(-1 * n.length + s); (i = u.exec(e)) != null; ) {
583
583
  if (l = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !l)
584
584
  continue;
585
585
  if (o = [...l].length, i[3] || i[4]) {
586
- p += o;
586
+ h += o;
587
587
  continue;
588
588
  } else if ((i[5] || i[6]) && s % 3 && !((s + o) % 3)) {
589
589
  c += o;
590
590
  continue;
591
591
  }
592
- if (p -= o, p > 0)
592
+ if (h -= o, h > 0)
593
593
  continue;
594
- o = Math.min(o, o + p + c);
595
- const h = [...i[0]][0].length, f = n.slice(0, s + i.index + h + o);
594
+ o = Math.min(o, o + h + c);
595
+ const p = [...i[0]][0].length, f = n.slice(0, s + i.index + p + o);
596
596
  if (Math.min(s, o) % 2) {
597
597
  const y = f.slice(1, -1);
598
598
  return {
@@ -730,7 +730,7 @@ const Me = /^(?: *(?:\n|$))+/, Fe = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Qe =
730
730
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
731
731
  paragraph: d(W).replace("hr", j).replace("heading", ` *#{1,6} *[^
732
732
  ]`).replace("lheading", de).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
733
- }, xe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ye = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, me = /^( {2,}|\\)\n(?!\s*$)/, et = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, P = "\\p{P}\\p{S}", tt = d(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, P).getRegex(), nt = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, st = d(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, P).getRegex(), it = d("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, P).getRegex(), rt = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, P).getRegex(), ot = d(/\\([punct])/, "gu").replace(/punct/g, P).getRegex(), lt = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), at = d(U).replace("(?:-->|$)", "-->").getRegex(), ct = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", at).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Z = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, ht = d(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Z).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), we = d(/^!?\[(label)\]\[(ref)\]/).replace("label", Z).replace("ref", G).getRegex(), be = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", G).getRegex(), pt = d("reflink|nolink(?!\\()", "g").replace("reflink", we).replace("nolink", be).getRegex(), V = {
733
+ }, xe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ye = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, me = /^( {2,}|\\)\n(?!\s*$)/, et = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, P = "\\p{P}\\p{S}", tt = d(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, P).getRegex(), nt = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, st = d(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, P).getRegex(), it = d("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, P).getRegex(), rt = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, P).getRegex(), ot = d(/\\([punct])/, "gu").replace(/punct/g, P).getRegex(), lt = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), at = d(U).replace("(?:-->|$)", "-->").getRegex(), ct = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", at).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Z = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, pt = d(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Z).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), we = d(/^!?\[(label)\]\[(ref)\]/).replace("label", Z).replace("ref", G).getRegex(), be = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", G).getRegex(), ht = d("reflink|nolink(?!\\()", "g").replace("reflink", we).replace("nolink", be).getRegex(), V = {
734
734
  _backpedal: E,
735
735
  // only used for GFM url
736
736
  anyPunctuation: ot,
@@ -743,11 +743,11 @@ const Me = /^(?: *(?:\n|$))+/, Fe = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Qe =
743
743
  emStrongRDelimAst: it,
744
744
  emStrongRDelimUnd: rt,
745
745
  escape: xe,
746
- link: ht,
746
+ link: pt,
747
747
  nolink: be,
748
748
  punctuation: tt,
749
749
  reflink: we,
750
- reflinkSearch: pt,
750
+ reflinkSearch: ht,
751
751
  tag: ct,
752
752
  text: et,
753
753
  url: E
@@ -828,7 +828,7 @@ class T {
828
828
  return this.inlineQueue = [], this.tokens;
829
829
  }
830
830
  blockTokens(n, e = []) {
831
- this.options.pedantic ? n = n.replace(/\t/g, " ").replace(/^ +$/gm, "") : n = n.replace(/^( *)(\t+)/gm, (l, o, p) => o + " ".repeat(p.length));
831
+ this.options.pedantic ? n = n.replace(/\t/g, " ").replace(/^ +$/gm, "") : n = n.replace(/^( *)(\t+)/gm, (l, o, h) => o + " ".repeat(h.length));
832
832
  let t, i, r, s;
833
833
  for (; n; )
834
834
  if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((l) => (t = l.call({ lexer: this }, n, e)) ? (n = n.substring(t.raw.length), e.push(t), !0) : !1))) {
@@ -887,9 +887,9 @@ class T {
887
887
  if (r = n, this.options.extensions && this.options.extensions.startBlock) {
888
888
  let l = 1 / 0;
889
889
  const o = n.slice(1);
890
- let p;
890
+ let h;
891
891
  this.options.extensions.startBlock.forEach((c) => {
892
- p = c.call({ lexer: this }, o), typeof p == "number" && p >= 0 && (l = Math.min(l, p));
892
+ h = c.call({ lexer: this }, o), typeof h == "number" && h >= 0 && (l = Math.min(l, h));
893
893
  }), l < 1 / 0 && l >= 0 && (r = n.substring(0, l + 1));
894
894
  }
895
895
  if (this.state.top && (t = this.tokenizer.paragraph(r))) {
@@ -922,7 +922,7 @@ class T {
922
922
  * Lexing/Compiling
923
923
  */
924
924
  inlineTokens(n, e = []) {
925
- let t, i, r, s = n, l, o, p;
925
+ let t, i, r, s = n, l, o, h;
926
926
  if (this.tokens.links) {
927
927
  const c = Object.keys(this.tokens.links);
928
928
  if (c.length > 0)
@@ -934,7 +934,7 @@ class T {
934
934
  for (; (l = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; )
935
935
  s = s.slice(0, l.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
936
936
  for (; n; )
937
- if (o || (p = ""), o = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((c) => (t = c.call({ lexer: this }, n, e)) ? (n = n.substring(t.raw.length), e.push(t), !0) : !1))) {
937
+ if (o || (h = ""), o = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((c) => (t = c.call({ lexer: this }, n, e)) ? (n = n.substring(t.raw.length), e.push(t), !0) : !1))) {
938
938
  if (t = this.tokenizer.escape(n)) {
939
939
  n = n.substring(t.raw.length), e.push(t);
940
940
  continue;
@@ -951,7 +951,7 @@ class T {
951
951
  n = n.substring(t.raw.length), i = e[e.length - 1], i && t.type === "text" && i.type === "text" ? (i.raw += t.raw, i.text += t.text) : e.push(t);
952
952
  continue;
953
953
  }
954
- if (t = this.tokenizer.emStrong(n, s, p)) {
954
+ if (t = this.tokenizer.emStrong(n, s, h)) {
955
955
  n = n.substring(t.raw.length), e.push(t);
956
956
  continue;
957
957
  }
@@ -978,13 +978,13 @@ class T {
978
978
  if (r = n, this.options.extensions && this.options.extensions.startInline) {
979
979
  let c = 1 / 0;
980
980
  const u = n.slice(1);
981
- let h;
981
+ let p;
982
982
  this.options.extensions.startInline.forEach((f) => {
983
- h = f.call({ lexer: this }, u), typeof h == "number" && h >= 0 && (c = Math.min(c, h));
983
+ p = f.call({ lexer: this }, u), typeof p == "number" && p >= 0 && (c = Math.min(c, p));
984
984
  }), c < 1 / 0 && c >= 0 && (r = n.substring(0, c + 1));
985
985
  }
986
986
  if (t = this.tokenizer.inlineText(r)) {
987
- n = n.substring(t.raw.length), t.raw.slice(-1) !== "_" && (p = t.raw.slice(-1)), o = !0, i = e[e.length - 1], i && i.type === "text" ? (i.raw += t.raw, i.text += t.text) : e.push(t);
987
+ n = n.substring(t.raw.length), t.raw.slice(-1) !== "_" && (h = t.raw.slice(-1)), o = !0, i = e[e.length - 1], i && i.type === "text" ? (i.raw += t.raw, i.text += t.text) : e.push(t);
988
988
  continue;
989
989
  }
990
990
  if (n) {
@@ -1186,15 +1186,15 @@ class z {
1186
1186
  for (let c = 0; c < s.header.length; c++)
1187
1187
  o += this.renderer.tablecell(this.parseInline(s.header[c].tokens), { header: !0, align: s.align[c] });
1188
1188
  l += this.renderer.tablerow(o);
1189
- let p = "";
1189
+ let h = "";
1190
1190
  for (let c = 0; c < s.rows.length; c++) {
1191
1191
  const u = s.rows[c];
1192
1192
  o = "";
1193
- for (let h = 0; h < u.length; h++)
1194
- o += this.renderer.tablecell(this.parseInline(u[h].tokens), { header: !1, align: s.align[h] });
1195
- p += this.renderer.tablerow(o);
1193
+ for (let p = 0; p < u.length; p++)
1194
+ o += this.renderer.tablecell(this.parseInline(u[p].tokens), { header: !1, align: s.align[p] });
1195
+ h += this.renderer.tablerow(o);
1196
1196
  }
1197
- t += this.renderer.table(l, p);
1197
+ t += this.renderer.table(l, h);
1198
1198
  continue;
1199
1199
  }
1200
1200
  case "blockquote": {
@@ -1203,19 +1203,19 @@ class z {
1203
1203
  continue;
1204
1204
  }
1205
1205
  case "list": {
1206
- const s = r, l = s.ordered, o = s.start, p = s.loose;
1206
+ const s = r, l = s.ordered, o = s.start, h = s.loose;
1207
1207
  let c = "";
1208
1208
  for (let u = 0; u < s.items.length; u++) {
1209
- const h = s.items[u], f = h.checked, w = h.task;
1209
+ const p = s.items[u], f = p.checked, w = p.task;
1210
1210
  let y = "";
1211
- if (h.task) {
1211
+ if (p.task) {
1212
1212
  const R = this.renderer.checkbox(!!f);
1213
- p ? h.tokens.length > 0 && h.tokens[0].type === "paragraph" ? (h.tokens[0].text = R + " " + h.tokens[0].text, h.tokens[0].tokens && h.tokens[0].tokens.length > 0 && h.tokens[0].tokens[0].type === "text" && (h.tokens[0].tokens[0].text = R + " " + h.tokens[0].tokens[0].text)) : h.tokens.unshift({
1213
+ h ? p.tokens.length > 0 && p.tokens[0].type === "paragraph" ? (p.tokens[0].text = R + " " + p.tokens[0].text, p.tokens[0].tokens && p.tokens[0].tokens.length > 0 && p.tokens[0].tokens[0].type === "text" && (p.tokens[0].tokens[0].text = R + " " + p.tokens[0].tokens[0].text)) : p.tokens.unshift({
1214
1214
  type: "text",
1215
1215
  text: R + " "
1216
1216
  }) : y += R + " ";
1217
1217
  }
1218
- y += this.parse(h.tokens, p), c += this.renderer.listitem(y, w, !!f);
1218
+ y += this.parse(p.tokens, h), c += this.renderer.listitem(y, w, !!f);
1219
1219
  }
1220
1220
  t += this.renderer.list(c, l, o);
1221
1221
  continue;
@@ -1382,8 +1382,8 @@ class gt {
1382
1382
  for (const o of l.header)
1383
1383
  t = t.concat(this.walkTokens(o.tokens, e));
1384
1384
  for (const o of l.rows)
1385
- for (const p of o)
1386
- t = t.concat(this.walkTokens(p.tokens, e));
1385
+ for (const h of o)
1386
+ t = t.concat(this.walkTokens(h.tokens, e));
1387
1387
  break;
1388
1388
  }
1389
1389
  case "list": {
@@ -1394,8 +1394,8 @@ class gt {
1394
1394
  default: {
1395
1395
  const l = s;
1396
1396
  (r = (i = this.defaults.extensions) == null ? void 0 : i.childTokens) != null && r[l.type] ? this.defaults.extensions.childTokens[l.type].forEach((o) => {
1397
- const p = l[o].flat(1 / 0);
1398
- t = t.concat(this.walkTokens(p, e));
1397
+ const h = l[o].flat(1 / 0);
1398
+ t = t.concat(this.walkTokens(h, e));
1399
1399
  }) : l.tokens && (t = t.concat(this.walkTokens(l.tokens, e)));
1400
1400
  }
1401
1401
  }
@@ -1429,10 +1429,10 @@ class gt {
1429
1429
  throw new Error(`renderer '${s}' does not exist`);
1430
1430
  if (s === "options")
1431
1431
  continue;
1432
- const l = s, o = t.renderer[l], p = r[l];
1432
+ const l = s, o = t.renderer[l], h = r[l];
1433
1433
  r[l] = (...c) => {
1434
1434
  let u = o.apply(r, c);
1435
- return u === !1 && (u = p.apply(r, c)), u || "";
1435
+ return u === !1 && (u = h.apply(r, c)), u || "";
1436
1436
  };
1437
1437
  }
1438
1438
  i.renderer = r;
@@ -1444,10 +1444,10 @@ class gt {
1444
1444
  throw new Error(`tokenizer '${s}' does not exist`);
1445
1445
  if (["options", "rules", "lexer"].includes(s))
1446
1446
  continue;
1447
- const l = s, o = t.tokenizer[l], p = r[l];
1447
+ const l = s, o = t.tokenizer[l], h = r[l];
1448
1448
  r[l] = (...c) => {
1449
1449
  let u = o.apply(r, c);
1450
- return u === !1 && (u = p.apply(r, c)), u;
1450
+ return u === !1 && (u = h.apply(r, c)), u;
1451
1451
  };
1452
1452
  }
1453
1453
  i.tokenizer = r;
@@ -1459,15 +1459,15 @@ class gt {
1459
1459
  throw new Error(`hook '${s}' does not exist`);
1460
1460
  if (s === "options")
1461
1461
  continue;
1462
- const l = s, o = t.hooks[l], p = r[l];
1462
+ const l = s, o = t.hooks[l], h = r[l];
1463
1463
  C.passThroughHooks.has(s) ? r[l] = (c) => {
1464
1464
  if (this.defaults.async)
1465
- return Promise.resolve(o.call(r, c)).then((h) => p.call(r, h));
1465
+ return Promise.resolve(o.call(r, c)).then((p) => h.call(r, p));
1466
1466
  const u = o.call(r, c);
1467
- return p.call(r, u);
1467
+ return h.call(r, u);
1468
1468
  } : r[l] = (...c) => {
1469
1469
  let u = o.apply(r, c);
1470
- return u === !1 && (u = p.apply(r, c)), u;
1470
+ return u === !1 && (u = h.apply(r, c)), u;
1471
1471
  };
1472
1472
  }
1473
1473
  i.hooks = r;
@@ -1507,8 +1507,8 @@ _ = new WeakSet(), H = function(n, e) {
1507
1507
  s.hooks && (t = s.hooks.preprocess(t));
1508
1508
  let o = n(t, s);
1509
1509
  s.hooks && (o = s.hooks.processAllTokens(o)), s.walkTokens && this.walkTokens(o, s.walkTokens);
1510
- let p = e(o, s);
1511
- return s.hooks && (p = s.hooks.postprocess(p)), p;
1510
+ let h = e(o, s);
1511
+ return s.hooks && (h = s.hooks.postprocess(h)), h;
1512
1512
  } catch (o) {
1513
1513
  return l(o);
1514
1514
  }
@@ -1530,12 +1530,12 @@ function g(a, n) {
1530
1530
  return S.parse(a, n);
1531
1531
  }
1532
1532
  g.options = g.setOptions = function(a) {
1533
- return S.setOptions(a), g.defaults = S.defaults, pe(g.defaults), g;
1533
+ return S.setOptions(a), g.defaults = S.defaults, he(g.defaults), g;
1534
1534
  };
1535
1535
  g.getDefaults = J;
1536
1536
  g.defaults = A;
1537
1537
  g.use = function(...a) {
1538
- return S.use(...a), g.defaults = S.defaults, pe(g.defaults), g;
1538
+ return S.use(...a), g.defaults = S.defaults, he(g.defaults), g;
1539
1539
  };
1540
1540
  g.walkTokens = function(a, n) {
1541
1541
  return S.walkTokens(a, n);
@@ -1563,10 +1563,10 @@ function dt(a) {
1563
1563
  const e = g.lexer(n), t = [], i = [];
1564
1564
  for (const r of e)
1565
1565
  if (r.type === "heading") {
1566
- const s = r, l = s.depth, o = $e(s.tokens), p = kt(o), c = {
1566
+ const s = r, l = s.depth, o = $e(s.tokens), h = kt(o), c = {
1567
1567
  level: l,
1568
- text: o,
1569
- id: p,
1568
+ text: o.trim(),
1569
+ id: h,
1570
1570
  children: []
1571
1571
  };
1572
1572
  for (; i.length > 0 && i[i.length - 1].level >= l; )
@@ -1591,9 +1591,9 @@ function $e(a) {
1591
1591
  }).join("");
1592
1592
  }
1593
1593
  function kt(a) {
1594
- return a.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
1594
+ return a.toLowerCase().replace(/\s+/g, "-").replace(/[^\p{L}\p{N}-]/gu, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
1595
1595
  }
1596
- async function he(a, n) {
1596
+ async function pe(a, n) {
1597
1597
  const e = {};
1598
1598
  for (const [t, i] of Object.entries(a)) {
1599
1599
  const r = x.join(n, `${t}.md`);
@@ -1632,10 +1632,10 @@ function Tt(a) {
1632
1632
  await m.writeJSON(l, s, { spaces: 2 }), $.info(
1633
1633
  `✅ Generated docs-meta.json with ${Object.keys(s).length} documents`
1634
1634
  );
1635
- const o = await ie(s, r), p = x.join(i, "search-index.json");
1636
- await m.writeJSON(p, o, { spaces: 2 }), $.info("✅ Generated search-index.json"), $.info("Generating TOC collection...");
1635
+ const o = await ie(s, r), h = x.join(i, "search-index.json");
1636
+ await m.writeJSON(h, o, { spaces: 2 }), $.info("✅ Generated search-index.json"), $.info("Generating TOC collection...");
1637
1637
  try {
1638
- const c = await he(s, r), u = x.join(i, "docs-toc.json");
1638
+ const c = await pe(s, r), u = x.join(i, "docs-toc.json");
1639
1639
  await m.writeJSON(u, c, { spaces: 2 }), $.info(
1640
1640
  `✅ Generated docs-toc.json with ${Object.keys(c).length} documents`
1641
1641
  );
@@ -1658,18 +1658,18 @@ function Tt(a) {
1658
1658
  * 在开发模式下通过 /.wsx-press 路径提供元数据和搜索索引
1659
1659
  */
1660
1660
  configureServer(s) {
1661
- s.middlewares.use("/.wsx-press", async (l, o, p) => {
1661
+ s.middlewares.use("/.wsx-press", async (l, o, h) => {
1662
1662
  try {
1663
- const h = new URL(l.url || "/", `http://${l.headers.host}`).pathname.replace(/^\/\.wsx-press\/?/, "").replace(/^\//, "");
1664
- if (h === "docs-meta.json" || h === "search-index.json" || h === "docs-toc.json") {
1665
- const f = x.join(i, h);
1663
+ const p = new URL(l.url || "/", `http://${l.headers.host}`).pathname.replace(/^\/\.wsx-press\/?/, "").replace(/^\//, "");
1664
+ if (p === "docs-meta.json" || p === "search-index.json" || p === "docs-toc.json") {
1665
+ const f = x.join(i, p);
1666
1666
  if (await m.pathExists(f)) {
1667
1667
  const w = await m.readFile(f, "utf-8");
1668
1668
  o.setHeader("Content-Type", "application/json"), o.end(w);
1669
1669
  return;
1670
1670
  }
1671
1671
  }
1672
- if (h === "docs-meta.json") {
1672
+ if (p === "docs-meta.json") {
1673
1673
  const f = await O(r);
1674
1674
  await m.ensureDir(i), await m.writeJSON(
1675
1675
  x.join(i, "docs-meta.json"),
@@ -1680,7 +1680,7 @@ function Tt(a) {
1680
1680
  ), o.setHeader("Content-Type", "application/json"), o.end(JSON.stringify(f, null, 2));
1681
1681
  return;
1682
1682
  }
1683
- if (h === "search-index.json") {
1683
+ if (p === "search-index.json") {
1684
1684
  const f = await O(r), w = await ie(f, r);
1685
1685
  await m.ensureDir(i), await m.writeJSON(
1686
1686
  x.join(i, "search-index.json"),
@@ -1689,8 +1689,8 @@ function Tt(a) {
1689
1689
  ), o.setHeader("Content-Type", "application/json"), o.end(JSON.stringify(w, null, 2));
1690
1690
  return;
1691
1691
  }
1692
- if (h === "docs-toc.json") {
1693
- const f = await O(r), w = await he(
1692
+ if (p === "docs-toc.json") {
1693
+ const f = await O(r), w = await pe(
1694
1694
  f,
1695
1695
  r
1696
1696
  );
@@ -1701,7 +1701,7 @@ function Tt(a) {
1701
1701
  ), o.setHeader("Content-Type", "application/json"), o.end(JSON.stringify(w, null, 2));
1702
1702
  return;
1703
1703
  }
1704
- p();
1704
+ h();
1705
1705
  } catch (c) {
1706
1706
  $.error("Middleware error:", c), o.statusCode = 500, o.end(JSON.stringify({ error: String(c) }));
1707
1707
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wsxjs/wsx-press",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "description": "A VitePress-like documentation system built with WSXJS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -28,10 +28,10 @@
28
28
  "dependencies": {
29
29
  "fuse.js": "^7.0.0",
30
30
  "marked": "^12.0.0",
31
- "@wsxjs/wsx-core": "0.0.25",
32
- "@wsxjs/wsx-logger": "0.0.25",
33
- "@wsxjs/wsx-marked-components": "0.0.25",
34
- "@wsxjs/wsx-router": "0.0.25"
31
+ "@wsxjs/wsx-logger": "0.0.27",
32
+ "@wsxjs/wsx-core": "0.0.27",
33
+ "@wsxjs/wsx-marked-components": "0.0.27",
34
+ "@wsxjs/wsx-router": "0.0.27"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/fs-extra": "^11.0.4",
@@ -48,8 +48,8 @@
48
48
  "typescript": "^5.0.0",
49
49
  "vite": "^5.4.19",
50
50
  "vitest": "^2.0.0",
51
- "@wsxjs/wsx-vite-plugin": "0.0.25",
52
- "@wsxjs/eslint-plugin-wsx": "0.0.25"
51
+ "@wsxjs/wsx-vite-plugin": "0.0.27",
52
+ "@wsxjs/eslint-plugin-wsx": "0.0.27"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "typedoc": "^0.26.0",
@@ -187,6 +187,9 @@ export default class DocPage extends LightComponent {
187
187
  this.loadDocument();
188
188
  });
189
189
  });
190
+
191
+ // Listen for hash changes
192
+ window.addEventListener("hashchange", this.onHashChange);
190
193
  }
191
194
 
192
195
  protected onDisconnected() {
@@ -203,10 +206,19 @@ export default class DocPage extends LightComponent {
203
206
  this.visibilityChangeHandler = null;
204
207
  }
205
208
 
209
+ window.removeEventListener("hashchange", this.onHashChange);
210
+
206
211
  // 取消正在进行的加载请求
207
212
  this.cancelLoading();
208
213
  }
209
214
 
215
+ /**
216
+ * Handle hash change event
217
+ */
218
+ private onHashChange = () => {
219
+ this.scrollToHash();
220
+ };
221
+
210
222
  /**
211
223
  * 取消正在进行的加载请求
212
224
  */
@@ -448,6 +460,51 @@ export default class DocPage extends LightComponent {
448
460
  }
449
461
  }
450
462
 
463
+ /**
464
+ * Scroll to the element matching the current hash
465
+ * 使用重试机制处理异步渲染的内容
466
+ */
467
+ private scrollToHash(retryCount: number = 0) {
468
+ const maxRetries = 5;
469
+ const retryDelay = 100; // ms
470
+
471
+ const hash = window.location.hash;
472
+ if (!hash) return;
473
+
474
+ // Remove the '#' character
475
+ const id = decodeURIComponent(hash.slice(1));
476
+ if (!id) return;
477
+
478
+ // Try to find the element
479
+ const element = document.getElementById(id);
480
+ if (element) {
481
+ // Scroll into view
482
+ element.scrollIntoView({ behavior: "smooth", block: "start" });
483
+ logger.debug(`Scrolled to anchor: ${id}`);
484
+ } else if (retryCount < maxRetries) {
485
+ // Element not found yet, retry after a short delay
486
+ // This handles the case where markdown content is still being rendered
487
+ setTimeout(() => {
488
+ this.scrollToHash(retryCount + 1);
489
+ }, retryDelay);
490
+ } else {
491
+ logger.warn(`Anchor element not found after ${maxRetries} retries: ${id}`);
492
+ }
493
+ }
494
+
495
+ protected updated() {
496
+ // Called after every render
497
+ if (this.loadingState === "success") {
498
+ // Attempt to scroll to hash if present
499
+ // specific check to avoid scrolling on every update if not needed,
500
+ // or we can rely on the fact that if user scrolled away, we shouldn't force it back?
501
+ // Actually, typically we only do this on initial load or hash change.
502
+ // But since content is loaded async, we need to do it once content is Ready.
503
+ // Let's use a small delay to ensure DOM is ready.
504
+ requestAnimationFrame(() => this.scrollToHash());
505
+ }
506
+ }
507
+
451
508
  render() {
452
509
  if (this.loadingState === "loading") {
453
510
  return (
@@ -3,11 +3,7 @@ wsx-doc-toc {
3
3
  flex-direction: column;
4
4
  width: 240px;
5
5
  min-width: 240px;
6
- height: 100%;
7
- overflow-y: auto;
8
- position: sticky;
9
- top: 70px; /* Navigation height */
10
- max-height: calc(100vh - 70px);
6
+ /* TOC scrolls with content instead of staying fixed at top */
11
7
  }
12
8
 
13
9
  .doc-toc {