|
|
|
|
|
by pvtmert
284 days ago
|
|
Why not using marked.js or equivalent, plugging it with a Fetch API instead? example: <html>
<head><title>hello</title></head>
<body>
<main id=root ></main>
<script src=./marked.min.js async defer ></script>
<script>
async function load() {
let element = document.querySelector("main#root");
await fetch("./index.md")
.then(resp => resp.text())
.then(text => marked(text, { ... }))
.then(html => {
element.innerHTML = html;
});
}
window.onload = load;
</script>
</body>
</html>
since it directly injects the resulting html, you may set "unsafe HTML" option in marked (or markdown.js) and include <title> tags within your markdown document. this will _also_ rewrite the browser title(s)> edit: formatting |
|