Skip to content

Instantly share code, notes, and snippets.

@DV8FromTheWorld
Last active October 2, 2023 21:37
Show Gist options
  • Save DV8FromTheWorld/790fd105f6b3325af88d2a242270b252 to your computer and use it in GitHub Desktop.
Save DV8FromTheWorld/790fd105f6b3325af88d2a242270b252 to your computer and use it in GitHub Desktop.
The follow script is intended as a browser bookmark and will replace all ![image](...) markdown in a github PR with the HTML <img src=...> versions instead. This is helpful when setting up big tables of images
;(() => {
const el = document.querySelector('[name="pull_request[body]"]');
const markdownImageRegex = /!\[.*?\]\((.*?)\)/gm;
window.__PREVIOUS_PR_CONTENT = el.value;
const newVal = el.value.replaceAll(markdownImageRegex, (match, url) => `<img width="450" src="${url}">`);
el.value = newVal;
alert("Replacements complete. Preview content available in window.__PREVIOUS_PR_CONTENT");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment