safe-mdx 1.3.6 → 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.map +1 -1
- package/dist/html/html-to-mdx-ast.js +41 -1
- package/dist/html/html-to-mdx-ast.js.map +1 -1
- package/dist/html/html-to-mdx-ast.test.js +277 -3
- package/dist/html/html-to-mdx-ast.test.js.map +1 -1
- package/package.json +1 -1
- package/src/html/html-to-mdx-ast.test.ts +299 -3
- package/src/html/html-to-mdx-ast.ts +49 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-to-mdx-ast.d.ts","sourceRoot":"","sources":["../../src/html/html-to-mdx-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,WAAW,EAAqB,MAAM,OAAO,CAAA;AAUjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAGrE,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAGhC,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,CAAA;AAGlE,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE;IAC7B,IAAI,EAAE,MAAM,CAAA;CACf,KAAK,WAAW,GAAG,WAAW,EAAE,CAAA;AAGjC,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAClB,KAAK,MAAM,CAAA;AAGZ,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChD,cAAc,CAAC,EAAE,cAAc,C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|
|
22
22
|
function defaultConvertAttributeValue({ value, }) {
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
|
+
// Remove common indentation from multi-line text while preserving relative indentation
|
|
26
|
+
function deindent(text) {
|
|
27
|
+
const lines = text.split('\n');
|
|
28
|
+
// Find minimum indentation (excluding empty lines)
|
|
29
|
+
let minIndent = Infinity;
|
|
30
|
+
for (const line of lines) {
|
|
31
|
+
if (line.trim()) {
|
|
32
|
+
const match = line.match(/^(\s*)/);
|
|
33
|
+
if (match) {
|
|
34
|
+
minIndent = Math.min(minIndent, match[1].length);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// If no indentation found, return as is
|
|
39
|
+
if (minIndent === 0 || minIndent === Infinity) {
|
|
40
|
+
return text;
|
|
41
|
+
}
|
|
42
|
+
// Remove common indentation from each line, preserving relative indentation
|
|
43
|
+
return lines
|
|
44
|
+
.map(line => line.slice(minIndent))
|
|
45
|
+
.join('\n');
|
|
46
|
+
}
|
|
25
47
|
// Convert HTML attribute to MDX JSX attribute
|
|
26
48
|
function convertAttribute(attr, tagName, options) {
|
|
27
49
|
let jsxName = convertAttributeNameToJSX(attr.name);
|
|
@@ -110,7 +132,25 @@ function htmlNodeToMdxAst(node, options) {
|
|
|
110
132
|
return [];
|
|
111
133
|
}
|
|
112
134
|
if (isTextNode(node)) {
|
|
113
|
-
|
|
135
|
+
let textValue = node.textContent || '';
|
|
136
|
+
// Skip whitespace-only nodes between elements
|
|
137
|
+
if (!textValue.trim()) {
|
|
138
|
+
const prevSibling = node.previousSibling;
|
|
139
|
+
const nextSibling = node.nextSibling;
|
|
140
|
+
// If between elements and contains newlines, it's likely formatting
|
|
141
|
+
if (textValue.includes('\n') &&
|
|
142
|
+
((prevSibling && isElementNode(prevSibling)) ||
|
|
143
|
+
(nextSibling && isElementNode(nextSibling)))) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
// Otherwise preserve the whitespace (could be intentional space)
|
|
147
|
+
}
|
|
148
|
+
// Always deindent text content
|
|
149
|
+
textValue = deindent(textValue).trim();
|
|
150
|
+
// Skip empty text after processing
|
|
151
|
+
if (!textValue) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
114
154
|
// If we have a textToMdast converter, use it
|
|
115
155
|
if (options?.textToMdast) {
|
|
116
156
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-to-mdx-ast.js","sourceRoot":"","sources":["../../src/html/html-to-mdx-ast.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,iCAAiC;AACjC,OAAO,EAAE,qBAAqB,EAAE,CAAA;AA2BhC,qCAAqC;AACrC,SAAS,aAAa,CAAC,IAAU;IAC7B,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAA,CAAC,oBAAoB;AACnD,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC1B,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAA,CAAC,iBAAiB;AAChD,CAAC;AAED,SAAS,aAAa,CAAC,IAAU;IAC7B,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAA,CAAC,oBAAoB;AACnD,CAAC;AAED,iDAAiD;AACjD,SAAS,qBAAqB,CAAC,EAAE,OAAO,EAAuB;IAC3D,OAAO,OAAO,CAAC,WAAW,EAAE,CAAA;AAChC,CAAC;AAED,wDAAwD;AACxD,SAAS,4BAA4B,CAAC,EAClC,KAAK,GAKR;IACG,OAAO,KAAK,CAAA;AAChB,CAAC;AAED,8CAA8C;AAC9C,SAAS,gBAAgB,CACrB,IAAU,EACV,OAAe,EACf,OAAkC;IAElC,IAAI,OAAO,GAAG,yBAAyB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
|
{
|
|
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
|
`);
|
|
@@ -332,6 +332,280 @@ describe('parseHtmlToMdxAst with markdown processor', () => {
|
|
|
332
332
|
name: 'span'
|
|
333
333
|
});
|
|
334
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
|
+
});
|
|
335
609
|
test('applies normalize plugin with parentType', () => {
|
|
336
610
|
// Test with a block element inside a paragraph (phrasing context)
|
|
337
611
|
const blockInParagraph = htmlToMdxAst({
|
|
@@ -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,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;IACD,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE;QAC/B,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACtD,CAAC;CACJ,CAAA;AAED,yDAAyD;AACzD,KAAK,UAAU,eAAe,CAAC,EAC3B,IAAI,EACJ,aAAa,GAAG,KAAK,E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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"}
|
package/package.json
CHANGED
|
@@ -124,7 +124,7 @@ describe('parseHtmlToMdxAst', () => {
|
|
|
124
124
|
"children": [
|
|
125
125
|
{
|
|
126
126
|
"type": "text",
|
|
127
|
-
"value": "Hello
|
|
127
|
+
"value": "Hello",
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
130
|
"attributes": [],
|
|
@@ -202,7 +202,7 @@ describe('parseHtmlToMdxAst', () => {
|
|
|
202
202
|
[
|
|
203
203
|
{
|
|
204
204
|
"type": "text",
|
|
205
|
-
"value": "Some text
|
|
205
|
+
"value": "Some text",
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
"attributes": [],
|
|
@@ -217,7 +217,7 @@ describe('parseHtmlToMdxAst', () => {
|
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
"type": "text",
|
|
220
|
-
"value": "
|
|
220
|
+
"value": "more text",
|
|
221
221
|
},
|
|
222
222
|
]
|
|
223
223
|
`)
|
|
@@ -376,6 +376,302 @@ describe('parseHtmlToMdxAst with markdown processor', () => {
|
|
|
376
376
|
})
|
|
377
377
|
})
|
|
378
378
|
|
|
379
|
+
test('handles indented HTML without preserving indentation', () => {
|
|
380
|
+
const indentedHtml = `
|
|
381
|
+
<columns>
|
|
382
|
+
<column>
|
|
383
|
+
<page url="https://notion.so/page1">Page 1</page>
|
|
384
|
+
Some text
|
|
385
|
+
</column>
|
|
386
|
+
<column>
|
|
387
|
+
<callout icon="💡" color="yellow_bg">
|
|
388
|
+
Important callout
|
|
389
|
+
</callout>
|
|
390
|
+
</column>
|
|
391
|
+
</columns>`
|
|
392
|
+
|
|
393
|
+
const result = parseHtmlToMdxAst({ html: indentedHtml })
|
|
394
|
+
expect(result).toMatchInlineSnapshot(`
|
|
395
|
+
[
|
|
396
|
+
{
|
|
397
|
+
"attributes": [],
|
|
398
|
+
"children": [
|
|
399
|
+
{
|
|
400
|
+
"attributes": [],
|
|
401
|
+
"children": [
|
|
402
|
+
{
|
|
403
|
+
"attributes": [
|
|
404
|
+
{
|
|
405
|
+
"name": "url",
|
|
406
|
+
"type": "mdxJsxAttribute",
|
|
407
|
+
"value": "https://notion.so/page1",
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
"children": [
|
|
411
|
+
{
|
|
412
|
+
"type": "text",
|
|
413
|
+
"value": "Page 1",
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
"name": "page",
|
|
417
|
+
"type": "mdxJsxTextElement",
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"type": "text",
|
|
421
|
+
"value": "Some text",
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
"name": "column",
|
|
425
|
+
"type": "mdxJsxTextElement",
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"attributes": [],
|
|
429
|
+
"children": [
|
|
430
|
+
{
|
|
431
|
+
"attributes": [
|
|
432
|
+
{
|
|
433
|
+
"name": "icon",
|
|
434
|
+
"type": "mdxJsxAttribute",
|
|
435
|
+
"value": "💡",
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"name": "color",
|
|
439
|
+
"type": "mdxJsxAttribute",
|
|
440
|
+
"value": "yellow_bg",
|
|
441
|
+
},
|
|
442
|
+
],
|
|
443
|
+
"children": [
|
|
444
|
+
{
|
|
445
|
+
"type": "text",
|
|
446
|
+
"value": "Important callout",
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
"name": "callout",
|
|
450
|
+
"type": "mdxJsxTextElement",
|
|
451
|
+
},
|
|
452
|
+
],
|
|
453
|
+
"name": "column",
|
|
454
|
+
"type": "mdxJsxTextElement",
|
|
455
|
+
},
|
|
456
|
+
],
|
|
457
|
+
"name": "columns",
|
|
458
|
+
"type": "mdxJsxTextElement",
|
|
459
|
+
},
|
|
460
|
+
]
|
|
461
|
+
`)
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
test('handles indented HTML with textToMdast', () => {
|
|
465
|
+
const indentedHtml = `
|
|
466
|
+
<div>
|
|
467
|
+
**Bold text** and
|
|
468
|
+
some regular text
|
|
469
|
+
</div>`
|
|
470
|
+
|
|
471
|
+
const receivedTexts: string[] = []
|
|
472
|
+
const textToMdast = ({ text }: { text: string }) => {
|
|
473
|
+
receivedTexts.push(text)
|
|
474
|
+
return [{ type: 'text', value: text } as RootContent]
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const result = parseHtmlToMdxAst({
|
|
478
|
+
html: indentedHtml,
|
|
479
|
+
textToMdast
|
|
480
|
+
})
|
|
481
|
+
|
|
482
|
+
expect(result).toMatchInlineSnapshot(`
|
|
483
|
+
[
|
|
484
|
+
{
|
|
485
|
+
"attributes": [],
|
|
486
|
+
"children": [
|
|
487
|
+
{
|
|
488
|
+
"type": "text",
|
|
489
|
+
"value": "**Bold text** and
|
|
490
|
+
some regular text",
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
"name": "div",
|
|
494
|
+
"type": "mdxJsxTextElement",
|
|
495
|
+
},
|
|
496
|
+
]
|
|
497
|
+
`)
|
|
498
|
+
|
|
499
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
500
|
+
[
|
|
501
|
+
"**Bold text** and
|
|
502
|
+
some regular text",
|
|
503
|
+
]
|
|
504
|
+
`)
|
|
505
|
+
})
|
|
506
|
+
|
|
507
|
+
test('handles multi-line indented text content', () => {
|
|
508
|
+
const htmlWithMultiLineText = `
|
|
509
|
+
<div>
|
|
510
|
+
This is a multi-line string
|
|
511
|
+
that has indentation on each line
|
|
512
|
+
and should be properly de-indented
|
|
513
|
+
|
|
514
|
+
Even with blank lines in between
|
|
515
|
+
it should maintain the structure
|
|
516
|
+
</div>`
|
|
517
|
+
|
|
518
|
+
const receivedTexts: string[] = []
|
|
519
|
+
const textToMdast = ({ text }: { text: string }) => {
|
|
520
|
+
receivedTexts.push(text)
|
|
521
|
+
return [{ type: 'text', value: text } as RootContent]
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const result = parseHtmlToMdxAst({
|
|
525
|
+
html: htmlWithMultiLineText,
|
|
526
|
+
textToMdast
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
expect(result).toMatchInlineSnapshot(`
|
|
530
|
+
[
|
|
531
|
+
{
|
|
532
|
+
"attributes": [],
|
|
533
|
+
"children": [
|
|
534
|
+
{
|
|
535
|
+
"type": "text",
|
|
536
|
+
"value": "This is a multi-line string
|
|
537
|
+
that has indentation on each line
|
|
538
|
+
and should be properly de-indented
|
|
539
|
+
|
|
540
|
+
Even with blank lines in between
|
|
541
|
+
it should maintain the structure",
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
"name": "div",
|
|
545
|
+
"type": "mdxJsxTextElement",
|
|
546
|
+
},
|
|
547
|
+
]
|
|
548
|
+
`)
|
|
549
|
+
|
|
550
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
551
|
+
[
|
|
552
|
+
"This is a multi-line string
|
|
553
|
+
that has indentation on each line
|
|
554
|
+
and should be properly de-indented
|
|
555
|
+
|
|
556
|
+
Even with blank lines in between
|
|
557
|
+
it should maintain the structure",
|
|
558
|
+
]
|
|
559
|
+
`)
|
|
560
|
+
})
|
|
561
|
+
|
|
562
|
+
test('handles multi-line text with markdown', () => {
|
|
563
|
+
const htmlWithMultiLineText = `
|
|
564
|
+
<article>
|
|
565
|
+
# Heading
|
|
566
|
+
|
|
567
|
+
This is a paragraph with **bold** text
|
|
568
|
+
that spans multiple lines and has
|
|
569
|
+
markdown formatting.
|
|
570
|
+
|
|
571
|
+
- List item 1
|
|
572
|
+
- List item 2
|
|
573
|
+
</article>`
|
|
574
|
+
|
|
575
|
+
const receivedTexts: string[] = []
|
|
576
|
+
const textToMdast = ({ text }: { text: string }) => {
|
|
577
|
+
receivedTexts.push(text)
|
|
578
|
+
return [{ type: 'text', value: text } as RootContent]
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const result = parseHtmlToMdxAst({
|
|
582
|
+
html: htmlWithMultiLineText,
|
|
583
|
+
textToMdast
|
|
584
|
+
})
|
|
585
|
+
|
|
586
|
+
expect(result).toMatchInlineSnapshot(`
|
|
587
|
+
[
|
|
588
|
+
{
|
|
589
|
+
"attributes": [],
|
|
590
|
+
"children": [
|
|
591
|
+
{
|
|
592
|
+
"type": "text",
|
|
593
|
+
"value": "# Heading
|
|
594
|
+
|
|
595
|
+
This is a paragraph with **bold** text
|
|
596
|
+
that spans multiple lines and has
|
|
597
|
+
markdown formatting.
|
|
598
|
+
|
|
599
|
+
- List item 1
|
|
600
|
+
- List item 2",
|
|
601
|
+
},
|
|
602
|
+
],
|
|
603
|
+
"name": "article",
|
|
604
|
+
"type": "mdxJsxTextElement",
|
|
605
|
+
},
|
|
606
|
+
]
|
|
607
|
+
`)
|
|
608
|
+
|
|
609
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
610
|
+
[
|
|
611
|
+
"# Heading
|
|
612
|
+
|
|
613
|
+
This is a paragraph with **bold** text
|
|
614
|
+
that spans multiple lines and has
|
|
615
|
+
markdown formatting.
|
|
616
|
+
|
|
617
|
+
- List item 1
|
|
618
|
+
- List item 2",
|
|
619
|
+
]
|
|
620
|
+
`)
|
|
621
|
+
})
|
|
622
|
+
|
|
623
|
+
test('preserves relative indentation when deindenting', () => {
|
|
624
|
+
const htmlWithRelativeIndent = `
|
|
625
|
+
<pre>
|
|
626
|
+
function example() {
|
|
627
|
+
if (true) {
|
|
628
|
+
console.log('nested');
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
</pre>`
|
|
632
|
+
|
|
633
|
+
const receivedTexts: string[] = []
|
|
634
|
+
const textToMdast = ({ text }: { text: string }) => {
|
|
635
|
+
receivedTexts.push(text)
|
|
636
|
+
return [{ type: 'text', value: text } as RootContent]
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const result = parseHtmlToMdxAst({
|
|
640
|
+
html: htmlWithRelativeIndent,
|
|
641
|
+
textToMdast
|
|
642
|
+
})
|
|
643
|
+
|
|
644
|
+
expect(result).toMatchInlineSnapshot(`
|
|
645
|
+
[
|
|
646
|
+
{
|
|
647
|
+
"attributes": [],
|
|
648
|
+
"children": [
|
|
649
|
+
{
|
|
650
|
+
"type": "text",
|
|
651
|
+
"value": "function example() {
|
|
652
|
+
if (true) {
|
|
653
|
+
console.log('nested');
|
|
654
|
+
}
|
|
655
|
+
}",
|
|
656
|
+
},
|
|
657
|
+
],
|
|
658
|
+
"name": "pre",
|
|
659
|
+
"type": "mdxJsxTextElement",
|
|
660
|
+
},
|
|
661
|
+
]
|
|
662
|
+
`)
|
|
663
|
+
|
|
664
|
+
expect(receivedTexts).toMatchInlineSnapshot(`
|
|
665
|
+
[
|
|
666
|
+
"function example() {
|
|
667
|
+
if (true) {
|
|
668
|
+
console.log('nested');
|
|
669
|
+
}
|
|
670
|
+
}",
|
|
671
|
+
]
|
|
672
|
+
`)
|
|
673
|
+
})
|
|
674
|
+
|
|
379
675
|
test('applies normalize plugin with parentType', () => {
|
|
380
676
|
// Test with a block element inside a paragraph (phrasing context)
|
|
381
677
|
const blockInParagraph = htmlToMdxAst({
|
|
@@ -67,6 +67,32 @@ function defaultConvertAttributeValue({
|
|
|
67
67
|
return value
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// Remove common indentation from multi-line text while preserving relative indentation
|
|
71
|
+
function deindent(text: string): string {
|
|
72
|
+
const lines = text.split('\n')
|
|
73
|
+
|
|
74
|
+
// Find minimum indentation (excluding empty lines)
|
|
75
|
+
let minIndent = Infinity
|
|
76
|
+
for (const line of lines) {
|
|
77
|
+
if (line.trim()) {
|
|
78
|
+
const match = line.match(/^(\s*)/)
|
|
79
|
+
if (match) {
|
|
80
|
+
minIndent = Math.min(minIndent, match[1].length)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// If no indentation found, return as is
|
|
86
|
+
if (minIndent === 0 || minIndent === Infinity) {
|
|
87
|
+
return text
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Remove common indentation from each line, preserving relative indentation
|
|
91
|
+
return lines
|
|
92
|
+
.map(line => line.slice(minIndent))
|
|
93
|
+
.join('\n')
|
|
94
|
+
}
|
|
95
|
+
|
|
70
96
|
// Convert HTML attribute to MDX JSX attribute
|
|
71
97
|
function convertAttribute(
|
|
72
98
|
attr: Attr,
|
|
@@ -170,7 +196,29 @@ function htmlNodeToMdxAst(
|
|
|
170
196
|
}
|
|
171
197
|
|
|
172
198
|
if (isTextNode(node)) {
|
|
173
|
-
|
|
199
|
+
let textValue = node.textContent || ''
|
|
200
|
+
|
|
201
|
+
// Skip whitespace-only nodes between elements
|
|
202
|
+
if (!textValue.trim()) {
|
|
203
|
+
const prevSibling = node.previousSibling
|
|
204
|
+
const nextSibling = node.nextSibling
|
|
205
|
+
|
|
206
|
+
// If between elements and contains newlines, it's likely formatting
|
|
207
|
+
if (textValue.includes('\n') &&
|
|
208
|
+
((prevSibling && isElementNode(prevSibling)) ||
|
|
209
|
+
(nextSibling && isElementNode(nextSibling)))) {
|
|
210
|
+
return []
|
|
211
|
+
}
|
|
212
|
+
// Otherwise preserve the whitespace (could be intentional space)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Always deindent text content
|
|
216
|
+
textValue = deindent(textValue).trim()
|
|
217
|
+
|
|
218
|
+
// Skip empty text after processing
|
|
219
|
+
if (!textValue) {
|
|
220
|
+
return []
|
|
221
|
+
}
|
|
174
222
|
|
|
175
223
|
// If we have a textToMdast converter, use it
|
|
176
224
|
if (options?.textToMdast) {
|