Skip to content

Commit db12ff4

Browse files
committed
fix: Fix html tag error.
1 parent a35457c commit db12ff4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,20 @@ export default React.forwardRef<MarkdownPreviewRef, MarkdownPreviewProps>((props
7979
[rehypeAttrs, { properties: 'attr' }],
8080
...(other.rehypePlugins || []),
8181
];
82+
const customProps: MarkdownPreviewProps = {
83+
allowElement: (element, index, parent) => {
84+
if (other.allowElement) {
85+
return other.allowElement(element, index, parent);
86+
}
87+
return /^[A-Za-z0-9]+$/.test(element.tagName);
88+
},
89+
};
8290
const remarkPlugins = [...(other.remarkPlugins || []), gfm];
8391
return (
8492
<div ref={mdp} onScroll={onScroll} onMouseOver={onMouseOver} {...warpperElement} className={cls} style={style}>
8593
<ReactMarkdown
8694
{...other}
95+
{...customProps}
8796
rehypePlugins={pluginsFilter ? pluginsFilter('rehype', rehypePlugins) : rehypePlugins}
8897
remarkPlugins={pluginsFilter ? pluginsFilter('remark', remarkPlugins) : remarkPlugins}
8998
children={source || ''}

0 commit comments

Comments
 (0)