diff --git a/src/utils/markdownToHtml.js b/src/utils/markdownToHtml.js index f1b57096d..75b81a125 100644 --- a/src/utils/markdownToHtml.js +++ b/src/utils/markdownToHtml.js @@ -20,6 +20,7 @@ const markdownImageRegex = /!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g; const urlRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/gm; const aTagRegex = /(<\s*a[^>]*>(.*?)<\s*[/]\s*a>)/g; const imgTagRegex = /(]*>)/g; +const iframeRegex = /(?:]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g; export const markDown2Html = (input) => { if (!input) { @@ -67,6 +68,10 @@ export const markDown2Html = (input) => { output = changeMarkdownImage(output); } + if (iframeRegex.test(output)) { + output = handleIframe(output); + } + if (linkRegex.test(output)) { output = handleLinks(output); } @@ -199,6 +204,17 @@ const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => { return link; }); +const handleIframe = input => input.replace(iframeRegex, (link) => { + const match = link.match(linkRegex); + + if (match && match[0]) { + + return iframeBody(match[0]); + } + + return link; +}); + const createDtubeIframe = input => input.replace(dTubeRegex, (link) => { const execLink = dTubeRegex.exec(link); const dTubeMatch = link.match(dTubeRegex)[0];