Markdown 预览原理与 GitHub 风格差异
常见方言差异点、净化渲染与表格/任务列表的兼容性。
Markdown renders differently on every platform, and READMEs that look perfect locally can break on GitHub. A good previewer should be the closest faithful stand-in for your target renderer — here is what to check.
The GitHub-flavored core
- Pipe tables with alignment colons — the most broken feature elsewhere.
- Task lists with [x] and [ ] checkboxes.
- Fenced code blocks with triple backticks and a language hint.
- Strikethrough with tildes and autolinks for bare URLs.
The Markdown Previewer covers exactly this core, updates panes in real time and remembers your draft across reloads — handy for writing long READMEs in one sitting.
Sanitization is a feature, not a nuisance
Markdown accepts inline HTML, and pasted HTML can carry script tags. A previewer that executes raw HTML turns a harmless paste into an XSS demo. Strip scripts and escape unknown markup — that is why the preview here silently sanitizes while keeping harmless tags.
Portable markdown checklist
- Prefer fenced code over indented code — indented blocks clash with list nesting.
- Avoid HTML divs inside tables; most renderers disagree there.
- Reference-style links survive renames better than inline URLs.
From markdown to typed code
READMEs often embed JSON examples that later become API types. A quick path: paste the sample into the JSON to TypeScript converter and the interface you document becomes the interface you compile.
相关指南
文中提到的工具
Markdown Previewer
Type Markdown on the left, see the rendered preview on the right — headings, lists, links, code blocks, quotes and emphasis. XSS-safe: everything is escaped first.
Open tool →JSON to TypeScript
Paste JSON and get ready-to-use TypeScript interfaces: nested objects become interfaces, arrays infer element types, keys are PascalCased, invalid keys quoted. Instant and offline.
Open tool →