nested-markdown 0.0.13 → 0.0.14

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.d.cts CHANGED
@@ -17,5 +17,13 @@ declare function expandNestedMarkdown(markdown: string, options?: {
17
17
  recursionLimit?: number;
18
18
  defaultShow?: "preview" | "code" | "both";
19
19
  }): Promise<string>;
20
+ declare function expandNestedMarkdownSync(markdown: string, options?: {
21
+ recursionLimit?: number;
22
+ defaultShow?: "preview" | "code" | "both";
23
+ }): string;
24
+ type MermaidRenderer = (chart: string) => string | Promise<string>;
25
+ declare function preRenderMermaid(markdown: string, options?: {
26
+ renderMermaid?: MermaidRenderer;
27
+ }): Promise<string>;
20
28
 
21
- export { NestedMarkdown, NestedMarkdown as default, expandNestedMarkdown };
29
+ export { NestedMarkdown, NestedMarkdown as default, expandNestedMarkdown, expandNestedMarkdownSync, preRenderMermaid };
package/dist/index.d.ts CHANGED
@@ -17,5 +17,13 @@ declare function expandNestedMarkdown(markdown: string, options?: {
17
17
  recursionLimit?: number;
18
18
  defaultShow?: "preview" | "code" | "both";
19
19
  }): Promise<string>;
20
+ declare function expandNestedMarkdownSync(markdown: string, options?: {
21
+ recursionLimit?: number;
22
+ defaultShow?: "preview" | "code" | "both";
23
+ }): string;
24
+ type MermaidRenderer = (chart: string) => string | Promise<string>;
25
+ declare function preRenderMermaid(markdown: string, options?: {
26
+ renderMermaid?: MermaidRenderer;
27
+ }): Promise<string>;
20
28
 
21
- export { NestedMarkdown, NestedMarkdown as default, expandNestedMarkdown };
29
+ export { NestedMarkdown, NestedMarkdown as default, expandNestedMarkdown, expandNestedMarkdownSync, preRenderMermaid };
package/dist/index.js CHANGED
@@ -28207,6 +28207,33 @@ function expandNestedMarkdownSync(markdown, options2) {
28207
28207
  options2?.defaultShow
28208
28208
  );
28209
28209
  }
28210
+ function shouldWrapMermaid(rendered) {
28211
+ const trimmed = rendered.trim();
28212
+ return trimmed.startsWith("<svg");
28213
+ }
28214
+ async function preRenderMermaid(markdown, options2) {
28215
+ const renderMermaid = options2?.renderMermaid;
28216
+ if (!renderMermaid) return markdown;
28217
+ const fenceRegex = /(^|\n)([ \t]*)```mermaid[^\n]*\n([\s\S]*?)\n\2```/g;
28218
+ let result = "";
28219
+ let lastIndex = 0;
28220
+ for (const match of markdown.matchAll(fenceRegex)) {
28221
+ const [fullMatch, leadingNewline, indent2, body] = match;
28222
+ const start2 = match.index ?? 0;
28223
+ result += markdown.slice(lastIndex, start2);
28224
+ const chart = body.replace(/\n$/, "");
28225
+ try {
28226
+ const rendered = await renderMermaid(chart);
28227
+ const wrapped = shouldWrapMermaid(rendered) ? `<div class="mermaid">${rendered}</div>` : rendered;
28228
+ result += `${leadingNewline}${indent2}${wrapped}`;
28229
+ } catch {
28230
+ result += fullMatch;
28231
+ }
28232
+ lastIndex = start2 + fullMatch.length;
28233
+ }
28234
+ result += markdown.slice(lastIndex);
28235
+ return result;
28236
+ }
28210
28237
 
28211
28238
  // src/NestedMarkdown.tsx
