Skip to content

Instantly share code, notes, and snippets.

@mickael-kerjean
Last active November 23, 2020 22:28
Show Gist options
  • Save mickael-kerjean/125af43f5d3a17afd8c1f9e5e453dc19 to your computer and use it in GitHub Desktop.
Save mickael-kerjean/125af43f5d3a17afd8c1f9e5e453dc19 to your computer and use it in GitHub Desktop.
markdown self render
function addLinkToHead(url) {
let $link = document.createElement("link")
$link.setAttribute("rel", "stylesheet")
$link.setAttribute("href", url)
document.head.appendChild($link)
}
function addScriptToHead(url) {
let $script = document.createElement("script")
$script.setAttribute("src", url)
document.head.appendChild($script)
}
function addToHead(stuff){
document.head.innerHTML = document.head.innerHTML + stuff
}
addToHead(`<style class="fallback">body{visibility:hidden}</style>`)
addToHead(`<style>
body{
color: #465862;
background: #FDFCFB;
font-size: 18px;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif
}
.md div.title, .md h1, .md h2, .md h3, .md h4{
border-bottom: none;
font-family: Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Droid Sans,Helvetica Neue,Fira Sans,sans-serif;
color: #0c1e29;
font-size: 1.4rem;
font-weight: 600;
}
.md div.title{ font-weight: 700; font-size: 2.2rem; }
.md h1{ font-size: 1.8rem; }
.md h1:before, .md h2:before, .md h3:before{ content: ""; margin-right: 0; }
.md a{ font-family: inherit; }
.markdeepFooter{ display: none; }
</style>`)
addScriptToHead(`https://morgan3d.github.io/markdeep/latest/markdeep.min.js`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment