jspdf-md-renderer 1.8.1 → 1.8.3
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/index.js +2 -2
- package/dist/index.mjs +252 -256
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("marked");var o=(t=>(t.Heading="heading",t.Paragraph="paragraph",t.List="list",t.ListItem="list_item",t.Blockquote="blockquote",t.Code="code",t.CodeSpan="codespan",t.Table="table",t.Html="html",t.Hr="hr",t.Image="image",t.Link="link",t.Strong="strong",t.Em="em",t.TableHeader="table_header",t.TableCell="table_cell",t.Raw="raw",t.Text="text",t))(o||{});const z=async t=>{const i=await I.marked.lexer(t,{async:!0});return W(i)},W=t=>{const i=[];return t.forEach(s=>{try{const x=k[s.type];x?i.push(x(s)):i.push({type:o.Raw,content:s.raw})}catch(x){console.error("Failed to handle token ==>",s,x)}}),i},k={[o.Heading]:t=>({type:o.Heading,depth:t.depth,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Paragraph]:t=>({type:o.Paragraph,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.List]:t=>({type:o.List,ordered:t.ordered,start:t.start,items:t.items?W(t.items):[]}),[o.ListItem]:t=>({type:o.ListItem,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Code]:t=>({type:o.Code,lang:t.lang,code:t.text}),[o.Table]:t=>({type:o.Table,header:t.header.map(i=>({type:o.TableHeader,content:i})),rows:t.rows.map(i=>i.map(s=>({type:o.TableCell,content:s})))}),[o.Image]:t=>({type:o.Image,src:t.href,alt:t.text}),[o.Link]:t=>({type:o.Link,href:t.href,text:t.text,items:t.tokens?W(t.tokens):[]}),[o.Strong]:t=>({type:o.Strong,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Em]:t=>({type:o.Em,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Text]:t=>({type:o.Text,content:t.text,items:t.tokens?W(t.tokens):[]}),[o.Hr]:t=>({type:o.Hr,content:t.raw,items:t.tokens?W(t.tokens):[]}),[o.CodeSpan]:t=>({type:o.CodeSpan,content:t.text,items:t.tokens?W(t.tokens):[]})},L=class L{static initialize(i){this.options_=i,this.cursor={x:i.cursor.x,y:i.cursor.y}}static getCursor(){return this.cursor}static setCursor(i){this.cursor=i}static get options(){return this.options_}static get isInlineLockActive(){return this.inlineLock}static activateInlineLock(){this.inlineLock=!0}static deactivateInlineLock(){this.inlineLock=!1}static updateX(i,s="set"){s==="set"?this.cursor.x=i:s==="add"&&(this.cursor.x+=i)}static updateY(i,s="set"){s==="set"?this.cursor.y=i:s==="add"&&(this.cursor.y+=i)}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};L.cursor={x:0,y:0},L.inlineLock=!1;let e=L;const C=t=>{var i,s;typeof e.options.pageBreakHandler=="function"?e.options.pageBreakHandler():t.addPage((i=e.options.page)==null?void 0:i.format,(s=e.options.page)==null?void 0:s.orientation),e.updateY(e.options.page.topmargin),e.updateX(e.options.page.xpading)},d=t=>t.getTextDimensions("H").h*e.options.page.defaultLineHeightFactor,y=t=>t.getTextDimensions("H").w*e.options.page.defaultLineHeightFactor,E=(t,i,s,x)=>{const h=6-((i==null?void 0:i.depth)??0)>0?6-((i==null?void 0:i.depth)??0):1;if(t.setFontSize(e.options.page.defaultFontSize+h),e.updateY(h*.2*d(t),"add"),i!=null&&i.items&&(i==null?void 0:i.items.length)>0)for(const p of(i==null?void 0:i.items)??[])x(p,s,!1);else t.text((i==null?void 0:i.content)??"",e.X+s,e.Y,{align:"left",maxWidth:e.options.page.maxContentWidth-s});t.setFontSize(e.options.page.defaultFontSize),e.updateX(e.options.page.xpading)},D=(t,i,s,x,h,p,c,g,a)=>{const l=(g-s)/(i.length-1);let n=h;const r=p+x*c;for(const u of i)t.text(u.text,n,r,{align:"justify",lineHeightFactor:a,maxWidth:g}),n+=u.wordLength+l},P=(t,i,s,x,h,p,c,g)=>{const a=t.map(l=>l.text).join(" ");i.text(a,s,x+h*p,{align:"justify",lineHeightFactor:g,maxWidth:c})},F=(t,i,s,x,h,p)=>{const c={x:s,y:x},g=t.getTextDimensions("A").h*p,a=i.split(" ");let l=0,n=[],r=0;for(const u of a){const b=t.getTextWidth(u+"a");b+r>=h&&(D(t,n,r,l++,s,x,g,h,p),n=[],r=0),n.push({text:u,wordLength:b}),r+=b}return n.length>0&&P(n,t,s,x,l,g,h,p),c.y=x+l*g,c.x=t.getTextWidth(i)+s,c},S=(t,i,s)=>{const x=t.getFont().fontName,h=t.getFont().fontStyle,p=t.getFontSize(),c=a=>{switch(a){case"normal":return 0;case"bold":return 1;case"italic":return 1.5;case"bolditalic":return 1.5;default:return 0}},g=(a,l)=>{var u;l==="bold"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,e.options.font.bold.style||"bold"):l==="italic"?t.setFont(e.options.font.regular.name,"italic"):l==="bolditalic"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,"bolditalic"):t.setFont(e.options.font.regular.name,h);const n=e.options.page.maxContentWidth-s-e.X,r=t.splitTextToSize(a,n);if(e.isInlineLockActive)for(let b=0;b<r.length;b++)t.text(r[b],e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(t.getTextDimensions(r[b]).w+1,"add"),b<r.length-1&&(e.updateY(d(t),"add"),e.updateX(e.options.page.xpading+s,"set"));else if(r.length>1){const b=r[0],f=(u=r==null?void 0:r.slice(1))==null?void 0:u.join(" ");t.text(b,e.X+(s>=2?s+2*c(l):0),e.Y,{baseline:"top",maxWidth:n}),e.updateX(e.options.page.xpading+s),e.updateY(d(t),"add");const Y=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(f,Y).forEach(m=>{t.text(m,e.X+y(t),e.Y,{baseline:"top",maxWidth:Y})})}else t.text(a,e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(t.getTextDimensions(a).w+(s>=2?a.split(" ").length+2:2)*c(l)*.5,"add")};if(i.type==="text"&&i.items&&i.items.length>0)for(const a of i.items)if(a.type==="em"||a.type==="strong"){const l=a.type==="em"?"italic":"bold";if(a.items&&a.items.length>0)for(const n of a.items)n.type==="strong"&&l==="italic"||n.type==="em"&&l==="bold"?g(n.content||"","bolditalic"):g(n.content||"",l);else g(a.content||"",l)}else g(a.content||"","normal");else i.type==="em"?g(i.content||"","italic"):i.type==="strong"?g(i.content||"","bold"):g(i.content||"","normal");t.setFont(x,h),t.setFontSize(p)},j=(t,i,s,x)=>{e.activateInlineLock(),t.setFontSize(e.options.page.defaultFontSize);let h=i.content;const p=t.getTextDimensions("A").h*e.options.page.defaultLineHeightFactor;if(i!=null&&i.items&&(i==null?void 0:i.items.length)>0){let c=0;for(const g of(i==null?void 0:i.items)??[])["strong","em","text"].includes(g.type)?(g.type!=="text"&&c!=0&&e.updateX(y(t)*1.5,"add"),S(t,g,s),g.type!=="text"&&c!=0&&e.updateX(y(t),"add")):x(g,s,!1),c++}else{if(e.Y+t.splitTextToSize(h??"",e.options.page.maxContentWidth-s).length*p-3*p>=e.options.page.maxContentHeight){const g=t.splitTextToSize(h??"",e.options.page.maxContentWidth-s),a=[],l=e.Y;for(let n=0;n<g.length;n++)if(e.Y-2*p<e.options.page.maxContentHeight)a.push(g[n]),e.updateY(e.options.page.lineSpace,"add");else{n<=g.length-1&&(h=g.slice(n).join(""));break}if(a.length>0){const n=F(t,a.join(" "),e.X+s,l,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor);e.setCursor(n)}C(t)}const c=F(t,h??"",e.X+s,e.Y,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor).y+d(t);e.updateY(c)}e.updateY(p,"add"),e.updateX(e.options.page.xpading),e.deactivateInlineLock()},v=(t,i,s,x)=>{var h;t.setFontSize(e.options.page.defaultFontSize);for(const[p,c]of((h=i==null?void 0:i.items)==null?void 0:h.entries())??[]){const g=i.ordered?(i.start??0)+p:i.start;x(c,s+1,!0,g,i.ordered)}},A=(t,i,s,x,h,p)=>{const c=s*e.options.page.indent,g=p?`${h}. `:"• ";e.Y+d(t)>=e.options.page.maxContentHeight&&C(t),t.setFont(e.options.font.regular.name,e.options.font.regular.style),t.text(g,e.X+c,e.Y,{baseline:"top"});const a=t.getTextWidth(g);if(e.updateX(a,"add"),i.items&&i.items.length>0)for(const l of i.items){if(e.Y+d(t)>=e.options.page.maxContentHeight&&C(t),l.type===o.List)x(l,s+1,!0,h,l.ordered??!1);else if(l.type===o.ListItem){const n=i.type===o.List?s:s+1;x(l,n,!0,h,p)}else S(t,l,c);e.updateX(e.options.page.xpading),e.updateY(d(t),"add")}else if(i.content){const l=e.X+c,n=t.getTextWidth(g),r=e.options.page.maxContentWidth-c-n,u=t.splitTextToSize(i.content,r);if(u.length>0){t.text(u[0],l+n,e.Y,{baseline:"top",maxWidth:r});for(let f=1;f<u.length;f++)e.updateY(d(t),"add"),t.text(u[f],l+n,e.Y,{baseline:"top",maxWidth:r});e.updateX(e.options.page.xmargin+c),e.updateY(d(t),"add");const b=t.getTextWidth(i.content);e.updateX(b,"add")}}},R=(t,i,s,x,h,p,c,g=!0)=>{if(i!=null&&i.items&&(i==null?void 0:i.items.length)>0)for(const a of(i==null?void 0:i.items)??[])h(a,s,x,p,c,g);else{const a=s*e.options.page.indent,l=x?c?`${p}. `:"• ":"";if(x&&l){const n=t.getTextWidth(l),r=e.options.page.maxContentWidth-a-n,u=t.splitTextToSize(i.content||"",r);if(u.length>0){t.text(l,e.X+a,e.Y,{baseline:"top"}),t.text(u[0],e.X+a+n,e.Y,{baseline:"top",maxWidth:r});for(let f=1;f<u.length;f++)e.updateX(e.options.page.xpading),e.updateY(d(t),"add"),t.text(u[f],e.X+a+n,e.Y,{baseline:"top",maxWidth:r-a-n});e.updateY(d(t),"add"),e.updateX(e.options.page.xpading+a);const b=t.getTextWidth(i.content||"");e.updateX(b,"add")}}else{const n=t.splitTextToSize(i.content||"",e.options.page.maxContentWidth-a);if(e.Y+n.length*d(t)>=e.options.page.maxContentHeight&&C(t),g){const r=F(t,i.content||"",e.X+a,e.Y,e.options.page.maxContentWidth-a,e.options.page.defaultLineHeightFactor).y+d(t)*.5;e.updateY(r),e.updateX(e.options.page.xpading)}else t.text(n||"",e.X+a,e.Y,{baseline:"top"}),e.updateX(t.getTextWidth(i.content||""),"add"),e.X>=e.options.page.xpading+e.options.page.maxContentWidth&&C(t)}}},B=t=>{const i=t.internal.pageSize.getWidth();t.setLineDashPattern([1,1],0),t.setLineWidth(.1),t.line(e.options.page.xpading,e.Y,i-e.options.page.xpading,e.Y),t.setLineWidth(.1),t.setLineDashPattern([],0),e.updateY(d(t),"add")},_=(t,i,s,x)=>{const h=s*e.options.page.indent;e.Y+t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-h).length*d(t)-2*d(t)>=e.options.page.maxContentHeight&&C(t);const p=t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-h).length*d(t);e.updateY(e.options.page.lineSpace,"add"),t.setFillColor("#EEEEEE"),t.setDrawColor("#eee"),t.roundedRect(e.X,e.Y-e.options.page.lineSpace,e.options.page.maxContentWidth,p,2,2,"FD"),t.setFontSize(10),t.text(i.lang??"",e.X+e.options.page.maxContentWidth-t.getTextWidth(i.lang??"")-e.options.page.lineSpace/2,e.Y),t.setFontSize(e.options.page.defaultFontSize),t.text(i.code??"",e.X+4,e.Y),e.updateY(p,"add")},q=(t,i,s)=>{var u,b;const x=t.getFont().fontName,h=t.getFont().fontStyle,p=t.getFontSize(),c=t.getTextColor(),g=((u=e.options.link)==null?void 0:u.linkColor)||[0,0,255];t.setTextColor(...g);const a=e.options.page.maxContentWidth-s-e.X,l=i.text||i.content||"",n=i.href||"",r=t.splitTextToSize(l,a);if(e.isInlineLockActive)for(let f=0;f<r.length;f++){const Y=t.getTextDimensions(r[f]).w,X=d(t)/2;t.link(e.X+s,e.Y,Y,X,{url:n}),t.text(r[f],e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(Y+1,"add"),e.X+Y>e.options.page.maxContentWidth-s&&(e.updateY(X,"add"),e.updateX(e.options.page.xpading+s,"set")),f<r.length-1&&(e.updateY(X,"add"),e.updateX(e.options.page.xpading+s,"set"))}else if(r.length>1){const f=r[0],Y=(b=r==null?void 0:r.slice(1))==null?void 0:b.join(" "),X=t.getTextDimensions(f).w,m=d(t)/2;t.link(e.X+s,e.Y,X,m,{url:n}),t.text(f,e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(e.options.page.xpading+s),e.updateY(m,"add");const H=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(Y,H).forEach(T=>{const w=t.getTextDimensions(T).w;t.link(e.X+y(t),e.Y,w,m,{url:n}),t.text(T,e.X+y(t),e.Y,{baseline:"top",maxWidth:H})})}else{const f=t.getTextDimensions(l).w,Y=d(t)/2;t.link(e.X+s,e.Y,f,Y,{url:n}),t.text(l,e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(f+2,"add")}t.setFont(x,h),t.setFontSize(p),t.setTextColor(c)},J=async(t,i,s)=>{e.initialize(s);const x=await z(i),h=(p,c=0,g=!1,a=0,l=!1,n=!0)=>{const r=c*s.page.indent;switch(e.Y+t.splitTextToSize(p.content??"",s.page.maxContentWidth-r).length*d(t)>=s.page.maxContentHeight&&C(t),p.type){case o.Heading:E(t,p,r,h);break;case o.Paragraph:j(t,p,r,h);break;case o.List:v(t,p,c,h);break;case o.ListItem:A(t,p,c,h,a,l);break;case o.Hr:B(t);break;case o.Code:_(t,p,c);break;case o.Strong:case o.Em:S(t,p,r);break;case o.Link:q(t,p,r);break;case o.Raw:case o.Text:R(t,p,c,g,h,a,l,n);break;default:console.warn(`Warning: Unsupported element type encountered: ${p.type}.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("marked");var o=(t=>(t.Heading="heading",t.Paragraph="paragraph",t.List="list",t.ListItem="list_item",t.Blockquote="blockquote",t.Code="code",t.CodeSpan="codespan",t.Table="table",t.Html="html",t.Hr="hr",t.Image="image",t.Link="link",t.Strong="strong",t.Em="em",t.TableHeader="table_header",t.TableCell="table_cell",t.Raw="raw",t.Text="text",t))(o||{});const H=async t=>{const i=await z.marked.lexer(t,{async:!0});return b(i)},b=t=>{const i=[];return t.forEach(s=>{try{const x=w[s.type];x?i.push(x(s)):i.push({type:o.Raw,content:s.raw})}catch(x){console.error("Failed to handle token ==>",s,x)}}),i},w={[o.Heading]:t=>({type:o.Heading,depth:t.depth,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Paragraph]:t=>({type:o.Paragraph,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.List]:t=>({type:o.List,ordered:t.ordered,start:t.start,items:t.items?b(t.items):[]}),[o.ListItem]:t=>({type:o.ListItem,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Code]:t=>({type:o.Code,lang:t.lang,code:t.text}),[o.Table]:t=>({type:o.Table,header:t.header.map(i=>({type:o.TableHeader,content:i})),rows:t.rows.map(i=>i.map(s=>({type:o.TableCell,content:s})))}),[o.Image]:t=>({type:o.Image,src:t.href,alt:t.text}),[o.Link]:t=>({type:o.Link,href:t.href,text:t.text,items:t.tokens?b(t.tokens):[]}),[o.Strong]:t=>({type:o.Strong,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Em]:t=>({type:o.Em,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Text]:t=>({type:o.Text,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Hr]:t=>({type:o.Hr,content:t.raw,items:t.tokens?b(t.tokens):[]}),[o.CodeSpan]:t=>({type:o.CodeSpan,content:t.text,items:t.tokens?b(t.tokens):[]})},L=class L{static initialize(i){this.options_=i,this.cursor={x:i.cursor.x,y:i.cursor.y}}static getCursor(){return this.cursor}static setCursor(i){this.cursor=i}static get options(){return this.options_}static get isInlineLockActive(){return this.inlineLock}static activateInlineLock(){this.inlineLock=!0}static deactivateInlineLock(){this.inlineLock=!1}static updateX(i,s="set"){s==="set"?this.cursor.x=i:s==="add"&&(this.cursor.x+=i)}static updateY(i,s="set"){s==="set"?this.cursor.y=i:s==="add"&&(this.cursor.y+=i)}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};L.cursor={x:0,y:0},L.inlineLock=!1;let e=L;const W=t=>{typeof e.options.pageBreakHandler=="function"?e.options.pageBreakHandler():t.addPage(e.options.page?.format,e.options.page?.orientation),e.updateY(e.options.page.topmargin),e.updateX(e.options.page.xpading)},f=t=>t.getTextDimensions("H").h*e.options.page.defaultLineHeightFactor,Y=t=>t.getTextDimensions("H").w*e.options.page.defaultLineHeightFactor,I=(t,i,s,x)=>{const g=6-(i?.depth??0)>0?6-(i?.depth??0):1;if(t.setFontSize(e.options.page.defaultFontSize+g),e.updateY(g*.2*f(t),"add"),i?.items&&i?.items.length>0)for(const p of i?.items??[])x(p,s,!1);else t.text(i?.content??"",e.X+s,e.Y,{align:"left",maxWidth:e.options.page.maxContentWidth-s});t.setFontSize(e.options.page.defaultFontSize),e.updateX(e.options.page.xpading)},k=(t,i,s,x,g,p,c,l,n)=>{const r=(l-s)/(i.length-1);let a=g;const h=p+x*c;for(const u of i)t.text(u.text,a,h,{align:"justify",lineHeightFactor:n,maxWidth:l}),a+=u.wordLength+r},E=(t,i,s,x,g,p,c,l)=>{const n=t.map(r=>r.text).join(" ");i.text(n,s,x+g*p,{align:"justify",lineHeightFactor:l,maxWidth:c})},y=(t,i,s,x,g,p)=>{const c={x:s,y:x},l=t.getTextDimensions("A").h*p,n=i.split(" ");let r=0,a=[],h=0;for(const u of n){const d=t.getTextWidth(u+"a");d+h>=g&&(k(t,a,h,r++,s,x,l,g,p),a=[],h=0),a.push({text:u,wordLength:d}),h+=d}return a.length>0&&E(a,t,s,x,r,l,g,p),c.y=x+r*l,c.x=t.getTextWidth(i)+s,c},F=(t,i,s)=>{const x=t.getFont().fontName,g=t.getFont().fontStyle,p=t.getFontSize(),c=n=>{switch(n){case"normal":return 0;case"bold":return 1;case"italic":return 1.5;case"bolditalic":return 1.5;default:return 0}},l=(n,r)=>{r==="bold"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,e.options.font.bold.style||"bold"):r==="italic"?t.setFont(e.options.font.regular.name,"italic"):r==="bolditalic"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,"bolditalic"):t.setFont(e.options.font.regular.name,g);const a=e.options.page.maxContentWidth-s-e.X,h=t.splitTextToSize(n,a);if(e.isInlineLockActive)for(let u=0;u<h.length;u++)t.text(h[u],e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(t.getTextDimensions(h[u]).w+1,"add"),u<h.length-1&&(e.updateY(f(t),"add"),e.updateX(e.options.page.xpading+s,"set"));else if(h.length>1){const u=h[0],d=h?.slice(1)?.join(" ");t.text(u,e.X+(s>=2?s+2*c(r):0),e.Y,{baseline:"top",maxWidth:a}),e.updateX(e.options.page.xpading+s),e.updateY(f(t),"add");const m=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(d,m).forEach(X=>{t.text(X,e.X+Y(t),e.Y,{baseline:"top",maxWidth:m})})}else t.text(n,e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(t.getTextDimensions(n).w+(s>=2?n.split(" ").length+2:2)*c(r)*.5,"add")};if(i.type==="text"&&i.items&&i.items.length>0)for(const n of i.items)if(n.type==="em"||n.type==="strong"){const r=n.type==="em"?"italic":"bold";if(n.items&&n.items.length>0)for(const a of n.items)a.type==="strong"&&r==="italic"||a.type==="em"&&r==="bold"?l(a.content||"","bolditalic"):l(a.content||"",r);else l(n.content||"",r)}else l(n.content||"","normal");else i.type==="em"?l(i.content||"","italic"):i.type==="strong"?l(i.content||"","bold"):l(i.content||"","normal");t.setFont(x,g),t.setFontSize(p)},D=(t,i,s,x)=>{e.activateInlineLock(),t.setFontSize(e.options.page.defaultFontSize);let g=i.content;const p=t.getTextDimensions("A").h*e.options.page.defaultLineHeightFactor;if(i?.items&&i?.items.length>0){let c=0;for(const l of i?.items??[])["strong","em","text"].includes(l.type)?(l.type!=="text"&&c!=0&&e.updateX(Y(t)*1.5,"add"),F(t,l,s),l.type!=="text"&&c!=0&&e.updateX(Y(t),"add")):x(l,s,!1),c++}else{if(e.Y+t.splitTextToSize(g??"",e.options.page.maxContentWidth-s).length*p-3*p>=e.options.page.maxContentHeight){const l=t.splitTextToSize(g??"",e.options.page.maxContentWidth-s),n=[],r=e.Y;for(let a=0;a<l.length;a++)if(e.Y-2*p<e.options.page.maxContentHeight)n.push(l[a]),e.updateY(e.options.page.lineSpace,"add");else{a<=l.length-1&&(g=l.slice(a).join(""));break}if(n.length>0){const a=y(t,n.join(" "),e.X+s,r,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor);e.setCursor(a)}W(t)}const c=y(t,g??"",e.X+s,e.Y,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor).y+f(t);e.updateY(c)}e.updateY(p,"add"),e.updateX(e.options.page.xpading),e.deactivateInlineLock()},P=(t,i,s,x)=>{t.setFontSize(e.options.page.defaultFontSize);for(const[g,p]of i?.items?.entries()??[]){const c=i.ordered?(i.start??0)+g:i.start;x(p,s+1,!0,c,i.ordered)}},j=(t,i,s,x,g,p)=>{const c=s*e.options.page.indent,l=p?`${g}. `:"• ";e.Y+f(t)>=e.options.page.maxContentHeight&&W(t),t.setFont(e.options.font.regular.name,e.options.font.regular.style),t.text(l,e.X+c,e.Y,{baseline:"top"});const n=t.getTextWidth(l);if(e.updateX(n,"add"),i.items&&i.items.length>0)for(const r of i.items){if(e.Y+f(t)>=e.options.page.maxContentHeight&&W(t),r.type===o.List)x(r,s+1,!0,g,r.ordered??!1);else if(r.type===o.ListItem){const a=i.type===o.List?s:s+1;x(r,a,!0,g,p)}else e.activateInlineLock(),F(t,r,c),e.deactivateInlineLock();e.updateX(e.options.page.xpading),e.updateY(f(t),"add")}else if(i.content){const r=e.X+c,a=t.getTextWidth(l),h=e.options.page.maxContentWidth-c-a,u=t.splitTextToSize(i.content,h);if(u.length>0){t.text(u[0],r+a,e.Y,{baseline:"top",maxWidth:h});for(let m=1;m<u.length;m++)e.updateY(f(t),"add"),t.text(u[m],r+a,e.Y,{baseline:"top",maxWidth:h});e.updateX(e.options.page.xmargin+c),e.updateY(f(t),"add");const d=t.getTextWidth(i.content);e.updateX(d,"add")}}},v=(t,i,s,x,g,p,c,l=!0)=>{if(i?.items&&i?.items.length>0)for(const n of i?.items??[])g(n,s,x,p,c,l);else{const n=s*e.options.page.indent,r=x?c?`${p}. `:"• ":"";if(x&&r){const a=t.getTextWidth(r),h=e.options.page.maxContentWidth-n-a,u=t.splitTextToSize(i.content||"",h);if(u.length>0){t.text(r,e.X+n,e.Y,{baseline:"top"}),t.text(u[0],e.X+n+a,e.Y,{baseline:"top",maxWidth:h});for(let m=1;m<u.length;m++)e.updateX(e.options.page.xpading),e.updateY(f(t),"add"),t.text(u[m],e.X+n+a,e.Y,{baseline:"top",maxWidth:h-n-a});e.updateY(f(t),"add"),e.updateX(e.options.page.xpading+n);const d=t.getTextWidth(i.content||"");e.updateX(d,"add")}}else{const a=t.splitTextToSize(i.content||"",e.options.page.maxContentWidth-n);if(e.Y+a.length*f(t)>=e.options.page.maxContentHeight&&W(t),l){const h=y(t,i.content||"",e.X+n,e.Y,e.options.page.maxContentWidth-n,e.options.page.defaultLineHeightFactor).y+f(t)*.5;e.updateY(h),e.updateX(e.options.page.xpading)}else t.text(a||"",e.X+n,e.Y,{baseline:"top"}),e.updateX(t.getTextWidth(i.content||""),"add"),e.X>=e.options.page.xpading+e.options.page.maxContentWidth&&W(t)}}},A=t=>{const i=t.internal.pageSize.getWidth();t.setLineDashPattern([1,1],0),t.setLineWidth(.1),t.line(e.options.page.xpading,e.Y,i-e.options.page.xpading,e.Y),t.setLineWidth(.1),t.setLineDashPattern([],0),e.updateY(f(t),"add")},R=(t,i,s,x)=>{const g=s*e.options.page.indent;e.Y+t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-g).length*f(t)-2*f(t)>=e.options.page.maxContentHeight&&W(t);const p=t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-g).length*f(t);e.updateY(e.options.page.lineSpace,"add"),t.setFillColor("#EEEEEE"),t.setDrawColor("#eee"),t.roundedRect(e.X,e.Y-e.options.page.lineSpace,e.options.page.maxContentWidth,p,2,2,"FD"),t.setFontSize(10),t.text(i.lang??"",e.X+e.options.page.maxContentWidth-t.getTextWidth(i.lang??"")-e.options.page.lineSpace/2,e.Y),t.setFontSize(e.options.page.defaultFontSize),t.text(i.code??"",e.X+4,e.Y),e.updateY(p,"add")},B=(t,i,s)=>{const x=t.getFont().fontName,g=t.getFont().fontStyle,p=t.getFontSize(),c=t.getTextColor(),l=e.options.link?.linkColor||[0,0,255];t.setTextColor(...l);const n=e.options.page.maxContentWidth-s-e.X,r=i.text||i.content||"",a=i.href||"",h=t.splitTextToSize(r,n);if(e.isInlineLockActive)for(let u=0;u<h.length;u++){const d=t.getTextDimensions(h[u]).w,m=f(t)/2;t.link(e.X+s,e.Y,d,m,{url:a}),t.text(h[u],e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(d+1,"add"),e.X+d>e.options.page.maxContentWidth-s&&(e.updateY(m,"add"),e.updateX(e.options.page.xpading+s,"set")),u<h.length-1&&(e.updateY(m,"add"),e.updateX(e.options.page.xpading+s,"set"))}else if(h.length>1){const u=h[0],d=h?.slice(1)?.join(" "),m=t.getTextDimensions(u).w,C=f(t)/2;t.link(e.X+s,e.Y,m,C,{url:a}),t.text(u,e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(e.options.page.xpading+s),e.updateY(C,"add");const X=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(d,X).forEach(S=>{const T=t.getTextDimensions(S).w;t.link(e.X+Y(t),e.Y,T,C,{url:a}),t.text(S,e.X+Y(t),e.Y,{baseline:"top",maxWidth:X})})}else{const u=t.getTextDimensions(r).w,d=f(t)/2;t.link(e.X+s,e.Y,u,d,{url:a}),t.text(r,e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(u+2,"add")}t.setFont(x,g),t.setFontSize(p),t.setTextColor(c)},_=async(t,i,s)=>{e.initialize(s);const x=await H(i),g=(p,c=0,l=!1,n=0,r=!1,a=!0)=>{const h=c*s.page.indent;switch(e.Y+t.splitTextToSize(p.content??"",s.page.maxContentWidth-h).length*f(t)>=s.page.maxContentHeight&&W(t),p.type){case o.Heading:I(t,p,h,g);break;case o.Paragraph:D(t,p,h,g);break;case o.List:P(t,p,c,g);break;case o.ListItem:j(t,p,c,g,n,r);break;case o.Hr:A(t);break;case o.Code:R(t,p,c);break;case o.Strong:case o.Em:F(t,p,h);break;case o.Link:B(t,p,h);break;case o.Raw:case o.Text:v(t,p,c,l,g,n,r,a);break;default:console.warn(`Warning: Unsupported element type encountered: ${p.type}.
|
|
2
2
|
If you believe this element type should be supported, please create an issue at:
|
|
3
3
|
https://github.com/JeelGajera/jspdf-md-renderer/issues
|
|
4
|
-
with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const p of x)
|
|
4
|
+
with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const p of x)g(p);s.endCursorYHandler(e.Y)};exports.MdTextParser=H;exports.MdTextRender=_;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { marked as
|
|
1
|
+
import { marked as z } from "marked";
|
|
2
2
|
var o = /* @__PURE__ */ ((t) => (t.Heading = "heading", t.Paragraph = "paragraph", t.List = "list", t.ListItem = "list_item", t.Blockquote = "blockquote", t.Code = "code", t.CodeSpan = "codespan", t.Table = "table", t.Html = "html", t.Hr = "hr", t.Image = "image", t.Link = "link", t.Strong = "strong", t.Em = "em", t.TableHeader = "table_header", t.TableCell = "table_cell", t.Raw = "raw", t.Text = "text", t))(o || {});
|
|
3
|
-
const
|
|
4
|
-
const i = await
|
|
5
|
-
return
|
|
6
|
-
},
|
|
3
|
+
const T = async (t) => {
|
|
4
|
+
const i = await z.lexer(t, { async: !0 });
|
|
5
|
+
return b(i);
|
|
6
|
+
}, b = (t) => {
|
|
7
7
|
const i = [];
|
|
8
8
|
return t.forEach((s) => {
|
|
9
9
|
try {
|
|
10
|
-
const x =
|
|
10
|
+
const x = w[s.type];
|
|
11
11
|
x ? i.push(x(s)) : i.push({
|
|
12
12
|
type: o.Raw,
|
|
13
13
|
content: s.raw
|
|
@@ -16,28 +16,28 @@ const I = async (t) => {
|
|
|
16
16
|
console.error("Failed to handle token ==>", s, x);
|
|
17
17
|
}
|
|
18
18
|
}), i;
|
|
19
|
-
},
|
|
19
|
+
}, w = {
|
|
20
20
|
[o.Heading]: (t) => ({
|
|
21
21
|
type: o.Heading,
|
|
22
22
|
depth: t.depth,
|
|
23
23
|
content: t.text,
|
|
24
|
-
items: t.tokens ?
|
|
24
|
+
items: t.tokens ? b(t.tokens) : []
|
|
25
25
|
}),
|
|
26
26
|
[o.Paragraph]: (t) => ({
|
|
27
27
|
type: o.Paragraph,
|
|
28
28
|
content: t.text,
|
|
29
|
-
items: t.tokens ?
|
|
29
|
+
items: t.tokens ? b(t.tokens) : []
|
|
30
30
|
}),
|
|
31
31
|
[o.List]: (t) => ({
|
|
32
32
|
type: o.List,
|
|
33
33
|
ordered: t.ordered,
|
|
34
34
|
start: t.start,
|
|
35
|
-
items: t.items ?
|
|
35
|
+
items: t.items ? b(t.items) : []
|
|
36
36
|
}),
|
|
37
37
|
[o.ListItem]: (t) => ({
|
|
38
38
|
type: o.ListItem,
|
|
39
39
|
content: t.text,
|
|
40
|
-
items: t.tokens ?
|
|
40
|
+
items: t.tokens ? b(t.tokens) : []
|
|
41
41
|
}),
|
|
42
42
|
[o.Code]: (t) => ({
|
|
43
43
|
type: o.Code,
|
|
@@ -66,34 +66,34 @@ const I = async (t) => {
|
|
|
66
66
|
type: o.Link,
|
|
67
67
|
href: t.href,
|
|
68
68
|
text: t.text,
|
|
69
|
-
items: t.tokens ?
|
|
69
|
+
items: t.tokens ? b(t.tokens) : []
|
|
70
70
|
}),
|
|
71
71
|
[o.Strong]: (t) => ({
|
|
72
72
|
type: o.Strong,
|
|
73
73
|
content: t.text,
|
|
74
|
-
items: t.tokens ?
|
|
74
|
+
items: t.tokens ? b(t.tokens) : []
|
|
75
75
|
}),
|
|
76
76
|
[o.Em]: (t) => ({
|
|
77
77
|
type: o.Em,
|
|
78
78
|
content: t.text,
|
|
79
|
-
items: t.tokens ?
|
|
79
|
+
items: t.tokens ? b(t.tokens) : []
|
|
80
80
|
}),
|
|
81
81
|
[o.Text]: (t) => ({
|
|
82
82
|
type: o.Text,
|
|
83
83
|
content: t.text,
|
|
84
|
-
items: t.tokens ?
|
|
84
|
+
items: t.tokens ? b(t.tokens) : []
|
|
85
85
|
}),
|
|
86
86
|
[o.Hr]: (t) => ({
|
|
87
87
|
type: o.Hr,
|
|
88
88
|
content: t.raw,
|
|
89
|
-
items: t.tokens ?
|
|
89
|
+
items: t.tokens ? b(t.tokens) : []
|
|
90
90
|
}),
|
|
91
91
|
[o.CodeSpan]: (t) => ({
|
|
92
92
|
type: o.CodeSpan,
|
|
93
93
|
content: t.text,
|
|
94
|
-
items: t.tokens ?
|
|
94
|
+
items: t.tokens ? b(t.tokens) : []
|
|
95
95
|
})
|
|
96
|
-
},
|
|
96
|
+
}, L = class L {
|
|
97
97
|
static initialize(i) {
|
|
98
98
|
this.options_ = i, this.cursor = { x: i.cursor.x, y: i.cursor.y };
|
|
99
99
|
}
|
|
@@ -141,19 +141,18 @@ const I = async (t) => {
|
|
|
141
141
|
return this.cursor.y;
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
-
|
|
145
|
-
let e =
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
for (const p of (i == null ? void 0 : i.items) ?? [])
|
|
144
|
+
L.cursor = { x: 0, y: 0 }, L.inlineLock = !1;
|
|
145
|
+
let e = L;
|
|
146
|
+
const W = (t) => {
|
|
147
|
+
typeof e.options.pageBreakHandler == "function" ? e.options.pageBreakHandler() : t.addPage(e.options.page?.format, e.options.page?.orientation), e.updateY(e.options.page.topmargin), e.updateX(e.options.page.xpading);
|
|
148
|
+
}, f = (t) => t.getTextDimensions("H").h * e.options.page.defaultLineHeightFactor, Y = (t) => t.getTextDimensions("H").w * e.options.page.defaultLineHeightFactor, I = (t, i, s, x) => {
|
|
149
|
+
const g = 6 - (i?.depth ?? 0) > 0 ? 6 - (i?.depth ?? 0) : 1;
|
|
150
|
+
if (t.setFontSize(e.options.page.defaultFontSize + g), e.updateY(g * 0.2 * f(t), "add"), i?.items && i?.items.length > 0)
|
|
151
|
+
for (const p of i?.items ?? [])
|
|
153
152
|
x(p, s, !1);
|
|
154
153
|
else
|
|
155
154
|
t.text(
|
|
156
|
-
|
|
155
|
+
i?.content ?? "",
|
|
157
156
|
e.X + s,
|
|
158
157
|
e.Y,
|
|
159
158
|
{
|
|
@@ -162,56 +161,56 @@ const C = (t) => {
|
|
|
162
161
|
}
|
|
163
162
|
);
|
|
164
163
|
t.setFontSize(e.options.page.defaultFontSize), e.updateX(e.options.page.xpading);
|
|
165
|
-
},
|
|
166
|
-
const
|
|
167
|
-
let
|
|
168
|
-
const
|
|
164
|
+
}, k = (t, i, s, x, g, p, c, l, n) => {
|
|
165
|
+
const r = (l - s) / (i.length - 1);
|
|
166
|
+
let a = g;
|
|
167
|
+
const h = p + x * c;
|
|
169
168
|
for (const u of i)
|
|
170
|
-
t.text(u.text,
|
|
169
|
+
t.text(u.text, a, h, {
|
|
171
170
|
align: "justify",
|
|
172
|
-
lineHeightFactor:
|
|
173
|
-
maxWidth:
|
|
174
|
-
}),
|
|
175
|
-
},
|
|
176
|
-
const
|
|
177
|
-
i.text(
|
|
171
|
+
lineHeightFactor: n,
|
|
172
|
+
maxWidth: l
|
|
173
|
+
}), a += u.wordLength + r;
|
|
174
|
+
}, E = (t, i, s, x, g, p, c, l) => {
|
|
175
|
+
const n = t.map((r) => r.text).join(" ");
|
|
176
|
+
i.text(n, s, x + g * p, {
|
|
178
177
|
align: "justify",
|
|
179
|
-
lineHeightFactor:
|
|
178
|
+
lineHeightFactor: l,
|
|
180
179
|
maxWidth: c
|
|
181
180
|
});
|
|
182
|
-
},
|
|
181
|
+
}, y = (t, i, s, x, g, p) => {
|
|
183
182
|
const c = {
|
|
184
183
|
x: s,
|
|
185
184
|
y: x
|
|
186
|
-
},
|
|
187
|
-
let
|
|
188
|
-
for (const u of
|
|
189
|
-
const
|
|
190
|
-
|
|
185
|
+
}, l = t.getTextDimensions("A").h * p, n = i.split(" ");
|
|
186
|
+
let r = 0, a = [], h = 0;
|
|
187
|
+
for (const u of n) {
|
|
188
|
+
const d = t.getTextWidth(u + "a");
|
|
189
|
+
d + h >= g && (k(
|
|
191
190
|
t,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
a,
|
|
192
|
+
h,
|
|
193
|
+
r++,
|
|
195
194
|
s,
|
|
196
195
|
x,
|
|
197
|
-
g,
|
|
198
196
|
l,
|
|
197
|
+
g,
|
|
199
198
|
p
|
|
200
|
-
),
|
|
199
|
+
), a = [], h = 0), a.push({ text: u, wordLength: d }), h += d;
|
|
201
200
|
}
|
|
202
|
-
return
|
|
203
|
-
|
|
201
|
+
return a.length > 0 && E(
|
|
202
|
+
a,
|
|
204
203
|
t,
|
|
205
204
|
s,
|
|
206
205
|
x,
|
|
207
|
-
|
|
208
|
-
g,
|
|
206
|
+
r,
|
|
209
207
|
l,
|
|
208
|
+
g,
|
|
210
209
|
p
|
|
211
|
-
), c.y = x +
|
|
212
|
-
},
|
|
213
|
-
const x = t.getFont().fontName,
|
|
214
|
-
switch (
|
|
210
|
+
), c.y = x + r * l, c.x = t.getTextWidth(i) + s, c;
|
|
211
|
+
}, F = (t, i, s) => {
|
|
212
|
+
const x = t.getFont().fontName, g = t.getFont().fontStyle, p = t.getFontSize(), c = (n) => {
|
|
213
|
+
switch (n) {
|
|
215
214
|
case "normal":
|
|
216
215
|
return 0;
|
|
217
216
|
case "bold":
|
|
@@ -223,261 +222,259 @@ const C = (t) => {
|
|
|
223
222
|
default:
|
|
224
223
|
return 0;
|
|
225
224
|
}
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
h === "bold" ? t.setFont(
|
|
225
|
+
}, l = (n, r) => {
|
|
226
|
+
r === "bold" ? t.setFont(
|
|
229
227
|
e.options.font.bold.name && e.options.font.bold.name !== "" ? e.options.font.bold.name : x,
|
|
230
228
|
e.options.font.bold.style || "bold"
|
|
231
|
-
) :
|
|
229
|
+
) : r === "italic" ? t.setFont(e.options.font.regular.name, "italic") : r === "bolditalic" ? t.setFont(
|
|
232
230
|
e.options.font.bold.name && e.options.font.bold.name !== "" ? e.options.font.bold.name : x,
|
|
233
231
|
"bolditalic"
|
|
234
232
|
) : t.setFont(
|
|
235
233
|
e.options.font.regular.name,
|
|
236
|
-
|
|
234
|
+
g
|
|
237
235
|
);
|
|
238
|
-
const
|
|
236
|
+
const a = e.options.page.maxContentWidth - s - e.X, h = t.splitTextToSize(n, a);
|
|
239
237
|
if (e.isInlineLockActive)
|
|
240
|
-
for (let
|
|
238
|
+
for (let u = 0; u < h.length; u++)
|
|
241
239
|
t.text(
|
|
242
|
-
|
|
240
|
+
h[u],
|
|
243
241
|
e.X + s,
|
|
244
242
|
e.Y,
|
|
245
243
|
{
|
|
246
244
|
baseline: "top",
|
|
247
|
-
maxWidth:
|
|
245
|
+
maxWidth: a
|
|
248
246
|
}
|
|
249
247
|
), e.updateX(
|
|
250
|
-
t.getTextDimensions(
|
|
248
|
+
t.getTextDimensions(h[u]).w + 1,
|
|
251
249
|
"add"
|
|
252
|
-
),
|
|
253
|
-
else if (
|
|
254
|
-
const
|
|
250
|
+
), u < h.length - 1 && (e.updateY(f(t), "add"), e.updateX(e.options.page.xpading + s, "set"));
|
|
251
|
+
else if (h.length > 1) {
|
|
252
|
+
const u = h[0], d = h?.slice(1)?.join(" ");
|
|
255
253
|
t.text(
|
|
256
|
-
|
|
257
|
-
e.X + (s >= 2 ? s + 2 * c(
|
|
254
|
+
u,
|
|
255
|
+
e.X + (s >= 2 ? s + 2 * c(r) : 0),
|
|
258
256
|
e.Y,
|
|
259
257
|
{
|
|
260
258
|
baseline: "top",
|
|
261
|
-
maxWidth:
|
|
259
|
+
maxWidth: a
|
|
262
260
|
}
|
|
263
|
-
), e.updateX(e.options.page.xpading + s), e.updateY(
|
|
264
|
-
const
|
|
265
|
-
t.splitTextToSize(
|
|
266
|
-
t.text(
|
|
261
|
+
), e.updateX(e.options.page.xpading + s), e.updateY(f(t), "add");
|
|
262
|
+
const m = e.options.page.maxContentWidth - s - e.options.page.xpading;
|
|
263
|
+
t.splitTextToSize(d, m).forEach((X) => {
|
|
264
|
+
t.text(X, e.X + Y(t), e.Y, {
|
|
267
265
|
baseline: "top",
|
|
268
|
-
maxWidth:
|
|
266
|
+
maxWidth: m
|
|
269
267
|
});
|
|
270
268
|
});
|
|
271
269
|
} else
|
|
272
|
-
t.text(
|
|
270
|
+
t.text(n, e.X + s, e.Y, {
|
|
273
271
|
baseline: "top",
|
|
274
|
-
maxWidth:
|
|
272
|
+
maxWidth: a
|
|
275
273
|
}), e.updateX(
|
|
276
|
-
t.getTextDimensions(
|
|
274
|
+
t.getTextDimensions(n).w + (s >= 2 ? n.split(" ").length + 2 : 2) * c(r) * 0.5,
|
|
277
275
|
"add"
|
|
278
276
|
);
|
|
279
277
|
};
|
|
280
278
|
if (i.type === "text" && i.items && i.items.length > 0)
|
|
281
|
-
for (const
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
for (const
|
|
286
|
-
|
|
287
|
-
|
|
279
|
+
for (const n of i.items)
|
|
280
|
+
if (n.type === "em" || n.type === "strong") {
|
|
281
|
+
const r = n.type === "em" ? "italic" : "bold";
|
|
282
|
+
if (n.items && n.items.length > 0)
|
|
283
|
+
for (const a of n.items)
|
|
284
|
+
a.type === "strong" && r === "italic" || a.type === "em" && r === "bold" ? l(
|
|
285
|
+
a.content || "",
|
|
288
286
|
"bolditalic"
|
|
289
|
-
) :
|
|
290
|
-
|
|
291
|
-
|
|
287
|
+
) : l(
|
|
288
|
+
a.content || "",
|
|
289
|
+
r
|
|
292
290
|
);
|
|
293
291
|
else
|
|
294
|
-
|
|
292
|
+
l(n.content || "", r);
|
|
295
293
|
} else
|
|
296
|
-
|
|
297
|
-
else i.type === "em" ?
|
|
298
|
-
t.setFont(x,
|
|
299
|
-
},
|
|
294
|
+
l(n.content || "", "normal");
|
|
295
|
+
else i.type === "em" ? l(i.content || "", "italic") : i.type === "strong" ? l(i.content || "", "bold") : l(i.content || "", "normal");
|
|
296
|
+
t.setFont(x, g), t.setFontSize(p);
|
|
297
|
+
}, D = (t, i, s, x) => {
|
|
300
298
|
e.activateInlineLock(), t.setFontSize(e.options.page.defaultFontSize);
|
|
301
|
-
let
|
|
299
|
+
let g = i.content;
|
|
302
300
|
const p = t.getTextDimensions("A").h * e.options.page.defaultLineHeightFactor;
|
|
303
|
-
if (i
|
|
301
|
+
if (i?.items && i?.items.length > 0) {
|
|
304
302
|
let c = 0;
|
|
305
|
-
for (const
|
|
306
|
-
["strong", "em", "text"].includes(
|
|
303
|
+
for (const l of i?.items ?? [])
|
|
304
|
+
["strong", "em", "text"].includes(l.type) ? (l.type !== "text" && c != 0 && e.updateX(Y(t) * 1.5, "add"), F(t, l, s), l.type !== "text" && c != 0 && e.updateX(Y(t), "add")) : x(l, s, !1), c++;
|
|
307
305
|
} else {
|
|
308
306
|
if (e.Y + t.splitTextToSize(
|
|
309
|
-
|
|
307
|
+
g ?? "",
|
|
310
308
|
e.options.page.maxContentWidth - s
|
|
311
309
|
).length * p - 3 * p >= e.options.page.maxContentHeight) {
|
|
312
|
-
const
|
|
313
|
-
|
|
310
|
+
const l = t.splitTextToSize(
|
|
311
|
+
g ?? "",
|
|
314
312
|
e.options.page.maxContentWidth - s
|
|
315
|
-
),
|
|
316
|
-
for (let
|
|
313
|
+
), n = [], r = e.Y;
|
|
314
|
+
for (let a = 0; a < l.length; a++)
|
|
317
315
|
if (e.Y - 2 * p < e.options.page.maxContentHeight)
|
|
318
|
-
|
|
316
|
+
n.push(l[a]), e.updateY(
|
|
319
317
|
e.options.page.lineSpace,
|
|
320
318
|
"add"
|
|
321
319
|
);
|
|
322
320
|
else {
|
|
323
|
-
|
|
321
|
+
a <= l.length - 1 && (g = l.slice(a).join(""));
|
|
324
322
|
break;
|
|
325
323
|
}
|
|
326
|
-
if (
|
|
327
|
-
const
|
|
324
|
+
if (n.length > 0) {
|
|
325
|
+
const a = y(
|
|
328
326
|
t,
|
|
329
|
-
|
|
327
|
+
n.join(" "),
|
|
330
328
|
e.X + s,
|
|
331
|
-
|
|
329
|
+
r,
|
|
332
330
|
e.options.page.maxContentWidth - s,
|
|
333
331
|
e.options.page.defaultLineHeightFactor
|
|
334
332
|
);
|
|
335
|
-
e.setCursor(
|
|
333
|
+
e.setCursor(a);
|
|
336
334
|
}
|
|
337
|
-
|
|
335
|
+
W(t);
|
|
338
336
|
}
|
|
339
|
-
const c =
|
|
337
|
+
const c = y(
|
|
340
338
|
t,
|
|
341
|
-
|
|
339
|
+
g ?? "",
|
|
342
340
|
e.X + s,
|
|
343
341
|
e.Y,
|
|
344
342
|
e.options.page.maxContentWidth - s,
|
|
345
343
|
e.options.page.defaultLineHeightFactor
|
|
346
|
-
).y +
|
|
344
|
+
).y + f(t);
|
|
347
345
|
e.updateY(c);
|
|
348
346
|
}
|
|
349
347
|
e.updateY(p, "add"), e.updateX(e.options.page.xpading), e.deactivateInlineLock();
|
|
350
|
-
},
|
|
351
|
-
var l;
|
|
348
|
+
}, P = (t, i, s, x) => {
|
|
352
349
|
t.setFontSize(e.options.page.defaultFontSize);
|
|
353
|
-
for (const [
|
|
354
|
-
const
|
|
350
|
+
for (const [g, p] of i?.items?.entries() ?? []) {
|
|
351
|
+
const c = i.ordered ? (i.start ?? 0) + g : i.start;
|
|
355
352
|
x(
|
|
356
|
-
|
|
353
|
+
p,
|
|
357
354
|
s + 1,
|
|
358
355
|
!0,
|
|
359
|
-
|
|
356
|
+
c,
|
|
360
357
|
i.ordered
|
|
361
358
|
);
|
|
362
359
|
}
|
|
363
|
-
},
|
|
364
|
-
const c = s * e.options.page.indent,
|
|
365
|
-
e.Y +
|
|
360
|
+
}, j = (t, i, s, x, g, p) => {
|
|
361
|
+
const c = s * e.options.page.indent, l = p ? `${g}. ` : "• ";
|
|
362
|
+
e.Y + f(t) >= e.options.page.maxContentHeight && W(t), t.setFont(
|
|
366
363
|
e.options.font.regular.name,
|
|
367
364
|
e.options.font.regular.style
|
|
368
|
-
), t.text(
|
|
365
|
+
), t.text(l, e.X + c, e.Y, {
|
|
369
366
|
baseline: "top"
|
|
370
367
|
});
|
|
371
|
-
const
|
|
372
|
-
if (e.updateX(
|
|
373
|
-
for (const
|
|
374
|
-
if (e.Y +
|
|
368
|
+
const n = t.getTextWidth(l);
|
|
369
|
+
if (e.updateX(n, "add"), i.items && i.items.length > 0)
|
|
370
|
+
for (const r of i.items) {
|
|
371
|
+
if (e.Y + f(t) >= e.options.page.maxContentHeight && W(t), r.type === o.List)
|
|
375
372
|
x(
|
|
376
|
-
|
|
373
|
+
r,
|
|
377
374
|
s + 1,
|
|
378
375
|
!0,
|
|
379
|
-
|
|
380
|
-
|
|
376
|
+
g,
|
|
377
|
+
r.ordered ?? !1
|
|
381
378
|
);
|
|
382
|
-
else if (
|
|
383
|
-
const
|
|
379
|
+
else if (r.type === o.ListItem) {
|
|
380
|
+
const a = i.type === o.List ? s : s + 1;
|
|
384
381
|
x(
|
|
385
|
-
|
|
386
|
-
|
|
382
|
+
r,
|
|
383
|
+
a,
|
|
387
384
|
!0,
|
|
388
|
-
|
|
385
|
+
g,
|
|
389
386
|
p
|
|
390
387
|
);
|
|
391
388
|
} else
|
|
392
|
-
|
|
393
|
-
e.updateX(e.options.page.xpading), e.updateY(
|
|
389
|
+
e.activateInlineLock(), F(t, r, c), e.deactivateInlineLock();
|
|
390
|
+
e.updateX(e.options.page.xpading), e.updateY(f(t), "add");
|
|
394
391
|
}
|
|
395
392
|
else if (i.content) {
|
|
396
|
-
const
|
|
393
|
+
const r = e.X + c, a = t.getTextWidth(l), h = e.options.page.maxContentWidth - c - a, u = t.splitTextToSize(i.content, h);
|
|
397
394
|
if (u.length > 0) {
|
|
398
|
-
t.text(u[0],
|
|
395
|
+
t.text(u[0], r + a, e.Y, {
|
|
399
396
|
baseline: "top",
|
|
400
|
-
maxWidth:
|
|
397
|
+
maxWidth: h
|
|
401
398
|
});
|
|
402
|
-
for (let
|
|
403
|
-
e.updateY(
|
|
399
|
+
for (let m = 1; m < u.length; m++)
|
|
400
|
+
e.updateY(f(t), "add"), t.text(u[m], r + a, e.Y, {
|
|
404
401
|
baseline: "top",
|
|
405
|
-
maxWidth:
|
|
402
|
+
maxWidth: h
|
|
406
403
|
});
|
|
407
|
-
e.updateX(e.options.page.xmargin + c), e.updateY(
|
|
408
|
-
const
|
|
409
|
-
e.updateX(
|
|
404
|
+
e.updateX(e.options.page.xmargin + c), e.updateY(f(t), "add");
|
|
405
|
+
const d = t.getTextWidth(i.content);
|
|
406
|
+
e.updateX(d, "add");
|
|
410
407
|
}
|
|
411
408
|
}
|
|
412
|
-
},
|
|
413
|
-
if (i
|
|
414
|
-
for (const
|
|
415
|
-
|
|
416
|
-
|
|
409
|
+
}, v = (t, i, s, x, g, p, c, l = !0) => {
|
|
410
|
+
if (i?.items && i?.items.length > 0)
|
|
411
|
+
for (const n of i?.items ?? [])
|
|
412
|
+
g(
|
|
413
|
+
n,
|
|
417
414
|
s,
|
|
418
415
|
x,
|
|
419
416
|
p,
|
|
420
417
|
c,
|
|
421
|
-
|
|
418
|
+
l
|
|
422
419
|
);
|
|
423
420
|
else {
|
|
424
|
-
const
|
|
425
|
-
if (x &&
|
|
426
|
-
const
|
|
421
|
+
const n = s * e.options.page.indent, r = x ? c ? `${p}. ` : "• " : "";
|
|
422
|
+
if (x && r) {
|
|
423
|
+
const a = t.getTextWidth(r), h = e.options.page.maxContentWidth - n - a, u = t.splitTextToSize(
|
|
427
424
|
i.content || "",
|
|
428
|
-
|
|
425
|
+
h
|
|
429
426
|
);
|
|
430
427
|
if (u.length > 0) {
|
|
431
|
-
t.text(
|
|
428
|
+
t.text(r, e.X + n, e.Y, {
|
|
432
429
|
baseline: "top"
|
|
433
430
|
}), t.text(
|
|
434
431
|
u[0],
|
|
435
|
-
e.X +
|
|
432
|
+
e.X + n + a,
|
|
436
433
|
e.Y,
|
|
437
434
|
{
|
|
438
435
|
baseline: "top",
|
|
439
|
-
maxWidth:
|
|
436
|
+
maxWidth: h
|
|
440
437
|
}
|
|
441
438
|
);
|
|
442
|
-
for (let
|
|
439
|
+
for (let m = 1; m < u.length; m++)
|
|
443
440
|
e.updateX(e.options.page.xpading), e.updateY(
|
|
444
|
-
|
|
441
|
+
f(t),
|
|
445
442
|
"add"
|
|
446
443
|
), t.text(
|
|
447
|
-
u[
|
|
448
|
-
e.X +
|
|
444
|
+
u[m],
|
|
445
|
+
e.X + n + a,
|
|
449
446
|
e.Y,
|
|
450
447
|
{
|
|
451
448
|
baseline: "top",
|
|
452
|
-
maxWidth:
|
|
449
|
+
maxWidth: h - n - a
|
|
453
450
|
}
|
|
454
451
|
);
|
|
455
452
|
e.updateY(
|
|
456
|
-
|
|
453
|
+
f(t),
|
|
457
454
|
"add"
|
|
458
|
-
), e.updateX(e.options.page.xpading +
|
|
459
|
-
const
|
|
460
|
-
e.updateX(
|
|
455
|
+
), e.updateX(e.options.page.xpading + n);
|
|
456
|
+
const d = t.getTextWidth(i.content || "");
|
|
457
|
+
e.updateX(d, "add");
|
|
461
458
|
}
|
|
462
459
|
} else {
|
|
463
|
-
const
|
|
460
|
+
const a = t.splitTextToSize(
|
|
464
461
|
i.content || "",
|
|
465
|
-
e.options.page.maxContentWidth -
|
|
462
|
+
e.options.page.maxContentWidth - n
|
|
466
463
|
);
|
|
467
|
-
if (e.Y +
|
|
468
|
-
const
|
|
464
|
+
if (e.Y + a.length * f(t) >= e.options.page.maxContentHeight && W(t), l) {
|
|
465
|
+
const h = y(
|
|
469
466
|
t,
|
|
470
467
|
i.content || "",
|
|
471
|
-
e.X +
|
|
468
|
+
e.X + n,
|
|
472
469
|
e.Y,
|
|
473
|
-
e.options.page.maxContentWidth -
|
|
470
|
+
e.options.page.maxContentWidth - n,
|
|
474
471
|
e.options.page.defaultLineHeightFactor
|
|
475
|
-
).y +
|
|
476
|
-
e.updateY(
|
|
472
|
+
).y + f(t) * 0.5;
|
|
473
|
+
e.updateY(h), e.updateX(e.options.page.xpading);
|
|
477
474
|
} else
|
|
478
475
|
t.text(
|
|
479
|
-
|
|
480
|
-
e.X +
|
|
476
|
+
a || "",
|
|
477
|
+
e.X + n,
|
|
481
478
|
e.Y,
|
|
482
479
|
{
|
|
483
480
|
baseline: "top"
|
|
@@ -485,27 +482,27 @@ const C = (t) => {
|
|
|
485
482
|
), e.updateX(
|
|
486
483
|
t.getTextWidth(i.content || ""),
|
|
487
484
|
"add"
|
|
488
|
-
), e.X >= e.options.page.xpading + e.options.page.maxContentWidth &&
|
|
485
|
+
), e.X >= e.options.page.xpading + e.options.page.maxContentWidth && W(t);
|
|
489
486
|
}
|
|
490
487
|
}
|
|
491
|
-
},
|
|
488
|
+
}, A = (t) => {
|
|
492
489
|
const i = t.internal.pageSize.getWidth();
|
|
493
490
|
t.setLineDashPattern([1, 1], 0), t.setLineWidth(0.1), t.line(
|
|
494
491
|
e.options.page.xpading,
|
|
495
492
|
e.Y,
|
|
496
493
|
i - e.options.page.xpading,
|
|
497
494
|
e.Y
|
|
498
|
-
), t.setLineWidth(0.1), t.setLineDashPattern([], 0), e.updateY(
|
|
499
|
-
},
|
|
500
|
-
const
|
|
495
|
+
), t.setLineWidth(0.1), t.setLineDashPattern([], 0), e.updateY(f(t), "add");
|
|
496
|
+
}, B = (t, i, s, x) => {
|
|
497
|
+
const g = s * e.options.page.indent;
|
|
501
498
|
e.Y + t.splitTextToSize(
|
|
502
499
|
i.code ?? "",
|
|
503
|
-
e.options.page.maxContentWidth -
|
|
504
|
-
).length *
|
|
500
|
+
e.options.page.maxContentWidth - g
|
|
501
|
+
).length * f(t) - 2 * f(t) >= e.options.page.maxContentHeight && W(t);
|
|
505
502
|
const p = t.splitTextToSize(
|
|
506
503
|
i.code ?? "",
|
|
507
|
-
e.options.page.maxContentWidth -
|
|
508
|
-
).length *
|
|
504
|
+
e.options.page.maxContentWidth - g
|
|
505
|
+
).length * f(t);
|
|
509
506
|
e.updateY(e.options.page.lineSpace, "add"), t.setFillColor("#EEEEEE"), t.setDrawColor("#eee"), t.roundedRect(
|
|
510
507
|
e.X,
|
|
511
508
|
e.Y - e.options.page.lineSpace,
|
|
@@ -519,145 +516,144 @@ const C = (t) => {
|
|
|
519
516
|
e.X + e.options.page.maxContentWidth - t.getTextWidth(i.lang ?? "") - e.options.page.lineSpace / 2,
|
|
520
517
|
e.Y
|
|
521
518
|
), t.setFontSize(e.options.page.defaultFontSize), t.text(i.code ?? "", e.X + 4, e.Y), e.updateY(p, "add");
|
|
522
|
-
},
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
t.
|
|
526
|
-
const a = e.options.page.maxContentWidth - s - e.X, h = i.text || i.content || "", n = i.href || "", r = t.splitTextToSize(h, a);
|
|
519
|
+
}, R = (t, i, s) => {
|
|
520
|
+
const x = t.getFont().fontName, g = t.getFont().fontStyle, p = t.getFontSize(), c = t.getTextColor(), l = e.options.link?.linkColor || [0, 0, 255];
|
|
521
|
+
t.setTextColor(...l);
|
|
522
|
+
const n = e.options.page.maxContentWidth - s - e.X, r = i.text || i.content || "", a = i.href || "", h = t.splitTextToSize(r, n);
|
|
527
523
|
if (e.isInlineLockActive)
|
|
528
|
-
for (let
|
|
529
|
-
const
|
|
524
|
+
for (let u = 0; u < h.length; u++) {
|
|
525
|
+
const d = t.getTextDimensions(h[u]).w, m = f(t) / 2;
|
|
530
526
|
t.link(
|
|
531
527
|
e.X + s,
|
|
532
528
|
e.Y,
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
{ url:
|
|
529
|
+
d,
|
|
530
|
+
m,
|
|
531
|
+
{ url: a }
|
|
536
532
|
), t.text(
|
|
537
|
-
|
|
533
|
+
h[u],
|
|
538
534
|
e.X + s,
|
|
539
535
|
e.Y,
|
|
540
536
|
{
|
|
541
537
|
baseline: "top",
|
|
542
|
-
maxWidth:
|
|
538
|
+
maxWidth: n
|
|
543
539
|
}
|
|
544
540
|
), e.updateX(
|
|
545
|
-
|
|
541
|
+
d + 1,
|
|
546
542
|
"add"
|
|
547
|
-
), e.X +
|
|
543
|
+
), e.X + d > e.options.page.maxContentWidth - s && (e.updateY(m, "add"), e.updateX(
|
|
548
544
|
e.options.page.xpading + s,
|
|
549
545
|
"set"
|
|
550
|
-
)),
|
|
546
|
+
)), u < h.length - 1 && (e.updateY(m, "add"), e.updateX(
|
|
551
547
|
e.options.page.xpading + s,
|
|
552
548
|
"set"
|
|
553
549
|
));
|
|
554
550
|
}
|
|
555
|
-
else if (
|
|
556
|
-
const
|
|
551
|
+
else if (h.length > 1) {
|
|
552
|
+
const u = h[0], d = h?.slice(1)?.join(" "), m = t.getTextDimensions(u).w, C = f(t) / 2;
|
|
557
553
|
t.link(
|
|
558
554
|
e.X + s,
|
|
559
555
|
e.Y,
|
|
560
|
-
X,
|
|
561
556
|
m,
|
|
562
|
-
|
|
557
|
+
C,
|
|
558
|
+
{ url: a }
|
|
563
559
|
), t.text(
|
|
564
|
-
|
|
560
|
+
u,
|
|
565
561
|
e.X + s,
|
|
566
562
|
e.Y,
|
|
567
563
|
{
|
|
568
564
|
baseline: "top",
|
|
569
|
-
maxWidth:
|
|
565
|
+
maxWidth: n
|
|
570
566
|
}
|
|
571
|
-
), e.updateX(e.options.page.xpading + s), e.updateY(
|
|
572
|
-
const
|
|
573
|
-
t.splitTextToSize(
|
|
574
|
-
const
|
|
567
|
+
), e.updateX(e.options.page.xpading + s), e.updateY(C, "add");
|
|
568
|
+
const X = e.options.page.maxContentWidth - s - e.options.page.xpading;
|
|
569
|
+
t.splitTextToSize(d, X).forEach((H) => {
|
|
570
|
+
const S = t.getTextDimensions(H).w;
|
|
575
571
|
t.link(
|
|
576
|
-
e.X +
|
|
572
|
+
e.X + Y(t),
|
|
577
573
|
e.Y,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
{ url:
|
|
574
|
+
S,
|
|
575
|
+
C,
|
|
576
|
+
{ url: a }
|
|
581
577
|
), t.text(
|
|
582
|
-
|
|
583
|
-
e.X +
|
|
578
|
+
H,
|
|
579
|
+
e.X + Y(t),
|
|
584
580
|
e.Y,
|
|
585
581
|
{
|
|
586
582
|
baseline: "top",
|
|
587
|
-
maxWidth:
|
|
583
|
+
maxWidth: X
|
|
588
584
|
}
|
|
589
585
|
);
|
|
590
586
|
});
|
|
591
587
|
} else {
|
|
592
|
-
const
|
|
588
|
+
const u = t.getTextDimensions(r).w, d = f(t) / 2;
|
|
593
589
|
t.link(
|
|
594
590
|
e.X + s,
|
|
595
591
|
e.Y,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
{ url:
|
|
592
|
+
u,
|
|
593
|
+
d,
|
|
594
|
+
{ url: a }
|
|
599
595
|
), t.text(
|
|
600
|
-
|
|
596
|
+
r,
|
|
601
597
|
e.X + s,
|
|
602
598
|
e.Y,
|
|
603
599
|
{
|
|
604
600
|
baseline: "top",
|
|
605
|
-
maxWidth:
|
|
601
|
+
maxWidth: n
|
|
606
602
|
}
|
|
607
|
-
), e.updateX(
|
|
603
|
+
), e.updateX(u + 2, "add");
|
|
608
604
|
}
|
|
609
|
-
t.setFont(x,
|
|
610
|
-
},
|
|
605
|
+
t.setFont(x, g), t.setFontSize(p), t.setTextColor(c);
|
|
606
|
+
}, N = async (t, i, s) => {
|
|
611
607
|
e.initialize(s);
|
|
612
|
-
const x = await
|
|
613
|
-
const
|
|
608
|
+
const x = await T(i), g = (p, c = 0, l = !1, n = 0, r = !1, a = !0) => {
|
|
609
|
+
const h = c * s.page.indent;
|
|
614
610
|
switch (e.Y + t.splitTextToSize(
|
|
615
611
|
p.content ?? "",
|
|
616
|
-
s.page.maxContentWidth -
|
|
617
|
-
).length *
|
|
612
|
+
s.page.maxContentWidth - h
|
|
613
|
+
).length * f(t) >= s.page.maxContentHeight && W(t), p.type) {
|
|
618
614
|
case o.Heading:
|
|
619
|
-
|
|
615
|
+
I(t, p, h, g);
|
|
620
616
|
break;
|
|
621
617
|
case o.Paragraph:
|
|
622
|
-
|
|
618
|
+
D(t, p, h, g);
|
|
623
619
|
break;
|
|
624
620
|
case o.List:
|
|
625
|
-
|
|
621
|
+
P(t, p, c, g);
|
|
626
622
|
break;
|
|
627
623
|
case o.ListItem:
|
|
628
|
-
|
|
624
|
+
j(
|
|
629
625
|
t,
|
|
630
626
|
p,
|
|
631
627
|
c,
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
628
|
+
g,
|
|
629
|
+
n,
|
|
630
|
+
r
|
|
635
631
|
);
|
|
636
632
|
break;
|
|
637
633
|
case o.Hr:
|
|
638
|
-
|
|
634
|
+
A(t);
|
|
639
635
|
break;
|
|
640
636
|
case o.Code:
|
|
641
|
-
|
|
637
|
+
B(t, p, c);
|
|
642
638
|
break;
|
|
643
639
|
case o.Strong:
|
|
644
640
|
case o.Em:
|
|
645
|
-
|
|
641
|
+
F(t, p, h);
|
|
646
642
|
break;
|
|
647
643
|
case o.Link:
|
|
648
|
-
|
|
644
|
+
R(t, p, h);
|
|
649
645
|
break;
|
|
650
646
|
case o.Raw:
|
|
651
647
|
case o.Text:
|
|
652
|
-
|
|
648
|
+
v(
|
|
653
649
|
t,
|
|
654
650
|
p,
|
|
655
651
|
c,
|
|
656
|
-
g,
|
|
657
652
|
l,
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
653
|
+
g,
|
|
654
|
+
n,
|
|
655
|
+
r,
|
|
656
|
+
a
|
|
661
657
|
);
|
|
662
658
|
break;
|
|
663
659
|
default:
|
|
@@ -671,10 +667,10 @@ const C = (t) => {
|
|
|
671
667
|
}
|
|
672
668
|
};
|
|
673
669
|
for (const p of x)
|
|
674
|
-
|
|
670
|
+
g(p);
|
|
675
671
|
s.endCursorYHandler(e.Y);
|
|
676
672
|
};
|
|
677
673
|
export {
|
|
678
|
-
|
|
679
|
-
|
|
674
|
+
T as MdTextParser,
|
|
675
|
+
N as MdTextRender
|
|
680
676
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jspdf-md-renderer",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "A jsPDF utility to render Markdown directly into formatted PDFs with custom designs.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"jspdf": "^3.0.1",
|
|
49
49
|
"jspdf-md-renderer": "file:",
|
|
50
|
-
"marked": "^
|
|
50
|
+
"marked": "^16.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@eslint/js": "^9.16.0",
|
|
54
|
-
"@types/node": "^
|
|
54
|
+
"@types/node": "^24.0.3",
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
56
56
|
"@typescript-eslint/parser": "^8.18.0",
|
|
57
57
|
"eslint": "^9.16.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"rimraf": "^6.0.1",
|
|
63
63
|
"typescript": "^5.7.2",
|
|
64
64
|
"typescript-eslint": "^8.18.0",
|
|
65
|
-
"vite": "^
|
|
65
|
+
"vite": "^7.0.4",
|
|
66
66
|
"vite-plugin-dts": "^4.5.3"
|
|
67
67
|
}
|
|
68
68
|
}
|