render all images in markdown preview

pull/138/head
Aevann 2023-03-07 03:52:02 +02:00
parent d230167f4d
commit 445b80bd4f
1 changed files with 7 additions and 0 deletions

View File

@ -29,6 +29,11 @@ marked.use({
const reDisableBeforeUnload = /^\/submit|^\/h\/[a-zA-Z0-9_\-]{3,20}\/submit/;
const image_regex_extensions = document.getElementById('IMAGE_FORMATS').value.replaceAll(',', '|')
const regex_pattern = String.raw`(^|\s)(https:\/\/[\w\-.#&/=\?@%;+,:]{5,250}(\.|\?format=)(` + image_regex_extensions + String.raw`)((\?|&)[\w\-.#&/=\?@%;+,:]*)?)($|\s)`
console.log(regex_pattern)
const compiled_regex = new RegExp(regex_pattern, "g");
function markdown(t) {
let input = t.value;
@ -90,6 +95,8 @@ function markdown(t) {
}
}
input = input.replace(compiled_regex, '$1\n\n![]($2)\n\n')
input = marked(input)
const preview = document.getElementById(t.dataset.preview)