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.cjs +261 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +261 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6755,7 +6755,9 @@ var index_exports = {};
|
|
|
6755
6755
|
__export(index_exports, {
|
|
6756
6756
|
NestedMarkdown: () => NestedMarkdown,
|
|
6757
6757
|
default: () => NestedMarkdown_default,
|
|
6758
|
-
expandNestedMarkdown: () => expandNestedMarkdown
|
|
6758
|
+
expandNestedMarkdown: () => expandNestedMarkdown,
|
|
6759
|
+
expandNestedMarkdownSync: () => expandNestedMarkdownSync,
|
|
6760
|
+
preRenderMermaid: () => preRenderMermaid
|
|
6759
6761
|
});
|
|
6760
6762
|
module.exports = __toCommonJS(index_exports);
|
|
6761
6763
|
|
|
@@ -28316,6 +28318,33 @@ function expandNestedMarkdownSync(markdown, options2) {
|
|
|
28316
28318
|
options2?.defaultShow
|
|
28317
28319
|
);
|
|
28318
28320
|
}
|
|
28321
|
+
function shouldWrapMermaid(rendered) {
|
|
28322
|
+
const trimmed = rendered.trim();
|
|
28323
|
+
return trimmed.startsWith("<svg");
|
|
28324
|
+
}
|
|
28325
|
+
async function preRenderMermaid(markdown, options2) {
|
|
28326
|
+
const renderMermaid = options2?.renderMermaid;
|
|
28327
|
+
if (!renderMermaid) return markdown;
|
|
28328
|
+
const fenceRegex = /(^|\n)([ \t]*)```mermaid[^\n]*\n([\s\S]*?)\n\2```/g;
|
|
28329
|
+
let result = "";
|
|
28330
|
+
let lastIndex = 0;
|
|
28331
|
+
for (const match of markdown.matchAll(fenceRegex)) {
|
|
28332
|
+
const [fullMatch, leadingNewline, indent2, body] = match;
|
|
28333
|
+
const start2 = match.index ?? 0;
|
|
28334
|
+
result += markdown.slice(lastIndex, start2);
|
|
28335
|
+
const chart = body.replace(/\n$/, "");
|
|
28336
|
+
try {
|
|
28337
|
+
const rendered = await renderMermaid(chart);
|
|
28338
|
+
const wrapped = shouldWrapMermaid(rendered) ? `<div class="mermaid">${rendered}</div>` : rendered;
|
|
28339
|
+
result += `${leadingNewline}${indent2}${wrapped}`;
|
|
28340
|
+
} catch {
|
|
28341
|
+
result += fullMatch;
|
|
28342
|
+
}
|
|
28343
|
+
lastIndex = start2 + fullMatch.length;
|
|
28344
|
+
}
|
|
28345
|
+
result += markdown.slice(lastIndex);
|
|
28346
|
+
return result;
|
|
28347
|
+
}
|
|
28319
28348
|
|
|
28320
28349
|
// src/NestedMarkdown.tsx
|
|
28321
28350
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -28381,7 +28410,215 @@ var customSchema = {
|
|
|
28381
28410
|
pre: [...defaultSchema.attributes?.pre || [], ["style"]],
|
|
28382
28411
|
blockquote: [["style"]],
|
|
28383
28412
|
code: [...defaultSchema.attributes?.code || [], ["style"]],
|
|
28384
|
-
hr: [...defaultSchema.attributes?.hr || [], ["style"]]
|
|
28413
|
+
hr: [...defaultSchema.attributes?.hr || [], ["style"]],
|
|
28414
|
+
svg: [
|
|
28415
|
+
...defaultSchema.attributes?.svg || [],
|
|
28416
|
+
["width"],
|
|
28417
|
+
["height"],
|
|
28418
|
+
["viewBox"],
|
|
28419
|
+
["xmlns"],
|
|
28420
|
+
["xmlnsXlink"],
|
|
28421
|
+
["preserveAspectRatio"],
|
|
28422
|
+
["role"],
|
|
28423
|
+
["aria-hidden"],
|
|
28424
|
+
["focusable"],
|
|
28425
|
+
["className"],
|
|
28426
|
+
["style"]
|
|
28427
|
+
],
|
|
28428
|
+
g: [
|
|
28429
|
+
...defaultSchema.attributes?.g || [],
|
|
28430
|
+
["transform"],
|
|
28431
|
+
["fill"],
|
|
28432
|
+
["stroke"],
|
|
28433
|
+
["strokeWidth"],
|
|
28434
|
+
["opacity"],
|
|
28435
|
+
["className"],
|
|
28436
|
+
["style"]
|
|
28437
|
+
],
|
|
28438
|
+
path: [
|
|
28439
|
+
...defaultSchema.attributes?.path || [],
|
|
28440
|
+
["d"],
|
|
28441
|
+
["fill"],
|
|
28442
|
+
["stroke"],
|
|
28443
|
+
["strokeWidth"],
|
|
28444
|
+
["strokeLinecap"],
|
|
28445
|
+
["strokeLinejoin"],
|
|
28446
|
+
["transform"],
|
|
28447
|
+
["opacity"],
|
|
28448
|
+
["className"],
|
|
28449
|
+
["style"]
|
|
28450
|
+
],
|
|
28451
|
+
rect: [
|
|
28452
|
+
...defaultSchema.attributes?.rect || [],
|
|
28453
|
+
["x"],
|
|
28454
|
+
["y"],
|
|
28455
|
+
["width"],
|
|
28456
|
+
["height"],
|
|
28457
|
+
["rx"],
|
|
28458
|
+
["ry"],
|
|
28459
|
+
["fill"],
|
|
28460
|
+
["stroke"],
|
|
28461
|
+
["strokeWidth"],
|
|
28462
|
+
["transform"],
|
|
28463
|
+
["opacity"],
|
|
28464
|
+
["className"],
|
|
28465
|
+
["style"]
|
|
28466
|
+
],
|
|
28467
|
+
circle: [
|
|
28468
|
+
...defaultSchema.attributes?.circle || [],
|
|
28469
|
+
["cx"],
|
|
28470
|
+
["cy"],
|
|
28471
|
+
["r"],
|
|
28472
|
+
["fill"],
|
|
28473
|
+
["stroke"],
|
|
28474
|
+
["strokeWidth"],
|
|
28475
|
+
["transform"],
|
|
28476
|
+
["opacity"],
|
|
28477
|
+
["className"],
|
|
28478
|
+
["style"]
|
|
28479
|
+
],
|
|
28480
|
+
line: [
|
|
28481
|
+
...defaultSchema.attributes?.line || [],
|
|
28482
|
+
["x1"],
|
|
28483
|
+
["y1"],
|
|
28484
|
+
["x2"],
|
|
28485
|
+
["y2"],
|
|
28486
|
+
["stroke"],
|
|
28487
|
+
["strokeWidth"],
|
|
28488
|
+
["strokeLinecap"],
|
|
28489
|
+
["transform"],
|
|
28490
|
+
["opacity"],
|
|
28491
|
+
["className"],
|
|
28492
|
+
["style"]
|
|
28493
|
+
],
|
|
28494
|
+
polyline: [
|
|
28495
|
+
...defaultSchema.attributes?.polyline || [],
|
|
28496
|
+
["points"],
|
|
28497
|
+
["fill"],
|
|
28498
|
+
["stroke"],
|
|
28499
|
+
["strokeWidth"],
|
|
28500
|
+
["transform"],
|
|
28501
|
+
["opacity"],
|
|
28502
|
+
["className"],
|
|
28503
|
+
["style"]
|
|
28504
|
+
],
|
|
28505
|
+
polygon: [
|
|
28506
|
+
...defaultSchema.attributes?.polygon || [],
|
|
28507
|
+
["points"],
|
|
28508
|
+
["fill"],
|
|
28509
|
+
["stroke"],
|
|
28510
|
+
["strokeWidth"],
|
|
28511
|
+
["transform"],
|
|
28512
|
+
["opacity"],
|
|
28513
|
+
["className"],
|
|
28514
|
+
["style"]
|
|
28515
|
+
],
|
|
28516
|
+
text: [
|
|
28517
|
+
...defaultSchema.attributes?.text || [],
|
|
28518
|
+
["x"],
|
|
28519
|
+
["y"],
|
|
28520
|
+
["dx"],
|
|
28521
|
+
["dy"],
|
|
28522
|
+
["textAnchor"],
|
|
28523
|
+
["dominantBaseline"],
|
|
28524
|
+
["fontFamily"],
|
|
28525
|
+
["fontSize"],
|
|
28526
|
+
["fontWeight"],
|
|
28527
|
+
["fill"],
|
|
28528
|
+
["transform"],
|
|
28529
|
+
["className"],
|
|
28530
|
+
["style"]
|
|
28531
|
+
],
|
|
28532
|
+
tspan: [
|
|
28533
|
+
...defaultSchema.attributes?.tspan || [],
|
|
28534
|
+
["x"],
|
|
28535
|
+
["y"],
|
|
28536
|
+
["dx"],
|
|
28537
|
+
["dy"],
|
|
28538
|
+
["textAnchor"],
|
|
28539
|
+
["dominantBaseline"],
|
|
28540
|
+
["fontFamily"],
|
|
28541
|
+
["fontSize"],
|
|
28542
|
+
["fontWeight"],
|
|
28543
|
+
["fill"],
|
|
28544
|
+
["transform"],
|
|
28545
|
+
["className"],
|
|
28546
|
+
["style"]
|
|
28547
|
+
],
|
|
28548
|
+
defs: [...defaultSchema.attributes?.defs || [], ["id"]],
|
|
28549
|
+
marker: [
|
|
28550
|
+
...defaultSchema.attributes?.marker || [],
|
|
28551
|
+
["id"],
|
|
28552
|
+
["markerWidth"],
|
|
28553
|
+
["markerHeight"],
|
|
28554
|
+
["refX"],
|
|
28555
|
+
["refY"],
|
|
28556
|
+
["orient"],
|
|
28557
|
+
["markerUnits"],
|
|
28558
|
+
["viewBox"]
|
|
28559
|
+
],
|
|
28560
|
+
linearGradient: [
|
|
28561
|
+
...defaultSchema.attributes?.linearGradient || [],
|
|
28562
|
+
["id"],
|
|
28563
|
+
["x1"],
|
|
28564
|
+
["y1"],
|
|
28565
|
+
["x2"],
|
|
28566
|
+
["y2"],
|
|
28567
|
+
["gradientUnits"],
|
|
28568
|
+
["gradientTransform"]
|
|
28569
|
+
],
|
|
28570
|
+
radialGradient: [
|
|
28571
|
+
...defaultSchema.attributes?.radialGradient || [],
|
|
28572
|
+
["id"],
|
|
28573
|
+
["cx"],
|
|
28574
|
+
["cy"],
|
|
28575
|
+
["r"],
|
|
28576
|
+
["fx"],
|
|
28577
|
+
["fy"],
|
|
28578
|
+
["gradientUnits"],
|
|
28579
|
+
["gradientTransform"]
|
|
28580
|
+
],
|
|
28581
|
+
stop: [
|
|
28582
|
+
...defaultSchema.attributes?.stop || [],
|
|
28583
|
+
["offset"],
|
|
28584
|
+
["stopColor"],
|
|
28585
|
+
["stopOpacity"]
|
|
28586
|
+
],
|
|
28587
|
+
clipPath: [
|
|
28588
|
+
...defaultSchema.attributes?.clipPath || [],
|
|
28589
|
+
["id"],
|
|
28590
|
+
["clipPathUnits"]
|
|
28591
|
+
],
|
|
28592
|
+
mask: [
|
|
28593
|
+
...defaultSchema.attributes?.mask || [],
|
|
28594
|
+
["id"],
|
|
28595
|
+
["x"],
|
|
28596
|
+
["y"],
|
|
28597
|
+
["width"],
|
|
28598
|
+
["height"],
|
|
28599
|
+
["maskUnits"],
|
|
28600
|
+
["maskContentUnits"]
|
|
28601
|
+
],
|
|
28602
|
+
pattern: [
|
|
28603
|
+
...defaultSchema.attributes?.pattern || [],
|
|
28604
|
+
["id"],
|
|
28605
|
+
["x"],
|
|
28606
|
+
["y"],
|
|
28607
|
+
["width"],
|
|
28608
|
+
["height"],
|
|
28609
|
+
["patternUnits"],
|
|
28610
|
+
["patternContentUnits"],
|
|
28611
|
+
["patternTransform"]
|
|
28612
|
+
],
|
|
28613
|
+
use: [
|
|
28614
|
+
...defaultSchema.attributes?.use || [],
|
|
28615
|
+
["href"],
|
|
28616
|
+
["xlinkHref"],
|
|
28617
|
+
["x"],
|
|
28618
|
+
["y"],
|
|
28619
|
+
["width"],
|
|
28620
|
+
["height"]
|
|
28621
|
+
]
|
|
28385
28622
|
},
|
|
28386
28623
|
tagNames: [
|
|
28387
28624
|
...defaultSchema.tagNames || [],
|
|
@@ -28391,7 +28628,28 @@ var customSchema = {
|
|
|
28391
28628
|
"code",
|
|
28392
28629
|
"hr",
|
|
28393
28630
|
"blockquote",
|
|
28394
|
-
"mark"
|
|
28631
|
+
"mark",
|
|
28632
|
+
"svg",
|
|
28633
|
+
"g",
|
|
28634
|
+
"path",
|
|
28635
|
+
"rect",
|
|
28636
|
+
"circle",
|
|
28637
|
+
"line",
|
|
28638
|
+
"polyline",
|
|
28639
|
+
"polygon",
|
|
28640
|
+
"text",
|
|
28641
|
+
"tspan",
|
|
28642
|
+
"defs",
|
|
28643
|
+
"marker",
|
|
28644
|
+
"linearGradient",
|
|
28645
|
+
"radialGradient",
|
|
28646
|
+
"stop",
|
|
28647
|
+
"clipPath",
|
|
28648
|
+
"mask",
|
|
28649
|
+
"pattern",
|
|
28650
|
+
"use",
|
|
28651
|
+
"title",
|
|
28652
|
+
"desc"
|
|
28395
28653
|
]
|
|
28396
28654
|
};
|
|
28397
28655
|
var remarkForceLooseLists = () => {
|