# Mistune Flavored Markdown - Version: 2019-01-01 - Author: Hsiaoming Yang --- ## Introduction Mistune Flavored Markdown (MFM) is a dialect of Markdown that Mistune 2.0 supported. This document contains the basic Markdown syntax. ### Why Not CommonMark CommonMark has certainly done something right. But there are so many weird rules that made it not Markdown anymore. Mistune 2.0 has taken CommonMark into consideration at the rewriting, there are test cases for CommonMark in the tests folder. While implementing the CommonMark rules, it turns out that John Gruber is right, the name of [Pedantic Markdown](https://twitter.com/gruber/status/507615356295200770) makes sense. > Markdown is a text-to-HTML conversion tool for web writers. Markdown allows > you to write using an easy-to-read, easy-to-write plain text format, then > convert it to structurally valid XHTML (or HTML). > > -- [John Gruber](https://daringfireball.net/projects/markdown/) The most difference among Markdown and other formatting syntax is readability, while cases in CommonMark on the other hand are not. Take the link definition as an example: ``` [foo]: /url ' title line1 line2 ' [foo] ``` Is it easy-to-read? Absolutely no. There are certainly cases that you need multiple lines for a link definition, either the link or the title is too long. The original perl script provided by John Gruber does accept multiple line link definition, but the title will always stay in one line, it looks like: ``` [foo]: /url "title" [foo] ``` ### Why MFM Mistune Flavored Markdown is not a specification. It is not created to enforce other developers to follow these rules. Instead, it is a clarification on how will Mistune render your text. This documentation is mainly based on CommonMark. But it doesn't contain the weird rules that Mistune dislikes. MFM is a guide on how will Mistune render the text in a lot of edge cases. Writers should read the [Style Guide][] instead, you are not supposed to write in those edge cases. [Style Guide]: docs/style-guide.md ## Blocks ### Thematic breaks A line consisting of 0-3 spaces of indentation, followed by a sequence of three or more matching `-`,` _`, or `*` characters, each followed optionally by any number of spaces, forms a thematic break: ```````````````````````````````` example * * * *** ***** - - - --------------------------------------- .
***
````````````````````````````````
Although a thematic break do not need blank lines before or after, it is
still suggested putting blank lines around them.
```````````````````````````````` example
Foo
***
bar
.
Foo
bar
```````````````````````````````` Mistune can convert it correctly, but you **SHOULD NOT** write in this syntax, keeping blank lines around a thematic break is easier to read: ```````````````````````````````` example Foo *** bar .Foo
bar
```````````````````````````````` ### AXT headings [atx]: http://www.aaronsw.com/2002/atx/ AXT headings was created by **Aaron Swartz** in its [atx][] software. Atx-style headers use 1-6 unescaped `#` at the start of the line and followed by a space, corresponding to header levels 1-6: ```````````````````````````````` example # This is an H1 ## This is an H2 ###### This is an H6 .####### foo
```````````````````````````````` At least one space is required between the `#` characters and the heading's contents, unless the heading is empty: ```````````````````````````````` example #5 bolt #hashtag .#5 bolt
#hashtag
```````````````````````````````` This is not a heading, because the first # is escaped: ```````````````````````````````` example \## foo .## foo
```````````````````````````````` One to three spaces indentation are allowed, but it is **NOT SUGGESTED**: ```````````````````````````````` example ### foo ## foo # foo .Foo bar
Bar foo
```````````````````````````````` Instead, you **SHOULD** always keep blank lines around headings like this:: ```````````````````````````````` example Foo bar # baz Bar foo .Foo bar
Bar foo
```````````````````````````````` ### Setext headings Setext-style headings are "underlined" with at least two `=` or `-` characters: ```````````````````````````````` example This is an H1 ============= This is an H2 ------------- .Foo =
```````````````````````````````` Unlike CommonMark, Mistune only allows one line content for a setext-style heading: ```````````````````````````````` example Foo Bar --- .Foo Bar
Foo
Foo
Foo
---
Foo
Foo = =
Foo
```````````````````````````````` ### Lists ```````````````````````````````` example - 1 - 2 - 3 - 4 - 5 - 6 - 7 .> 7