@readme/markdown 14.11.5 → 14.12.1
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/components/HTMLBlock/index.tsx +12 -10
- package/dist/main.js +1901 -1777
- package/dist/main.node.js +1894 -1770
- package/dist/main.node.js.map +1 -1
- package/dist/processor/plugin/hard-breaks.d.ts +13 -0
- package/dist/processor/transform/mdxish/components/mdx-blocks.d.ts +4 -0
- package/dist/processor/transform/mdxish/components/utils.d.ts +13 -1
- package/dist/processor/transform/mdxish/indentation.d.ts +19 -0
- package/dist/processor/transform/mdxish/mdxish-html-blocks.d.ts +7 -6
- package/dist/processor/transform/mdxish/normalize-closing-tag-whitespace.d.ts +13 -0
- package/dist/render-fixture.node.js +1829 -1705
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +2 -3
|
@@ -21,16 +21,12 @@ interface Props {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const HTMLBlock = ({ children = '', html: htmlProp, runScripts, safeMode: safeModeRaw = false }: Props) => {
|
|
24
|
-
// Determine HTML source: MDXish uses html prop (from HAST), MDX uses children
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw new TypeError('HTMLBlock: children must be a string');
|
|
31
|
-
}
|
|
32
|
-
html = children;
|
|
33
|
-
}
|
|
24
|
+
// Determine HTML source: MDXish uses html prop (from HAST), MDX uses children.
|
|
25
|
+
// A non-string child (no html prop) can't be injected as raw HTML — see the
|
|
26
|
+
// fail-soft fallback below.
|
|
27
|
+
const htmlSource = htmlProp !== undefined ? htmlProp : children;
|
|
28
|
+
const nonStringChildren = typeof htmlSource !== 'string';
|
|
29
|
+
const html: string = nonStringChildren ? '' : htmlSource;
|
|
34
30
|
|
|
35
31
|
// eslint-disable-next-line no-param-reassign
|
|
36
32
|
runScripts = typeof runScripts !== 'boolean' ? runScripts === 'true' : runScripts;
|
|
@@ -45,6 +41,12 @@ const HTMLBlock = ({ children = '', html: htmlProp, runScripts, safeMode: safeMo
|
|
|
45
41
|
if (typeof window !== 'undefined' && typeof runScripts === 'boolean' && runScripts) exec();
|
|
46
42
|
}, [runScripts, exec]);
|
|
47
43
|
|
|
44
|
+
if (nonStringChildren) {
|
|
45
|
+
// Fail soft: a non-string child (e.g. JSX that wasn't serialized back to a
|
|
46
|
+
// raw string) should never throw, so render the child nodes directly
|
|
47
|
+
return <div className="rdmd-html">{children}</div>;
|
|
48
|
+
}
|
|
49
|
+
|
|
48
50
|
if (safeMode) {
|
|
49
51
|
return (
|
|
50
52
|
<pre className="html-unsafe">
|