Last active
October 2, 2023 21:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(() => { | |
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