5 ms·
Ask HN: Why don't web browsers render Markdown yet?
- theandrewbailey 4y agoBecause 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/ 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.
- brantonb 4y agoThe alt text on that XKCD has aged so well.
- chrisseaton 4y ago> Because web browsers are supposed to render HTML, not markdown. Ok but they could also render Markdown. > When presented with a file full of markdown, how should the browser present it? Render it on the screen. > Black text on white? Opposite? Something else? ... The browser can pick a sensible default, just like it does with HTML. How do you think GitHub manages to render Markdown? It picks a sensible default. > That's not considering the dozens of flavors of markdown Send the flavour in the MIME type. (Not sure we have MIME types for different flavours, but we could do that.)
- izietto 4y ago> Because web browsers are supposed to render HTML, not markdown. Well, they render HTML, XML, XSLT, plain text, images, videos, even PDF nowadays
- deleted 4y ago[deleted]
- yellowapple 4y agoRe: presentation and styling, Firefox's Reader Mode seems like a sensible approach.
- jscheel 4y agoCheck 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/ https://gemini.circumlunar.space/
- deleted 4y ago[deleted]
- aliqot 4y agoThis discussion is about rendered text on the normal web in a normal browser when arriving at an .md doc.
- jscheel 4y agoFor sure, I think other people answered that pretty fully. Was just showing you a cool little protocol where they decided markdown was the format of choice.
- zen21 4y agoGemtext isn’t markdown at all. That was an intentional decision. The Lagrange Gemini browser does render markdown as well as gemtext, but that’s a non-standard feature.
- jscheel 4y agoyeah, I mean, fair, it's markdown-adjacent I guess
- aliqot 4y agoIm already on gemini and gopher, thanks. A browser renders all types of things from PDFs to MIDI, markdown doesn't present a hurdle.
- thomascgalvin 4y agoA 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.
- Schroedingersat 4y ago> Github? Pandoc? The OG from Daring Fireball? The most popular one that doesn't do something extremely stupid, with a piece of version info in the http header mime type in case it's a mistake. > You'd also probably need an extension to Markdown that links it to a style sheet, so there's yet another dialect. Absolutely not. Let the user have a local style sheet to render it how they want with 1-4 sensible defaults much like FF reader mode. > And then you'll want metadata, so ... which format do you support? Hugo's? Jekyll's? Something else? None of the above. Just the markdown. > Turning Markdown into HTML is (often) trivial. Turning it into a web page is often not. Don't turn it into a webpage then, we already have those. Just render some markdown.
- v3ss0n 4y agoCommonmark is most proper specs
- jeffreportmill1 4y agoIsn't there a simple way to pair a markdown file with an html/JS file so that the md file is rendered? Myfile.html: <script>loadMarkDownFile()</script> Myfile.md: ## Markdown in the browser!
- WorldMaker 4y agodocsify [1] takes that approach. It's a tiny HTML file with a chunky JS script that fetches Markdown files and renders them. It doesn't work if JS is turned off and it's probably less accessible than if the browser natively understood Markdown, but it is an approach to building documentation sites. [1] https://docsify.js.org/ https://docsify.js.org/
- deafpolygon 4y agoIt 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?
- x86hacker1010 4y agoActually, yes. Why not?
- kesava 4y agoI mean - one could argue they should render word and ppt documents as well. What are the trade-offs should be the question, dont you think?
- WorldMaker 4y agoThey all render PDF today. Word and PowerPoint aren't that wild after PDF.
- deafpolygon 4y agoWell, I'm sure we can turn our browser into an operating system[1]? [1]https://www.google.com/chromebook/chrome-os/ https://www.google.com/chromebook/chrome-os/
- duped 4y agoI'd love if browsers could render TeX
- deleted 4y ago[deleted]
- xyzsparetimexyz 4y agoThere are addons for this: https://addons.mozilla.org/en-US/firefox/addon/markdown-viewer-chrome/ https://addons.mozilla.org/en-US/firefox/addon/markdown-view... as well as rss: https://addons.mozilla.org/en-US/firefox/addon/rsspreview/ https://addons.mozilla.org/en-US/firefox/addon/rsspreview/
- aliqot 4y agoThanks sparetime. Edit: The markdown extension did not function as intended.
- wmil 4y agoOne 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.
- Josh5 4y agoWhat? How could rendered markdown get used for XSS?
- rtev 4y agoMarkdown has been a popular vector for XSS in the past due to the more esoteric media embedding features it has.
- kazinator 4y agoAnd so ... if a given markdown author finds that some commoly used browsers don't render things the way they want (or a different subset of browser does the right thing when they fiddle with the markdown, never reaching a happy consensus), they will just throw up their arms and use their mardown->HTML converter of choice.
- 6510 4y agoBack 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.
- hinkley 4y agoThe sort of stagnation we are seeing is IMO caused by the fact that being original and subversive involved finding new 'places' to try out new ideas, where the community is small and more amenable to trying random things out to see what happens. Systems like Mastodon and IPFS should be trying out new structures and new protocols. In particular IPFS, because it's content without a server.
- preordained 4y agoHave to agree there. But the purpose is HTML, PDF is a historical artifact (or list your reason why that should make sense and not this...), blah blah. People can come up with some very interesting ideas about why something unnatural is great (WASM and the nutty ideas some have about that) and why something like supporting an extremely popular static doc format is "out there".
- ironmagma 4y agoAre browsers not already complex enough?
- kazinator 4y agoBrowser 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.