jspdf-md-renderer 3.2.0 → 3.3.0

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.mjs CHANGED
@@ -1,90 +1,90 @@
1
1
  import { marked as j } from "marked";
2
2
  import O from "jspdf-autotable";
3
3
  var u = /* @__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))(u || {});
4
- const A = "__jmr_", G = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, q = /(\w+)\s*=\s*(\w+)/g, B = ["left", "center", "right"], U = (t) => {
4
+ const D = "__jmr_", q = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, U = /(\w+)\s*=\s*(\w+)/g, R = ["left", "center", "right"], Q = (t) => {
5
5
  const e = [];
6
- return t.width !== void 0 && e.push(`w=${t.width}`), t.height !== void 0 && e.push(`h=${t.height}`), t.align && e.push(`a=${t.align}`), e.length > 0 ? `#${A}${e.join("&")}` : "";
7
- }, J = (t) => {
6
+ return t.width !== void 0 && e.push(`w=${t.width}`), t.height !== void 0 && e.push(`h=${t.height}`), t.align && e.push(`a=${t.align}`), e.length > 0 ? `#${D}${e.join("&")}` : "";
7
+ }, V = (t) => {
8
8
  const e = {};
9
- let s;
10
- for (; (s = q.exec(t)) !== null; ) {
11
- const c = s[1].toLowerCase(), g = s[2];
12
- switch (c) {
9
+ let i;
10
+ for (; (i = U.exec(t)) !== null; ) {
11
+ const r = i[1].toLowerCase(), h = i[2];
12
+ switch (r) {
13
13
  case "width":
14
14
  case "w": {
15
- const r = parseInt(g, 10);
16
- !isNaN(r) && r > 0 && (e.width = r);
15
+ const o = parseInt(h, 10);
16
+ !isNaN(o) && o > 0 && (e.width = o);
17
17
  break;
18
18
  }
19
19
  case "height":
20
20
  case "h": {
21
- const r = parseInt(g, 10);
22
- !isNaN(r) && r > 0 && (e.height = r);
21
+ const o = parseInt(h, 10);
22
+ !isNaN(o) && o > 0 && (e.height = o);
23
23
  break;
24
24
  }
25
25
  case "align": {
26
- const r = g.toLowerCase();
27
- B.includes(
28
- r
29
- ) && (e.align = r);
26
+ const o = h.toLowerCase();
27
+ R.includes(
28
+ o
29
+ ) && (e.align = o);
30
30
  break;
31
31
  }
32
32
  }
33
33
  }
34
34
  return e;
35
- }, V = (t) => t.replace(
36
- G,
37
- (e, s, c, g, r) => {
38
- const l = J(r), i = U(l);
39
- return `${s}${c}${i}${g}`;
35
+ }, Z = (t) => t.replace(
36
+ q,
37
+ (e, i, r, h, o) => {
38
+ const l = V(o), a = Q(l);
39
+ return `${i}${r}${a}${h}`;
40
40
  }
41
41
  ), K = (t) => {
42
- const e = t.indexOf(`#${A}`);
42
+ const e = t.indexOf(`#${D}`);
43
43
  if (e === -1)
44
44
  return { cleanHref: t, attrs: {} };
45
- const s = t.substring(0, e), c = t.substring(e + 1 + A.length), g = {}, r = c.split("&");
46
- for (const l of r) {
47
- const [i, a] = l.split("=");
48
- switch (i) {
45
+ const i = t.substring(0, e), r = t.substring(e + 1 + D.length), h = {}, o = r.split("&");
46
+ for (const l of o) {
47
+ const [a, s] = l.split("=");
48
+ switch (a) {
49
49
  case "w": {
50
- const p = parseInt(a, 10);
51
- !isNaN(p) && p > 0 && (g.width = p);
50
+ const g = parseInt(s, 10);
51
+ !isNaN(g) && g > 0 && (h.width = g);
52
52
  break;
53
53
  }
54
54
  case "h": {
55
- const p = parseInt(a, 10);
56
- !isNaN(p) && p > 0 && (g.height = p);
55
+ const g = parseInt(s, 10);
56
+ !isNaN(g) && g > 0 && (h.height = g);
57
57
  break;
58
58
  }
59
59
  case "a": {
60
- B.includes(
61
- a
62
- ) && (g.align = a);
60
+ R.includes(
61
+ s
62
+ ) && (h.align = s);
63
63
  break;
64
64
  }
65
65
  }
66
66
  }
67
- return { cleanHref: s, attrs: g };
68
- }, Q = async (t) => {
69
- const e = V(t), s = await j.lexer(e, {
67
+ return { cleanHref: i, attrs: h };
68
+ }, M = async (t) => {
69
+ const e = Z(t), i = await j.lexer(e, {
70
70
  async: !0,
71
71
  gfm: !0
72
72
  });
73
- return W(s);
73
+ return W(i);
74
74
  }, W = (t) => {
75
75
  const e = [];
76
- return t.forEach((s) => {
76
+ return t.forEach((i) => {
77
77
  try {
78
- const c = Z[s.type];
79
- c ? e.push(c(s)) : e.push({
78
+ const r = tt[i.type];
79
+ r ? e.push(r(i)) : e.push({
80
80
  type: u.Raw,
81
- content: s.raw
81
+ content: i.raw
82
82
  });
83
- } catch (c) {
84
- console.error("Failed to handle token ==>", s, c);
83
+ } catch (r) {
84
+ console.error("Failed to handle token ==>", i, r);
85
85
  }
86
86
  }), e;
87
- }, Z = {
87
+ }, tt = {
88
88
  [u.Heading]: (t) => ({
89
89
  type: u.Heading,
90
90
  depth: t.depth,
@@ -119,21 +119,21 @@ const A = "__jmr_", G = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, q = /(\w+)\
119
119
  content: e.text
120
120
  })),
121
121
  rows: t.rows.map(
122
- (e) => e.map((s) => ({
122
+ (e) => e.map((i) => ({
123
123
  type: u.TableCell,
124
- content: s.text
124
+ content: i.text
125
125
  }))
126
126
  )
127
127
  }),
128
128
  [u.Image]: (t) => {
129
- const { cleanHref: e, attrs: s } = K(t.href);
129
+ const { cleanHref: e, attrs: i } = K(t.href);
130
130
  return {
131
131
  type: u.Image,
132
132
  src: e,
133
133
  alt: t.text,
134
- width: s.width,
135
- height: s.height,
136
- align: s.align
134
+ width: i.width,
135
+ height: i.height,
136
+ align: i.align
137
137
  };
138
138
  },
139
139
  [u.Link]: (t) => ({
@@ -172,7 +172,7 @@ const A = "__jmr_", G = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, q = /(\w+)\
172
172
  content: t.text,
173
173
  items: t.tokens ? W(t.tokens) : []
174
174
  })
175
- }, H = class H {
175
+ }, I = class I {
176
176
  static initialize(e) {
177
177
  this.options_ = e, this.cursor = { x: e.cursor.x, y: e.cursor.y }, this.lastContentY_ = e.cursor.y;
178
178
  }
@@ -200,8 +200,8 @@ const A = "__jmr_", G = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, q = /(\w+)\
200
200
  * @param operation 'set' to assign a new value, 'add' to increment the current value.
201
201
  * @default operation = 'set'
202
202
  */
