render all images in markdown preview
parent
d230167f4d
commit
445b80bd4f
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue