Why web browsers don't support Markdown
Markdown is a lightweight markup language for formatting text, but web browsers don't natively support it because they are designed to render HTML, the standard language of the web. While Markdown is popular among developers for writing documentation and notes, browsers leave its conversion to HTML to third-party tools and extensions rather than implementing it directly.
背景メモ
- この記事は「なぜウェブブラウザはMarkdownをネイティブに解釈しないのか」という疑問に答えるもの。著者はブラウザの仕組み(HTML/CSS/JavaScriptのレンダリングエンジン)とMarkdownの位置づけを整理している。
- Markdownは2004年にJohn GruberがAaron Swartzの協力を得て開発した軽量マークアップ言語。プレーンテキストで書き、HTMLに変換して使うのが前提。
- ブラウザが解釈するのはHTML/CSS/JavaScriptだけ。Markdownを表示するには、ライブラリ(例:marked, remark)を使って動的にHTMLに変換するか、静的サイトジェネレーター(例:Jekyll, Hugo, Next.js)で事前変換する必要がある。
- 背景として、2020年代後半になっても「Markdownをそのままブラウザに貼れば表示されるべき」という誤解が一部で根強い。しかしブラウザはMarkdownを「未知のファイル形式」として扱うため、ダウンロード促すか生テキストとして表示する。