mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-16 09:02:24 +03:00
fixed #3077
This commit is contained in:
parent
8e7d6e7bad
commit
1a4f6fe8ce
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user