Last active
May 29, 2023 18:39
-
-
Save tesla3327/676d480473f2611f7354209a6fde0ba6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Run in the console to inline all code block styles before | |
* copy + pasting into ConvertKit in HTML mode | |
*/ | |
const CSS_PROPERTIES = [ | |
'background-color', | |
'font-size', | |
'color', | |
]; | |
const arr = document.querySelectorAll('pre, pre *'); | |
arr.forEach(el => { | |
// Grab computed styles | |
const styles = getComputedStyle(el); | |
// Generate inline style and apply | |
el.style = CSS_PROPERTIES.reduce((prev, next) => { | |
prev += `${next}: ${styles.getPropertyValue(next)}; color-scheme: only light;` | |
return prev; | |
}, ''); | |
}); | |
let html = document.querySelector('.content').innerHTML; | |
// Escape interpolation | |
html = html.replaceAll('{{', '{% raw %}{{'); | |
html = html.replaceAll('}}', '}}{% endraw %}'); | |
console.log(html); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment