Lurker News

Comments (1) 1 thread

hakanserce#
Hi HN, I'm Hakan. I've been building CompMD, a Markdown flavor with components, layout and data, and I'd love your feedback on it.

The constraint I started from: a CompMD file has to read well in any plain Markdown renderer, on GitHub, in your editor, in a diff. Components are lines like "::: grid" and ":: rating[4 of 5]{value=4}". Where they aren't supported, those lines show as text and the content between them still reads in order. In a CompMD renderer the same file becomes a page with layout, lists made from data (CSV, JSON or the frontmatter), inputs, and components written in JS, React or Svelte.
A few things that may be interesting:
- There's a spec (https://compmd.dev/spec/), with conformance tests, so other implementations are possible. It's a draft for now.
- Components run sandboxed. The host, not the document, gives each component its trust level; untrusted ones run in a cross-origin iframe with a strict content security policy. Remote images and data ask the reader first, unless the host allows them.
- The processor is written in Rust and compiled to WebAssembly for the browser. Around it: a renderer and sandbox, a Vite plugin, a Tauri plugin, and a small static blog generator (@compmd/blog), which the intro post is built with.
- Compared with MDX: MDX puts JSX in Markdown and runs it with full trust at build time. CompMD keeps the file readable as plain text and treats components as untrusted by default.
Try it in the playground, which has many examples you can edit live: https://compmd.dev/playground/
The intro post: https://compmd.dev/blog/hello-world/
The code (MIT) and the spec (CC BY 4.0): https://github.com/comp-markdown/compmd
It's early: version 0.9, and the spec is still a draft. Editor support (a language server, Neovim/Helix/Emacs, VS Code) and more component packs are what I'm working on next. I'd especially like to hear from people who write a lot of Markdown or build tools that render it: what's missing, what's confusing, and where it falls apart.

All comments shown.