203
- static updateX(e, s = "set") {
204
- s === "set" ? this.cursor.x = e : s === "add" && (this.cursor.x += e);
203
+ static updateX(e, i = "set") {
204
+ i === "set" ? this.cursor.x = e : i === "add" && (this.cursor.x += e);
205
205
  }
206
206
  /**
207
207
  * Updates the y pointer of the cursor.
@@ -209,8 +209,8 @@ const A = "__jmr_", G = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, q = /(\w+)\
209
209
  * @param operation 'set' to assign a new value, 'add' to increment the current value.
210
210
  * @default operation = 'set'
211
211
  */
212
- static updateY(e, s = "set") {
213
- s === "set" ? this.cursor.y = e : s === "add" && (this.cursor.y += e);
212
+ static updateY(e, i = "set") {
213
+ i === "set" ? this.cursor.y = e : i === "add" && (this.cursor.y += e);
214
214
  }
215
215
  /**
216
216
  * Records a Y position as the bottom of rendered content.
@@ -235,34 +235,151 @@ const A = "__jmr_", G = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, q = /(\w+)\
235
235
  return this.cursor.y;
236
236
  }
237
237
  };
238
- H.cursor = { x: 0, y: 0 }, H.lastContentY_ = 0, H.inlineLock = !1;
239
- let n = H;
240
- const C = (t) => t.getTextDimensions("H").h * n.options.page.defaultLineHeightFactor, Y = (t) => t.getTextDimensions("H").w * n.options.page.defaultLineHeightFactor, M = (t, e, s, c) => {
241
- const g = 6 - (e?.depth ?? 0) > 0 ? 6 - (e?.depth ?? 0) : 1;
242
- if (t.setFontSize(n.options.page.defaultFontSize + g), e?.items && e?.items.length > 0)
243
- for (const r of e?.items ?? [])
244
- c(r, s, !1);
238
+ I.cursor = { x: 0, y: 0 }, I.lastContentY_ = 0, I.inlineLock = !1;
239
+ let n = I;
240
+ const C = (t) => t.getTextDimensions("H").h * n.options.page.defaultLineHeightFactor, y = (t) => t.getTextDimensions("H").w * n.options.page.defaultLineHeightFactor, et = (t, e, i, r) => {
241
+ const h = 6 - (e?.depth ?? 0) > 0 ? 6 - (e?.depth ?? 0) : 1;
242
+ if (t.setFontSize(n.options.page.defaultFontSize + h), e?.items && e?.items.length > 0)
243
+ for (const o of e?.items ?? [])
244
+ r(o, i, !1);
245
245
  else {
246
- const r = C(t);
246
+ const o = C(t);
247
247
  t.text(
248
248
  e?.content ?? "",
249
- n.X + s,
249
+ n.X + i,
250
250
  n.Y,
251
251
  {
252
252
  align: "left",
253
- maxWidth: n.options.page.maxContentWidth - s,
253
+ maxWidth: n.options.page.maxContentWidth - i,
254
254
  baseline: "top"
255
255
  }
256
- ), n.recordContentY(n.Y + r), n.updateY(r, "add");
256
+ ), n.recordContentY(n.Y + o), n.updateY(o, "add");
257
257
  }
258
258
  t.setFontSize(n.options.page.defaultFontSize), n.updateX(n.options.page.xpading, "set");
259
- }, y = (t) => {
259
+ }, Y = (t) => {
260
260
  typeof n.options.pageBreakHandler == "function" ? n.options.pageBreakHandler(t) : t.addPage(
261
261
  n.options.page?.format,
262
262
  n.options.page?.orientation
263
263
  ), n.updateY(n.options.page.topmargin), n.updateX(n.options.page.xpading);
264
+ }, z = 96, k = (t, e = "mm") => {
265
+ switch (e) {
266
+ case "pt":
267
+ return t * 72 / z;
268
+ case "in":
269
+ return t / z;
270
+ case "px":
271
+ return t;
272
+ default:
273
+ return t * 25.4 / z;
274
+ }
275
+ }, G = (t) => {
276
+ try {
277
+ let e = "";
278
+ if (t.includes("base64,")) {
279
+ const a = t.split("base64,")[1];
280
+ typeof window < "u" && typeof window.atob == "function" ? e = decodeURIComponent(escape(window.atob(a))) : typeof Buffer < "u" ? e = Buffer.from(a, "base64").toString("utf-8") : e = decodeURIComponent(escape(atob(a)));
281
+ } else
282
+ e = decodeURIComponent(t.split(",")[1] || "");
283
+ const i = e.match(
284
+ /<svg[^>]*\swidth=(?:'|")([0-9.]+)[a-zA-Z]*(?:'|")/i
285
+ ), r = e.match(
286
+ /<svg[^>]*\sheight=(?:'|")([0-9.]+)[a-zA-Z]*(?:'|")/i
287
+ ), h = e.match(
288
+ /<svg[^>]*\sviewBox=(?:'|")[^'"]*(?:'|")/i
289
+ );
290
+ let o = i ? parseFloat(i[1]) : 0, l = r ? parseFloat(r[1]) : 0;
291
+ if ((!o || !l) && h) {
292
+ const a = h[0].match(
293
+ /viewBox=(?:'|")([^'"]+)(?:'|")/i
294
+ );
295
+ if (a) {
296
+ const s = a[1].split(/[ ,]+/).filter(Boolean).map(parseFloat);
297
+ s.length >= 4 && (o = o || s[2], l = l || s[3]);
298
+ }
299
+ }
300
+ if (o > 0 && l > 0) return { width: o, height: l };
301
+ } catch (e) {
302
+ console.warn("Failed to extract SVG dimensions:", e);
303
+ }
304
+ return null;
305
+ }, _ = (t, e, i, r, h = "mm") => {
306
+ if (!e.data)
307
+ return { finalWidth: 0, finalHeight: 0 };
308
+ let o = e.naturalWidth || 0, l = e.naturalHeight || 0;
309
+ if (!o || !l)
310
+ if (e.data.startsWith("data:image/svg")) {
311
+ const c = G(e.data);
312
+ c && (o = c.width, l = c.height);
313
+ } else
314
+ try {
315
+ const c = t.getImageProperties(e.data);
316
+ o = c.width, l = c.height;
317
+ } catch (c) {
318
+ console.warn(
319
+ "Failed to get image properties for intrinsic sizing:",
320
+ c
321
+ );
322
+ }
323
+ const a = l > 0 ? o / l : 1;
324
+ let s, g;
325
+ if (e.width && e.height ? (s = k(e.width, h), g = k(e.height, h)) : e.width ? (s = k(e.width, h), g = s / a) : e.height ? (g = k(e.height, h), s = g * a) : (s = k(o, h), g = k(l, h)), s > i) {
326
+ const c = i / s;
327
+ s = i, g = g * c;
328
+ }
329
+ if (g > r) {
330
+ const c = r / g;
331
+ g = r, s = s * c;
332
+ }
333
+ return { finalWidth: s, finalHeight: g };
334
+ }, $ = async (t) => {
335
+ for (const e of t) {
336
+ if (e.type === u.Image && e.src)
337
+ try {
338
+ if (e.src.startsWith("data:"))
339
+ e.data = e.src;
340
+ else {
341
+ const i = await fetch(e.src);
342
+ if (!i.ok)
343
+ throw new Error(
344
+ `Failed to fetch image: ${i.statusText}`
345
+ );
346
+ const r = await i.blob(), h = await new Promise(
347
+ (o, l) => {
348
+ const a = new FileReader();
349
+ a.onloadend = () => {
350
+ typeof a.result == "string" ? o(a.result) : l(
351
+ new Error(
352
+ "Failed to convert image to base64 string"
353
+ )
354
+ );
355
+ }, a.onerror = l, a.readAsDataURL(r);
356
+ }
357
+ );
358
+ e.data = h;
359
+ }
360
+ e.data && e.data.startsWith("data:image/svg") && typeof window < "u" && typeof document < "u" && (e.data = await new Promise((i) => {
361
+ const r = new Image();
362
+ r.onload = () => {
363
+ const h = document.createElement("canvas"), o = G(
364
+ e.data
365
+ ), l = o ? o.width : r.width || 300, a = o ? o.height : r.height || 150;
366
+ e.naturalWidth = l, e.naturalHeight = a;
367
+ const s = 4;
368
+ h.width = l * s, h.height = a * s;
369
+ const g = h.getContext("2d");
370
+ g ? (g.scale(s, s), g.drawImage(r, 0, 0, l, a), i(h.toDataURL("image/png"))) : i(e.data);
371
+ }, r.onerror = () => i(e.data), r.src = e.data;
372
+ }));
373
+ } catch (i) {
374
+ console.warn(
375
+ `[jspdf-md-renderer] Warning: Failed to load image at ${e.src}. It will be skipped.`,
376
+ i
377
+ );
378
+ }
379
+ e.items && e.items.length > 0 && await $(e.items);
380
+ }
264
381
  };
265
- class v {
382
+ class A {
266
383
  // Default codespan styling (can be overridden via RenderStore.options.codespan)
267
384
  static getCodespanOptions() {
268
385
  const e = n.options.codespan ?? {};
@@ -276,18 +393,18 @@ class v {
276
393
  /**
277
394
  * Apply font style to the jsPDF document.
278
395
  */
279
- static applyStyle(e, s) {
280
- const c = e.getFont().fontName, g = e.getFontSize(), r = () => {
281
- const i = n.options.font.bold?.name;
282
- return i && i !== "" ? i : c;
396
+ static applyStyle(e, i) {
397
+ const r = e.getFont().fontName, h = e.getFontSize(), o = () => {
398
+ const a = n.options.font.bold?.name;
399
+ return a && a !== "" ? a : r;
283
400
  }, l = () => {
284
- const i = n.options.font.regular?.name;
285
- return i && i !== "" ? i : c;
401
+ const a = n.options.font.regular?.name;
402
+ return a && a !== "" ? a : r;
286
403
  };
287
- switch (s) {
404
+ switch (i) {
288
405
  case "bold":
289
406
  e.setFont(
290
- r(),
407
+ o(),
291
408
  n.options.font.bold?.style || "bold"
292
409
  );
293
410
  break;
@@ -295,11 +412,11 @@ class v {
295
412
  e.setFont(l(), "italic");
296
413
  break;
297
414
  case "bolditalic":
298
- e.setFont(r(), "bolditalic");
415
+ e.setFont(o(), "bolditalic");
299
416
  break;
300
417
  case "codespan":
301
418
  e.setFont("courier", "normal"), e.setFontSize(
302
- g * this.getCodespanOptions().fontSizeScale
419
+ h * this.getCodespanOptions().fontSizeScale
303
420
  );
304
421
  break;
305
422
  default:
@@ -312,60 +429,79 @@ class v {
312
429
  * NOTE: jsPDF's getTextWidth() does NOT include charSpace in its calculation,
313
430
  * so we must manually add it: effectiveWidth = getTextWidth(text) + (text.length * charSpace)
314
431
  */
315
- static measureWordWidth(e, s, c) {
316
- const g = e.getFont(), r = e.getFontSize();
317
- this.applyStyle(e, c);
318
- const l = e.getTextWidth(s), i = e.getCharSpace?.() ?? 0, a = l + s.length * i;
319
- return e.setFont(g.fontName, g.fontStyle), e.setFontSize(r), a;
432
+ static measureWordWidth(e, i, r) {
433
+ const h = e.getFont(), o = e.getFontSize();
434
+ this.applyStyle(e, r);
435
+ const l = e.getTextWidth(i), a = e.getCharSpace?.() ?? 0, s = l + i.length * a;
436
+ return e.setFont(h.fontName, h.fontStyle), e.setFontSize(o), s;
320
437
  }
321
438
  /**
322
439
  * Extract style from element type string.
323
440
  */
324
- static getStyleFromType(e, s) {
441
+ static getStyleFromType(e, i) {
325
442
  switch (e) {
326
443
  case "strong":
327
- return s === "italic" ? "bolditalic" : "bold";
444
+ return i === "italic" ? "bolditalic" : "bold";
328
445
  case "em":
329
- return s === "bold" ? "bolditalic" : "italic";
446
+ return i === "bold" ? "bolditalic" : "italic";
330
447
  case "codespan":
331
448
  return "codespan";
332
449
  default:
333
- return s || "normal";
450
+ return i || "normal";
334
451
  }
335
452
  }
336
453
  /**
337
454
  * Flatten ParsedElement tree into an array of StyledWordInfo.
338
455
  * Handles nested inline elements.
339
456
  */
340
- static flattenToWords(e, s, c = "normal", g = !1, r) {
457
+ static flattenToWords(e, i, r = "normal", h = !1, o) {
341
458
  const l = [];
342
- for (const i of s) {
343
- const a = this.getStyleFromType(i.type, c), p = i.type === "link" || g, h = i.href || r;
344
- if (i.items && i.items.length > 0) {
459
+ for (const a of i) {
460
+ const s = this.getStyleFromType(a.type, r), g = a.type === "link" || h, c = a.href || o;
461
+ if (a.items && a.items.length > 0) {
345
462
  const f = this.flattenToWords(
346
463
  e,
347
- i.items,
348
- a,
349
- p,
350
- h
464
+ a.items,
465
+ s,
466
+ g,
467
+ c
351
468
  );
352
469
  l.push(...f);
470
+ } else if (a.type === "image") {
471
+ const f = n.options.page.maxContentHeight - n.options.page.topmargin, d = n.options.page.maxContentWidth - n.options.page.indent * 0, p = n.options.page.unit || "mm", { finalWidth: m, finalHeight: x } = _(
472
+ e,
473
+ a,
474
+ d,
475
+ f,
476
+ p
477
+ );
478
+ l.push({
479
+ text: "",
480
+ width: m,
481
+ style: s,
482
+ isLink: g,
483
+ href: c,
484
+ linkColor: g ? n.options.link?.linkColor || [0, 0, 255] : void 0,
485
+ isImage: !0,
486
+ imageElement: a,
487
+ imageHeight: x
488
+ });
353
489
  } else {
354
- const f = i.content || i.text || "";
490
+ const f = a.content || a.text || "";
355
491
  if (!f) continue;
356
- if (a === "codespan") {
357
- const o = f.trim();
358
- o && l.push({
359
- text: o,
492
+ if (s === "codespan") {
493
+ const p = f.trim();
494
+ p && l.push({
495
+ text: p,
360
496
  width: this.measureWordWidth(
361
497
  e,
362
- o,
363
- a
498
+ p,
499
+ s
364
500
  ),
365
- style: a,
366
- isLink: p,
367
- href: h,
368
- linkColor: p ? n.options.link?.linkColor || [
501
+ style: s,
502
+ isLink: g,
503
+ href: c,
504
+ linkColor: g ? n.options.link?.linkColor || [
369
505
  0,
370
506
  0,
371
507
  255
@@ -373,18 +509,18 @@ class v {
373
509
  });
374
510
  continue;
375
511
  }
376
- const d = f.split(/\s+/).filter((o) => o.length > 0);
512
+ const d = f.split(/\s+/).filter((p) => p.length > 0);
377
513
  if (d.length === 0)
378
514
  continue;
379
- for (let o = 0; o < d.length; o++) {
380
- const m = d[o];
515
+ for (let p = 0; p < d.length; p++) {
516
+ const m = d[p];
381
517
  l.push({
382
518
  text: m,
383
- width: this.measureWordWidth(e, m, a),
384
- style: a,
385
- isLink: p,
386
- href: h,
387
- linkColor: p ? n.options.link?.linkColor || [0, 0, 255] : void 0
519
+ width: this.measureWordWidth(e, m, s),
520
+ style: s,
521
+ isLink: g,
522
+ href: c,
523
+ linkColor: g ? n.options.link?.linkColor || [0, 0, 255] : void 0
388
524
  });
389
525
  }
390
526
  }
@@ -395,71 +531,108 @@ class v {
395
531
  * Break a flat list of words into lines that fit within maxWidth.
396
532
  * Correctly tracks totalTextWidth (sum of word widths only) for justification.
397
533
  */
398
- static breakIntoLines(e, s, c) {
399
- const g = [];
400
- let r = [], l = 0, i = 0;
401
- const a = e.getTextWidth(" ");
402
- for (let p = 0; p < s.length; p++) {
403
- const h = s[p], f = r.length > 0 ? a + h.width : h.width;
404
- i + f > c && r.length > 0 ? (g.push({
405
- words: r,
534
+ static breakIntoLines(e, i, r) {
535
+ const h = [];
536
+ let o = [], l = 0, a = 0, s = C(e) * n.options.page.defaultLineHeightFactor;
537
+ const g = e.getTextWidth(" ");
538
+ for (let c = 0; c < i.length; c++) {
539
+ const f = i[c], d = o.length > 0 ? g + f.width : f.width, p = f.isImage && f.imageHeight ? f.imageHeight : C(e) * n.options.page.defaultLineHeightFactor;
540
+ a + d > r && o.length > 0 ? (h.push({
541
+ words: o,
406
542
  totalTextWidth: l,
407
- isLastLine: !1
408
- }), r = [h], l = h.width, i = h.width) : (r.push(h), l += h.width, i += f);
543
+ isLastLine: !1,
544
+ lineHeight: s
545
+ }), o = [f], l = f.width, a = f.width, s = p) : (o.push(f), l += f.width, a += d, s = Math.max(s, p));
409
546
  }
410
- return r.length > 0 && g.push({
411
- words: r,
547
+ return o.length > 0 && h.push({
548
+ words: o,
412
549
  totalTextWidth: l,
413
- isLastLine: !0
414
- }), g;
550
+ isLastLine: !0,
551
+ lineHeight: s
552
+ }), h;
415
553
  }
416
554
  /**
417
555
  * Render a single word with its style applied.
418
556
  */
419
- static renderWord(e, s, c, g) {
420
- const r = e.getFont(), l = e.getFontSize(), i = e.getTextColor();
421
- if (this.applyStyle(e, s.style), s.isLink && s.linkColor && e.setTextColor(...s.linkColor), s.style === "codespan") {
422
- const a = this.getCodespanOptions();
423
- if (a.showBackground) {
424
- const p = C(e), h = a.padding;
425
- e.setFillColor(a.backgroundColor), e.rect(
426
- c - h,
427
- g - h,
428
- s.width + h * 2,
429
- p + h * 2,
430
- "F"
431
- ), e.setFillColor("#000000");
557
+ static renderWord(e, i, r, h) {
558
+ const o = e.getFont(), l = e.getFontSize(), a = e.getTextColor();
559
+ if (this.applyStyle(e, i.style), i.isLink && i.linkColor && e.setTextColor(...i.linkColor), i.isImage && i.imageElement && i.imageElement.data)
560
+ try {
561
+ let s = "JPEG";
562
+ if (i.imageElement.data.startsWith("data:image/png"))
563
+ s = "PNG";
564
+ else if (i.imageElement.data.startsWith("data:image/webp"))
565
+ s = "WEBP";
566
+ else if (i.imageElement.data.startsWith("data:image/gif"))
567
+ s = "GIF";
568
+ else if (i.imageElement.src) {
569
+ const c = i.imageElement.src.split("?")[0].split("#")[0].split(".").pop()?.toUpperCase();
570
+ c && ["PNG", "JPEG", "JPG", "WEBP", "GIF"].includes(c) && (s = c === "JPG" ? "JPEG" : c);
571
+ }
572
+ if (i.width > 0 && (i.imageHeight || 0) > 0) {
573
+ const g = i.imageHeight || 0, c = h - g;
574
+ e.addImage(
575
+ i.imageElement.data,
576
+ s,
577
+ r,
578
+ c,
579
+ i.width,
580
+ g
581
+ );
582
+ }
583
+ } catch (s) {
584
+ console.warn("Failed to render inline image", s);
585
+ }
586
+ else {
587
+ if (i.style === "codespan") {
588
+ const s = this.getCodespanOptions();
589
+ if (s.showBackground) {
590
+ const g = C(e), c = s.padding;
591
+ e.setFillColor(s.backgroundColor), e.rect(
592
+ r - c,
593
+ h - c,
594
+ i.width + c * 2,
595
+ g + c * 2,
596
+ "F"
597
+ ), e.setFillColor("#000000");
598
+ }
432
599
  }
600
+ e.text(i.text, r, h, { baseline: "top" });
433
601
  }
434
- if (e.text(s.text, c, g, { baseline: "top" }), s.isLink && s.href) {
435
- const a = C(e) / 2;
436
- e.link(c, g, s.width, a, { url: s.href });
602
+ if (i.isLink && i.href) {
603
+ const s = i.isImage && i.imageHeight ? i.imageHeight : C(e);
604
+ e.link(r, h, i.width, s, { url: i.href });
437
605
  }
438
- e.setFont(r.fontName, r.fontStyle), e.setFontSize(l), e.setTextColor(i);
606
+ e.setFont(o.fontName, o.fontStyle), e.setFontSize(l), e.setTextColor(a);
439
607
  }
440
608
  /**
441
609
  * Render a single line with specified alignment.
442
610
  */
443
- static renderAlignedLine(e, s, c, g, r, l = "left") {
444
- const { words: i, totalTextWidth: a, isLastLine: p } = s;
445
- if (i.length === 0) return;
446
- const h = e.getTextWidth(" ");
447
- let f = c, d = h;
448
- const o = a + (i.length - 1) * h;
611
+ static renderAlignedLine(e, i, r, h, o, l = "left") {
612
+ const { words: a, totalTextWidth: s, isLastLine: g } = i;
613
+ if (a.length === 0) return;
614
+ const c = e.getTextWidth(" ");
615
+ let f = r, d = c;
616
+ const p = s + (a.length - 1) * c;
449
617
  switch (l) {
450
618
  case "right":
451
- f = c + r - o;
619
+ f = r + o - p;
452
620
  break;
453
621
  case "center":
454
- f = c + (r - o) / 2;
622
+ f = r + (o - p) / 2;
455
623
  break;
456
624
  case "justify":
457
- !p && i.length > 1 && (d = (r - a) / (i.length - 1));
625
+ !g && a.length > 1 && (d = (o - s) / (a.length - 1));
458
626
  break;
459
627
  }
460
628
  let m = f;
461
- for (let x = 0; x < i.length; x++)
462
- this.renderWord(e, i[x], m, g), m += i[x].width, x < i.length - 1 && (m += d);
629
+ const x = C(e) * n.options.page.defaultLineHeightFactor;
630
+ for (let F = 0; F < a.length; F++) {
631
+ const b = a[F];
632
+ let H = h;
633
+ const w = b.isImage && b.imageHeight ? b.imageHeight : x;
634
+ w < i.lineHeight && (H = h + (i.lineHeight - w)), this.renderWord(e, b, m, H), m += b.width, F < a.length - 1 && (m += d);
635
+ }
463
636
  }
464
637
  /**
465
638
  * Main entry point: Render a paragraph with mixed inline elements.
@@ -472,34 +645,34 @@ class v {
472
645
  * @param maxWidth Maximum width for text wrapping
473
646
  * @param alignment Optional alignment override (defaults to RenderStore option)
474
647
  */
475
- static renderStyledParagraph(e, s, c, g, r, l) {
476
- const i = l ?? n.options.content?.textAlignment ?? "left", a = this.flattenToWords(e, s);
477
- if (a.length === 0) return;
478
- const p = this.breakIntoLines(e, a, r), h = C(e) * n.options.page.defaultLineHeightFactor;
479
- let f = g;
480
- for (const o of p)
481
- f + h > n.options.page.maxContentHeight && (y(e), f = n.Y), this.renderAlignedLine(
648
+ static renderStyledParagraph(e, i, r, h, o, l) {
649
+ const a = l ?? n.options.content?.textAlignment ?? "left", s = this.flattenToWords(e, i);
650
+ if (s.length === 0) return;
651
+ const g = this.breakIntoLines(e, s, o);
652
+ let c = h;
653
+ for (const d of g)
654
+ c + d.lineHeight > n.options.page.maxContentHeight && (Y(e), c = n.Y), this.renderAlignedLine(
482
655
  e,
483
- o,
484
- c,
485
- f,
656
+ d,
486
657
  r,
487
- i
488
- ), n.recordContentY(f + C(e)), f += h, n.updateY(h, "add");
489
- const d = p[p.length - 1];
490
- if (d) {
491
- const o = d.totalTextWidth + (d.words.length - 1) * e.getTextWidth(" ");
492
- n.updateX(c + o, "set");
658
+ c,
659
+ o,
660
+ a
661
+ ), n.recordContentY(c + d.lineHeight), c += d.lineHeight, n.updateY(d.lineHeight, "add");
662
+ const f = g[g.length - 1];
663
+ if (f) {
664
+ const d = f.totalTextWidth + (f.words.length - 1) * e.getTextWidth(" ");
665
+ n.updateX(r + d, "set");
493
666
  }
494
667
  }
495
668
  /**
496
669
  * @deprecated Use renderStyledParagraph instead
497
670
  */
498
- static renderJustifiedParagraph(e, s, c, g, r) {
499
- this.renderStyledParagraph(e, s, c, g, r);
671
+ static renderJustifiedParagraph(e, i, r, h, o) {
672
+ this.renderStyledParagraph(e, i, r, h, o);
500
673
  }
501
674
  }
502
- class I {
675
+ class T {
503
676
  /**
504
677
  * Renders text with automatic line wrapping and page breaking.
505
678
  * @param doc jsPDF instance
@@ -509,164 +682,172 @@ class I {
509
682
  * @param maxWidth Max width for text wrapping
510
683
  * @param justify Whether to justify the text
511
684
  */
512
- static renderText(e, s, c = n.X, g = n.Y, r, l = !1) {
513
- const i = e.splitTextToSize(s, r), a = C(e), p = a * n.options.page.defaultLineHeightFactor;
514
- let h = g;
515
- for (let f = 0; f < i.length; f++) {
516
- const d = i[f];
517
- h + p > n.options.page.maxContentHeight && (y(e), h = n.Y), l ? f === i.length - 1 ? e.text(d, c, h, { baseline: "top" }) : e.text(d, c, h, {
518
- maxWidth: r,
685
+ static renderText(e, i, r = n.X, h = n.Y, o, l = !1) {
686
+ const a = e.splitTextToSize(i, o), s = C(e), g = s * n.options.page.defaultLineHeightFactor;
687
+ let c = h;
688
+ for (let f = 0; f < a.length; f++) {
689
+ const d = a[f];
690
+ c + g > n.options.page.maxContentHeight && (Y(e), c = n.Y), l ? f === a.length - 1 ? e.text(d, r, c, { baseline: "top" }) : e.text(d, r, c, {
691
+ maxWidth: o,
519
692
  align: "justify",
520
693
  baseline: "top"
521
- }) : e.text(d, c, h, { baseline: "top" }), n.recordContentY(h + a), h += p, n.updateY(p, "add");
694
+ }) : e.text(d, r, c, { baseline: "top" }), n.recordContentY(c + s), c += g, n.updateY(g, "add");
522
695
  }
523
- return h;
696
+ return c;
524
697
  }
525
698
  }
526
- const tt = (t, e, s, c) => {
699
+ const nt = (t, e, i, r) => {
527
700
  n.activateInlineLock(), t.setFontSize(n.options.page.defaultFontSize);
528
- const g = n.options.page.maxContentWidth - s;
529
- if (e?.items && e?.items.length > 0)
701
+ const h = n.options.page.maxContentWidth - i;
702
+ if (e?.items && e?.items.length > 0) {
703
+ if (e.items.length === 1 && e.items[0].type === "image") {
704
+ r(e.items[0], i, !1), n.updateX(n.options.page.xpading), n.deactivateInlineLock();
705
+ return;
706
+ }
707
+ const o = [
708
+ "strong",
709
+ "em",
710
+ "text",
711
+ "codespan",
712
+ "link",
713
+ "image"
714
+ ];
530
715
  if (e.items.some(
531
- (l) => !["strong", "em", "text", "codespan", "link"].includes(
532
- l.type
533
- )
716
+ (a) => !o.includes(a.type)
534
717
  )) {
535
- const l = [], i = () => {
536
- l.length > 0 && (v.renderStyledParagraph(
718
+ const a = [], s = () => {
719
+ a.length > 0 && (A.renderStyledParagraph(
537
720
  t,
538
- l,
539
- n.X + s,
721
+ a,
722
+ n.X + i,
540
723
  n.Y,
541
- g
542
- ), l.length = 0);
724
+ h
725
+ ), a.length = 0);
543
726
  };
544
- for (const a of e.items)
545
- ["strong", "em", "text", "codespan", "link"].includes(
546
- a.type
547
- ) ? l.push(a) : (i(), c(a, s, !1));
548
- i();
727
+ for (const g of e.items)
728
+ o.includes(g.type) ? a.push(g) : (s(), r(g, i, !1));
729
+ s();
549
730
  } else
550
- v.renderStyledParagraph(
731
+ A.renderStyledParagraph(
551
732
  t,
552
733
  e.items,
553
- n.X + s,
734
+ n.X + i,
554
735
  n.Y,
555
- g
736
+ h
556
737
  );
557
- else {
558
- const r = e.content ?? "", l = n.options.content?.textAlignment ?? "left";
559
- r.trim() && I.renderText(
738
+ } else {
739
+ const o = e.content ?? "", l = n.options.content?.textAlignment ?? "left";
740
+ o.trim() && T.renderText(
560
741
  t,
561
- r,
562
- n.X + s,
742
+ o,
743
+ n.X + i,
563
744
  n.Y,
564
- g,
745
+ h,
565
746
  l === "justify"
566
747
  );
567
748
  }
568
749
  n.updateX(n.options.page.xpading), n.deactivateInlineLock();
569
- }, et = (t, e, s, c) => {
750
+ }, it = (t, e, i, r) => {
570
751
  t.setFontSize(n.options.page.defaultFontSize);
571
- for (const [g, r] of e?.items?.entries() ?? []) {
572
- const l = e.ordered ? (e.start ?? 0) + g : e.start;
573
- c(
574
- r,
575
- s + 1,
752
+ for (const [h, o] of e?.items?.entries() ?? []) {
753
+ const l = e.ordered ? (e.start ?? 0) + h : e.start;
754
+ r(
755
+ o,
756
+ i + 1,
576
757
  !0,
577
758
  l,
578
759
  e.ordered
579
760
  );
580
761
  }
581
- }, nt = (t, e, s, c, g, r) => {
582
- n.Y + C(t) >= n.options.page.maxContentHeight && y(t);
583
- const l = n.options, i = s * l.page.indent, a = r ? `${g}. ` : "• ", p = l.page.xpading;
584
- n.updateX(p, "set"), t.setFont(l.font.regular.name, l.font.regular.style), t.text(a, p + i, n.Y, { baseline: "top" });
585
- const h = t.getTextWidth(a), f = p + i + h, d = l.page.maxContentWidth - i - h;
762
+ }, st = (t, e, i, r, h, o) => {
763
+ n.Y + C(t) >= n.options.page.maxContentHeight && Y(t);
764
+ const l = n.options, a = i * l.page.indent, s = o ? `${h}. ` : "• ", g = l.page.xpading;
765
+ n.updateX(g, "set"), t.setFont(l.font.regular.name, l.font.regular.style), t.text(s, g + a, n.Y, { baseline: "top" });
766
+ const c = t.getTextWidth(s), f = g + a + c, d = l.page.maxContentWidth - a - c;
586
767
  if (e.items && e.items.length > 0) {
587
- const o = [], m = () => {
588
- o.length > 0 && (v.renderStyledParagraph(
768
+ const p = [], m = () => {
769
+ p.length > 0 && (A.renderStyledParagraph(
589
770
  t,
590
- o,
771
+ p,
591
772
  f,
592
773
  n.Y,
593
774
  d
594
- ), o.length = 0, n.updateX(p, "set"));
775
+ ), p.length = 0, n.updateX(g, "set"));
595
776
  };
596
777
  for (const x of e.items)
597
- x.type === u.List ? (m(), c(
778
+ x.type === u.List ? (m(), r(
598
779
  x,
599
- s,
780
+ i,
600
781
  !0,
601
- g,
782
+ h,
602
783
  x.ordered ?? !1
603
- )) : x.type === u.ListItem ? (m(), c(
784
+ )) : x.type === u.ListItem ? (m(), r(
604
785
  x,
605
- s,
786
+ i,
606
787
  !0,
607
- g,
608
- r
609
- )) : o.push(x);
788
+ h,
789
+ o
790
+ )) : p.push(x);
610
791
  m();
611
792
  } else if (e.content) {
612
- const o = l.content?.textAlignment ?? "left";
613
- I.renderText(
793
+ const p = l.content?.textAlignment ?? "left";
794
+ T.renderText(
614
795
  t,
615
796
  e.content,
616
797
  f,
617
798
  n.Y,
618
799
  d,
619
- o === "justify"
800
+ p === "justify"
620
801
  );
621
802
  }
622
- }, st = (t, e, s, c, g, r, l, i = !0) => {
803
+ }, at = (t, e, i, r, h, o, l, a = !0) => {
623
804
  if (e?.items && e?.items.length > 0)
624
- for (const a of e?.items ?? [])
625
- g(
626
- a,
805
+ for (const s of e?.items ?? [])
806
+ h(
627
807
  s,
628
- c,
808
+ i,
629
809
  r,
810
+ o,
630
811
  l,
631
- i
812
+ a
632
813
  );
633
814
  else {
634
- const a = n.options, p = s * a.page.indent, h = c ? l ? `${r}. ` : "• " : "", f = e.content || "", d = a.page.xpading;
635
- if (!f && !h) return;
636
- if (!f.trim() && !h) {
637
- const o = (f.match(/\n/g) || []).length;
638
- if (o > 1) {
639
- const m = o - 1, x = t.getTextDimensions("A").h * a.page.defaultLineHeightFactor, F = m * x;
640
- n.Y + F > a.page.maxContentHeight ? y(t) : (n.updateY(F, "add"), n.recordContentY(n.Y));
815
+ const s = n.options, g = i * s.page.indent, c = r ? l ? `${o}. ` : "• " : "", f = e.content || "", d = s.page.xpading;
816
+ if (!f && !c) return;
817
+ if (!f.trim() && !c) {
818
+ const p = (f.match(/\n/g) || []).length;
819
+ if (p > 1) {
820
+ const m = p - 1, x = t.getTextDimensions("A").h * s.page.defaultLineHeightFactor, F = m * x;
821
+ n.Y + F > s.page.maxContentHeight ? Y(t) : (n.updateY(F, "add"), n.recordContentY(n.Y));
641
822
  }
642
823
  return;
643
824
  }
644
- if (n.updateX(d, "set"), c && h) {
645
- const o = t.getTextWidth(h), m = a.page.maxContentWidth - p - o;
646
- t.setFont(a.font.regular.name, a.font.regular.style), t.text(h, d + p, n.Y, {
825
+ if (n.updateX(d, "set"), r && c) {
826
+ const p = t.getTextWidth(c), m = s.page.maxContentWidth - g - p;
827
+ t.setFont(s.font.regular.name, s.font.regular.style), t.text(c, d + g, n.Y, {
647
828
  baseline: "top"
648
- }), I.renderText(
829
+ }), T.renderText(
649
830
  t,
650
831
  f,
651
- d + p + o,
832
+ d + g + p,
652
833
  n.Y,
653
834
  m,
654
- i
835
+ a
655
836
  );
656
837
  } else {
657
- const o = a.page.maxContentWidth - p;
658
- I.renderText(
838
+ const p = s.page.maxContentWidth - g;
839
+ T.renderText(
659
840
  t,
660
841
  f,
661
- d + p,
842
+ d + g,
662
843
  n.Y,
663
- o,
664
- i
844
+ p,
845
+ a
665
846
  );
666
847
  }
667
848
  n.updateX(d, "set");
668
849
  }
669
- }, it = (t) => {
850
+ }, ot = (t) => {
670
851
  const e = t.internal.pageSize.getWidth();
671
852
  t.setLineDashPattern([1, 1], 0), t.setLineWidth(0.1), t.line(
672
853
  n.options.page.xpading,
@@ -674,63 +855,63 @@ const tt = (t, e, s, c) => {
674
855
  e - n.options.page.xpading,
675
856
  n.Y
676
857
  ), t.setLineWidth(0.1), t.setLineDashPattern([], 0), n.updateY(C(t), "add");
677
- }, at = (t, e, s, c) => {
678
- const g = t.getFont(), r = t.getFontSize();
858
+ }, rt = (t, e, i, r) => {
859
+ const h = t.getFont(), o = t.getFontSize();
679
860
  t.setFont("courier", "normal");
680
861
  const l = n.options.page.defaultFontSize * 0.9;
681
862
  t.setFontSize(l);
682
- const i = s * n.options.page.indent, a = n.options.page.maxContentWidth - i - 8, p = t.getLineHeightFactor(), h = l / t.internal.scaleFactor * p, d = (e.code ?? "").replace(/[\r\n\s]+$/, "");
863
+ const a = i * n.options.page.indent, s = n.options.page.maxContentWidth - a - 8, g = t.getLineHeightFactor(), c = l / t.internal.scaleFactor * g, d = (e.code ?? "").replace(/[\r\n\s]+$/, "");
683
864
  if (!d) {
684
- t.setFont(g.fontName, g.fontStyle), t.setFontSize(r);
865
+ t.setFont(h.fontName, h.fontStyle), t.setFontSize(o);
685
866
  return;
686
867
  }
687
- const o = t.splitTextToSize(d, a);
688
- for (; o.length > 0 && o[o.length - 1].trim() === ""; )
689
- o.pop();
690
- if (o.length === 0) {
691
- t.setFont(g.fontName, g.fontStyle), t.setFontSize(r);
868
+ const p = t.splitTextToSize(d, s);
869
+ for (; p.length > 0 && p[p.length - 1].trim() === ""; )
870
+ p.pop();
871
+ if (p.length === 0) {
872
+ t.setFont(h.fontName, h.fontStyle), t.setFontSize(o);
692
873
  return;
693
874
  }
694
875
  const m = 4, x = "#EEEEEE", F = "#DDDDDD";
695
876
  let b = 0;
696
- for (; b < o.length; ) {
697
- const k = n.options.page.maxContentHeight - n.Y, w = o.length - b, T = k - m * 2;
698
- let S = Math.floor(T / h);
877
+ for (; b < p.length; ) {
878
+ const H = n.options.page.maxContentHeight - n.Y, w = p.length - b, L = H - m * 2;
879
+ let S = Math.floor(L / c);
699
880
  if (S <= 0) {
700
- y(t);
881
+ Y(t);
701
882
  continue;
702
883
  }
703
884
  S > w && (S = w);
704
- const $ = o.slice(
885
+ const J = p.slice(
705
886
  b,
706
887
  b + S
707
- ), X = b === 0, z = b + S >= o.length, N = S * h;
708
- if (X && n.updateY(m, "add"), t.setFillColor(x), t.setDrawColor(F), t.roundedRect(
888
+ ), E = b === 0, X = b + S >= p.length, B = S * c;
889
+ if (E && n.updateY(m, "add"), t.setFillColor(x), t.setDrawColor(F), t.roundedRect(
709
890
  n.X,
710
891
  n.Y - m,
711
892
  n.options.page.maxContentWidth,
712
- N + (X ? m : 0) + (z ? m : 0),
893
+ B + (E ? m : 0) + (X ? m : 0),
713
894
  2,
714
895
  2,
715
896
  "FD"
716
- ), X && e.lang) {
717
- const E = t.getFontSize();
897
+ ), E && e.lang) {
898
+ const P = t.getFontSize();
718
899
  t.setFontSize(10), t.setTextColor("#666666"), t.text(
719
900
  e.lang,
720
901
  n.X + n.options.page.maxContentWidth - t.getTextWidth(e.lang) - 4,
721
902
  n.Y,
722
903
  { baseline: "top" }
723
- ), t.setFontSize(E), t.setTextColor("#000000");
904
+ ), t.setFontSize(P), t.setTextColor("#000000");
724
905
  }
725
- let R = n.Y;
726
- for (const E of $)
727
- t.text(E, n.X + 4, R, { baseline: "top" }), R += h;
728
- n.updateY(N, "add"), n.recordContentY(n.Y + (z ? m : 0)), z && n.updateY(m, "add"), b += S, b < o.length && y(t);
906
+ let N = n.Y;
907
+ for (const P of J)
908
+ t.text(P, n.X + 4, N, { baseline: "top" }), N += c;
909
+ n.updateY(B, "add"), n.recordContentY(n.Y + (X ? m : 0)), X && n.updateY(m, "add"), b += S, b < p.length && Y(t);
729
910
  }
730
- t.setFont(g.fontName, g.fontStyle), t.setFontSize(r);
731
- }, ot = (t, e, s) => {
732
- const c = t.getFont().fontName, g = t.getFont().fontStyle, r = t.getFontSize(), l = (a) => {
733
- switch (a) {
911
+ t.setFont(h.fontName, h.fontStyle), t.setFontSize(o);
912
+ }, lt = (t, e, i) => {
913
+ const r = t.getFont().fontName, h = t.getFont().fontStyle, o = t.getFontSize(), l = (s) => {
914
+ switch (s) {
734
915
  case "normal":
735
916
  return 0;
736
917
  case "bold":
@@ -744,37 +925,37 @@ const tt = (t, e, s, c) => {
744
925
  default:
745
926
  return 0;
746
927
  }
747
- }, i = (a, p) => {
748
- p === "bold" ? t.setFont(
749
- n.options.font.bold.name && n.options.font.bold.name !== "" ? n.options.font.bold.name : c,
928
+ }, a = (s, g) => {
929
+ g === "bold" ? t.setFont(
930
+ n.options.font.bold.name && n.options.font.bold.name !== "" ? n.options.font.bold.name : r,
750
931
  n.options.font.bold.style || "bold"
751
- ) : p === "italic" ? t.setFont(n.options.font.regular.name, "italic") : p === "bolditalic" ? t.setFont(
752
- n.options.font.bold.name && n.options.font.bold.name !== "" ? n.options.font.bold.name : c,
932
+ ) : g === "italic" ? t.setFont(n.options.font.regular.name, "italic") : g === "bolditalic" ? t.setFont(
933
+ n.options.font.bold.name && n.options.font.bold.name !== "" ? n.options.font.bold.name : r,
753
934
  "bolditalic"
754
- ) : p === "codespan" ? (t.setFont("courier", "normal"), t.setFontSize(r * 0.9)) : t.setFont(
935
+ ) : g === "codespan" ? (t.setFont("courier", "normal"), t.setFontSize(o * 0.9)) : t.setFont(
755
936
  n.options.font.regular.name,
756
- g
937
+ h
757
938
  );
758
- const h = n.options.page.maxContentWidth - s - n.X, f = t.splitTextToSize(a, h), d = p === "codespan", o = 1, m = "#EEEEEE";
939
+ const c = n.options.page.maxContentWidth - i - n.X, f = t.splitTextToSize(s, c), d = g === "codespan", p = 1, m = "#EEEEEE";
759
940
  if (n.isInlineLockActive)
760
941
  for (let x = 0; x < f.length; x++) {
761
942
  if (d) {
762
- const F = t.getTextWidth(f[x]) + Y(t), b = C(t);
943
+ const F = t.getTextWidth(f[x]) + y(t), b = C(t);
763
944
  t.setFillColor(m), t.roundedRect(
764
- n.X + s - o,
765
- n.Y - o,
766
- F + o * 2,
767
- b + o * 2,
945
+ n.X + i - p,
946
+ n.Y - p,
947
+ F + p * 2,
948
+ b + p * 2,
768
949
  2,
769
950
  2,
770
951
  "F"
771
952
  ), t.setFillColor("#000000");
772
953
  }
773
- t.text(f[x], n.X + s, n.Y, {
954
+ t.text(f[x], n.X + i, n.Y, {
774
955
  baseline: "top",
775
- maxWidth: h
956
+ maxWidth: c
776
957
  }), n.updateX(
777
- t.getTextDimensions(f[x]).w + (d ? o * 2 : 1),
958
+ t.getTextDimensions(f[x]).w + (d ? p * 2 : 1),
778
959
  "add"
779
960
  ), x < f.length - 1 && (n.updateY(C(t), "add"), n.updateX(
780
961
  n.options.page.xpading,
@@ -784,12 +965,12 @@ const tt = (t, e, s, c) => {
784
965
  else if (f.length > 1) {
785
966
  const x = f[0], F = f?.slice(1)?.join(" ");
786
967
  if (d) {
787
- const w = t.getTextWidth(x) + Y(t), T = C(t);
968
+ const w = t.getTextWidth(x) + y(t), L = C(t);
788
969
  t.setFillColor(m), t.roundedRect(
789
- n.X + (s >= 2 ? s + 2 : 0) - o,
790
- n.Y - o,
791
- w + o * 2,
792
- T + o * 2,
970
+ n.X + (i >= 2 ? i + 2 : 0) - p,
971
+ n.Y - p,
972
+ w + p * 2,
973
+ L + p * 2,
793
974
  2,
794
975
  2,
795
976
  "F"
@@ -797,25 +978,25 @@ const tt = (t, e, s, c) => {
797
978
  }
798
979
  t.text(
799
980
  x,
800
- n.X + (s >= 2 ? s + 2 * l(p) : 0),
981
+ n.X + (i >= 2 ? i + 2 * l(g) : 0),
801
982
  n.Y,
802
983
  {
803
984
  baseline: "top",
804
- maxWidth: h
985
+ maxWidth: c
805
986
  }
806
- ), n.updateX(n.options.page.xpading + s), n.updateY(C(t), "add");
807
- const b = n.options.page.maxContentWidth - s - n.options.page.xpading;
987
+ ), n.updateX(n.options.page.xpading + i), n.updateY(C(t), "add");
988
+ const b = n.options.page.maxContentWidth - i - n.options.page.xpading;
808
989
  t.splitTextToSize(
809
990
  F,
810
991
  b
811
992
  ).forEach((w) => {
812
993
  if (d) {
813
- const T = t.getTextWidth(w) + Y(t), S = C(t);
994
+ const L = t.getTextWidth(w) + y(t), S = C(t);
814
995
  t.setFillColor(m), t.roundedRect(
815
- n.X + Y(t) - o,
816
- n.Y - o,
817
- T + o * 2,
818
- S + o * 2,
996
+ n.X + y(t) - p,
997
+ n.Y - p,
998
+ L + p * 2,
999
+ S + p * 2,
819
1000
  2,
820
1001
  2,
821
1002
  "F"
@@ -823,7 +1004,7 @@ const tt = (t, e, s, c) => {
823
1004
  }
824
1005
  t.text(
825
1006
  w,
826
- n.X + Y(t),
1007
+ n.X + y(t),
827
1008
  n.Y,
828
1009
  {
829
1010
  baseline: "top",
@@ -833,95 +1014,95 @@ const tt = (t, e, s, c) => {
833
1014
  });
834
1015
  } else {
835
1016
  if (d) {
836
- const x = t.getTextWidth(a) + Y(t), F = C(t);
1017
+ const x = t.getTextWidth(s) + y(t), F = C(t);
837
1018
  t.setFillColor(m), t.roundedRect(
838
- n.X + s - o,
839
- n.Y - o,
840
- x + o * 2,
841
- F + o * 2,
1019
+ n.X + i - p,
1020
+ n.Y - p,
1021
+ x + p * 2,
1022
+ F + p * 2,
842
1023
  2,
843
1024
  2,
844
1025
  "F"
845
1026
  ), t.setFillColor("#000000");
846
1027
  }
847
- t.text(a, n.X + s, n.Y, {
1028
+ t.text(s, n.X + i, n.Y, {
848
1029
  baseline: "top",
849
- maxWidth: h
1030
+ maxWidth: c
850
1031
  }), n.updateX(
851
- t.getTextDimensions(a).w + (s >= 2 ? a.split(" ").length + 2 : 2) * l(p) * 0.5 + (d ? o * 2 : 0),
1032
+ t.getTextDimensions(s).w + (i >= 2 ? s.split(" ").length + 2 : 2) * l(g) * 0.5 + (d ? p * 2 : 0),
852
1033
  "add"
853
1034
  );
854
1035
  }
855
1036
  };
856
1037
  if (e.type === "text" && e.items && e.items.length > 0)
857
- for (const a of e.items)
858
- if (a.type === "codespan")
859
- i(a.content || "", "codespan");
860
- else if (a.type === "em" || a.type === "strong") {
861
- const p = a.type === "em" ? "italic" : "bold";
862
- if (a.items && a.items.length > 0)
863
- for (const h of a.items)
864
- h.type === "strong" && p === "italic" || h.type === "em" && p === "bold" ? i(
865
- h.content || "",
1038
+ for (const s of e.items)
1039
+ if (s.type === "codespan")
1040
+ a(s.content || "", "codespan");
1041
+ else if (s.type === "em" || s.type === "strong") {
1042
+ const g = s.type === "em" ? "italic" : "bold";
1043
+ if (s.items && s.items.length > 0)
1044
+ for (const c of s.items)
1045
+ c.type === "strong" && g === "italic" || c.type === "em" && g === "bold" ? a(
1046
+ c.content || "",
866
1047
  "bolditalic"
867
- ) : i(
868
- h.content || "",
869
- p
1048
+ ) : a(
1049
+ c.content || "",
1050
+ g
870
1051
  );
871
1052
  else
872
- i(a.content || "", p);
1053
+ a(s.content || "", g);
873
1054
  } else
874
- i(a.content || "", "normal");
875
- else e.type === "em" ? i(e.content || "", "italic") : e.type === "strong" ? i(e.content || "", "bold") : e.type === "codespan" ? i(e.content || "", "codespan") : i(e.content || "", "normal");
876
- t.setFont(c, g), t.setFontSize(r);
877
- }, rt = (t, e, s) => {
878
- const c = t.getFont().fontName, g = t.getFont().fontStyle, r = t.getFontSize(), l = t.getTextColor(), i = n.options.link?.linkColor || [0, 0, 255];
879
- t.setTextColor(...i);
880
- const a = n.options.page.maxContentWidth - s - n.X, p = e.text || e.content || "", h = e.href || "", f = t.splitTextToSize(p, a);
1055
+ a(s.content || "", "normal");
1056
+ else e.type === "em" ? a(e.content || "", "italic") : e.type === "strong" ? a(e.content || "", "bold") : e.type === "codespan" ? a(e.content || "", "codespan") : a(e.content || "", "normal");
1057
+ t.setFont(r, h), t.setFontSize(o);
1058
+ }, gt = (t, e, i) => {
1059
+ const r = t.getFont().fontName, h = t.getFont().fontStyle, o = t.getFontSize(), l = t.getTextColor(), a = n.options.link?.linkColor || [0, 0, 255];
1060
+ t.setTextColor(...a);
1061
+ const s = n.options.page.maxContentWidth - i - n.X, g = e.text || e.content || "", c = e.href || "", f = t.splitTextToSize(g, s);
881
1062
  if (n.isInlineLockActive)
882
1063
  for (let d = 0; d < f.length; d++) {
883
- const o = t.getTextDimensions(f[d]).w, m = C(t) / 2;
1064
+ const p = t.getTextDimensions(f[d]).w, m = C(t) / 2;
884
1065
  t.link(
885
- n.X + s,
1066
+ n.X + i,
886
1067
  n.Y,
887
- o,
1068
+ p,
888
1069
  m,
889
- { url: h }
890
- ), t.text(f[d], n.X + s, n.Y, {
1070
+ { url: c }
1071
+ ), t.text(f[d], n.X + i, n.Y, {
891
1072
  baseline: "top",
892
- maxWidth: a
893
- }), n.updateX(o + 1, "add"), n.X + o > n.options.page.maxContentWidth - s && (n.updateY(m, "add"), n.updateX(
894
- n.options.page.xpading + s,
1073
+ maxWidth: s
1074
+ }), n.updateX(p + 1, "add"), n.X + p > n.options.page.maxContentWidth - i && (n.updateY(m, "add"), n.updateX(
1075
+ n.options.page.xpading + i,
895
1076
  "set"
896
1077
  )), d < f.length - 1 && (n.updateY(m, "add"), n.updateX(
897
- n.options.page.xpading + s,
1078
+ n.options.page.xpading + i,
898
1079
  "set"
899
1080
  ));
900
1081
  }
901
1082
  else if (f.length > 1) {
902
- const d = f[0], o = f?.slice(1)?.join(" "), m = t.getTextDimensions(d).w, x = C(t) / 2;
1083
+ const d = f[0], p = f?.slice(1)?.join(" "), m = t.getTextDimensions(d).w, x = C(t) / 2;
903
1084
  t.link(
904
- n.X + s,
1085
+ n.X + i,
905
1086
  n.Y,
906
1087
  m,
907
1088
  x,
908
- { url: h }
909
- ), t.text(d, n.X + s, n.Y, {
1089
+ { url: c }
1090
+ ), t.text(d, n.X + i, n.Y, {
910
1091
  baseline: "top",
911
- maxWidth: a
912
- }), n.updateX(n.options.page.xpading + s), n.updateY(x, "add");
913
- const F = n.options.page.maxContentWidth - s - n.options.page.xpading;
914
- t.splitTextToSize(o, F).forEach((k) => {
915
- const w = t.getTextDimensions(k).w;
1092
+ maxWidth: s
1093
+ }), n.updateX(n.options.page.xpading + i), n.updateY(x, "add");
1094
+ const F = n.options.page.maxContentWidth - i - n.options.page.xpading;
1095
+ t.splitTextToSize(p, F).forEach((H) => {
1096
+ const w = t.getTextDimensions(H).w;
916
1097
  t.link(
917
- n.X + Y(t),
1098
+ n.X + y(t),
918
1099
  n.Y,
919
1100
  w,
920
1101
  x,
921
- { url: h }
1102
+ { url: c }
922
1103
  ), t.text(
923
- k,
924
- n.X + Y(t),
1104
+ H,
1105
+ n.X + y(t),
925
1106
  n.Y,
926
1107
  {
927
1108
  baseline: "top",
@@ -930,152 +1111,108 @@ const tt = (t, e, s, c) => {
930
1111
  );
931
1112
  });
932
1113
  } else {
933
- const d = t.getTextDimensions(p).w, o = C(t) / 2;
1114
+ const d = t.getTextDimensions(g).w, p = C(t) / 2;
934
1115
  t.link(
935
- n.X + s,
1116
+ n.X + i,
936
1117
  n.Y,
937
1118
  d,
938
- o,
939
- { url: h }
940
- ), t.text(p, n.X + s, n.Y, {
1119
+ p,
1120
+ { url: c }
1121
+ ), t.text(g, n.X + i, n.Y, {
941
1122
  baseline: "top",
942
- maxWidth: a
1123
+ maxWidth: s
943
1124
  }), n.updateX(d + 2, "add");
944
1125
  }
945
- t.setFont(c, g), t.setFontSize(r), t.setTextColor(l);
946
- }, lt = (t, e, s, c) => {
947
- const g = n.options, r = s + 1, l = n.X + s * g.page.indent, i = n.Y, a = l + g.page.indent / 2, p = i, h = t.internal.getCurrentPageInfo().pageNumber;
948
- e.items && e.items.length > 0 && e.items.forEach((o) => {
949
- c(o, r);
1126
+ t.setFont(r, h), t.setFontSize(o), t.setTextColor(l);
1127
+ }, ct = (t, e, i, r) => {
1128
+ const h = n.options, o = i + 1, l = n.X + i * h.page.indent, a = n.Y, s = l + h.page.indent / 2, g = a, c = t.internal.getCurrentPageInfo().pageNumber;
1129
+ e.items && e.items.length > 0 && e.items.forEach((p) => {
1130
+ r(p, o);
950
1131
  });
951
1132
  const f = n.Y, d = t.internal.getCurrentPageInfo().pageNumber;
952
1133
  t.setDrawColor(100), t.setLineWidth(1);
953
- for (let o = h; o <= d; o++) {
954
- t.setPage(o);
955
- const m = o === h, x = o === d, F = m ? p : g.page.topmargin, b = x ? f : g.page.maxContentHeight;
956
- t.line(a, F, a, b);
1134
+ for (let p = c; p <= d; p++) {
1135
+ t.setPage(p);
1136
+ const m = p === c, x = p === d, F = m ? g : h.page.topmargin, b = x ? f : h.page.maxContentHeight;
1137
+ t.line(s, F, s, b);
957
1138
  }
958
1139
  n.recordContentY(), t.setPage(d);
959
- }, P = 96, ct = (t) => {
1140
+ }, ht = (t) => {
960
1141
  if (t.data) {
961
1142
  if (t.data.startsWith("data:image/png")) return "PNG";
962
1143
  if (t.data.startsWith("data:image/jpeg") || t.data.startsWith("data:image/jpg"))
963
1144
  return "JPEG";
964
- if (t.data.startsWith("data:image/webp")) return "WEBP";
1145
+ if (t.data.startsWith("data:image/webp") || t.data.startsWith("data:image/webp")) return "WEBP";
965
1146
  if (t.data.startsWith("data:image/gif")) return "GIF";
966
1147
  }
967
- return t.src?.split(".").pop()?.toUpperCase() || "JPEG";
968
- }, L = (t, e = "mm") => {
969
- switch (e) {
970
- case "pt":
971
- return t * 72 / P;
972
- case "in":
973
- return t / P;
974
- case "px":
975
- return t;
976
- default:
977
- return t * 25.4 / P;
1148
+ if (t.src) {
1149
+ const i = t.src.split("?")[0].split("#")[0].split(".").pop()?.toUpperCase();
1150
+ if (i && ["PNG", "JPEG", "JPG", "WEBP", "GIF"].includes(i))
1151
+ return i === "JPG" ? "JPEG" : i;
978
1152
  }
979
- }, gt = (t, e, s) => {
1153
+ return "JPEG";
1154
+ }, pt = (t, e, i) => {
980
1155
  if (!e.data)
981
1156
  return;
982
- const c = n.options, g = c.page.unit || "mm", r = s * c.page.indent, l = c.page.maxContentWidth - r, i = n.X + r;
983
- let a = n.Y;
1157
+ const r = n.options, h = r.page.unit || "mm", o = i * r.page.indent, l = r.page.maxContentWidth - o, a = n.X + o;
1158
+ let s = n.Y;
984
1159
  try {
985
- const p = t.getImageProperties(e.data), h = p.width, f = p.height, d = f > 0 ? h / f : 1;
986
- let o, m;
987
- if (e.width && e.height ? (o = L(e.width, g), m = L(e.height, g)) : e.width ? (o = L(e.width, g), m = o / d) : e.height ? (m = L(e.height, g), o = m * d) : (o = L(h, g), m = L(f, g)), o > l) {
988
- const w = l / o;
989
- o = l, m = m * w;
990
- }
991
- const x = c.page.maxContentHeight - c.page.topmargin;
992
- if (m > x) {
993
- const w = x / m;
994
- m = x, o = o * w;
995
- }
996
- a + m > c.page.maxContentHeight && (y(t), a = n.Y);
997
- const F = e.align || c.image?.defaultAlign || "left";
998
- let b;
999
- switch (F) {
1160
+ const g = r.page.maxContentHeight - r.page.topmargin, { finalWidth: c, finalHeight: f } = _(
1161
+ t,
1162
+ e,
1163
+ l,
1164
+ g,
1165
+ h
1166
+ );
1167
+ s + f > r.page.maxContentHeight && (Y(t), s = n.Y);
1168
+ const d = e.align || r.image?.defaultAlign || "left";
1169
+ let p;
1170
+ switch (d) {
1000
1171
  case "right":
1001
- b = i + l - o;
1172
+ p = a + l - c;
1002
1173
  break;
1003
1174
  case "center":
1004
- b = i + (l - o) / 2;
1175
+ p = a + (l - c) / 2;
1005
1176
  break;
1006
1177
  default:
1007
- b = i;
1178
+ p = a;
1008
1179
  break;
1009
1180
  }
1010
- const k = ct(e);
1011
- t.addImage(
1181
+ const m = ht(e);
1182
+ c > 0 && f > 0 && t.addImage(
1012
1183
  e.data,
1013
- k,
1014
- b,
1015
- a,
1016
- o,
1017
- m
1018
- ), n.updateY(m, "add"), n.recordContentY();
1019
- } catch (p) {
1020
- console.warn("Failed to render image", p);
1184
+ m,
1185
+ p,
1186
+ s,
1187
+ c,
1188
+ f
1189
+ ), n.updateY(f, "add"), n.recordContentY();
1190
+ } catch (g) {
1191
+ console.warn("Failed to render image", g);
1021
1192
  }
1022
- }, pt = (t, e, s) => {
1193
+ }, ft = (t, e, i) => {
1023
1194
  if (!e.header || !e.rows)
1024
1195
  return;
1025
- const c = n.options, g = c.page.xmargin + s * c.page.indent, r = [e.header.map((a) => a.content || "")], l = e.rows.map(
1026
- (a) => a.map((p) => p.content || "")
1027
- ), i = c.table || {};
1196
+ const r = n.options, h = r.page.xmargin + i * r.page.indent, o = [e.header.map((s) => s.content || "")], l = e.rows.map(
1197
+ (s) => s.map((g) => g.content || "")
1198
+ ), a = r.table || {};
1028
1199
  O(t, {
1029
- head: r,
1200
+ head: o,
1030
1201
  body: l,
1031
1202
  startY: n.Y,
1032
- margin: { left: g, right: c.page.xmargin },
1033
- ...i,
1034
- didDrawPage: (a) => {
1035
- i.didDrawPage && i.didDrawPage(a);
1203
+ margin: { left: h, right: r.page.xmargin },
1204
+ ...a,
1205
+ didDrawPage: (s) => {
1206
+ a.didDrawPage && a.didDrawPage(s);
1036
1207
  },
1037
- didDrawCell: (a) => {
1038
- i.didDrawCell && i.didDrawCell(a), n.setCursor({
1208
+ didDrawCell: (s) => {
1209
+ a.didDrawCell && a.didDrawCell(s), n.setCursor({
1039
1210
  x: n.X,
1040
- y: a.cell.y + 2 * c.page.lineSpace
1211
+ y: s.cell.y + s.cell.height + 2 * r.page.lineSpace
1041
1212
  });
1042
1213
  }
1043
1214
  });
1044
- }, _ = async (t) => {
1045
- for (const e of t) {
1046
- if (e.type === u.Image && e.src)
1047
- try {
1048
- if (e.src.startsWith("data:"))
1049
- e.data = e.src;
1050
- else {
1051
- const s = await fetch(e.src);
1052
- if (!s.ok)
1053
- throw new Error(
1054
- `Failed to fetch image: ${s.statusText}`
1055
- );
1056
- const c = await s.blob(), g = await new Promise(
1057
- (r, l) => {
1058
- const i = new FileReader();
1059
- i.onloadend = () => {
1060
- typeof i.result == "string" ? r(i.result) : l(
1061
- new Error(
1062
- "Failed to convert image to base64 string"
1063
- )
1064
- );
1065
- }, i.onerror = l, i.readAsDataURL(c);
1066
- }
1067
- );
1068
- e.data = g;
1069
- }
1070
- } catch (s) {
1071
- console.warn(
1072
- `[jspdf-md-renderer] Warning: Failed to load image at ${e.src}. It will be skipped.`,
1073
- s
1074
- );
1075
- }
1076
- e.items && e.items.length > 0 && await _(e.items);
1077
- }
1078
- }, D = {
1215
+ }, v = {
1079
1216
  page: {
1080
1217
  indent: 10,
1081
1218
  maxContentWidth: 190,
@@ -1098,77 +1235,77 @@ const tt = (t, e, s, c) => {
1098
1235
  image: {
1099
1236
  defaultAlign: "left"
1100
1237
  }
1101
- }, ht = (t) => {
1238
+ }, dt = (t) => {
1102
1239
  if (!t)
1103
1240
  throw new Error("RenderOption is required");
1104
- const e = { ...D.page, ...t.page }, s = { ...D.font, ...t.font }, c = { ...D.image, ...t.image };
1241
+ const e = { ...v.page, ...t.page }, i = { ...v.font, ...t.font }, r = { ...v.image, ...t.image };
1105
1242
  return e.maxContentWidth || (e.maxContentWidth = 190), e.maxContentHeight || (e.maxContentHeight = 277), {
1106
1243
  ...t,
1107
1244
  page: e,
1108
- font: s,
1109
- image: c
1245
+ font: i,
1246
+ image: r
1110
1247
  };
1111
- }, ut = async (t, e, s) => {
1112
- const c = ht(s);
1113
- n.initialize(c);
1114
- const g = await Q(e);
1115
- await _(g);
1116
- const r = (l, i = 0, a = !1, p = 0, h = !1, f = !0) => {
1117
- const d = i * c.page.indent;
1248
+ }, xt = async (t, e, i) => {
1249
+ const r = dt(i);
1250
+ n.initialize(r);
1251
+ const h = await M(e);
1252
+ await $(h);
1253
+ const o = (l, a = 0, s = !1, g = 0, c = !1, f = !0) => {
1254
+ const d = a * r.page.indent;
1118
1255
  switch (l.type) {
1119
1256
  case u.Heading:
1120
- M(t, l, d, r);
1257
+ et(t, l, d, o);
1121
1258
  break;
1122
1259
  case u.Paragraph:
1123
- tt(t, l, d, r);
1260
+ nt(t, l, d, o);
1124
1261
  break;
1125
1262
  case u.List:
1126
- et(t, l, i, r);
1263
+ it(t, l, a, o);
1127
1264
  break;
1128
1265
  case u.ListItem:
1129
- nt(
1266
+ st(
1130
1267
  t,
1131
1268
  l,
1132
- i,
1133
- r,
1134
- p,
1135
- h
1269
+ a,
1270
+ o,
1271
+ g,
1272
+ c
1136
1273
  );
1137
1274
  break;
1138
1275
  case u.Hr:
1139
- it(t);
1276
+ ot(t);
1140
1277
  break;
1141
1278
  case u.Code:
1142
- at(t, l, i);
1279
+ rt(t, l, a);
1143
1280
  break;
1144
1281
  case u.Strong:
1145
1282
  case u.Em:
1146
1283
  case u.CodeSpan:
1147
- ot(t, l, d);
1284
+ lt(t, l, d);
1148
1285
  break;
1149
1286
  case u.Link:
1150
- rt(t, l, d);
1287
+ gt(t, l, d);
1151
1288
  break;
1152
1289
  case u.Blockquote:
1153
- lt(t, l, i, r);
1290
+ ct(t, l, a, o);
1154
1291
  break;
1155
1292
  case u.Image:
1156
- gt(t, l, i);
1293
+ pt(t, l, a);
1157
1294
  break;
1158
1295
  case u.Table:
1159
- pt(t, l, i);
1296
+ ft(t, l, a);
1160
1297
  break;
1161
1298
  case u.Raw:
1162
1299
  case u.Text:
1163
- st(
1300
+ at(
1164
1301
  t,
1165
1302
  l,
1166
- i,
1167
1303
  a,
1168
- r,
1169
- p,
1170
- h,
1171
- c.page.defaultFontSize > 0
1304
+ s,
1305
+ o,
1306
+ g,
1307
+ c,
1308
+ r.page.defaultFontSize > 0
1172
1309
  // Using validOptions here if needed, or just true for justify
1173
1310
  );
1174
1311
  break;
@@ -1182,11 +1319,11 @@ const tt = (t, e, s, c) => {
1182
1319
  break;
1183
1320
  }
1184
1321
  };
1185
- for (const l of g)
1186
- r(l);
1187
- c.endCursorYHandler(n.Y);
1322
+ for (const l of h)
1323
+ o(l);
1324
+ r.endCursorYHandler(n.Y);
1188
1325
  };
1189
1326
  export {
1190
- Q as MdTextParser,
1191
- ut as MdTextRender
1327
+ M as MdTextParser,
1328
+ xt as MdTextRender
1192
1329
  };