28212
28239
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
@@ -28272,7 +28299,215 @@ var customSchema = {
28272
28299
  pre: [...defaultSchema.attributes?.pre || [], ["style"]],
28273
28300
  blockquote: [["style"]],
28274
28301
  code: [...defaultSchema.attributes?.code || [], ["style"]],
28275
- hr: [...defaultSchema.attributes?.hr || [], ["style"]]
28302
+ hr: [...defaultSchema.attributes?.hr || [], ["style"]],
28303
+ svg: [
28304
+ ...defaultSchema.attributes?.svg || [],
28305
+ ["width"],
28306
+ ["height"],
28307
+ ["viewBox"],
28308
+ ["xmlns"],
28309
+ ["xmlnsXlink"],
28310
+ ["preserveAspectRatio"],
28311
+ ["role"],
28312
+ ["aria-hidden"],
28313
+ ["focusable"],
28314
+ ["className"],
28315
+ ["style"]
28316
+ ],
28317
+ g: [
28318
+ ...defaultSchema.attributes?.g || [],
28319
+ ["transform"],
28320
+ ["fill"],
28321
+ ["stroke"],
28322
+ ["strokeWidth"],
28323
+ ["opacity"],
28324
+ ["className"],
28325
+ ["style"]
28326
+ ],
28327
+ path: [
28328
+ ...defaultSchema.attributes?.path || [],
28329
+ ["d"],
28330
+ ["fill"],
28331
+ ["stroke"],
28332
+ ["strokeWidth"],
28333
+ ["strokeLinecap"],
28334
+ ["strokeLinejoin"],
28335
+ ["transform"],
28336
+ ["opacity"],
28337
+ ["className"],
28338
+ ["style"]
28339
+ ],
28340
+ rect: [
28341
+ ...defaultSchema.attributes?.rect || [],
28342
+ ["x"],
28343
+ ["y"],
28344
+ ["width"],
28345
+ ["height"],
28346
+ ["rx"],
28347
+ ["ry"],
28348
+ ["fill"],
28349
+ ["stroke"],
28350
+ ["strokeWidth"],
28351
+ ["transform"],
28352
+ ["opacity"],
28353
+ ["className"],
28354
+ ["style"]
28355
+ ],
28356
+ circle: [
28357
+ ...defaultSchema.attributes?.circle || [],
28358
+ ["cx"],
28359
+ ["cy"],
28360
+ ["r"],
28361
+ ["fill"],
28362
+ ["stroke"],
28363
+ ["strokeWidth"],
28364
+ ["transform"],
28365
+ ["opacity"],
28366
+ ["className"],
28367
+ ["style"]
28368
+ ],
28369
+ line: [
28370
+ ...defaultSchema.attributes?.line || [],
28371
+ ["x1"],
28372
+ ["y1"],
28373
+ ["x2"],
28374
+ ["y2"],
28375
+ ["stroke"],
28376
+ ["strokeWidth"],
28377
+ ["strokeLinecap"],
28378
+ ["transform"],
28379
+ ["opacity"],
28380
+ ["className"],
28381
+ ["style"]
28382
+ ],
28383
+ polyline: [
28384
+ ...defaultSchema.attributes?.polyline || [],
28385
+ ["points"],
28386
+ ["fill"],
28387
+ ["stroke"],
28388
+ ["strokeWidth"],
28389
+ ["transform"],
28390
+ ["opacity"],
28391
+ ["className"],
28392
+ ["style"]
28393
+ ],
28394
+ polygon: [
28395
+ ...defaultSchema.attributes?.polygon || [],
28396
+ ["points"],
28397
+ ["fill"],
28398
+ ["stroke"],
28399
+ ["strokeWidth"],
28400
+ ["transform"],
28401
+ ["opacity"],
28402
+ ["className"],
28403
+ ["style"]
28404
+ ],
28405
+ text: [
28406
+ ...defaultSchema.attributes?.text || [],
28407
+ ["x"],
28408
+ ["y"],
28409
+ ["dx"],
28410
+ ["dy"],
28411
+ ["textAnchor"],
28412
+ ["dominantBaseline"],
28413
+ ["fontFamily"],
28414
+ ["fontSize"],
28415
+ ["fontWeight"],
28416
+ ["fill"],
28417
+ ["transform"],
28418
+ ["className"],
28419
+ ["style"]
28420
+ ],
28421
+ tspan: [
28422
+ ...defaultSchema.attributes?.tspan || [],
28423
+ ["x"],
28424
+ ["y"],
28425
+ ["dx"],
28426
+ ["dy"],
28427
+ ["textAnchor"],
28428
+ ["dominantBaseline"],
28429
+ ["fontFamily"],
28430
+ ["fontSize"],
28431
+ ["fontWeight"],
28432
+ ["fill"],
28433
+ ["transform"],
28434
+ ["className"],
28435
+ ["style"]
28436
+ ],
28437
+ defs: [...defaultSchema.attributes?.defs || [], ["id"]],
28438
+ marker: [
28439
+ ...defaultSchema.attributes?.marker || [],
28440
+ ["id"],
28441
+ ["markerWidth"],
28442
+ ["markerHeight"],
28443
+ ["refX"],
28444
+ ["refY"],
28445
+ ["orient"],
28446
+ ["markerUnits"],
28447
+ ["viewBox"]
28448
+ ],
28449
+ linearGradient: [
28450
+ ...defaultSchema.attributes?.linearGradient || [],
28451
+ ["id"],
28452
+ ["x1"],
28453
+ ["y1"],
28454
+ ["x2"],
28455
+ ["y2"],
28456
+ ["gradientUnits"],
28457
+ ["gradientTransform"]
28458
+ ],
28459
+ radialGradient: [
28460
+ ...defaultSchema.attributes?.radialGradient || [],
28461
+ ["id"],
28462
+ ["cx"],
28463
+ ["cy"],
28464
+ ["r"],
28465
+ ["fx"],
28466
+ ["fy"],
28467
+ ["gradientUnits"],
28468
+ ["gradientTransform"]
28469
+ ],
28470
+ stop: [
28471
+ ...defaultSchema.attributes?.stop || [],
28472
+ ["offset"],
28473
+ ["stopColor"],
28474
+ ["stopOpacity"]
28475
+ ],
28476
+ clipPath: [
28477
+ ...defaultSchema.attributes?.clipPath || [],
28478
+ ["id"],
28479
+ ["clipPathUnits"]
28480
+ ],
28481
+ mask: [
28482
+ ...defaultSchema.attributes?.mask || [],
28483
+ ["id"],
28484
+ ["x"],
28485
+ ["y"],
28486
+ ["width"],
28487
+ ["height"],
28488
+ ["maskUnits"],
28489
+ ["maskContentUnits"]
28490
+ ],
28491
+ pattern: [
28492
+ ...defaultSchema.attributes?.pattern || [],
28493
+ ["id"],
28494
+ ["x"],
28495
+ ["y"],
28496
+ ["width"],
28497
+ ["height"],
28498
+ ["patternUnits"],
28499
+ ["patternContentUnits"],
28500
+ ["patternTransform"]
28501
+ ],
28502
+ use: [
28503
+ ...defaultSchema.attributes?.use || [],
28504
+ ["href"],
28505
+ ["xlinkHref"],
28506
+ ["x"],
28507
+ ["y"],
28508
+ ["width"],
28509
+ ["height"]
28510
+ ]
28276
28511
  },
