### 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" .

foo

``` -------------------------------- ### 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. ```markdown . ``` ```html

https://foo.bar.`baz`

``` -------------------------------- ### List item starting with blank line followed by fenced code block Source: https://spec.commonmark.org/changelog.txt Shows a list item that begins with a blank line and contains a fenced code block. This example illustrates the revised Rule 3 for list items, which now applies to any list item starting with a blank line, not just empty ones. ```markdown - ``` code ``` ``` -------------------------------- ### Tabs in code block (example 1) Source: https://spec.commonmark.org/0.31.2/spec.json Example 1: A code block with tabs. The tabs are expanded to 4 spaces, so the output shows the content without leading tabs. ```markdown foo baz bim ``` ```html
foo	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

Foo

``` -------------------------------- ### Full reference link with angle brackets (https) Source: https://spec.commonmark.org/0.31.2/changes.html Example showing a full reference link with an https URI, demonstrating that the URI scheme does not affect parsing. ```markdown [foo [ref]: /uri .

[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 `` is parsed as a link, with the URI as the label and proper HTML escaping of ampersands. ```markdown .

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 ``` ```html
a	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 ``` ```html

foo
bar

``` -------------------------------- ### Full and collapsed references precedence Source: https://spec.commonmark.org/0.31.2/changes.html Shows that full and collapsed references take precedence over shortcut references. The example defines `[foo]: /url1` and `[bar]: /url2`, and `[foo][bar]` resolves to the `bar` definition. ```markdown [foo][bar] [foo]: /url1 [bar]: /url2 .

foo

``` -------------------------------- ### Reference link with space Source: https://spec.commonmark.org/changelog.txt Example of a reference link with a space between link text and label, which is no longer allowed. ```markdown [foo] [bar] ``` -------------------------------- ### Setext heading multiline example Source: https://spec.commonmark.org/changelog.txt Shows that text like this is now interpreted as a heading followed by a paragraph, not a paragraph plus thematic break. ```markdown Foo bar --- baz ``` -------------------------------- ### Tabs in code block with leading spaces (example 2) Source: https://spec.commonmark.org/0.31.2/spec.json Example 2: A code block with leading spaces and tabs. The tabs are expanded to 4 spaces, so the output shows the content without leading tabs. ```markdown foo baz bim ``` ```html
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]: (baz)` is not recognized as a link, so the paragraph renders as literal text. ```markdown [foo]: (baz) [foo] .

[foo]: (baz)

[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 ``` ```html
  • foo

    bar

``` -------------------------------- ### Tab-separated thematic break (example 11) Source: https://spec.commonmark.org/0.31.2/spec.json Example 11: A thematic break with tabs between asterisks. The tabs are expanded to 4 spaces, so the line is rendered as a horizontal rule. ```markdown * * * ``` ```html
``` -------------------------------- ### New spec test format Source: https://spec.commonmark.org/changelog.txt The new format uses fenced code blocks with an 'example' info string, making spec.txt a valid CommonMark file. ```markdown `````````````````````````````` example markdown . html `````````````````````````````` ``` -------------------------------- ### Tab-indented nested list item (example 9) Source: https://spec.commonmark.org/0.31.2/spec.json Example 9: A nested list with a tab-indented item. The tab is expanded to 4 spaces, so the item is part of the nested list. ```markdown - foo - bar - baz ``` ```html
  • foo
    • bar
      • baz
``` -------------------------------- ### Tab-indented line in code block (example 8) Source: https://spec.commonmark.org/0.31.2/spec.json Example 8: A code block with a tab-indented line. The tab is expanded to 4 spaces, so the line is part of the code block. ```markdown foo bar ``` ```html
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
    
``` -------------------------------- ### Link reference with emphasis Source: https://spec.commonmark.org/0.31.2/changes.html Demonstrates that a link reference definition can include emphasis markers, and the link label is parsed accordingly. The example `[foo*]: /url` and `*[foo*]` produces a link with the label `foo*`. ```markdown [foo*]: /url *[foo*] .

*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 `` is parsed as a link with the URI as the label. ```markdown .

irc://foo.bar:2233/baz

``` -------------------------------- ### Full reference link with angle brackets Source: https://spec.commonmark.org/0.31.2/changes.html Example showing a full reference link where the link text contains an inline link with angle brackets. The URI is parsed as a link, and the reference definition is used for the link's URI and title. ```markdown [foo [ref]: /uri .

[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
    
``` -------------------------------- ### Emphasis parsing example: quotes inside emphasis Source: https://spec.commonmark.org/changelog.txt Example showing improved emphasis parsing around punctuation, where a delimiter clump with punctuation to the right and a normal character to the left can only be a closer. This handles cases like quotes inside emphasis. ```markdown **foo "*bar*" foo** ``` -------------------------------- ### Markdown example: paragraph and code block ambiguity Source: https://spec.commonmark.org/0.31.2/changes.html Shows a Markdown paragraph followed by an indented code block, illustrating the ambiguity about whether a blank line is needed before an indented code block. The example is from the section discussing question 3 about blank lines before indented code blocks. ```markdown ``` markdown paragraph code? ``` ``` -------------------------------- ### Example: Backtick code span with single backtick Source: https://spec.commonmark.org/0.31.2/changes.html Shows that a single backtick can be used as a code span delimiter, and the content is rendered as code. ```markdown `foo``bar`` ``` ```html

`foobar

``` -------------------------------- ### List item indentation example: three spaces Source: https://spec.commonmark.org/0.31.2/changes.html Shows that a list item cannot be formed by indenting a block with three spaces and prepending a list marker. The input ' foo' followed by 'bar' results in a paragraph and a code block, not a list. ```markdown foo bar . ``` ```html

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" .

foo

``` -------------------------------- ### 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 '' is parsed as a link with the backtick included in the URL. ```markdown . ``` ```html

http://foo.bar.`baz`

``` -------------------------------- ### Backslash escape in link URL with query 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 .

http://example.com?find=\\*

``` -------------------------------- ### Example: Unicode nonbreaking spaces count as whitespace Source: https://spec.commonmark.org/0.31.2/changes.html Shows that Unicode nonbreaking spaces are treated as whitespace for emphasis flanking rules, so asterisks are not flanking. ```markdown * a * ``` ```html

* 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 .

https://example.com?find=\\*

``` -------------------------------- ### Link with query and fragment (http) Source: https://spec.commonmark.org/0.31.2/changes.html Shows that a link can contain fragment identifiers and queries. Input: '[link](http://example.com?foo=3#frag)' outputs '

link

'. ```markdown [link](http://example.com?foo=3#frag) .

link

``` -------------------------------- ### Backslash escapes for non-punctuation (example 13) Source: https://spec.commonmark.org/0.31.2/spec.json Example 13: Backslash escapes for non-punctuation characters. The backslash is not removed and the characters are rendered literally. ```markdown \ \A\a\ \3\φ\« ``` ```html

\ \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 '

link

'. ```markdown [link](https://example.com?foo=3#frag) .

link

``` -------------------------------- ### 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

\[\`

``` -------------------------------- ### Link with fragment identifier (http) Source: https://spec.commonmark.org/0.31.2/changes.html Shows that a link can contain fragment identifiers and queries. Input: '[link](http://example.com#fragment)' outputs '

link

'. ```markdown [link](http://example.com#fragment) .

link

``` -------------------------------- ### Autolink with http and https schemes Source: https://spec.commonmark.org/0.31.2/changes.html Demonstrates that both http and https autolinks are valid, producing links with the same URL. ```markdown .

http://../

``` ```markdown .

https://../

``` -------------------------------- ### Autolink with localhost Source: https://spec.commonmark.org/0.31.2/changes.html Shows that autolinks with localhost are valid and produce a link. ```markdown .

localhost:5001/foo

``` -------------------------------- ### Backslash escapes in indented code block (example 18) Source: https://spec.commonmark.org/0.31.2/spec.json Example 18: Backslash escapes inside indented code blocks 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 '

link

'. ```markdown [link](https://example.com#fragment) .

link

``` -------------------------------- ### 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
  foo
``` -------------------------------- ### 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* \
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 ``` ```html

*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" &ouml; 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. ```xml Try CommonMark You can try CommonMark here. This dingus is powered by commonmark.js , the JavaScript reference implementation. item one item two sublist sublist ``` -------------------------------- ### HTML output for CommonMark sample Source: https://spec.commonmark.org/dingus The HTML output generated by commonmark.js for the sample Markdown input. It shows the rendered structure including headings, paragraphs, links, and lists. ```html

Try CommonMark

You can try CommonMark here. This dingus is powered by commonmark.js, the JavaScript reference implementation.

  1. item one
  2. item two
    • sublist
    • sublist
``` -------------------------------- ### Link with angle bracket destination containing ** (https) 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: '**a' outputs '

**ahttps://foo.bar/?q=**

'. ```markdown **a .

**ahttps://foo.bar/?q=**

``` -------------------------------- ### HTML comment with hyphen at end Source: https://spec.commonmark.org/0.31.2/changes.html Example showing that a comment cannot end with a hyphen. The output escapes the '>' in the comment. ```markdown foo .

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: '**a' outputs '

**ahttp://foo.bar/?q=**

'. ```markdown **a .

**ahttp://foo.bar/?q=**

``` -------------------------------- ### HTML comment with double hyphen Source: https://spec.commonmark.org/0.31.2/changes.html Example showing that a comment cannot contain '--' inside. The output escapes the '>' in the comment. ```markdown foo .

foo