Hacker News new | ask | show | jobs
by aylmao 565 days ago
On the note of embedding HTML in Markdown, I think it'd be cool if it were just as easy to embed Markdown in HTML. Something akin to a <markdown> tag.

Markdown makes it easy to write formatted content at the cost of initial compiler setup, HTML is 0-cost setup but takes some effort to write formatted content. With a <markdown> tag one could start with vanilla HTML at zero cost, use all its features straight away, but not have to type HTML for the simple, "content" parts of a site.

EDIT: there seem to be web components for this already:

- https://github.com/xan105/web-component-markdown

- https://www.webcomponents.org/element/zero-md

- https://www.webcomponents.org/element/@vanillawc/wc-markdown

3 comments

Take a look at https://www.tducret.com/pure-markdown It's just a single JS script import, and then plain Markdown. You can host it as-is, no build required (à la Jekyll, Hugo...).

You can verify the content with : curl https://www.tducret.com/pure-markdown/

That sounds like a good idea, until you remember that there is no officially agreed upon markdown spec. For content authors it'd be both fantastic if browsers could just go "you guys go fight it out, we're just gonna go with GitHub flavored markdown" but at the same time for browser makers that's taking a position on something that they have no stake in.

So writing or using someone else's custom element is pretty much your only option here.

There is a Markdown spec: https://commonmark.org

Although of course in practice, commonmark renderers are not plentiful or up to date. In my experience, most library authors end up just implementing the bits of Markdown they care about and the behavior they prefer for the ambiguous parts.

There are multiple markdown specs. This is one of them, probably the most well-known, but certainly not the only one.
“This is my Markdown. There are many like it but this one is mine.”
yeah, I wasn't hypothesizing this as something that should be added natively to browsers. Web is complicated enough officially supporting 3 languages (or 6, if you consider wasm, webgl and wgsl)

Though for what its worth, "no official agreed upon spec" didn't stop browsers before haha

It will probably never happen, because the browser would need to translate to HTML anyway, before rendering it. At that point it could simply be done beforehand on the server, not putting more tasks onto the browser and adding the complexities of HTML inside md inside HTML inside md ... and so on.