### Processing instruction example Source: https://spec.commonmark.org/0.31.2/changes.html Example showing that processing instructions are parsed as raw HTML. The output includes the processing instruction as-is. ```markdown foo .
foo
``` -------------------------------- ### Shortcut reference link example Source: https://spec.commonmark.org/0.31.2/changes.html Shows that `[foo]` is equivalent to `[foo][]` when a matching link reference definition exists. The example defines `[foo]: /url "title"` and renders the link with the title. ```markdown [foo] [foo]: /url "title" . ``` -------------------------------- ### AsciiDoc example from the AsciiDoc manual Source: https://spec.commonmark.org/0.31.2/changes.html A sample of AsciiDoc syntax showing a list item with a continuation and an indented block. The example is used to illustrate the readability of Markdown compared to AsciiDoc. ```asciidoc 1. List item one. + List item one continued with a second paragraph followed by an Indented block. + ................. ``` -------------------------------- ### Autolink with backtick example (https variant) Source: https://spec.commonmark.org/0.31.2/changes.html Same as the previous example but using https:// instead of http://. Demonstrates that the backtick is still literal in the autolink. ```markdownfoo baz bim
```
--------------------------------
### List interrupt example: paragraph with numbers
Source: https://spec.commonmark.org/0.31.2/changes.html
Demonstrates that a list starting with '1' can interrupt a paragraph, but other numbers cannot. The input 'The number of windows...' followed by '14. The number of doors is 6.' is treated as a single paragraph.
```markdown
The number of windows in my house is
14. The number of doors is 6.
.
```
```html
The number of windows in my house is 14. The number of doors is 6.
``` -------------------------------- ### Tab after heading marker (example 10) Source: https://spec.commonmark.org/0.31.2/spec.json Example 10: A heading with a tab after the #. The tab is expanded to 4 spaces, so the heading is rendered normally. ```markdown # Foo ``` ```html[foohttps://example.com/?search=][ref]
``` -------------------------------- ### URI autolink with query parameters Source: https://spec.commonmark.org/0.31.2/changes.html Demonstrates a URI autolink with query parameters. The example `http://foo.bar.baz/test?q=hello&id=22&boolean
``` -------------------------------- ### Example: Neither left nor right-flanking delimiter runs Source: https://spec.commonmark.org/0.31.2/changes.html Shows that delimiter runs that are neither left- nor right-flanking do not open or close emphasis. ```markdown abc *** def a _ b ``` -------------------------------- ### Tabs in code block with Unicode (example 3) Source: https://spec.commonmark.org/0.31.2/spec.json Example 3: A code block with tabs and Unicode characters. The tabs are expanded to 4 spaces, so the output shows the content without leading tabs. ```markdown a a ὐ a ``` ```htmla a
ὐ a
```
--------------------------------
### Backslash before backslash (example 15)
Source: https://spec.commonmark.org/0.31.2/spec.json
Example 15: A backslash before a backslash produces a literal backslash, and the following asterisk is not escaped, so emphasis is applied.
```markdown
\\*emphasis*
```
```html
\emphasis
``` -------------------------------- ### Backslash hard line break (example 16) Source: https://spec.commonmark.org/0.31.2/spec.json Example 16: A backslash at the end of a line produces a hard line break. ```markdown foo\ bar ``` ```htmlfoo
bar
foo baz bim
```
--------------------------------
### Disallow link destination beginning with `<`
Source: https://spec.commonmark.org/changelog.txt
Example showing that a link destination cannot begin with `<` unless it is inside `<..>`. The reference link definition `[foo]: [foo]:
[foo]
``` -------------------------------- ### Markdown example: ordered list with sublist and right-aligned markers Source: https://spec.commonmark.org/0.31.2/changes.html Shows a Markdown ordered list with a sublist, illustrating the question of whether list markers can be indented and whether ordered list markers can be right-aligned. The example is from the section discussing question 5. ```markdown ``` markdown 1. one - a - b 2. two ``` ``` -------------------------------- ### Emphasis parsing example: nested parentheses Source: https://spec.commonmark.org/changelog.txt Example showing improved emphasis parsing around punctuation, where a delimiter clump with punctuation to the left and a normal character to the right can only be an opener. This handles cases like nested parentheses in emphasis. ```markdown **Gomphocarpus (*Gomphocarpus physocarpus*, syn. *Asclepias physocarpa*)** ``` -------------------------------- ### Backslash escapes for ASCII punctuation (example 12) Source: https://spec.commonmark.org/0.31.2/spec.json Example 12: Backslash escapes for ASCII punctuation. The backslash is removed and the punctuation is rendered literally. ```markdown \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~ ``` ```html!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
``` -------------------------------- ### Tab-indented paragraph in list (example 4) Source: https://spec.commonmark.org/0.31.2/spec.json Example 4: A list item with a tab-indented paragraph. The tab is expanded to 4 spaces, so the paragraph is part of the list item. ```markdown - foo bar ``` ```htmlfoo
bar
foo
bar
```
--------------------------------
### Tab-indented code block in list (example 5)
Source: https://spec.commonmark.org/0.31.2/spec.json
Example 5: A list item with a tab-indented code block. The tab is expanded to 4 spaces, so the code block is indented by 2 spaces.
```markdown
- foo
bar
```
```html
foo
bar
*foo*
``` -------------------------------- ### URI autolink with port number Source: https://spec.commonmark.org/0.31.2/changes.html Shows a URI autolink with a port number. The example `[foohttp://example.com/?search=][ref]
``` -------------------------------- ### Tab-indented code block in list item (example 7) Source: https://spec.commonmark.org/0.31.2/spec.json Example 7: A list item with a tab-indented code block. The tab is expanded to 4 spaces, so the code block is indented by 2 spaces. ```markdown - foo ``` ```html foo
`foobar
foo
bar
.
```
--------------------------------
### Example: Code span with backticks
Source: https://spec.commonmark.org/0.31.2/changes.html
Shows that a code span with backticks is rendered as a code element, with the backticks removed.
```markdown
```foo``
```
```html
```foo``
``` -------------------------------- ### Not comments: invalid comment syntax Source: https://spec.commonmark.org/0.31.2/changes.html Examples showing that '' and '' are not valid comments. The output escapes the '>' in the comment. ```markdown foo foo --> .foo foo --> .
foo foo -->
``` -------------------------------- ### Case-insensitive reference link matching Source: https://spec.commonmark.org/0.31.2/changes.html Example showing that reference link matching is case-insensitive. The link label [BaR] matches the definition [bar]. ```markdown [foo][BaR] [bar]: /url "title" . ``` -------------------------------- ### Old spec test format Source: https://spec.commonmark.org/changelog.txt The previous format for spec examples used lines with a single period to delimit markdown and HTML sections. ```markdown . markdown . html . ``` -------------------------------- ### Collapsed reference link with empty brackets Source: https://spec.commonmark.org/0.31.2/changes.html Example showing a collapsed reference link where the link text is empty and the link label is used as the text. The link URI and title come from the definition. ```markdown [foo][] [foo]: /url "title" .foo []
``` -------------------------------- ### Example: Unicode symbols count as punctuation Source: https://spec.commonmark.org/0.31.2/changes.html Shows that Unicode symbols like $, £, and € count as punctuation for emphasis flanking, so asterisks are not flanking. ```markdown *$*alpha. *£*bravo. *€*charlie. ``` ```html*$*alpha.
*£*bravo.
*€*charlie.
``` -------------------------------- ### Backslash escape in link URL Source: https://spec.commonmark.org/0.31.2/changes.html Example showing that backslash escapes work in URLs, as demonstrated by a link with a backslash before an asterisk. The output shows the escaped backslash in the href attribute. ```markdown ~~~ \\[\\] ~~~ .\\[\\]
```
--------------------------------
### Autolink with backtick example
Source: https://spec.commonmark.org/0.31.2/changes.html
Shows that a backtick inside an autolink is treated as a literal character, not as code delimiter. The input '* a *
``` -------------------------------- ### Backslash escape in link URL with query (https) Source: https://spec.commonmark.org/0.31.2/changes.html Example showing that backslash escapes work in URLs, as demonstrated by a link with a backslash before an asterisk in the query string. The output shows the escaped backslash in the href attribute. ```markdown\ \A\a\ \3\φ\«
``` -------------------------------- ### Link with query and fragment (https) Source: https://spec.commonmark.org/0.31.2/changes.html Shows that a link can contain fragment identifiers and queries. Input: '[link](https://example.com?foo=3#frag)' outputs ''. ```markdown [link](https://example.com?foo=3#frag) . ``` -------------------------------- ### Backslash escapes in code span (example 17) Source: https://spec.commonmark.org/0.31.2/spec.json Example 17: Backslash escapes inside code spans are not processed; the backslashes are rendered literally. ```markdown `` \[\` `` ``` ```html\[\`
\[\]
```
--------------------------------
### Backslash escapes in fenced code block (example 19)
Source: https://spec.commonmark.org/0.31.2/spec.json
Example 19: Backslash escapes inside fenced code blocks are not processed; the backslashes are rendered literally.
```markdown
~~~
\[\]
~~~
```
```html
\[\]
```
--------------------------------
### Link with fragment identifier (https)
Source: https://spec.commonmark.org/0.31.2/changes.html
Shows that a link can contain fragment identifiers and queries. Input: '[link](https://example.com#fragment)' outputs ''.
```markdown
[link](https://example.com#fragment)
.
```
--------------------------------
### Tab-indented code block in blockquote (example 6)
Source: https://spec.commonmark.org/0.31.2/spec.json
Example 6: A blockquote with a tab-indented code block. The tab is expanded to 4 spaces, so the code block is indented by 2 spaces.
```markdown
> foo
```
```html
``` -------------------------------- ### Backslash escapes prevent Markdown interpretation (example 14) Source: https://spec.commonmark.org/0.31.2/spec.json Example 14: Backslash escapes prevent Markdown interpretation for emphasis, tags, links, code, lists, headings, references, and character entities. ```markdown \*not emphasized* \foo
*not emphasized* <br/> not a tag [not a link](/foo) `not code` 1. not a list * not a list # not a heading [foo]: /url "not a reference" ö not a character entity
``` -------------------------------- ### AST output for CommonMark sample Source: https://spec.commonmark.org/dingus The AST (Abstract Syntax Tree) output in XML format generated by commonmark.js for the sample Markdown input. It shows the parsed document structure with headings, paragraphs, links, and lists. ```xmlYou can try CommonMark here. This dingus is powered by commonmark.js, the JavaScript reference implementation.
foo
``` -------------------------------- ### HTML comment with hyphen Source: https://spec.commonmark.org/0.31.2/changes.html Example showing that a comment can contain hyphens, but not '--' inside. The output escapes the '>' in the comment. ```markdown foo .foo
``` -------------------------------- ### Link with angle bracket destination containing ** Source: https://spec.commonmark.org/0.31.2/changes.html Shows that a link destination can contain '**' and that the destination is parsed correctly. Input: '**afoo