28277
28512
  tagNames: [
28278
28513
  ...defaultSchema.tagNames || [],
@@ -28282,7 +28517,28 @@ var customSchema = {
28282
28517
  "code",
28283
28518
  "hr",
28284
28519
  "blockquote",
28285
- "mark"
28520
+ "mark",
28521
+ "svg",
28522
+ "g",
28523
+ "path",
28524
+ "rect",
28525
+ "circle",
28526
+ "line",
28527
+ "polyline",
28528
+ "polygon",
28529
+ "text",
28530
+ "tspan",
28531
+ "defs",
28532
+ "marker",
28533
+ "linearGradient",
28534
+ "radialGradient",
28535
+ "stop",
28536
+ "clipPath",
28537
+ "mask",
28538
+ "pattern",
28539
+ "use",
28540
+ "title",
28541
+ "desc"
28286
28542
  ]
28287
28543
  };
28288
28544
  var remarkForceLooseLists = () => {
@@ -28694,7 +28950,9 @@ var NestedMarkdown_default = NestedMarkdown;
28694
28950
  export {
28695
28951
  NestedMarkdown,
28696
28952
  NestedMarkdown_default as default,
28697
- expandNestedMarkdown
28953
+ expandNestedMarkdown,
28954
+ expandNestedMarkdownSync,
28955
+ preRenderMermaid
28698
28956
  };
28699
28957
  /*! Bundled license information:
28700
28958