HACKER Q&A
📣 aliqot

Why don't web browsers render Markdown yet?


Why don't web browsers render Markdown yet?


  👤 theandrewbailey Accepted Answer ✓
Because web browsers are supposed to render HTML, not markdown.

When presented with a file full of markdown, how should the browser present it? As a webpage? PDF? Plain text? Something else?

Once that format is chosen, markdown doesn't have any way to control that presentation. Black text on white? Opposite? Something else? How wide should paragraphs be? Each author and page has different preferences and requirements.

That's not considering the dozens of flavors of markdown, each with their own extensions, features, and subtle edge cases. See XKCD on standards: https://xkcd.com/927/

20 years ago, people were trying to make web pages out of XML. It didn't catch on. Markdown, likewise, has some pretty obvious pitfalls and feature deficiencies compared to HTML.


👤 wmil
One of the strongpoints of Markdown is that the browser doesn't do anything with it. Therefore it's safe to just send it to the client.

If browsers started supporting Markdown then they'd inevitably extend it with autoloading resources. This would lead to Markdown XSS attacks. This would lead to developers needing to sanitize all markdown from untrusted sources, as well as scanning blocks of text for inline markdown that could cause problems.

That sounds like a stretch, but it's a well worn path.


👤 deafpolygon
It already does. In plain-text.

Which is already the correct thing to do. It's a plain-text format, and browsers shouldn't be in the business of figuring how to render MarkDown.

What's next? AsciiDoc? LaTex?



👤 kazinator
Browser developers should love Markdown because it's ill-defined, and so they could go to town trying to detect which quirks flags to enable for a given piece of Markdown that doesn't identify what version of Markdown it's using.

Would there be syntax highlighting?

   ```c
   int main(void) { }
   ```
The more RAM and modules required to render a page, the merrier!

How about styling? People style the results of markdown by targetting the HTML conversion with CSS. So you're going to have to define a correspondence between markdown and the DOM in order to do that.


👤 jeffreportmill1
Isn't there a simple way to pair a markdown file with an html/JS file so that the md file is rendered?

Myfile.html:

Myfile.md: ## Markdown in the browser!


👤 thomascgalvin
A big part of that, I think, is which flavor of Markdown? Github? Pandoc? The OG from Daring Fireball?

You'd also probably need an extension to Markdown that links it to a style sheet, so there's yet another dialect.

And then you'll want metadata, so ... which format do you support? Hugo's? Jekyll's? Something else?

Turning Markdown into HTML is (often) trivial. Turning it into a web page is often not.


👤 6510
Back when everything was a new idea such things would have been obvious. Now we act more like everything is set in stone.

I don't like markdown or wikicode but browsers accepting a document format (any format) that is just a static document would be great.


👤 ironmagma
Are browsers not already complex enough?

👤 jscheel
Check out The Gemini protocol. It is based on “gemtext” which is a flavor of markdown. The browser is responsible for determining how to render it. https://gemini.circumlunar.space/