This commit is contained in:
u-e 2018-12-28 13:33:27 +03:00
parent 8e7d6e7bad
commit 1a4f6fe8ce

View File

@ -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 = /(<img[^>]*>)/g;
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/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];