@p-buddy/parkdown 0.0.3 → 0.0.5
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 +325 -94
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +293 -217
- package/dist/index.umd.cjs +11 -14
- package/package.json +7 -7
package/dist/index.umd.cjs
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`),
|
|
1
|
+
(function(p,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("node:fs"),require("node:path"),require("node:url"),require("unified"),require("remark-parse"),require("unist-util-visit"),require("stable-hash"),require("ts-dedent"),require("extract-comments")):typeof define=="function"&&define.amd?define(["exports","node:fs","node:path","node:url","unified","remark-parse","unist-util-visit","stable-hash","ts-dedent","extract-comments"],h):(p=typeof globalThis<"u"?globalThis:p||self,h(p.index={},p.node_fs,p.node_path,p.node_url,p.unified,p.remarkParse,p.unistUtilVisit,p.hash,p.tsDedent,p._extractComments))})(this,function(p,h,d,oe,re,ie,ce,le,q,ae){"use strict";var Xe=Object.defineProperty;var Ve=(p,h,d)=>h in p?Xe(p,h,{enumerable:!0,configurable:!0,writable:!0,value:d}):p[h]=d;var se=(p,h,d)=>Ve(p,typeof h!="symbol"?h+"":h,d);const v=(e,t)=>e.position.start.offset-t.position.start.offset;v.reverse=(e,t)=>v(t,e);const T=e=>e.position!==void 0&&e.position.start.offset!==void 0&&e.position.end.offset!==void 0,pe=re.unified().use(ie),b={md:e=>pe.parse(e)},k=(e,t)=>{const n=[];return ce.visit(e,(o,s,r)=>{if(o.type!=="root"){if(t&&o.type!==t)return;if(T(o)){const i=le(r),c=((r==null?void 0:r.children.length)??0)-1;n.push({...o,parentID:i,siblingIndex:s,siblingCount:c})}}}),n},ue=e=>e.children.length===0,R=(e,t,...n)=>{if(n.length===0)throw new Error("No nodes to replace content from");n.sort(v);const o=n.at(0),s=n.at(-1);return e.slice(0,o.position.start.offset)+t+e.slice(s.position.end.offset)},me=(e,t,n)=>{const o=Math.min(t.position.end.offset,n.position.end.offset),s=Math.max(t.position.start.offset,n.position.start.offset);return e.slice(o,s)},x=(...e)=>e.join(" "),he=(...e)=>e.join(`
|
|
2
|
+
`),de=e=>{const t=e.split("?");return t.length>1?[t.slice(0,-1).join("?"),t.at(-1)]:[e,""]},fe=e=>de(e)[0];class w{constructor(){se(this,"intervals",[])}push(t,n){this.intervals.push([Math.min(t,n),Math.max(t,n)])}combine(t){this.intervals.push(...t.intervals)}collapse(){const{intervals:t}=this;if(!t.length)return this.intervals=[];t.sort((r,i)=>r[0]-i[0]);const n=[];let[o,s]=t[0];for(let r=1;r<t.length;r++){const[i,c]=t[r];i<=s?s=Math.max(s,c):(n.push([o,s]),o=i,s=c)}return n.push([o,s]),this.intervals=n}subtract(t){const{intervals:n}=this,{intervals:o}=t;if(!n.length||!o.length)return n;let s=[...n];for(const[r,i]of o){const c=[];for(const[l,a]of s){if(i<=l||r>=a){c.push([l,a]);continue}r>l&&c.push([l,r]),i<a&&c.push([i,a])}s=c}return this.intervals=s}}const _=/,\s*(?![^()]*\))/,A={reserved:{semi:";",slash:"/",question:"?",colon:":",at:"@",equal:"=",and:"&"},unsafe:{quote:'"',angle:"<",unangle:">",hash:"#",percent:"%",curly:"{",uncurly:"}",pipe:"|",back:"\\",carrot:"^",tilde:"~",square:"[",unsquare:"]",tick:"`"}},ge="-",L={static:[["'''",'"'],["''","'"],[/parkdown:\s+/g,""],[/p↓:\s+/g,""]],url:[...Object.entries(A.unsafe),...Object.entries(A.reserved)]},W=(e,[t,n])=>e.replaceAll(t,n),B=(e,t=ge)=>{const n=L.static.reduce(W,e);return L.url.map(([o,s])=>[t+o+t,s]).reduce(W,n).replaceAll(t," ")},ve=["string","number","boolean"],we=e=>ve.includes(e),$e=/^([a-zA-Z0-9_-]+)(?:\(([^)]*)\))?$/,Ce=e=>{const t=e.match($e);if(!t)throw new Error(`Invalid invocation: ${e}`);const[,n,o=""]=t;if(!o.trim())return{name:n,parameters:[]};const s=Ee(o);return{name:n,parameters:s}},ye=(e,t)=>{for(let n=t+1;n<e.length;n++)if(e[n]!==void 0)return!1;return!0},Ee=e=>{const t=[];let n="",o=!1;for(let s=0;s<e.length;s++){const r=e[s],i=r==="'";if(i&&e.at(s+1)==="'"){const c=e.at(s+2)==="'";o=!o,n+=c?"'''":"''",s+=c?2:1}else i?(o=!o,n+=r):r===","&&!o?(t.push(n.trim()),n=""):n+=r}return t.push(n.trim()),t.map(s=>s===""?void 0:s?Se(s):void 0).filter((s,r,i)=>s!==void 0||!ye(i,r))},Se=e=>{const t=e.length>=2&&e[0]==="'"&&e.at(-1)==="'",n=t&&e.length>=4&&e[1]==="'"&&e.at(-2)==="'";return!t||n?e:e.slice(1,-1)},ke=e=>{const t=/^(\w+)(?:\(([^)]*)\))?/,n=e.match(t);if(!n)return{name:e};const[,o,s]=n;if(!s)return{name:o};const r=/(\w+)(\?)?:\s*([^,]+)/g,i=[];let c;for(;(c=r.exec(s))!==null;){const[,l,a,u]=c,m=u.trim();if(!we(m))throw new Error(`Unsupported type: ${m}`);i.push({name:l,optional:a==="?",type:m})}return{name:o,parameters:i}},F=e=>{const t=e.map(ke).reduce((n,{name:o,parameters:s})=>n.set(o,s),new Map);return n=>{const{name:o,parameters:s}=Ce(n);if(!t.has(o))throw new Error(`Unknown method: ${o}`);const r=t.get(o);if(r===void 0)return{name:o};if(s.length>r.length){const i=r.filter(({optional:l})=>!l).length,c=i===r.length?i.toString():`${i} - ${r.length}`;throw new Error(`Too many parameters: ${s.length} for method '${o}' (expected: ${c})`)}return r.reduce((i,{name:c,optional:l,type:a},u)=>{const m=s[u];if(m===void 0){if(l)return i;throw new Error(`Missing required parameter: ${c} for method '${o}'`)}switch(a){case"string":i[c]=m;break;case"number":case"boolean":i[c]=JSON.parse(m);break}if(typeof i[c]!==a)throw new Error(`Invalid type: ${c} must be ${a}, got ${typeof i[c]} for method '${o}'`);return i},{name:o})}},U=e=>Object.entries(e).filter(([t])=>t!=="name"&&!isNaN(Number(t))).map(([t,n])=>n),xe=F(["code(lang?: string, meta?: string)","quote()","dropdown(summary: string, open?: boolean, space?: string)"]),$=(e,t=1)=>`
|
|
3
|
+
`.repeat(t)+e+`
|
|
4
|
+
`.repeat(t),j=(e,t,n)=>`<${t}${n?` ${n}`:""}>${$(e)}</${t}>`,G=(e,t,n)=>{const o=xe(t);switch(o.name){case"code":if(!o.lang&&!o.meta&&(n==null?void 0:n.inline)&&!e.includes(`
|
|
5
|
+
`))return`\`${e}\``;const r=o.lang??(n==null?void 0:n.extension)??"",i=o.meta?` ${o.meta}`:"";return $(`\`\`\`${r}${i}${$(e)}\`\`\``);case"quote":return n!=null&&n.inline&&!e.includes(`
|
|
3
6
|
|
|
4
|
-
`)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</blockquote>
|
|
11
|
-
`;case"dropdown":const c=`<details${o.open?" open":""}>`,l=`<summary>${o.summary.split(o.space??$e).join(" ")}</summary>`;return["",c,l,"",e,"</details>",""].join(`
|
|
12
|
-
`)}},ye=R(["extract(id: string, 0?: string, 1?: string, 2?: string)","remove(id: string, 0?: string, 1?: string, 2?: string)","replace(id: string, with?: string, space?: string)"]),T=e=>te(e),W=(e,n)=>T(e).filter(({value:t})=>t.includes(n)).sort((t,o)=>t.range[0]-o.range[0]),Se=(e,...n)=>{if(n.length===0)return e;const t=([i,c])=>e.slice(i,c),o=T(e),s=new v,r=new v;for(const i of n){const c=o.filter(({value:l})=>l.includes(i)).sort((l,a)=>l.range[0]-a.range[0]);for(let l=0;l<c.length-1;l+=2){const a=c[l],p=c[l+1];s.push(a.range[1],p.range[0]);const[m,...$]=t([a.range[1],p.range[0]]),b=$[$.length-1];r.push(a.range[0],a.range[1]+(m.trim()?0:1)),r.push(p.range[0],p.range[1]+(b.trim()?0:1))}}return s.collapse(),r.collapse(),x.dedent(s.subtract(r).map(t).filter(Boolean).join("")).trim()},Ee=(e,...n)=>{if(n.length===0)return e;const t=([i,c])=>e.slice(i,c),o=T(e),s=new v;for(const i of n){const c=o.filter(({value:l})=>l.includes(i)).sort((l,a)=>l.range[0]-a.range[0]);for(let l=0;l<c.length-1;l+=2){const a=c[l],p=c[l+1],m=t([p.range[1],p.range[1]+1]).at(-1);s.push(a.range[0],m===`
|
|
13
|
-
`?p.range[1]+1:p.range[1])}}s.collapse();const r=new v;return r.push(0,e.length),r.subtract(s),x.dedent(r.collapse().map(t).filter(Boolean).join("")).trim()},Me=(e,n,t,o)=>{if(!n)return e;const s=W(e,n);if(s.length<2)return e;let r="",i=0;for(let l=0;l<s.length-1;l+=2){const a=s[l],p=s[l+1];r+=e.slice(i,a.range[1]),r+=ae(t??a.value,o),i=p.range[0]}r+=e.slice(i);const c=new v;return c.push(0,r.length),c.subtract(W(r,n).reduce((l,{range:a})=>(l.push(...a),l),new v)),x.dedent(c.collapse().map(([l,a])=>r.slice(l,a)).filter(Boolean).join("")).trim()},xe=(e,n)=>{const t=ye(n);switch(t.name){case"extract":return Se(e,t.id,..._(t));case"remove":return Ee(e,t.id,..._(t));case"replace":return Me(e,t.id,t.with,t.space)}},Ne=["http","./","../"],ke=({url:e})=>Ne.some(n=>e.startsWith(n)),Te=e=>N(e)&&se(e)&&ke(e),I=({url:e},n)=>`[](${n?f.join(n,e):e})`,d={_open:"<!--",_close:"-->",_flag:"p▼",get begin(){return A(d._open,d._flag,"BEGIN",d._close)},get end(){return A(d._open,d._flag,"END",d._close)}},B=e=>n=>N(n)&&n.value===d[e],Ie=({position:e,url:n,siblingCount:t},o)=>({position:e,url:n,headingDepth:o,inline:t>=1}),je=({position:{start:e},url:n,siblingCount:t},{position:{end:o}},s)=>({position:{start:e,end:o},url:n,headingDepth:s,inline:t>=1}),be=(e,n,t)=>e.inline?`${I(e,t)} ${d.begin} ${n} ${d.end}`:re(I(e,t),d.begin,n,d.end),qe=e=>{const n=E(e,"heading").reduce((t,{position:o,depth:s})=>t.set(o.start.line,s),new Map);return t=>{for(let o=t.position.start.line;o>=1;o--){const s=n.get(o);if(s)return s}return 0}},M={openingCommentDoesNotFollowLink:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) does not follow link`),closingCommentNotMatchedToOpening:({position:{start:e}})=>new Error(`Closing comment (@${e.line}:${e.column}) does not match to opening comment`),openingCommentNotClosed:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) is not followed by a closing comment`)},De=(e,n)=>{const t=[],o=[...e.map(r=>({node:r,type:"open"})),...n.map(r=>({node:r,type:"close"}))].sort((r,i)=>g(r.node,i.node)),s=[];for(const r of o)if(r.type==="open")s.push(r);else{const i=r.node;if(s.length===0)throw M.closingCommentNotMatchedToOpening(i);const c=s.pop().node;if(s.length>0)continue;t.push({open:c,close:i})}if(s.length>0)throw M.openingCommentNotClosed(s[0].node);return t},Oe=(e,n,t)=>{const o=[...n].sort(g),s=[];return[...t].sort((r,i)=>g.reverse(r.open,i.open)).forEach(r=>{for(;o.length>0;){const i=o.pop();if(i.position.start.offset<r.open.position.start.offset){if(oe(e,i,r.open).trim()!=="")throw M.openingCommentDoesNotFollowLink(r.open);return s.push([i,r])}s.push(i)}throw M.openingCommentDoesNotFollowLink(r.open)}),s.push(...o.reverse()),s.reverse()},U=(e,n)=>{n??(n=k.md(e));const t=qe(n),o=E(n,"link").filter(Te),s=E(n,"html").sort(g),r=s.filter(B("begin")),i=s.filter(B("end")),c=De(r,i);return Oe(e,o,c).map(a=>Array.isArray(a)?je(a[0],a[1].close,t(a[0])):Ie(a,t(a)))},Pe=(e,{url:n})=>t=>e(f.join(f.dirname(n),t)),G=(...e)=>{const n=e.reduce((t,o)=>t+o,0);return Math.min(Math.max(n,1),6)},Ae=(e,n,t)=>{if(n===0)return e;t??(t=k.md(e));const o=E(t,"heading"),s=e.split(`
|
|
14
|
-
`);for(const r of o){const{depth:i,position:{start:c,end:l}}=r,a=G(i,n),p=s[c.line-1].slice(i,l.column),m="#".repeat(a)+p;s[c.line-1]=m,r.depth=a}return s.join(`
|
|
15
|
-
`)},H=e=>U(e).reverse().sort(g.reverse).reduce((n,t)=>P(n,I(t),t),e),Q=(e,n,t,o)=>{e=H(e),e=Ae(e,n);const s=k.md(e);return U(e,s).sort(g).reverse().map(r=>{var X,V;const{url:i,headingDepth:c}=r,[l,...a]=f.basename(i).split("?"),p=l.split(".").pop()??"",m=a.join("?"),$=f.dirname(i),b=f.join($,l);if(i.startsWith("./")||i.startsWith("../")){let h=t(b);const C=new J.URLSearchParams(m),q=(X=C.get("region"))==null?void 0:X.split(L);h=(q==null?void 0:q.reduce((y,S)=>xe(y,S),h))??h;const Fe=C.has("skip"),We=C.get("heading")??0,Be=C.has("inline");let{inline:D}=r;if(Be&&(D=!0),!Fe)if(p==="md"){const y=Pe(t,r),S=o?f.join(o,$):$,Ue=G(c,Number(We));h=Q(h,Ue,y,S)}else/^(js|ts)x?|svelte$/i.test(p)&&(h=F(h,"code",{extension:p,inline:D}));const O=(V=C.get("wrap"))==null?void 0:V.split(L);return h=(O==null?void 0:O.reduce((y,S)=>F(y,S,{extension:p,inline:D}),h))??h,{target:r,content:be(r,h,o)}}else throw i.startsWith("http")?new Error("External web links are not implemented yet"):new Error(`Unsupported link type: ${i}`)}).reduce((r,{target:i,content:c})=>P(r,c,i),e)},z=e=>w.readFileSync(e,"utf-8"),j=e=>{const n=f.resolve(e),t=f.dirname(n);return{markdown:z(n),dir:t,path:n}},Le=(e,n=!0)=>{const{dir:t,path:o,markdown:s}=j(e),i=Q(s,0,c=>z(f.resolve(t,ce(c))));return n&&w.writeFileSync(o,i),i},Re=(e,n=!0)=>{const{path:t,markdown:o}=j(e),s=H(o);return n&&w.writeFileSync(t,s),s},_e=(e,n=!0)=>{j(e)};u.depopulateMarkdownInclusions=Re,u.populateMarkdownInclusions=Le,u.remapImportSpecifiers=_e,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
7
|
+
`)?`> ${e}`:$(j($(e),"blockquote"));case"dropdown":const c=j(B(o.summary),"summary");return $(j([c,e].join(`
|
|
8
|
+
`),"details",o.open?"open":void 0))}},Me=F(["extract(id: string, 0?: string, 1?: string, 2?: string)","remove(id: string, 0?: string, 1?: string, 2?: string)","replace(id: string, with?: string, space?: string)"]),O=e=>ae(e),H=(e,t)=>O(e).filter(({value:n})=>n.includes(t)).sort((n,o)=>n.range[0]-o.range[0]),Ne=(e,...t)=>{if(t.length===0)return e;const n=([i,c])=>e.slice(i,c),o=O(e),s=new w,r=new w;for(const i of t){const c=o.filter(({value:l})=>l.includes(i)).sort((l,a)=>l.range[0]-a.range[0]);for(let l=0;l<c.length-1;l+=2){const a=c[l],u=c[l+1];s.push(a.range[1],u.range[0]);const[m,...N]=n([a.range[1],u.range[0]]),C=N[N.length-1];r.push(a.range[0],a.range[1]+(m.trim()?0:1)),r.push(u.range[0],u.range[1]+(C.trim()?0:1))}}return s.collapse(),r.collapse(),q.dedent(s.subtract(r).map(n).filter(Boolean).join("")).trim()},qe=(e,...t)=>{if(t.length===0)return e;const n=([i,c])=>e.slice(i,c),o=O(e),s=new w;for(const i of t){const c=o.filter(({value:l})=>l.includes(i)).sort((l,a)=>l.range[0]-a.range[0]);for(let l=0;l<c.length-1;l+=2){const a=c[l],u=c[l+1],m=n([u.range[1],u.range[1]+1]).at(-1);s.push(a.range[0],m===`
|
|
9
|
+
`?u.range[1]+1:u.range[1])}}s.collapse();const r=new w;return r.push(0,e.length),r.subtract(s),q.dedent(r.collapse().map(n).filter(Boolean).join("")).trim()},Te=(e,t,n,o)=>{if(!t)return e;const s=H(e,t);if(s.length<2)return e;let r="",i=0;for(let l=0;l<s.length-1;l+=2){const a=s[l],u=s[l+1];r+=e.slice(i,a.range[1]),r+=B(n??a.value,o),i=u.range[0]}r+=e.slice(i);const c=new w;return c.push(0,r.length),c.subtract(H(r,t).reduce((l,{range:a})=>(l.push(...a),l),new w)),q.dedent(c.collapse().map(([l,a])=>r.slice(l,a)).filter(Boolean).join("")).trim()},be=(e,t)=>{const n=Me(t);switch(n.name){case"extract":e=Ne(e,n.id,...U(n));break;case"remove":e=qe(e,n.id,...U(n));break;case"replace":e=Te(e,n.id,n.with,n.space);break}return e},je=["http","./","../"],Oe=({url:e})=>je.some(t=>e.startsWith(t)),Ie=e=>T(e)&&ue(e)&&Oe(e),Q=({url:e},t)=>`[](${t?d.join(t,e):e})`,f={_open:"<!--",_close:"-->",_flag:"p↓",get begin(){return x(f._open,f._flag,"BEGIN",f._close)},get end(){return x(f._open,f._flag,"END",f._close)},lengthOf(e){const t=`lines: ${e.split(`
|
|
10
|
+
`).length}`,n=`chars: ${e.length}`;return x(f._open,f._flag,"length",t,n,f._close)}},z=e=>t=>T(t)&&t.value===f[e],De=({position:e,url:t,siblingCount:n},o)=>({position:e,url:t,headingDepth:o,inline:n>=1}),Pe=({position:{start:e},url:t,siblingCount:n},{position:{end:o}},s)=>({position:{start:e,end:o},url:t,headingDepth:s,inline:n>=1}),Re=(e,t,n)=>(e.inline?x:he)(Q(e,n),f.begin,f.lengthOf(t),t,f.end),_e=e=>{const t=k(e,"heading").reduce((n,{position:o,depth:s})=>n.set(o.start.line,s),new Map);return n=>{for(let o=n.position.start.line;o>=1;o--){const s=t.get(o);if(s)return s}return 0}},M={openingCommentDoesNotFollowLink:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) does not follow link`),closingCommentNotMatchedToOpening:({position:{start:e}})=>new Error(`Closing comment (@${e.line}:${e.column}) does not match to opening comment`),openingCommentNotClosed:({position:{start:e}})=>new Error(`Opening comment (@${e.line}:${e.column}) is not followed by a closing comment`)},Ae=(e,t)=>{const n=[],o=[...e.map(r=>({node:r,type:"open"})),...t.map(r=>({node:r,type:"close"}))].sort((r,i)=>v(r.node,i.node)),s=[];for(const r of o)if(r.type==="open")s.push(r);else{const i=r.node;if(s.length===0)throw M.closingCommentNotMatchedToOpening(i);const c=s.pop().node;if(s.length>0)continue;n.push({open:c,close:i})}if(s.length>0)throw M.openingCommentNotClosed(s[0].node);return n},Le=(e,t,n)=>{const o=[...t].sort(v),s=[];return[...n].sort((r,i)=>v.reverse(r.open,i.open)).forEach(r=>{for(;o.length>0;){const i=o.pop();if(i.position.start.offset<r.open.position.start.offset){if(me(e,i,r.open).trim()!=="")throw M.openingCommentDoesNotFollowLink(r.open);return s.push([i,r])}s.push(i)}throw M.openingCommentDoesNotFollowLink(r.open)}),s.push(...o.reverse()),s.reverse()},X=(e,t)=>{t??(t=b.md(e));const n=_e(t),o=k(t,"link").filter(Ie),s=k(t,"html").sort(v),r=s.filter(z("begin")),i=s.filter(z("end")),c=Ae(r,i);return Le(e,o,c).map(a=>Array.isArray(a)?Pe(a[0],a[1].close,n(a[0])):De(a,n(a)))},We=(e,{url:t})=>n=>e(d.join(d.dirname(t),n)),V=(...e)=>{const t=e.reduce((n,o)=>n+o,0);return Math.min(Math.max(t,1),6)},Be=(e,t,n)=>{if(t===0)return e;n??(n=b.md(e));const o=k(n,"heading"),s=e.split(`
|
|
11
|
+
`);for(const r of o){const{depth:i,position:{start:c,end:l}}=r,a=V(i,t),u=s[c.line-1].slice(i,l.column),m="#".repeat(a)+u;s[c.line-1]=m,r.depth=a}return s.join(`
|
|
12
|
+
`)},J=e=>X(e).reverse().sort(v.reverse).reduce((t,n)=>R(t,Q(n),n),e),Z=(e,t,n,o,s)=>{try{e=J(e),e=Be(e,t);const r=b.md(e);return X(e,r).sort(v).reverse().map(i=>{var te,ne;const{url:c,headingDepth:l}=i,[a,...u]=d.basename(c).split("?"),m=a.split(".").pop()??"",N=u.join("?"),C=d.dirname(c),ee=d.join(C,a);if(c.startsWith("./")||c.startsWith("../")){let g=n(ee);const y=new oe.URLSearchParams(N),I=(te=y.get("region"))==null?void 0:te.split(_);g=(I==null?void 0:I.reduce((E,S)=>be(E,S),g))??g;const Ge=y.has("skip"),He=y.get("heading")??0,Qe=y.has("inline");let{inline:D}=i;if(Qe&&(D=!0),!Ge)if(m==="md"){const E=We(n,i),S=s?d.join(s,C):C,ze=V(l,Number(He));g=Z(g,ze,E,ee,S)}else/^(js|ts)x?|svelte$/i.test(m)&&(g=G(g,"code",{extension:m,inline:D}));const P=(ne=y.get("wrap"))==null?void 0:ne.split(_);return g=(P==null?void 0:P.reduce((E,S)=>G(E,S,{extension:m,inline:D}),g))??g,{target:i,content:Re(i,g,s)}}else throw c.startsWith("http")?new Error("External web links are not implemented yet"):new Error(`Unsupported link type: ${c}`)}).reduce((i,{target:c,content:l})=>R(i,l,c),e)}catch(r){throw new Error(`Error populating inclusions in file ${o}: ${r}`)}},K=e=>h.readFileSync(e,"utf-8"),Y=e=>{const t=d.resolve(e),n=d.dirname(t);return{markdown:K(t),dir:n,path:t}},Fe=(e,t=!0)=>{const{dir:n,path:o,markdown:s}=Y(e),i=Z(s,0,c=>K(d.resolve(n,fe(c))),o);return t&&h.writeFileSync(o,i),i},Ue=(e,t=!0)=>{const{path:n,markdown:o}=Y(e),s=J(o);return t&&h.writeFileSync(n,s),s};p.depopulateMarkdownInclusions=Ue,p.populateMarkdownInclusions=Fe,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@p-buddy/parkdown",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.0.
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"bin": "dist/cli.js",
|
|
5
|
+
"version": "0.0.5",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": "./dist/cli.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
10
|
"README.md",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"test": "vitest",
|
|
40
40
|
"test:run": "vitest run"
|
|
41
41
|
},
|
|
42
|
-
"typings": "dist/index.d.ts",
|
|
42
|
+
"typings": "./dist/index.d.ts",
|
|
43
43
|
"exports": {
|
|
44
44
|
".": {
|
|
45
|
-
"types": "dist/index.d.ts",
|
|
46
|
-
"import": "dist/index.js",
|
|
47
|
-
"require": "dist/index.umd.cjs"
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"import": "./dist/index.js",
|
|
47
|
+
"require": "./dist/index.umd.cjs"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|