Skip to content

Commit

Permalink
fix bug: enforce proper image src onweru#15
Browse files Browse the repository at this point in the history
Signed-off-by: weru <fromweru@gmail.com>
  • Loading branch information
onweru authored and hupfdule committed May 25, 2023
1 parent cbaad27 commit 25601fd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions assets/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ function wrapEl(el, wrapper) {
function wrapText(text, context, wrapper = 'mark') {
let open = `<${wrapper}>`;
let close = `</${wrapper}>`;
let escapedOpen = `%3C${wrapper}%3E`;
let escapedClose = `%3C/${wrapper}%3E`;
function wrap(context) {
let c = context.innerHTML;
let pattern = new RegExp(text, "gi");
Expand All @@ -121,6 +123,14 @@ function wrapText(text, context, wrapper = 'mark') {
c = c.replaceAll(matchStr, `${open}${matchStr}${close}`);
context.innerHTML = c;
});

const images = elems('img', context);

if(images) {
images.forEach(image => {
image.src = image.src.replaceAll(open, '').replaceAll(close, '').replaceAll(escapedOpen, '').replaceAll(escapedClose, '');
});
}
}
}

Expand Down

0 comments on commit 25601fd

Please sign in to comment.