UNPKG

@kiwicom/smart-faq

Version:

Smart FAQ

29 lines (23 loc) 598 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 className="SmartFAQMarkdownField" dangerouslySetInnerHTML={{ __html: renderMarkdown(props.children) }} /> ); export default Markdown;