safe-mdx 1.3.3 → 1.3.7
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/html/html-to-mdx-ast.d.ts +4 -2
- package/dist/html/html-to-mdx-ast.d.ts.map +1 -1
- package/dist/html/html-to-mdx-ast.js +105 -45
- package/dist/html/html-to-mdx-ast.js.map +1 -1
- package/dist/html/html-to-mdx-ast.test.js +365 -4
- package/dist/html/html-to-mdx-ast.test.js.map +1 -1
- package/dist/html/remark-mdx-jsx-normalize.d.ts +1 -1
- package/dist/html/remark-mdx-jsx-normalize.d.ts.map +1 -1
- package/dist/html/remark-mdx-jsx-normalize.js +92 -15
- package/dist/html/remark-mdx-jsx-normalize.js.map +1 -1
- package/dist/parse.d.ts +2 -2
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +2 -2
- package/dist/parse.js.map +1 -1
- package/dist/safe-mdx.d.ts +1 -1
- package/dist/safe-mdx.d.ts.map +1 -1
- package/dist/safe-mdx.js +8 -12
- package/dist/safe-mdx.js.map +1 -1
- package/package.json +2 -1
- package/src/html/html-to-mdx-ast.test.ts +393 -3
- package/src/html/html-to-mdx-ast.ts +118 -47
- package/src/html/remark-mdx-jsx-normalize.ts +98 -17
- package/src/parse.ts +2 -2
- package/src/safe-mdx.tsx +8 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test, expect, describe } from 'vitest';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
4
|
-
import { parseHtmlToMdxAst, } from './html-to-mdx-ast.js';
|
|
4
|
+
import { parseHtmlToMdxAst, htmlToMdxAst, } from './html-to-mdx-ast.js';
|
|
5
5
|
import { unified } from 'unified';
|
|
6
6
|
import remarkMdx from 'remark-mdx';
|
|
7
7
|
import remarkStringify from 'remark-stringify';
|
|
@@ -94,7 +94,7 @@ describe('parseHtmlToMdxAst', () => {
|
|
|
94
94
|
"children": [
|
|
95
95
|
{
|
|
96
96
|
"type": "text",
|
|
97
|
-
"value": "Hello
|
|
97
|
+
"value": "Hello",
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"attributes": [],
|
|
@@ -169,7 +169,7 @@ describe('parseHtmlToMdxAst', () => {
|
|
|
169
169
|
[
|
|
170
170
|
{
|
|
171
171
|
"type": "text",
|
|
172
|
-
"value": "Some text
|
|
172
|
+
"value": "Some text",
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
"attributes": [],
|
|
@@ -184,7 +184,7 @@ describe('parseHtmlToMdxAst', () => {
|
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
186
|
"type": "text",
|
|
187
|
-
"value": "
|
|
187
|
+
"value": "more text",
|
|
188
188
|
},
|
|
189
189
|
]
|
|
190
190
|
`);
|
|
@@ -320,5 +320,366 @@ describe('parseHtmlToMdxAst with markdown processor', () => {
|
|
|
320
320
|
}
|
|
321
321
|
`);
|
|
322
322
|
});
|
|
323
|
+
test('normalize plugin without parentType does not apply', () => {
|
|
324
|
+
// Without parentType, normalization should not happen
|
|
325
|
+
const withoutParent = htmlToMdxAst({
|
|
326
|
+
html: '<span>Text</span>'
|
|
327
|
+
});
|
|
328
|
+
// Without normalization, elements remain as initially created (text elements)
|
|
329
|
+
expect(withoutParent).toHaveLength(1);
|
|
330
|
+
expect(withoutParent[0]).toMatchObject({
|
|
331
|
+
type: 'mdxJsxTextElement',
|
|
332
|
+
name: 'span'
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
test('handles indented HTML without preserving indentation', () => {
|
|
336
|
+
const indentedHtml = `
|
|
337
|
+
<columns>
|
|
338
|
+
<column>
|
|
339
|
+
<page url="https://notion.so/page1">Page 1</page>
|
|
340
|
+
Some text
|
|
341
|
+
</column>
|
|
342
|
+
<column>
|
|
343
|
+
<callout icon="💡" color="yellow_bg">
|
|
344
|
+
Important callout
|
|
345
|
+
</callout>
|
|
346
|
+
</column>
|
|
347
|
+
</columns>`;
|
|
348
|
+
const result = parseHtmlToMdxAst({ html: indentedHtml });
|
|
349
|
+
expect(result).toMatchInlineSnapshot(`
|
|
350
|
+
[
|
|
351
|
+
{
|
|
352
|
+
"attributes": [],
|
|
353
|
+
"children": [
|
|
354
|
+
{
|
|
355
|
+
"attributes": [],
|
|
356
|
+
"children": [
|
|
357
|
+
{
|
|
358
|
+
"attributes": [
|
|
359
|
+
{
|
|
360
|
+
"name": "url",
|
|
361
|
+
"type": "mdxJsxAttribute",
|
|
362
|
+
"value": "https://notion.so/page1",
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
"children": [
|
|
366
|
+
{
|
|
367
|
+
"type": "text",
|
|
368
|
+
"value": "Page 1",
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
"name": "page",
|
|
372
|
+
"type": "mdxJsxTextElement",
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"type": "text",
|
|
376
|
+
"value": "Some text",
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
"name": "column",
|
|
380
|
+
"type": "mdxJsxTextElement",
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"attributes": [],
|
|
384
|
+
"children": [
|
|
385
|
+
{
|
|
386
|
+
"attributes": [
|
|
387
|
+
{
|
|
388
|
+
"name": "icon",
|
|
389
|
+
"type": "mdxJsxAttribute",
|
|
390
|
+
"value": "💡",
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"name": "color",
|
|
394
|
+
"type": "mdxJsxAttribute",
|
|
395
|
+
"value": "yellow_bg",
|
|
396
|
+
},
|
|
397
|
+
],
|
|
398
|
+
"children": [
|
|
399
|
+
{
|
|
400
|
+
"type": "text",
|
|
401
|
+
"value": "Important callout",
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
"name": "callout",
|
|
405
|
+
"type": "mdxJsxTextElement",
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
"name": "column",
|
|
409
|
+
"type": "mdxJsxTextElement",
|
|
410
|
+
},
|
|
411
|
+
],
|
|
412
|
+
"name": "columns",
|
|
413
|
+
"type": "mdxJsxTextElement",
|
|
414
|
+
},
|
|
415
|
+
]
|
|
416
|
+
`);
|
|
417
|
+
});
|
|
418
|
+
test('handles indented HTML with textToMdast', () => {
|
|
419
|
+
const indentedHtml = `
|
|
420
|
+
<div>
|
|
421
|
+
**Bold text** and
|
|
422
|
+
some regular text
|
|
423
|
+
</div>`;
|
|
424
|
+
const receivedTexts = [];
|
|
425
|
+
const textToMdast = ({ text }) => {
|
|
426
|
+
receivedTexts.push(text);
|
|
427
|
+
return [{ type: 'text', value: text }];
|
|
428
|
+
};
|
|
429
|
+
const result = parseHtmlToMdxAst({
|
|
430
|
+
html: indentedHtml,
|
|
431
|
+
textToMdast
|
|
432
|
+
});
|
|
433
|
+
expect(result).toMatchInlineSnapshot(`
|
|
434
|
+
[
|
|
435
|
+
{
|
|
436
|
+
"attributes": [],
|
|
437
|
+
"children": [
|
|
438
|
+
{
|
|
439
|
+
"type": "text",
|
|
440
|
+
"value": "**Bold text** and
|
|
441
|
+
some regular text",
|
|
442
|
+
},
|
|
443
|
+
],
|
|
444
|
+
"name": "div",
|
|
445
|
+
"type": "mdxJsxTextElement",
|
|
446
|
+
},
|
|
447
|
+
]
|
|
448
|
+
`);
|
|
449
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
450
|
+
[
|
|
451
|
+
"**Bold text** and
|
|
452
|
+
some regular text",
|
|
453
|
+
]
|
|
454
|
+
`);
|
|
455
|
+
});
|
|
456
|
+
test('handles multi-line indented text content', () => {
|
|
457
|
+
const htmlWithMultiLineText = `
|
|
458
|
+
<div>
|
|
459
|
+
This is a multi-line string
|
|
460
|
+
that has indentation on each line
|
|
461
|
+
and should be properly de-indented
|
|
462
|
+
|
|
463
|
+
Even with blank lines in between
|
|
464
|
+
it should maintain the structure
|
|
465
|
+
</div>`;
|
|
466
|
+
const receivedTexts = [];
|
|
467
|
+
const textToMdast = ({ text }) => {
|
|
468
|
+
receivedTexts.push(text);
|
|
469
|
+
return [{ type: 'text', value: text }];
|
|
470
|
+
};
|
|
471
|
+
const result = parseHtmlToMdxAst({
|
|
472
|
+
html: htmlWithMultiLineText,
|
|
473
|
+
textToMdast
|
|
474
|
+
});
|
|
475
|
+
expect(result).toMatchInlineSnapshot(`
|
|
476
|
+
[
|
|
477
|
+
{
|
|
478
|
+
"attributes": [],
|
|
479
|
+
"children": [
|
|
480
|
+
{
|
|
481
|
+
"type": "text",
|
|
482
|
+
"value": "This is a multi-line string
|
|
483
|
+
that has indentation on each line
|
|
484
|
+
and should be properly de-indented
|
|
485
|
+
|
|
486
|
+
Even with blank lines in between
|
|
487
|
+
it should maintain the structure",
|
|
488
|
+
},
|
|
489
|
+
],
|
|
490
|
+
"name": "div",
|
|
491
|
+
"type": "mdxJsxTextElement",
|
|
492
|
+
},
|
|
493
|
+
]
|
|
494
|
+
`);
|
|
495
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
496
|
+
[
|
|
497
|
+
"This is a multi-line string
|
|
498
|
+
that has indentation on each line
|
|
499
|
+
and should be properly de-indented
|
|
500
|
+
|
|
501
|
+
Even with blank lines in between
|
|
502
|
+
it should maintain the structure",
|
|
503
|
+
]
|
|
504
|
+
`);
|
|
505
|
+
});
|
|
506
|
+
test('handles multi-line text with markdown', () => {
|
|
507
|
+
const htmlWithMultiLineText = `
|
|
508
|
+
<article>
|
|
509
|
+
# Heading
|
|
510
|
+
|
|
511
|
+
This is a paragraph with **bold** text
|
|
512
|
+
that spans multiple lines and has
|
|
513
|
+
markdown formatting.
|
|
514
|
+
|
|
515
|
+
- List item 1
|
|
516
|
+
- List item 2
|
|
517
|
+
</article>`;
|
|
518
|
+
const receivedTexts = [];
|
|
519
|
+
const textToMdast = ({ text }) => {
|
|
520
|
+
receivedTexts.push(text);
|
|
521
|
+
return [{ type: 'text', value: text }];
|
|
522
|
+
};
|
|
523
|
+
const result = parseHtmlToMdxAst({
|
|
524
|
+
html: htmlWithMultiLineText,
|
|
525
|
+
textToMdast
|
|
526
|
+
});
|
|
527
|
+
expect(result).toMatchInlineSnapshot(`
|
|
528
|
+
[
|
|
529
|
+
{
|
|
530
|
+
"attributes": [],
|
|
531
|
+
"children": [
|
|
532
|
+
{
|
|
533
|
+
"type": "text",
|
|
534
|
+
"value": "# Heading
|
|
535
|
+
|
|
536
|
+
This is a paragraph with **bold** text
|
|
537
|
+
that spans multiple lines and has
|
|
538
|
+
markdown formatting.
|
|
539
|
+
|
|
540
|
+
- List item 1
|
|
541
|
+
- List item 2",
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
"name": "article",
|
|
545
|
+
"type": "mdxJsxTextElement",
|
|
546
|
+
},
|
|
547
|
+
]
|
|
548
|
+
`);
|
|
549
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
550
|
+
[
|
|
551
|
+
"# Heading
|
|
552
|
+
|
|
553
|
+
This is a paragraph with **bold** text
|
|
554
|
+
that spans multiple lines and has
|
|
555
|
+
markdown formatting.
|
|
556
|
+
|
|
557
|
+
- List item 1
|
|
558
|
+
- List item 2",
|
|
559
|
+
]
|
|
560
|
+
`);
|
|
561
|
+
});
|
|
562
|
+
test('preserves relative indentation when deindenting', () => {
|
|
563
|
+
const htmlWithRelativeIndent = `
|
|
564
|
+
<pre>
|
|
565
|
+
function example() {
|
|
566
|
+
if (true) {
|
|
567
|
+
console.log('nested');
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
</pre>`;
|
|
571
|
+
const receivedTexts = [];
|
|
572
|
+
const textToMdast = ({ text }) => {
|
|
573
|
+
receivedTexts.push(text);
|
|
574
|
+
return [{ type: 'text', value: text }];
|
|
575
|
+
};
|
|
576
|
+
const result = parseHtmlToMdxAst({
|
|
577
|
+
html: htmlWithRelativeIndent,
|
|
578
|
+
textToMdast
|
|
579
|
+
});
|
|
580
|
+
expect(result).toMatchInlineSnapshot(`
|
|
581
|
+
[
|
|
582
|
+
{
|
|
583
|
+
"attributes": [],
|
|
584
|
+
"children": [
|
|
585
|
+
{
|
|
586
|
+
"type": "text",
|
|
587
|
+
"value": "function example() {
|
|
588
|
+
if (true) {
|
|
589
|
+
console.log('nested');
|
|
590
|
+
}
|
|
591
|
+
}",
|
|
592
|
+
},
|
|
593
|
+
],
|
|
594
|
+
"name": "pre",
|
|
595
|
+
"type": "mdxJsxTextElement",
|
|
596
|
+
},
|
|
597
|
+
]
|
|
598
|
+
`);
|
|
599
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
600
|
+
[
|
|
601
|
+
"function example() {
|
|
602
|
+
if (true) {
|
|
603
|
+
console.log('nested');
|
|
604
|
+
}
|
|
605
|
+
}",
|
|
606
|
+
]
|
|
607
|
+
`);
|
|
608
|
+
});
|
|
609
|
+
test('applies normalize plugin with parentType', () => {
|
|
610
|
+
// Test with a block element inside a paragraph (phrasing context)
|
|
611
|
+
const blockInParagraph = htmlToMdxAst({
|
|
612
|
+
html: '<div>Block in paragraph</div>',
|
|
613
|
+
parentType: 'paragraph'
|
|
614
|
+
});
|
|
615
|
+
// Even though div is a block element, it should remain mdxJsxFlowElement
|
|
616
|
+
// because block-level tags have priority
|
|
617
|
+
expect(blockInParagraph).toHaveLength(1);
|
|
618
|
+
expect(blockInParagraph[0]).toMatchObject({
|
|
619
|
+
type: 'mdxJsxFlowElement',
|
|
620
|
+
name: 'div'
|
|
621
|
+
});
|
|
622
|
+
// Test with inline element in paragraph (should be text element)
|
|
623
|
+
const inlineInParagraph = htmlToMdxAst({
|
|
624
|
+
html: '<span>Inline in paragraph</span>',
|
|
625
|
+
parentType: 'paragraph'
|
|
626
|
+
});
|
|
627
|
+
expect(inlineInParagraph).toHaveLength(1);
|
|
628
|
+
expect(inlineInParagraph[0]).toMatchObject({
|
|
629
|
+
type: 'mdxJsxTextElement',
|
|
630
|
+
name: 'span'
|
|
631
|
+
});
|
|
632
|
+
// Test with inline element in root (should be flow element)
|
|
633
|
+
const inlineInRoot = htmlToMdxAst({
|
|
634
|
+
html: '<span>Inline in root</span>',
|
|
635
|
+
parentType: 'root'
|
|
636
|
+
});
|
|
637
|
+
expect(inlineInRoot).toHaveLength(1);
|
|
638
|
+
expect(inlineInRoot[0]).toMatchObject({
|
|
639
|
+
type: 'mdxJsxFlowElement',
|
|
640
|
+
name: 'span'
|
|
641
|
+
});
|
|
642
|
+
// Test with multiple elements
|
|
643
|
+
const multipleElements = htmlToMdxAst({
|
|
644
|
+
html: '<span>First</span><div>Second</div>',
|
|
645
|
+
parentType: 'paragraph'
|
|
646
|
+
});
|
|
647
|
+
expect(multipleElements).toHaveLength(2);
|
|
648
|
+
expect(multipleElements[0]).toMatchObject({
|
|
649
|
+
type: 'mdxJsxTextElement',
|
|
650
|
+
name: 'span'
|
|
651
|
+
});
|
|
652
|
+
expect(multipleElements[1]).toMatchObject({
|
|
653
|
+
type: 'mdxJsxFlowElement',
|
|
654
|
+
name: 'div'
|
|
655
|
+
});
|
|
656
|
+
// Test with nested elements - the normalize plugin should handle nested context correctly
|
|
657
|
+
const nestedElements = htmlToMdxAst({
|
|
658
|
+
html: '<div><span>Nested span</span><p><em>Emphasis</em></p></div>',
|
|
659
|
+
parentType: 'root'
|
|
660
|
+
});
|
|
661
|
+
// The plugin normalizes based on the entire tree structure
|
|
662
|
+
expect(nestedElements).toHaveLength(1);
|
|
663
|
+
expect(nestedElements[0]).toMatchObject({
|
|
664
|
+
type: 'mdxJsxFlowElement',
|
|
665
|
+
name: 'div',
|
|
666
|
+
children: expect.arrayContaining([
|
|
667
|
+
expect.objectContaining({
|
|
668
|
+
type: 'mdxJsxFlowElement',
|
|
669
|
+
name: 'span'
|
|
670
|
+
}),
|
|
671
|
+
expect.objectContaining({
|
|
672
|
+
type: 'mdxJsxFlowElement',
|
|
673
|
+
name: 'p',
|
|
674
|
+
children: expect.arrayContaining([
|
|
675
|
+
expect.objectContaining({
|
|
676
|
+
type: 'mdxJsxTextElement',
|
|
677
|
+
name: 'em'
|
|
678
|
+
})
|
|
679
|
+
])
|
|
680
|
+
})
|
|
681
|
+
])
|
|
682
|
+
});
|
|
683
|
+
});
|
|
323
684
|
});
|
|
324
685
|
//# sourceMappingURL=html-to-mdx-ast.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-to-mdx-ast.test.js","sourceRoot":"","sources":["../../src/html/html-to-mdx-ast.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EACH,iBAAiB,
|
|
1
|
+
{"version":3,"file":"html-to-mdx-ast.test.js","sourceRoot":"","sources":["../../src/html/html-to-mdx-ast.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EACH,iBAAiB,EACjB,YAAY,GAEf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,iCAAiC;AACjC,MAAM,UAAU,GAAG;IACf,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE;QACjC,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACrD,CAAC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AAC,CAAC,CAAC,CAAA;QACxC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YACtC,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,MAAM;SACf,CAAC,CAAA;QACF,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YACtC,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,KAAK;SACd,CAAC,CAAA;QAEF,0FAA0F;QAC1F,MAAM,cAAc,GAAG,YAAY,CAAC;YAChC,IAAI,EAAE,6DAA6D;YACnE,UAAU,EAAE,MAAM;SACrB,CAAC,CAAA;QAEF,2DAA2D;QAC3D,MAAM,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QACtC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YACpC,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC;gBAC7B,MAAM,CAAC,gBAAgB,CAAC;oBACpB,IAAI,EAAE,mBAAmB;oBACzB,IAAI,EAAE,MAAM;iBACf,CAAC;gBACF,MAAM,CAAC,gBAAgB,CAAC;oBACpB,IAAI,EAAE,mBAAmB;oBACzB,IAAI,EAAE,GAAG;oBACT,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC;wBAC7B,MAAM,CAAC,gBAAgB,CAAC;4BACpB,IAAI,EAAE,mBAAmB;4BACzB,IAAI,EAAE,IAAI;yBACb,CAAC;qBACL,CAAC;iBACL,CAAC;aACL,CAAC;SACL,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -6,5 +6,5 @@ import type { Root } from 'mdast';
|
|
|
6
6
|
* - Elements with block-level tag names → mdxJsxFlowElement
|
|
7
7
|
* - Elements containing non-phrasing children → mdxJsxFlowElement
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export declare function remarkMdxJsxNormalize(): (tree: Root) => void;
|
|
10
10
|
//# sourceMappingURL=remark-mdx-jsx-normalize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-mdx-jsx-normalize.d.ts","sourceRoot":"","sources":["../../src/html/remark-mdx-jsx-normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAgC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"remark-mdx-jsx-normalize.d.ts","sourceRoot":"","sources":["../../src/html/remark-mdx-jsx-normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAgC,MAAM,OAAO,CAAA;AA6I/D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,WACD,IAAI,UAoDvC"}
|
|
@@ -16,6 +16,39 @@ const PHRASE_CONTAINERS = new Set([
|
|
|
16
16
|
'tableCell',
|
|
17
17
|
'mdxJsxTextElement', // MDX JSX text elements should contain phrasing
|
|
18
18
|
]);
|
|
19
|
+
/** HTML tags that require phrasing/inline children */
|
|
20
|
+
const PHRASE_HTML_CONTAINERS = new Set([
|
|
21
|
+
'p',
|
|
22
|
+
'h1',
|
|
23
|
+
'h2',
|
|
24
|
+
'h3',
|
|
25
|
+
'h4',
|
|
26
|
+
'h5',
|
|
27
|
+
'h6',
|
|
28
|
+
'em',
|
|
29
|
+
'strong',
|
|
30
|
+
'b',
|
|
31
|
+
'i',
|
|
32
|
+
'u',
|
|
33
|
+
's',
|
|
34
|
+
'del',
|
|
35
|
+
'ins',
|
|
36
|
+
'mark',
|
|
37
|
+
'small',
|
|
38
|
+
'sub',
|
|
39
|
+
'sup',
|
|
40
|
+
'a',
|
|
41
|
+
'abbr',
|
|
42
|
+
'cite',
|
|
43
|
+
'code',
|
|
44
|
+
'dfn',
|
|
45
|
+
'kbd',
|
|
46
|
+
'q',
|
|
47
|
+
'samp',
|
|
48
|
+
'span',
|
|
49
|
+
'time',
|
|
50
|
+
'var',
|
|
51
|
+
]);
|
|
19
52
|
/** Parents that accept/expect flow (block) content */
|
|
20
53
|
const FLOW_CONTAINERS = new Set([
|
|
21
54
|
'root',
|
|
@@ -47,22 +80,51 @@ const blockLevelTags = new Set([
|
|
|
47
80
|
'div',
|
|
48
81
|
'p',
|
|
49
82
|
'blockquote',
|
|
50
|
-
'h1',
|
|
51
|
-
'
|
|
83
|
+
'h1',
|
|
84
|
+
'h2',
|
|
85
|
+
'h3',
|
|
86
|
+
'h4',
|
|
87
|
+
'h5',
|
|
88
|
+
'h6',
|
|
89
|
+
'ul',
|
|
90
|
+
'ol',
|
|
91
|
+
'li',
|
|
52
92
|
'pre',
|
|
53
93
|
'hr',
|
|
54
|
-
'table',
|
|
55
|
-
'
|
|
56
|
-
'
|
|
94
|
+
'table',
|
|
95
|
+
'thead',
|
|
96
|
+
'tbody',
|
|
97
|
+
'tfoot',
|
|
98
|
+
'tr',
|
|
99
|
+
'th',
|
|
100
|
+
'td',
|
|
101
|
+
'section',
|
|
102
|
+
'article',
|
|
103
|
+
'aside',
|
|
104
|
+
'nav',
|
|
105
|
+
'header',
|
|
106
|
+
'footer',
|
|
107
|
+
'main',
|
|
108
|
+
'figure',
|
|
109
|
+
'figcaption',
|
|
57
110
|
// Notion-specific block elements
|
|
58
111
|
'callout',
|
|
59
|
-
'columns',
|
|
112
|
+
'columns',
|
|
113
|
+
'column',
|
|
60
114
|
'page',
|
|
61
115
|
'database',
|
|
62
116
|
'data-source',
|
|
63
|
-
'audio',
|
|
64
|
-
'
|
|
65
|
-
'
|
|
117
|
+
'audio',
|
|
118
|
+
'video',
|
|
119
|
+
'file',
|
|
120
|
+
'pdf',
|
|
121
|
+
'embed',
|
|
122
|
+
'synced_block',
|
|
123
|
+
'synced_block_reference',
|
|
124
|
+
'meeting-notes',
|
|
125
|
+
'summary',
|
|
126
|
+
'notes',
|
|
127
|
+
'transcript',
|
|
66
128
|
'table_of_contents',
|
|
67
129
|
'unknown',
|
|
68
130
|
'image', // Images can be block-level in Notion
|
|
@@ -74,18 +136,33 @@ const blockLevelTags = new Set([
|
|
|
74
136
|
* - Elements with block-level tag names → mdxJsxFlowElement
|
|
75
137
|
* - Elements containing non-phrasing children → mdxJsxFlowElement
|
|
76
138
|
*/
|
|
77
|
-
export
|
|
139
|
+
export function remarkMdxJsxNormalize() {
|
|
78
140
|
return function transform(tree) {
|
|
79
141
|
visitParents(tree, isMdxJsx, (node, ancestors) => {
|
|
80
142
|
const element = node;
|
|
81
143
|
const parent = ancestors[ancestors.length - 1];
|
|
82
144
|
if (!parent)
|
|
83
145
|
return;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
146
|
+
// Check if parent expects phrasing or flow content
|
|
147
|
+
let parentExpectsPhrasing = false;
|
|
148
|
+
let parentExpectsFlow = false;
|
|
149
|
+
if ((parent.type === 'mdxJsxFlowElement' || parent.type === 'mdxJsxTextElement') &&
|
|
150
|
+
parent.name) {
|
|
151
|
+
// For MDX JSX elements, check the tag name
|
|
152
|
+
const parentTagName = parent.name.toLowerCase();
|
|
153
|
+
parentExpectsPhrasing = PHRASE_HTML_CONTAINERS.has(parentTagName);
|
|
154
|
+
// If not phrasing and is a block-level tag, it expects flow
|
|
155
|
+
parentExpectsFlow = !parentExpectsPhrasing && blockLevelTags.has(parentTagName);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// For mdast nodes, check the type
|
|
159
|
+
parentExpectsPhrasing = PHRASE_CONTAINERS.has(parent.type);
|
|
160
|
+
parentExpectsFlow = FLOW_CONTAINERS.has(parent.type);
|
|
161
|
+
}
|
|
87
162
|
// Check element properties
|
|
88
|
-
const hasBlockTag = element.name
|
|
163
|
+
const hasBlockTag = element.name
|
|
164
|
+
? blockLevelTags.has(element.name.toLowerCase())
|
|
165
|
+
: false;
|
|
89
166
|
const children = (element.children || []);
|
|
90
167
|
const containsNonPhrasing = children.some((c) => !isPhrasing(c));
|
|
91
168
|
// Determine desired type
|
|
@@ -112,6 +189,6 @@ export default function remarkMdxJsxNormalize() {
|
|
|
112
189
|
}
|
|
113
190
|
/** Check if a node is an MDX JSX element */
|
|
114
191
|
function isMdxJsx(node) {
|
|
115
|
-
return node.type === 'mdxJsxTextElement' || node.type === 'mdxJsxFlowElement';
|
|
192
|
+
return (node.type === 'mdxJsxTextElement' || node.type === 'mdxJsxFlowElement');
|
|
116
193
|
}
|
|
117
194
|
//# sourceMappingURL=remark-mdx-jsx-normalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-mdx-jsx-normalize.js","sourceRoot":"","sources":["../../src/html/remark-mdx-jsx-normalize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGvD,mDAAmD;AACnD,yFAAyF;AACzF,8HAA8H;AAC9H,2DAA2D;AAC3D,mEAAmE;AAEnE,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAC9B,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,eAAe;IACf,WAAW;IACX,mBAAmB,EAAE,gDAAgD;CACxE,CAAC,CAAA;AAEF,sDAAsD;AACtD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC5B,MAAM;IACN,UAAU;IACV,YAAY;IACZ,oBAAoB;IACpB,mBAAmB,EAAE,4CAA4C;CACpE,CAAC,CAAA;AAEF,kDAAkD;AAClD,SAAS,UAAU,CAAC,IAAU;IAC1B,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;QAC1B,MAAM;QACN,UAAU;QACV,QAAQ;QACR,QAAQ;QACR,MAAM;QACN,OAAO;QACP,gBAAgB;QAChB,YAAY;QACZ,MAAM;QACN,eAAe;QACf,OAAO;QACP,mBAAmB;KACtB,CAAC,CAAA;IACF,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACvC,CAAC;AAED,mDAAmD;AACnD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC3B,KAAK;IACL,GAAG;IACH,YAAY;IACZ,IAAI,
|
|
1
|
+
{"version":3,"file":"remark-mdx-jsx-normalize.js","sourceRoot":"","sources":["../../src/html/remark-mdx-jsx-normalize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGvD,mDAAmD;AACnD,yFAAyF;AACzF,8HAA8H;AAC9H,2DAA2D;AAC3D,mEAAmE;AAEnE,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAC9B,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,eAAe;IACf,WAAW;IACX,mBAAmB,EAAE,gDAAgD;CACxE,CAAC,CAAA;AAEF,sDAAsD;AACtD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACnC,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,GAAG;IACH,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;IACL,GAAG;IACH,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;CACR,CAAC,CAAA;AAEF,sDAAsD;AACtD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC5B,MAAM;IACN,UAAU;IACV,YAAY;IACZ,oBAAoB;IACpB,mBAAmB,EAAE,4CAA4C;CACpE,CAAC,CAAA;AAEF,kDAAkD;AAClD,SAAS,UAAU,CAAC,IAAU;IAC1B,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;QAC1B,MAAM;QACN,UAAU;QACV,QAAQ;QACR,QAAQ;Q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,mBAAmB,CAAA;aAChC;iBAAM,IAAI,iBAAiB,EAAE;gBAC1B,OAAO,GAAG,mBAAmB,CAAA;aAChC;YAED,6BAA6B;YAC7B,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;gBAC1B,OAAO,CAAC,IAAI,GAAG,OAAO,CAAA;aACzB;QACL,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;AACL,CAAC;AAED,4CAA4C;AAC5C,SAAS,QAAQ,CAAC,IAAU;IACxB,OAAO,CACH,IAAI,CAAC,IAAI,KAAK,mBAAmB,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,CACzE,CAAA;AACL,CAAC"}
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Root } from 'mdast';
|
|
2
|
-
import { parseHtmlToMdxAst } from './html/html-to-mdx-ast.js';
|
|
3
|
-
export { parseHtmlToMdxAst };
|
|
2
|
+
import { parseHtmlToMdxAst, remarkMdxJsxNormalize } from './html/html-to-mdx-ast.js';
|
|
3
|
+
export { parseHtmlToMdxAst, remarkMdxJsxNormalize };
|
|
4
4
|
export declare function mdxParse(code: string): Root;
|
|
5
5
|
/**
|
|
6
6
|
* https://github.com/mdx-js/mdx/blob/b3351fadcb6f78833a72757b7135dcfb8ab646fe/packages/mdx/lib/plugin/remark-mark-and-unravel.js
|
package/dist/parse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAe,MAAM,OAAO,CAAA;AAIzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAe,MAAM,OAAO,CAAA;AAIzC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAEpF,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAA;AAEnD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,QAGpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,WACT,IAAI,UAqE9B"}
|
package/dist/parse.js
CHANGED
|
@@ -4,8 +4,8 @@ import { visit } from 'unist-util-visit';
|
|
|
4
4
|
import { remark } from 'remark';
|
|
5
5
|
import remarkGfm from 'remark-gfm';
|
|
6
6
|
import remarkMdx from 'remark-mdx';
|
|
7
|
-
import { parseHtmlToMdxAst } from './html/html-to-mdx-ast.js';
|
|
8
|
-
export { parseHtmlToMdxAst };
|
|
7
|
+
import { parseHtmlToMdxAst, remarkMdxJsxNormalize } from './html/html-to-mdx-ast.js';
|
|
8
|
+
export { parseHtmlToMdxAst, remarkMdxJsxNormalize };
|
|
9
9
|
export function mdxParse(code) {
|
|
10
10
|
const file = mdxProcessor.processSync(code);
|
|
11
11
|
return file.data.ast;
|
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAs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AAI,EAAE,EAAE;QAClB,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;IACxB,CAAC,CAAA;AACL,CAAC,CAAC,CAAA"}
|
package/dist/safe-mdx.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare class MdastToJsx {
|
|
|
62
62
|
transformJsxElement(jsxElement: JSXElement, onError?: (err: SafeMdxError) => void, line?: number): ReactNode;
|
|
63
63
|
getJsxAttrs(node: MdxJsxFlowElement | MdxJsxTextElement, onError?: (err: SafeMdxError) => void): [string, any][];
|
|
64
64
|
run(): any;
|
|
65
|
-
mdastTransformer(node: MyRootContent): ReactNode;
|
|
65
|
+
mdastTransformer(node: MyRootContent, parentType?: string): ReactNode;
|
|
66
66
|
}
|
|
67
67
|
export declare function mdastBfs(node: Parent | Node, cb?: (node: Node | Parent) => any): any[];
|
|
68
68
|
type ComponentsMap = {
|