3 ms·
I made a comment about how to do this as my very first HN post on this account[1] in a code-golf-y sort of thread: Here's the example: # Markdown header
by BeefWellington 4y ago
I made a comment about how to do this as my very first HN post on this account[1] in a code-golf-y sort of thread:
Here's the example:
# Markdown header
## Subheader
### Section header
1. Numbered
1. List
- Unordered
- List
[//]: # (<html><body></body><script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script><script>var doc = document.children[0].textContent.split('\n'); md = doc.slice(0, doc.length - 1).join("\n"); document.body.innerHTML = marked(md);</script></html><!--)
Now, whether this is wise to encourage or not I can't speak to.
It would be great if browsers parsed markdown as text-only
[1]: https://news.ycombinator.com/item?id=25352385#25355751 https://news.ycombinator.com/item?id=25352385#25355751
- piskerpan 4y agoNice! You don't need the HTML and BODY tags though. I think however this defeats the purpose: yes you're delivering the content as Markdown, but you have to deliver it as `text/html` for it to be rendered, so anyone fetching it can't tell it's Markdown content. Also every document has to have (invisible-ish) HTML junk appended A "better" solution would be a browser that sends the `Accept: text/markdown, text/html` header and a server that serves Markdown only when requested.