@wenyan-md/core 1.0.11 → 1.0.12

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/README.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  # 文颜 CORE
6
6
 
7
+ [![npm](https://img.shields.io/npm/v/@wenyan-md/core)](https://www.npmjs.com/package/@wenyan-md/core)
8
+ [![License](https://img.shields.io/github/license/caol64/wenyan-core)](LICENSE)
9
+ ![NPM Downloads](https://img.shields.io/npm/dm/%40wenyan-md%2Fcore)
10
+ [![Stars](https://img.shields.io/github/stars/caol64/wenyan-core?style=social)](https://github.com/caol64/wenyan-core)
11
+
7
12
  「文颜」是一款多平台排版美化工具,让你将 Markdown 一键发布至微信公众号、知乎、今日头条等主流写作平台。
8
13
 
9
14
  **文颜**现已推出多个版本:
@@ -90,5 +90,5 @@ Please report this to https://github.com/markedjs/marked.`,r){const o="<p>An err
90
90
  `:`<p>${o.parseInline(t.tokens)}</p>
91
91
  `},i.image=function(t,a,s){return`<img src="${t.href}" alt="${t.text||""}" title="${t.text||""}">`},O.use({renderer:i})}function vi(r){const n=new Map;return r.split(/\s+/).forEach(i=>{const[o,t]=i.split("=");o&&t&&n.set(o,t.replace(/^["']|["']$/g,""))}),n}function bi(r){const{attributes:n,body:i}=mi(r),o={};let t="";const{title:a,description:s,cover:u}=n;return a&&(o.title=a),s&&(t+="> "+s+`
92
92
 
93
- `,o.description=s),u&&(o.cover=u),o.body=t+i,o}async function yi(r){const n=O.parse(r);return await tt.renderMathInHtml(n)}async function wi(r,n,i,o=!0,t=!0){let a=Je.themes.default;if(n&&(a=Je.themes[n],a||(a=Object.values(Je.themes).find(p=>p.name.toLowerCase()===n.toLowerCase()))),!a)throw new Error("主题不存在");if(!(i in Kn.hlThemes))throw new Error("代码块主题不存在");const s=Xr(await a.getCss()),c=await Kn.hlThemes[i].getCss();return Jr(r,s,c,o,t)}async function Jr(r,n,i,o=!0,t=!0){t&&nt(!1,r),n=et(n,{"#wenyan pre code":[{property:"font-family",value:Pn,append:!0}],"#wenyan pre":[{property:"font-size",value:"12px",append:!0}]});const a=N.parse(n,{context:"stylesheet",positions:!1,parseAtrulePrelude:!1,parseCustomProperty:!1,parseValue:!1}),s=N.parse(i,{context:"stylesheet",positions:!1,parseAtrulePrelude:!1,parseCustomProperty:!1,parseValue:!1});if(a.children.appendList(s.children),o){const c=N.parse(it,{context:"stylesheet",positions:!1,parseAtrulePrelude:!1,parseCustomProperty:!1,parseValue:!1});a.children.appendList(c.children)}N.walk(a,{visit:"Rule",enter(c,p,f){const v=c.prelude.children;v&&v.forEach(x=>{const F=N.generate(x),_=c.block.children.toArray();F==="#wenyan"?_.forEach($=>{const H=N.generate($.value);r.style[$.property]=H}):r.querySelectorAll(F).forEach(H=>{_.forEach(Z=>{const K=N.generate(Z.value);H.style[Z.property]=K})})})}});let u=r.querySelectorAll("mjx-container");return u.forEach(c=>{const p=c.querySelector("svg");p.style.width=p.getAttribute("width"),p.style.height=p.getAttribute("height"),p.removeAttribute("width"),p.removeAttribute("height");const f=c.parentElement;c.remove(),f.appendChild(p),f.classList.contains("block-equation")&&f.setAttribute("style","text-align: center; margin-bottom: 1rem;")}),u=r.querySelectorAll("pre code"),u.forEach(c=>{c.innerHTML=c.innerHTML.replace(/\n/g,"<br>").replace(/(>[^<]+)|(^[^<]+)/g,p=>p.replace(/\s/g,"&nbsp;"))}),u=r.querySelectorAll("h1, h2, h3, h4, h5, h6, blockquote, pre"),u.forEach(c=>{const p=new Map,f=new Map;N.walk(a,{visit:"Rule",enter(v){const x=N.generate(v.prelude),F=c.tagName.toLowerCase();x.includes(`${F}::after`)?qn(v,p):x.includes(`${F}::before`)&&qn(v,f)}}),p.size>0&&c.appendChild(Nn(p,r.ownerDocument)),f.size>0&&c.insertBefore(Nn(f,r.ownerDocument),c.firstChild)}),r.setAttribute("data-provider","WenYan"),`${r.outerHTML.replace(/class="mjx-solid"/g,'fill="none" stroke-width="70"')}`}function Xr(r){const n=/--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g,i=/var\(--([a-zA-Z0-9\-]+)\)/g,o={};let t;for(;(t=n.exec(r))!==null;){const u=t[1],c=t[2].trim().replaceAll(`
93
+ `,o.description=s),u&&(o.cover=u),o.body=t+i,o}async function yi(r){const n=O.parse(r);return await tt.renderMathInHtml(n)}async function wi(r,n,i,o=!0,t=!0){let a=Je.themes.default;if(n&&(a=Je.themes[n],a||(a=Object.values(Je.themes).find(p=>p.name.toLowerCase()===n.toLowerCase()))),!a)throw new Error("主题不存在");if(!(i in Kn.hlThemes))throw new Error("代码块主题不存在");const s=Xr(await a.getCss()),c=await Kn.hlThemes[i].getCss();return Jr(r,s,c,o,t)}async function Jr(r,n,i,o=!0,t=!0){t&&nt(!1,r),n=et(n,{"#wenyan pre code":[{property:"font-family",value:Pn,append:!0}],"#wenyan pre":[{property:"font-size",value:"12px",append:!0}]});const a=N.parse(n,{context:"stylesheet",positions:!1,parseAtrulePrelude:!1,parseCustomProperty:!1,parseValue:!1}),s=N.parse(i,{context:"stylesheet",positions:!1,parseAtrulePrelude:!1,parseCustomProperty:!1,parseValue:!1});if(a.children.appendList(s.children),o){const c=N.parse(it,{context:"stylesheet",positions:!1,parseAtrulePrelude:!1,parseCustomProperty:!1,parseValue:!1});a.children.appendList(c.children)}N.walk(a,{visit:"Rule",enter(c,p,f){const v=c.prelude.children;v&&v.forEach(x=>{const F=N.generate(x),_=c.block.children.toArray();F==="#wenyan"?_.forEach($=>{const H=N.generate($.value);r.style[$.property]=H}):r.querySelectorAll(F).forEach(H=>{_.forEach(Z=>{const K=N.generate(Z.value);H.style[Z.property]=K})})})}});let u=r.querySelectorAll("mjx-container");return u.forEach(c=>{const p=c.querySelector("svg");p.style.width=p.getAttribute("width"),p.style.height=p.getAttribute("height"),p.removeAttribute("width"),p.removeAttribute("height");const f=c.parentElement;c.remove(),f.appendChild(p),f.classList.contains("block-equation")&&f.setAttribute("style","text-align: center; margin-bottom: 1rem;")}),u=r.querySelectorAll("pre code"),u.forEach(c=>{c.innerHTML=c.innerHTML.replace(/\n/g,"<br>").replace(/(>[^<]+)|(^[^<]+)/g,p=>p.replace(/\s/g,"&nbsp;"))}),u=r.querySelectorAll("h1, h2, h3, h4, h5, h6, blockquote, pre"),u.forEach(c=>{const p=new Map,f=new Map;N.walk(a,{visit:"Rule",enter(v){const x=N.generate(v.prelude),F=c.tagName.toLowerCase();x.includes(`${F}::after`)?qn(v,p):x.includes(`${F}::before`)&&qn(v,f)}}),p.size>0&&c.appendChild(Nn(p,r.ownerDocument)),f.size>0&&c.insertBefore(Nn(f,r.ownerDocument),c.firstChild)}),u=r.querySelectorAll("li"),u.forEach(c=>{const p=r.ownerDocument.createElement("section");for(;c.firstChild;)p.appendChild(c.firstChild);c.appendChild(p)}),r.setAttribute("data-provider","WenYan"),`${r.outerHTML.replace(/class="mjx-solid"/g,'fill="none" stroke-width="70"')}`}function Xr(r){const n=/--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g,i=/var\(--([a-zA-Z0-9\-]+)\)/g,o={};let t;for(;(t=n.exec(r))!==null;){const u=t[1],c=t[2].trim().replaceAll(`
94
94
  `,"");o[u]=c}o["sans-serif-font"]||(o["sans-serif-font"]=Qr),o["monospace-font"]||(o["monospace-font"]=Pn);function a(u,c,p=new Set){if(p.has(u))return u;p.add(u);let f=u,v;for(;(v=i.exec(f))!==null;){const x=v[1];if(c[x]){const F=a(c[x],c,p);f=f.replace(v[0],F)}}return f}for(const u in o){const c=a(o[u],o);o[u]=c}let s=r;for(;(t=i.exec(r))!==null;){const u=t[1];o[u]&&(s=s.replace(t[0],o[u]))}return s.replace(/:root\s*\{[^}]*\}/g,"")}function et(r,n){const i=N.parse(r,{context:"stylesheet",positions:!1,parseAtrulePrelude:!1,parseCustomProperty:!1,parseValue:!1});return N.walk(i,{visit:"Rule",leave:(o,t,a)=>{if(o.prelude.type!=="SelectorList")return;const s=o.prelude.children.toArray().map(u=>N.generate(u));if(s){const u=s[0],c=n[u];if(!c)return;for(const{property:p,value:f,append:v}of c)if(f){let x=!1;N.walk(o.block,F=>{F.type==="Declaration"&&F.property===p&&(F.value=N.parse(f,{context:"value"}),x=!0)}),!x&&v&&o.block.children.prepend(a.createItem({type:"Declaration",property:p,value:N.parse(f,{context:"value"})}))}}}}),N.generate(i)}function qn(r,n){N.walk(r.block,{visit:"Declaration",enter(i){const o=i.property,t=N.generate(i.value);n.set(o,t)}})}function Nn(r,n){const i=n.createElement("section");r.get("content")&&(i.textContent=r.get("content").replace(/['"]/g,""),r.delete("content"));for(const[a,s]of r)if(s.includes("url(")){const u=s.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/),c=s.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/),p=s.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);if(u){const f=decodeURIComponent(u[1]);i.innerHTML=f}else if(c){const f=atob(c[1]);i.innerHTML=f}else if(p){const f=n.createElement("img");f.src=p[1],f.setAttribute("style","vertical-align: top;"),i.appendChild(f)}r.delete(a)}const t=Array.from(r.entries()).map(([a,s])=>`${a}: ${s}`).join("; ");return i.style.cssText=t,i}function nt(r,n){let i=[],o=0;if(n.querySelectorAll("a[href]").forEach(a=>{const s=a.textContent||a.innerText,u=a.getAttribute("href");i.push([++o,s,u]);const c=n.ownerDocument.createElement("sup");c.setAttribute("class","footnote"),c.innerHTML=`[${o}]`,a.after(c)}),o>0)if(r){const s=`<h3>引用链接</h3><div id="footnotes"><ul>${i.map(u=>u[1]===u[2]?`<li id="#footnote-${u[0]}">[${u[0]}]: <i>${u[1]}</i></li>`:`<li id="#footnote-${u[0]}">[${u[0]}] ${u[1]}: <i>${u[2]}</i></li>`).join("")}</ul></div>`;n.innerHTML+=s}else{const s=`<h3>引用链接</h3><section id="footnotes">${i.map(u=>u[1]===u[2]?`<p><span class="footnote-num">[${u[0]}]</span><span class="footnote-txt"><i>${u[1]}</i></span></p>`:`<p><span class="footnote-num">[${u[0]}]</span><span class="footnote-txt">${u[1]}: <i>${u[2]}</i></span></p>`).join("")}</section>`;n.innerHTML+=s}}return U.addFootnotes=nt,U.buildPseudoSpan=Nn,U.configureMarked=ki,U.extractDeclarations=qn,U.getContentForGzhBuiltinTheme=wi,U.getContentForGzhCustomCss=Jr,U.handleFrontMatter=bi,U.modifyCss=et,U.monospace=Pn,U.renderMarkdown=yi,U.replaceCSSVariables=Xr,U.sansSerif=Qr,U.serif=xi,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"}),U})({},hljs,csstree,WenyanMath,macStyleCss,themes,hlThemes);
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { marked as d } from "marked";
1
+ import { marked as g } from "marked";
2
2
  import { markedHighlight as H } from "marked-highlight";
3
3
  import x from "highlight.js";
4
4
  import P from "front-matter";
@@ -7,7 +7,7 @@ import { mathjax as j } from "mathjax-full/js/mathjax.js";
7
7
  import { TeX as V } from "mathjax-full/js/input/tex.js";
8
8
  import { SVG as q } from "mathjax-full/js/output/svg.js";
9
9
  import { liteAdaptor as I } from "mathjax-full/js/adaptors/liteAdaptor.js";
10
- import { RegisterHTMLHandler as S } from "mathjax-full/js/handlers/html.js";
10
+ import { RegisterHTMLHandler as k } from "mathjax-full/js/handlers/html.js";
11
11
  import { AllPackages as R } from "mathjax-full/js/input/tex/AllPackages.js";
12
12
  import { themes as b } from "./theme.js";
13
13
  import { hlThemes as C } from "./hltheme.js";
@@ -16,19 +16,19 @@ const z = {
16
16
  displayMath: [["$$", "$$"], ["\\[", "\\]"]],
17
17
  processEscapes: !0,
18
18
  packages: R
19
- }, E = {
19
+ }, D = {
20
20
  fontCache: "none"
21
21
  };
22
22
  let m;
23
23
  if (!m) {
24
24
  m = I();
25
25
  try {
26
- S(m);
26
+ k(m);
27
27
  } catch {
28
28
  }
29
29
  }
30
- S(m);
31
- const N = new V(z), D = new q(E);
30
+ k(m);
31
+ const E = new V(z), N = new q(D);
32
32
  function A(t, i) {
33
33
  const l = t.display ? "section" : "span", o = t.display ? "block-equation" : "inline-equation";
34
34
  t.typesetRoot = i.adaptor.node(l, { class: o }, [t.typesetRoot]);
@@ -36,8 +36,8 @@ function A(t, i) {
36
36
  async function F(t) {
37
37
  try {
38
38
  const i = j.document(t, {
39
- InputJax: N,
40
- OutputJax: D,
39
+ InputJax: E,
40
+ OutputJax: N,
41
41
  renderActions: {
42
42
  addContainer: [190, (o) => {
43
43
  for (const r of o.math)
@@ -64,12 +64,12 @@ function le() {
64
64
  const t = H({
65
65
  emptyLangClass: "hljs",
66
66
  langPrefix: "hljs language-",
67
- highlight: function(r, n, s) {
68
- const e = x.getLanguage(n) ? n : "plaintext";
67
+ highlight: function(r, s, a) {
68
+ const e = x.getLanguage(s) ? s : "plaintext";
69
69
  return x.highlight(r, { language: e }).value;
70
70
  }
71
71
  });
72
- d.use(t);
72
+ g.use(t);
73
73
  const i = {
74
74
  name: "attributeImage",
75
75
  level: "inline",
@@ -77,37 +77,37 @@ function le() {
77
77
  return r.indexOf("![");
78
78
  },
79
79
  tokenizer(r) {
80
- const s = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(r);
81
- if (s)
80
+ const a = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(r);
81
+ if (a)
82
82
  return {
83
83
  type: "attributeImage",
84
- raw: s[0],
85
- alt: s[1],
86
- href: s[2],
87
- attrs: s[3]
84
+ raw: a[0],
85
+ alt: a[1],
86
+ href: a[2],
87
+ attrs: a[3]
88
88
  };
89
89
  },
90
90
  renderer(r) {
91
- const n = J(r.attrs), s = Array.from(n).map(
92
- ([e, a]) => /^\d+$/.test(a) ? `${e}:${a}px` : `${e}:${a}`
91
+ const s = J(r.attrs), a = Array.from(s).map(
92
+ ([e, n]) => /^\d+$/.test(n) ? `${e}:${n}px` : `${e}:${n}`
93
93
  ).join("; ");
94
- return `<img src="${r.href}" alt="${r.alt || ""}" title="${r.alt || ""}" style="${s}">`;
94
+ return `<img src="${r.href}" alt="${r.alt || ""}" title="${r.alt || ""}" style="${a}">`;
95
95
  }
96
96
  };
97
- d.use({ extensions: [i] });
98
- const l = d.Renderer, o = d.Parser;
97
+ g.use({ extensions: [i] });
98
+ const l = g.Renderer, o = g.Parser;
99
99
  l.heading = function(r) {
100
- const n = o.parseInline(r.tokens), s = r.depth;
101
- return `<h${s}><span>${n}</span></h${s}>
100
+ const s = o.parseInline(r.tokens), a = r.depth;
101
+ return `<h${a}><span>${s}</span></h${a}>
102
102
  `;
103
103
  }, l.paragraph = function(r) {
104
- const n = r.text;
105
- return n.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(n) || /\\\[[\s\S]*?\\\]/g.test(n)) ? `${n}
104
+ const s = r.text;
105
+ return s.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(s) || /\\\[[\s\S]*?\\\]/g.test(s)) ? `${s}
106
106
  ` : `<p>${o.parseInline(r.tokens)}</p>
107
107
  `;
108
- }, l.image = function(r, n, s) {
108
+ }, l.image = function(r, s, a) {
109
109
  return `<img src="${r.href}" alt="${r.text || ""}" title="${r.text || ""}">`;
110
- }, d.use({ renderer: l });
110
+ }, g.use({ renderer: l });
111
111
  }
112
112
  function J(t) {
113
113
  const i = /* @__PURE__ */ new Map();
@@ -119,25 +119,25 @@ function J(t) {
119
119
  function ce(t) {
120
120
  const { attributes: i, body: l } = P(t), o = {};
121
121
  let r = "";
122
- const { title: n, description: s, cover: e } = i;
123
- return n && (o.title = n), s && (r += "> " + s + `
122
+ const { title: s, description: a, cover: e } = i;
123
+ return s && (o.title = s), a && (r += "> " + a + `
124
124
 
125
- `, o.description = s), e && (o.cover = e), o.body = r + l, o;
125
+ `, o.description = a), e && (o.cover = e), o.body = r + l, o;
126
126
  }
127
127
  async function pe(t) {
128
- const i = d.parse(t);
128
+ const i = g.parse(t);
129
129
  return await F(i);
130
130
  }
131
131
  async function fe(t, i, l, o = !0, r = !0) {
132
- let n = b.default;
133
- if (i && (n = b[i], n || (n = Object.values(b).find(
132
+ let s = b.default;
133
+ if (i && (s = b[i], s || (s = Object.values(b).find(
134
134
  (c) => c.name.toLowerCase() === i.toLowerCase()
135
- ))), !n)
135
+ ))), !s)
136
136
  throw new Error("主题不存在");
137
137
  if (!(l in C))
138
138
  throw new Error("代码块主题不存在");
139
- const s = U(await n.getCss()), a = await C[l].getCss();
140
- return O(t, s, a, o, r);
139
+ const a = U(await s.getCss()), n = await C[l].getCss();
140
+ return O(t, a, n, o, r);
141
141
  }
142
142
  async function O(t, i, l, o = !0, r = !0) {
143
143
  r && Y(!1, t), i = W(i, {
@@ -156,35 +156,35 @@ async function O(t, i, l, o = !0, r = !0) {
156
156
  }
157
157
  ]
158
158
  });
159
- const n = f.parse(i, {
159
+ const s = f.parse(i, {
160
160
  context: "stylesheet",
161
161
  positions: !1,
162
162
  parseAtrulePrelude: !1,
163
163
  parseCustomProperty: !1,
164
164
  parseValue: !1
165
- }), s = f.parse(l, {
165
+ }), a = f.parse(l, {
166
166
  context: "stylesheet",
167
167
  positions: !1,
168
168
  parseAtrulePrelude: !1,
169
169
  parseCustomProperty: !1,
170
170
  parseValue: !1
171
171
  });
172
- if (n.children.appendList(s.children), o) {
173
- const a = f.parse(G, {
172
+ if (s.children.appendList(a.children), o) {
173
+ const n = f.parse(G, {
174
174
  context: "stylesheet",
175
175
  positions: !1,
176
176
  parseAtrulePrelude: !1,
177
177
  parseCustomProperty: !1,
178
178
  parseValue: !1
179
179
  });
180
- n.children.appendList(a.children);
180
+ s.children.appendList(n.children);
181
181
  }
182
- f.walk(n, {
182
+ f.walk(s, {
183
183
  visit: "Rule",
184
- enter(a, c, p) {
185
- const u = a.prelude.children;
186
- u && u.forEach((g) => {
187
- const h = f.generate(g), $ = a.block.children.toArray();
184
+ enter(n, c, p) {
185
+ const u = n.prelude.children;
186
+ u && u.forEach((d) => {
187
+ const h = f.generate(d), $ = n.block.children.toArray();
188
188
  h === "#wenyan" ? $.forEach((y) => {
189
189
  const v = f.generate(y.value);
190
190
  t.style[y.property] = v;
@@ -198,56 +198,61 @@ async function O(t, i, l, o = !0, r = !0) {
198
198
  }
199
199
  });
200
200
  let e = t.querySelectorAll("mjx-container");
201
- return e.forEach((a) => {
202
- const c = a.querySelector("svg");
201
+ return e.forEach((n) => {
202
+ const c = n.querySelector("svg");
203
203
  c.style.width = c.getAttribute("width"), c.style.height = c.getAttribute("height"), c.removeAttribute("width"), c.removeAttribute("height");
204
- const p = a.parentElement;
205
- a.remove(), p.appendChild(c), p.classList.contains("block-equation") && p.setAttribute("style", "text-align: center; margin-bottom: 1rem;");
206
- }), e = t.querySelectorAll("pre code"), e.forEach((a) => {
207
- a.innerHTML = a.innerHTML.replace(/\n/g, "<br>").replace(/(>[^<]+)|(^[^<]+)/g, (c) => c.replace(/\s/g, "&nbsp;"));
208
- }), e = t.querySelectorAll("h1, h2, h3, h4, h5, h6, blockquote, pre"), e.forEach((a) => {
204
+ const p = n.parentElement;
205
+ n.remove(), p.appendChild(c), p.classList.contains("block-equation") && p.setAttribute("style", "text-align: center; margin-bottom: 1rem;");
206
+ }), e = t.querySelectorAll("pre code"), e.forEach((n) => {
207
+ n.innerHTML = n.innerHTML.replace(/\n/g, "<br>").replace(/(>[^<]+)|(^[^<]+)/g, (c) => c.replace(/\s/g, "&nbsp;"));
208
+ }), e = t.querySelectorAll("h1, h2, h3, h4, h5, h6, blockquote, pre"), e.forEach((n) => {
209
209
  const c = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
210
- f.walk(n, {
210
+ f.walk(s, {
211
211
  visit: "Rule",
212
212
  enter(u) {
213
- const g = f.generate(u.prelude), h = a.tagName.toLowerCase();
214
- g.includes(`${h}::after`) ? M(u, c) : g.includes(`${h}::before`) && M(u, p);
213
+ const d = f.generate(u.prelude), h = n.tagName.toLowerCase();
214
+ d.includes(`${h}::after`) ? M(u, c) : d.includes(`${h}::before`) && M(u, p);
215
215
  }
216
- }), c.size > 0 && a.appendChild(k(c, t.ownerDocument)), p.size > 0 && a.insertBefore(k(p, t.ownerDocument), a.firstChild);
216
+ }), c.size > 0 && n.appendChild(S(c, t.ownerDocument)), p.size > 0 && n.insertBefore(S(p, t.ownerDocument), n.firstChild);
217
+ }), e = t.querySelectorAll("li"), e.forEach((n) => {
218
+ const c = t.ownerDocument.createElement("section");
219
+ for (; n.firstChild; )
220
+ c.appendChild(n.firstChild);
221
+ n.appendChild(c);
217
222
  }), t.setAttribute("data-provider", "WenYan"), `${t.outerHTML.replace(/class="mjx-solid"/g, 'fill="none" stroke-width="70"')}`;
218
223
  }
219
224
  function U(t) {
220
225
  const i = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g, l = /var\(--([a-zA-Z0-9\-]+)\)/g, o = {};
221
226
  let r;
222
227
  for (; (r = i.exec(t)) !== null; ) {
223
- const e = r[1], a = r[2].trim().replaceAll(`
228
+ const e = r[1], n = r[2].trim().replaceAll(`
224
229
  `, "");
225
- o[e] = a;
230
+ o[e] = n;
226
231
  }
227
232
  o["sans-serif-font"] || (o["sans-serif-font"] = B), o["monospace-font"] || (o["monospace-font"] = L);
228
- function n(e, a, c = /* @__PURE__ */ new Set()) {
233
+ function s(e, n, c = /* @__PURE__ */ new Set()) {
229
234
  if (c.has(e)) return e;
230
235
  c.add(e);
231
236
  let p = e, u;
232
237
  for (; (u = l.exec(p)) !== null; ) {
233
- const g = u[1];
234
- if (a[g]) {
235
- const h = n(a[g], a, c);
238
+ const d = u[1];
239
+ if (n[d]) {
240
+ const h = s(n[d], n, c);
236
241
  p = p.replace(u[0], h);
237
242
  }
238
243
  }
239
244
  return p;
240
245
  }
241
246
  for (const e in o) {
242
- const a = n(o[e], o);
243
- o[e] = a;
247
+ const n = s(o[e], o);
248
+ o[e] = n;
244
249
  }
245
- let s = t;
250
+ let a = t;
246
251
  for (; (r = l.exec(t)) !== null; ) {
247
252
  const e = r[1];
248
- o[e] && (s = s.replace(r[0], o[e]));
253
+ o[e] && (a = a.replace(r[0], o[e]));
249
254
  }
250
- return s.replace(/:root\s*\{[^}]*\}/g, "");
255
+ return a.replace(/:root\s*\{[^}]*\}/g, "");
251
256
  }
252
257
  function W(t, i) {
253
258
  const l = f.parse(t, {
@@ -259,19 +264,19 @@ function W(t, i) {
259
264
  });
260
265
  return f.walk(l, {
261
266
  visit: "Rule",
262
- leave: (o, r, n) => {
267
+ leave: (o, r, s) => {
263
268
  if (o.prelude.type !== "SelectorList") return;
264
- const s = o.prelude.children.toArray().map((e) => f.generate(e));
265
- if (s) {
266
- const e = s[0], a = i[e];
267
- if (!a) return;
268
- for (const { property: c, value: p, append: u } of a)
269
+ const a = o.prelude.children.toArray().map((e) => f.generate(e));
270
+ if (a) {
271
+ const e = a[0], n = i[e];
272
+ if (!n) return;
273
+ for (const { property: c, value: p, append: u } of n)
269
274
  if (p) {
270
- let g = !1;
275
+ let d = !1;
271
276
  f.walk(o.block, (h) => {
272
- h.type === "Declaration" && h.property === c && (h.value = f.parse(p, { context: "value" }), g = !0);
273
- }), !g && u && o.block.children.prepend(
274
- n.createItem({
277
+ h.type === "Declaration" && h.property === c && (h.value = f.parse(p, { context: "value" }), d = !0);
278
+ }), !d && u && o.block.children.prepend(
279
+ s.createItem({
275
280
  type: "Declaration",
276
281
  property: c,
277
282
  value: f.parse(p, { context: "value" })
@@ -291,46 +296,46 @@ function M(t, i) {
291
296
  }
292
297
  });
293
298
  }
294
- function k(t, i) {
299
+ function S(t, i) {
295
300
  const l = i.createElement("section");
296
301
  t.get("content") && (l.textContent = t.get("content").replace(/['"]/g, ""), t.delete("content"));
297
- for (const [n, s] of t)
298
- if (s.includes("url(")) {
299
- const e = s.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/), a = s.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/), c = s.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
302
+ for (const [s, a] of t)
303
+ if (a.includes("url(")) {
304
+ const e = a.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/), n = a.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/), c = a.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
300
305
  if (e) {
301
306
  const p = decodeURIComponent(e[1]);
302
307
  l.innerHTML = p;
303
- } else if (a) {
304
- const p = atob(a[1]);
308
+ } else if (n) {
309
+ const p = atob(n[1]);
305
310
  l.innerHTML = p;
306
311
  } else if (c) {
307
312
  const p = i.createElement("img");
308
313
  p.src = c[1], p.setAttribute("style", "vertical-align: top;"), l.appendChild(p);
309
314
  }
310
- t.delete(n);
315
+ t.delete(s);
311
316
  }
312
- const r = Array.from(t.entries()).map(([n, s]) => `${n}: ${s}`).join("; ");
317
+ const r = Array.from(t.entries()).map(([s, a]) => `${s}: ${a}`).join("; ");
313
318
  return l.style.cssText = r, l;
314
319
  }
315
320
  function Y(t, i) {
316
321
  let l = [], o = 0;
317
- if (i.querySelectorAll("a[href]").forEach((n) => {
318
- const s = n.textContent || n.innerText, e = n.getAttribute("href");
319
- l.push([++o, s, e]);
320
- const a = i.ownerDocument.createElement("sup");
321
- a.setAttribute("class", "footnote"), a.innerHTML = `[${o}]`, n.after(a);
322
+ if (i.querySelectorAll("a[href]").forEach((s) => {
323
+ const a = s.textContent || s.innerText, e = s.getAttribute("href");
324
+ l.push([++o, a, e]);
325
+ const n = i.ownerDocument.createElement("sup");
326
+ n.setAttribute("class", "footnote"), n.innerHTML = `[${o}]`, s.after(n);
322
327
  }), o > 0)
323
328
  if (t) {
324
- const s = `<h3>引用链接</h3><div id="footnotes"><ul>${l.map((e) => e[1] === e[2] ? `<li id="#footnote-${e[0]}">[${e[0]}]: <i>${e[1]}</i></li>` : `<li id="#footnote-${e[0]}">[${e[0]}] ${e[1]}: <i>${e[2]}</i></li>`).join("")}</ul></div>`;
325
- i.innerHTML += s;
329
+ const a = `<h3>引用链接</h3><div id="footnotes"><ul>${l.map((e) => e[1] === e[2] ? `<li id="#footnote-${e[0]}">[${e[0]}]: <i>${e[1]}</i></li>` : `<li id="#footnote-${e[0]}">[${e[0]}] ${e[1]}: <i>${e[2]}</i></li>`).join("")}</ul></div>`;
330
+ i.innerHTML += a;
326
331
  } else {
327
- const s = `<h3>引用链接</h3><section id="footnotes">${l.map((e) => e[1] === e[2] ? `<p><span class="footnote-num">[${e[0]}]</span><span class="footnote-txt"><i>${e[1]}</i></span></p>` : `<p><span class="footnote-num">[${e[0]}]</span><span class="footnote-txt">${e[1]}: <i>${e[2]}</i></span></p>`).join("")}</section>`;
328
- i.innerHTML += s;
332
+ const a = `<h3>引用链接</h3><section id="footnotes">${l.map((e) => e[1] === e[2] ? `<p><span class="footnote-num">[${e[0]}]</span><span class="footnote-txt"><i>${e[1]}</i></span></p>` : `<p><span class="footnote-num">[${e[0]}]</span><span class="footnote-txt">${e[1]}: <i>${e[2]}</i></span></p>`).join("")}</section>`;
333
+ i.innerHTML += a;
329
334
  }
330
335
  }
331
336
  export {
332
337
  Y as addFootnotes,
333
- k as buildPseudoSpan,
338
+ S as buildPseudoSpan,
334
339
  le as configureMarked,
335
340
  M as extractDeclarations,
336
341
  fe as getContentForGzhBuiltinTheme,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenyan-md/core",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Core library for Wenyan markdown rendering & publishing",
5
5
  "author": "Lei <caol64@gmail.com> (https://github.com/caol64)",
6
6
  "license": "Apache-2.0",