Unclaimed project
Are you a maintainer of md4w? Claim this project to take control of your public changelog and roadmap.
By implementing a html renderer in Zig, we removed the dependency on md4c-html.c and some libc functions. The compiled wasm binary is now 50% smaller (from 98KB to 52KB).
Since we are now using a custom html renderer, we can also add some features that are not supported by md4c-html.c, such as:
'# Hello World!' -> <h1>Hello World! <a class="anchor" id="hello-world" href="#hello-world"></h1>
import { mdToReadableHtml } from "md4w";
const largeMarkdown = `# Hello, World!\n`.repeat(1_000_000);
const readable = mdToReadableHtml(largeMarkdown);
// write to file
const file = await Deno.open("/foo/bar.html", { write: true, create: true });
readable.pipeTo(file.writable);
// or send to client
const response = new Response(readable, {
headers: { "Content-Type": "text/html" },
});
setCodeHighlighter function to add any code highlighter you like.
import { setCodeHighlighter } from "md4w";
setCodeHighlighter((code, lang) => {
return `<pre><code class="language-js"><span style="color:#green">...<span></code></pre>`;
});