UNPKG

@kiwicom/smart-faq

Version:

Smart FAQ

26 lines (20 loc) 554 B
// @flow import React from 'react'; import MarkdownIt from 'markdown-it'; const md = MarkdownIt({ html: true, linkify: true, typographer: true, }).disable('code'); type Props = { children: ?string, }; const renderMarkdown = markdown => { const domString = md.render(markdown); return domString.replace(/<a href=/g, '<a target="_blank" href='); }; const Markdown = (props: Props) => ( // eslint-disable-next-line react/no-danger <div dangerouslySetInnerHTML={{ __html: renderMarkdown(props.children) }} /> ); export default Markdown;