Markdown mode
Typeset the prose of a CommonMark or MDX document, leaving code, links, HTML and frontmatter exactly as written.
markdown mode parses a Markdown document and runs the rules over its prose: paragraphs, headings, list items, table cells and the text of links. Code, link destinations, raw HTML and the frontmatter block are skipped and come back byte for byte.
It has one required option, dialect, because "Markdown" is not one language. It has one optional option, frontmatterKeys, which opens named fields of the frontmatter block to the rules.
Examples #
Input
Output
The heading and the paragraph are typeset. The link text is prose and is typeset; the link destination and its title are not. The code span is skipped whole.
A fenced block is skipped including its info string and fences:
Input
Output
Quotation marks and nesting across markup #
The prose of a document is read as one text, not paragraph by paragraph and not node by node. Emphasis, links and inline code in the middle of a sentence do not break a quotation in two, and a straight quote next to a code span is not mistaken for one that touches it. See Span model.
Input
Output
What the mode needs from you #
- A dialect.
dialecthas no default and is never detected. Omitting it throwsPOLYTYPO_INVALID_DIALECT. See Dialects. - Nothing else. GFM (tables, strikethrough, task lists, autolink literals) is on in both dialects.
Pages in this section #
- Dialects:
commonmarkandmdx, and why the library never guesses - Frontmatter: the skipped block,
frontmatterKeys, and how the block is located - Skip list: everything the mode leaves alone
- MDX: JSX, expressions and parse errors
Related #
- HTML mode: the skip list inline HTML follows
- MDX content guide
- Error codes
Normative text: spec/rules/modes.md (§3.7).