Yesss, finally a use-case for the `<noframes>`-hack! This is actually even better than the approach of OP since we're guaranteed to get a plain text representation of the text (instead of the browser parsing it as HTML).
example.html:
<script src="mdpage.js"></script><noframes>
# Header
Welcome to my simplest site
- A
- awesome
- list
mdpage.js:
document.write("<div id=main></div>");
document.addEventListener("DOMContentLoaded", function() {
var script = document.createElement('script');
script.src = "https://unpkg.com/showdown";
document.head.appendChild(script);
var noframes = document.querySelector('noframes');
script.onload = function() {
var converter = new showdown.Converter({
emoji: true,
underline: true,
})
converter.setFlavor('github')
main.innerHTML = converter.makeHtml(noframes.textContent)
};
});
Thanks @judofyr + @matt-tingen. I just updated it to use the 'noscript' opening tag. Good idea, and solved my normal html not working problem! Thanks a bunch!
example.html:
mdpage.js: