### Markdown Example Source: https://spec.commonmark.org/0.31.2 This code block demonstrates the equivalent Markdown syntax for the AsciiDoc example. It highlights Markdown's readability for nested lists and indented blocks. ```markdown 1. List item one. List item one continued with a second paragraph followed by an Indented block. $ ls *.sh $ mv *.sh ~\tmp List item continued with a third paragraph. 2. List item two continued with an open block. This paragraph is part of the preceding list item. 1. This list is nested and does not require explicit item continuation. This paragraph is part of the preceding list item. 2. List item b. This paragraph belongs to item two of the outer list. ``` -------------------------------- ### Document Tree Structure Example Source: https://spec.commonmark.org/0.31.2 An example illustrating the tree structure of blocks in a parsed document, with open blocks indicated. ```text -> document -> block_quote paragraph "Lorem ipsum dolor\nsit amet." -> list (type=bullet tight=true bullet_char=-) list_item paragraph "Qui *quodsi iracundia*" -> list_item -> paragraph "aliquando id" ``` -------------------------------- ### List item starting with a blank line and code block Source: https://spec.commonmark.org/0.31.2 Demonstrates a list item starting with a blank line, followed by a code block. The blank line is handled, and the code block is correctly rendered as part of the list item. ```markdown - ``` bar ``` ``` -------------------------------- ### Ordered List with Different Delimiters Source: https://spec.commonmark.org/0.31.2 Shows how different delimiters ('.' or ')') for ordered list numbers start new lists. The start number is determined by the first item. ```markdown 1. foo 2. bar 3) baz ``` ```html
  1. foo
  2. bar
  1. baz
``` -------------------------------- ### Unordered List Example Source: https://spec.commonmark.org/0.31.2 Demonstrates a basic unordered list with three items, including an empty item. ```markdown - foo - - bar ``` -------------------------------- ### Ordered List Example Source: https://spec.commonmark.org/0.31.2 Illustrates an ordered list with three items, including an empty item. ```markdown 1. foo 2. 3. bar ``` -------------------------------- ### AsciiDoc Example Source: https://spec.commonmark.org/0.31.2 This code block shows an example of AsciiDoc syntax for a numbered list with nested elements and indented blocks. It is used for comparison with Markdown. ```asciidoc 1. List item one. + List item one continued with a second paragraph followed by an Indented block. + ................. $ ls *.sh $ mv *.sh ~\tmp ................. + List item continued with a third paragraph. 2. List item two continued with an open block. + -- This paragraph is part of the preceding list item. a. This list is nested and does not require explicit item continuation. + This paragraph is part of the preceding list item. b. List item b. This paragraph belongs to item two of the outer list. -- ``` -------------------------------- ### CDATA Section Example Source: https://spec.commonmark.org/0.31.2 Demonstrates a CDATA section within a JavaScript function. This is a direct representation of how CDATA is handled. ```html ``` ```html

okay

``` -------------------------------- ### Lazy Continuation Lines Example Source: https://spec.commonmark.org/0.31.2 Demonstrates lazy continuation lines in a list item, where indentation is partially removed. ```markdown 1. A paragraph with two lines. indented code > A block quote. ``` -------------------------------- ### HTML Block with Non-Standard Tag Start Source: https://spec.commonmark.org/0.31.2 Shows that the initial tag in an HTML block doesn't need to be strictly valid HTML, as long as it starts like a tag. ```html
``` -------------------------------- ### Basic Strong Emphasis Examples Source: https://spec.commonmark.org/0.31.2 Illustrates various ways to achieve strong emphasis using triple asterisks or underscores, including nested emphasis. ```markdown ***strong emph*** ***strong** in emph* ***emph* in strong** **in strong *emph*** *in emph **strong*** ``` -------------------------------- ### Link with Image in Text Source: https://spec.commonmark.org/0.31.2 Shows an example where an image is used as part of the link text. ```Markdown [![moon](moon.jpg)](/uri) ``` -------------------------------- ### HTML Block with Incomplete Tag Source: https://spec.commonmark.org/0.31.2 An example of an HTML block starting with an incomplete tag. The parser treats this as raw HTML and continues until a blank line. ```markdown
  • ``` -------------------------------- ### Setext Heading Level 1 and 2 Examples Source: https://spec.commonmark.org/0.31.2 Demonstrates basic Setext headings with level 1 ('=') and level 2 ('-') underlines. The content is parsed as CommonMark inline. ```markdown Foo *bar* ========= Foo *bar* --------- ``` ```html

    Foo bar

    Foo bar

    ``` -------------------------------- ### Ordered list with zero start number Source: https://spec.commonmark.org/0.31.2 Shows an ordered list starting with '0'. CommonMark allows a start number of 0 for ordered lists. ```markdown 0. ok ``` -------------------------------- ### Basic Block Quote Example Source: https://spec.commonmark.org/0.31.2 Demonstrates a simple block quote with a heading and paragraphs. Requires a block quote marker ('>') followed by a space at the beginning of each line. ```markdown > # Foo > bar > baz ``` -------------------------------- ### HTML Tag Parsing Source: https://spec.commonmark.org/0.31.2 Contrasts with the previous example, showing that when backticks are not present, the content is parsed as a standard HTML tag. ```html ` ``` -------------------------------- ### Ordered list with nine-digit start number Source: https://spec.commonmark.org/0.31.2 Demonstrates an ordered list where the start number is a nine-digit number. CommonMark allows start numbers up to nine digits. ```markdown 123456789. ok ``` -------------------------------- ### Ordered list with negative start number Source: https://spec.commonmark.org/0.31.2 Illustrates an ordered list with a negative start number. CommonMark does not allow negative start numbers and will render this as plain text. ```markdown -1. not ok ``` -------------------------------- ### Autolink Parsing Source: https://spec.commonmark.org/0.31.2 Contrasts with the previous example, showing that without backticks, a URL-like string is parsed as an autolink. ```html https://foo.bar.`baz` ``` -------------------------------- ### Markdown.pl Two-Space Indentation Example Source: https://spec.commonmark.org/0.31.2 Demonstrates how Markdown.pl's more forgiving two-space rule can parse text indented less than the list marker as a continuation paragraph. ```markdown - one two ``` -------------------------------- ### HTML Block with Div Tag Source: https://spec.commonmark.org/0.31.2 A simple HTML block starting with a
    tag. This example demonstrates type 6 HTML block parsing, where the block is terminated by a blank line. ```markdown
    *hello* ``` ```html
    *hello* ``` -------------------------------- ### URI Autolink Example Source: https://spec.commonmark.org/0.31.2 A basic URI autolink is enclosed in angle brackets. Ensure the URI is absolute and properly formatted. ```CommonMark ``` ```HTML

    http://foo.bar.baz

    ``` -------------------------------- ### Ordered list with ten-digit start number Source: https://spec.commonmark.org/0.31.2 Illustrates an ordered list with a ten-digit start number, which is not allowed by CommonMark. This will be rendered as plain text. ```markdown 1234567890. not ok ``` -------------------------------- ### List item starting with a blank line and text Source: https://spec.commonmark.org/0.31.2 Illustrates a list item that begins with a blank line followed by text. The blank line is handled according to list item rules, and the text forms the content. ```markdown - foo ``` -------------------------------- ### Unordered List with Different Bullet Types Source: https://spec.commonmark.org/0.31.2 Demonstrates how changing the bullet marker starts a new list. Use '-' or '+' for unordered lists. ```markdown - foo - bar + baz ``` ```html
    • foo
    • bar
    • baz
    ``` -------------------------------- ### Ordered list with leading zeros in start number Source: https://spec.commonmark.org/0.31.2 Demonstrates an ordered list with a start number that includes leading zeros (e.g., '003'). CommonMark correctly parses this as the number 3. ```markdown 003. ok ``` -------------------------------- ### Ordered list item starting with indented code block Source: https://spec.commonmark.org/0.31.2 Demonstrates an ordered list item where the first block is an indented code block. The start number is applied, and subsequent content follows list item indentation rules. ```markdown 1. indented code paragraph more code ``` -------------------------------- ### Markdown.pl Blockquote HTML Output Source: https://spec.commonmark.org/0.31.2 Shows the HTML output for the blockquote example, demonstrating that 'two' is correctly nested within the list item and blockquote. ```html
    • one

      two

    ``` -------------------------------- ### Basic Code Span Example Source: https://spec.commonmark.org/0.31.2 Demonstrates a simple code span with backticks. Line endings are converted to spaces, and leading/trailing spaces are stripped if present on both sides and the content is not solely spaces. ```markdown `foo` ``` ```html

    foo

    ``` -------------------------------- ### CommonMark List Item Parsing Example Source: https://spec.commonmark.org/0.31.2 Illustrates how a paragraph with multiple lines and other block elements is parsed as an ordered list item when preceded by a list marker and appropriate indentation. ```CommonMark A paragraph with two lines. indented code > A block quote. ``` ```HTML

    A paragraph with two lines.

    indented code
    

    A block quote.

    ``` -------------------------------- ### Left-Flanking Delimiter Runs Source: https://spec.commonmark.org/0.31.2 Examples of delimiter runs that are left-flanking but not right-flanking, indicating potential emphasis opening. ```markdown ***abc _abc **"abc" _"abc" ``` -------------------------------- ### Declaration HTML Block Source: https://spec.commonmark.org/0.31.2 Example of an HTML declaration (``). The content is treated literally. ```html ``` -------------------------------- ### Processing Instruction HTML Block Source: https://spec.commonmark.org/0.31.2 Example of an HTML processing instruction (``). The content is treated literally. ```html '; ?> okay ``` -------------------------------- ### Markdown.pl HTML Output for Two-Space Indentation Source: https://spec.commonmark.org/0.31.2 Shows the HTML output for the Markdown.pl two-space indentation example, where 'two' is correctly included as a continuation paragraph within the list item. ```html
    • one

      two

    ``` -------------------------------- ### Link with Quoted Title (No Destination) Source: https://spec.commonmark.org/0.31.2 Shows an example where a quoted string is interpreted as a URL destination because no destination is explicitly provided. ```Markdown [link]("title") ``` -------------------------------- ### Full and Collapsed References Precedence Source: https://spec.commonmark.org/0.31.2 Full and collapsed reference links take precedence over shortcut references. This example shows a full reference link. ```markdown [foo][bar] [foo]: /url1 [bar]: /url2 ``` ```html

    foo

    ``` -------------------------------- ### Case-Insensitive Shortcut Reference Link Matching Source: https://spec.commonmark.org/0.31.2 Link labels for shortcut reference links are case-insensitive. This example shows that '[Foo]' matches '[foo]: /url'. ```markdown [Foo] [foo]: /url "title" ``` -------------------------------- ### HTML Block with Closing Tag Source: https://spec.commonmark.org/0.31.2 Demonstrates an HTML block starting with a closing tag, which is treated as raw HTML. ```html *bar* ``` -------------------------------- ### Right-Flanking Delimiter Runs Source: https://spec.commonmark.org/0.31.2 Examples of delimiter runs that are right-flanking but not left-flanking, indicating potential emphasis closing. ```markdown abc*** abc_ "abc"** "abc"_ ``` -------------------------------- ### Nested Blockquote with Lazy Continuation Source: https://spec.commonmark.org/0.31.2 Example of a nested blockquote within a list item, demonstrating lazy continuation. ```markdown > 1. > Blockquote continued here. ``` -------------------------------- ### Unintended List Interruption with '1' Source: https://spec.commonmark.org/0.31.2 An example where a list starting with '1' unintentionally interrupts a paragraph, highlighting a potential edge case despite the general rule. ```markdown The number of windows in my house is 1. The number of doors is 6. ``` ```html

    The number of windows in my house is

    1. The number of doors is 6.
    ``` -------------------------------- ### Unordered List with Simple Items Source: https://spec.commonmark.org/0.31.2 Demonstrates a basic unordered list structure. ```markdown - c - d - e - f - g ``` -------------------------------- ### List Interrupting Paragraph (Rule for Numerals) Source: https://spec.commonmark.org/0.31.2 To prevent spurious list captures, CommonMark allows only lists starting with '1' to interrupt paragraphs. This example shows a numeral list that does not interrupt. ```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.

    ``` -------------------------------- ### Four-Space Rule List Example Source: https://spec.commonmark.org/0.31.2 Illustrates how the strict four-space rule parses nested lists and intervening paragraphs, which can be unintuitive. ```markdown - foo bar - baz ``` -------------------------------- ### Markdown.pl Blockquote Two-Space Indentation Example Source: https://spec.commonmark.org/0.31.2 Illustrates Markdown.pl's handling of indentation within a blockquote, where 'two' is still parsed as a continuation paragraph despite reduced indentation. ```markdown > - one > > two ``` -------------------------------- ### HTML Block with Table Structure Source: https://spec.commonmark.org/0.31.2 Example of an HTML block containing a table structure, where the content is treated as raw HTML. ```html
    foo
    ``` -------------------------------- ### HTML Block with Tag on Same Line as End Tag Source: https://spec.commonmark.org/0.31.2 Demonstrates a ` *foo* ``` -------------------------------- ### Invalid Link Destinations Source: https://spec.commonmark.org/0.31.2 Examples of invalid link destinations that are not rendered as links due to improperly matched or unescaped angle brackets. ```markdown [a]( [a](c) ``` ```html

    [a](<b)c [a](<b)c> [a](<b>c)

    ``` -------------------------------- ### HTML Block with Partial Open Tag Source: https://spec.commonmark.org/0.31.2 Demonstrates an HTML block where the opening
    tag is split across lines with whitespace. This is still recognized as a valid start condition for an HTML block. ```markdown
    ``` ```html
    ``` -------------------------------- ### Basic Emphasis with Underscore Source: https://spec.commonmark.org/0.31.2 Demonstrates basic emphasis using underscores. The opening and closing delimiters must be within separate delimiter runs and not preceded or followed by whitespace. ```markdown _foo bar_ ``` ```html

    foo bar

    ``` -------------------------------- ### Indented List Item (1 Space) Source: https://spec.commonmark.org/0.31.2 Example of a list item indented by one space, containing a paragraph, code block, and blockquote. ```markdown 1. A paragraph with two lines. indented code > A block quote. ``` -------------------------------- ### HTML for Loose List with Reference Definition Source: https://spec.commonmark.org/0.31.2 HTML output for a loose list containing a reference definition between items. ```html
    • a

    • b

    • d

    ``` -------------------------------- ### Bullet List Item Indentation Example 1 Source: https://spec.commonmark.org/0.31.2 Shows a simple bullet list item where the subsequent line is not indented, resulting in it being parsed as a separate paragraph. ```CommonMark - one two ``` ```HTML
    • one

    two

    ``` -------------------------------- ### Processing Instructions Source: https://spec.commonmark.org/0.31.2 Shows how processing instructions within angle brackets are handled. They are rendered directly as they appear. ```markdown foo ``` ```markdown

    foo

    ``` -------------------------------- ### Pre Tag HTML Block Source: https://spec.commonmark.org/0.31.2 Example of a `
    ` tag used as an HTML block. Content within `
    ` tags is treated literally and does not end at the first blank line.
    
    ```html
    
    
    import Text.HTML.TagSoup
    
    main :: IO ()
    main = print $ parseTags tags
    
    okay ``` -------------------------------- ### Code Span vs. Autolink Precedence Source: https://spec.commonmark.org/0.31.2 Shows that code spans have the same precedence as autolinks. This example parses the URL-like string as a code span due to the backticks. ```markdown `` ``` ```html

    <https://foo.bar.baz>`

    ``` -------------------------------- ### Links with Fragment Identifiers and Queries Source: https://spec.commonmark.org/0.31.2 Shows various ways to include fragment identifiers and query parameters in link URLs. ```Markdown [link](#fragment) [link](https://example.com#fragment) [link](https://example.com?foo=3#frag) ``` -------------------------------- ### Basic Emphasis with Asterisks Source: https://spec.commonmark.org/0.31.2 Demonstrates basic emphasis using single asterisks. Ensure delimiters do not match evenly to avoid unexpected emphasis. ```CommonMark foo *_* ``` ```HTML

    foo _

    ``` -------------------------------- ### HTML for Tight List with Nested Single-Paragraph Item Source: https://spec.commonmark.org/0.31.2 HTML output for a tight list with a nested single-paragraph item. ```html
    • a
      • b
    ``` -------------------------------- ### Basic Emphasis with Asterisk Source: https://spec.commonmark.org/0.31.2 Demonstrates basic emphasis using asterisks. The opening and closing delimiters must be within separate delimiter runs and not preceded or followed by whitespace. ```markdown *foo bar* ``` ```html

    foo bar

    ``` -------------------------------- ### Bullet List Item Indentation Example 2 Source: https://spec.commonmark.org/0.31.2 Illustrates a bullet list item where the subsequent line is indented, causing it to be parsed as a new paragraph within the same list item. ```CommonMark - one two ``` ```HTML
    • one

      two

    ``` -------------------------------- ### Basic Image Syntax Source: https://spec.commonmark.org/0.31.2 Standard image syntax with source, alt text, and optional title. Renders to an HTML img tag. ```markdown ![foo](/url "title") ``` ```html

    foo

    ``` -------------------------------- ### ATX headings with varying numbers of '#' characters Source: https://spec.commonmark.org/0.31.2 Demonstrates the creation of ATX headings using 1 to 6 '#' characters, followed by a space or end of line. ```markdown # foo ## foo ### foo #### foo ##### foo ``` ```html

    foo

    foo

    foo

    foo

    foo
    ``` -------------------------------- ### List Marker Spacing Requirement Source: https://spec.commonmark.org/0.31.2 Shows examples where content immediately following a list marker without at least one space or tab is parsed as a paragraph, not a list item. ```CommonMark -one 2.two ``` ```HTML

    -one

    2.two

    ``` -------------------------------- ### Reference Link Label Matching - Normalized Strings Source: https://spec.commonmark.org/0.31.2 Link label matching is performed on normalized strings, not parsed inline content. This example shows that '[bar][foo!]' does not match '[foo]: /url' because the labels are not identical after normalization. ```markdown [bar][foo!] [foo!]: /url ``` -------------------------------- ### HTML for Single-Paragraph Tight List Source: https://spec.commonmark.org/0.31.2 HTML rendering of a tight list with a single paragraph item. ```html
    • a
    ``` -------------------------------- ### List item starting with a blank line and indented code Source: https://spec.commonmark.org/0.31.2 Shows a list item beginning with a blank line, followed by an indented code block. The indentation rules for list items and code blocks are applied. ```markdown - baz ``` -------------------------------- ### Style Tag HTML Block Source: https://spec.commonmark.org/0.31.2 Example of a ` okay ``` -------------------------------- ### Simple Image Source: https://spec.commonmark.org/0.31.2 A basic image with alt text and source URL. ```markdown ![foo](train.jpg) ``` ```html

    foo

    ``` -------------------------------- ### HTML Block with Nested Pre Tag Source: https://spec.commonmark.org/0.31.2 Demonstrates an HTML block started by a tag, containing a
     tag. The HTML block is terminated by a blank line, and the content within 
     is treated as raw HTML.
    
    ```markdown
    
    **Hello**,
    
    _world_.
    
    ``` ```html
    **Hello**,
    
    _world_.
    
    ``` -------------------------------- ### Numbered List Item Containing Unordered List Source: https://spec.commonmark.org/0.31.2 Example of a numbered list item containing an unordered list. ```markdown 1. - 2. foo ``` -------------------------------- ### Empty List Item at Start/End Source: https://spec.commonmark.org/0.31.2 Shows how an empty list item can appear at the beginning or end of a list. ```markdown * ``` -------------------------------- ### List item with blank line and subsequent text Source: https://spec.commonmark.org/0.31.2 Illustrates a list item that starts with a blank line, but subsequent text is not considered part of that list item due to CommonMark's rules on blank lines within list items. ```markdown - foo ``` -------------------------------- ### HTML Block with Inline-Style Tag Source: https://spec.commonmark.org/0.31.2 Shows an HTML block starting with a tag that is not a block-level tag, requiring the tag to be on its own line. ```html *bar* ``` -------------------------------- ### Nested Lists with Multiple Items Source: https://spec.commonmark.org/0.31.2 Demonstrates nested unordered lists, each with multiple items. ```markdown - a - b - c - d - e - f ``` -------------------------------- ### HTML for Tight List with Code Block Source: https://spec.commonmark.org/0.31.2 HTML rendering of a tight list containing a code block with internal blank lines. ```html
    • a
    • b
      
      
      
    • c
    ``` -------------------------------- ### HTML for Tight List with Consecutive Block Elements Source: https://spec.commonmark.org/0.31.2 HTML output for a tight list with consecutive block elements in a list item. ```html
    • a

      b

      c
      
    • d
    ``` -------------------------------- ### Nested List with Numbered Marker Source: https://spec.commonmark.org/0.31.2 Example of a nested unordered list following a numbered list item, requiring specific indentation. ```markdown 10) foo - bar ``` -------------------------------- ### Tight List with Code Block Source: https://spec.commonmark.org/0.31.2 Illustrates a tight list where blank lines within a code block do not affect list looseness. ```markdown - a - ``` b ``` - c ``` -------------------------------- ### Link Reference Definition with Title Source: https://spec.commonmark.org/0.31.2 Demonstrates a link reference definition with an associated title, which is then used in the rendered output. ```CommonMark [foo]: /url === [foo] ``` -------------------------------- ### HTML Comment Block Source: https://spec.commonmark.org/0.31.2 Example of an HTML comment block. The content within the comment is treated literally and does not affect CommonMark parsing. ```html okay ``` -------------------------------- ### HTML Block with Inline HTML Tag Source: https://spec.commonmark.org/0.31.2 Example of an HTML block using an inline HTML tag, where the content is interpreted as CommonMark. ```html *bar* ``` -------------------------------- ### URI Autolink with Host and Port Source: https://spec.commonmark.org/0.31.2 Autolinks can specify a host and port. ```CommonMark ``` ```HTML

    localhost:5001/foo

    ``` -------------------------------- ### Link with Parentheses in URL Source: https://spec.commonmark.org/0.31.2 Demonstrates a link where parentheses in the URL are handled correctly by CommonMark. ```Markdown [link](foo(and(bar))) ``` -------------------------------- ### Email Autolink Example Source: https://spec.commonmark.org/0.31.2 Email addresses enclosed in angle brackets are parsed as mailto links. The email address itself serves as the link label. ```CommonMark ``` ```HTML

    foo@bar.example.com

    ``` -------------------------------- ### Mixed Emphasis and Strong Emphasis Source: https://spec.commonmark.org/0.31.2 Shows how emphasis and strong emphasis can be combined, with rules determining which delimiters apply to which. ```CommonMark ***foo*** ``` ```HTML

    foo

    ``` ```CommonMark _____foo_____ ``` ```HTML

    foo

    ``` -------------------------------- ### Image Label with Unescaped Brackets Source: https://spec.commonmark.org/0.31.2 Link labels in image syntax cannot contain unescaped brackets. This example shows how such syntax is not parsed as an image. ```markdown ![[foo]] [[foo]]: /url "title" ``` ```html

    ![[foo]]

    [[foo]]: /url "title"

    ``` -------------------------------- ### HTML Rendering of Unordered List Source: https://spec.commonmark.org/0.31.2 Shows the HTML output for a simple unordered list. ```html
    • a
    • b
    • c
    • d
    • e
    • f
    • g
    ``` -------------------------------- ### Link with Unbalanced Brackets in Text (Invalid) Source: https://spec.commonmark.org/0.31.2 Shows an example of unbalanced brackets within link text that CommonMark does not interpret as a valid link. ```Markdown [link] bar](/uri) ``` -------------------------------- ### List Item with Continuation Paragraph Indentation Source: https://spec.commonmark.org/0.31.2 Example of a list item where the continuation paragraph 'bar' is indented relative to the list marker, not the margin. ```markdown 10. foo bar ``` -------------------------------- ### Single-Paragraph Tight List Source: https://spec.commonmark.org/0.31.2 Demonstrates a simple tight list containing a single paragraph. ```markdown - a ``` -------------------------------- ### Multiple Link Reference Definitions Source: https://spec.commonmark.org/0.31.2 Shows how multiple link reference definitions, including those with titles and multi-line titles, can be defined consecutively and then referenced. ```CommonMark [foo]: /foo-url "foo" [bar]: /bar-url "bar" [baz]: /baz-url [foo], [bar], [baz] ``` -------------------------------- ### Basic HTML Tags Source: https://spec.commonmark.org/0.31.2 Demonstrates the parsing of simple HTML tags within CommonMark text. These tags are rendered directly as HTML. ```markdown ``` ```markdown

    ``` -------------------------------- ### Non-entities in CommonMark Source: https://spec.commonmark.org/0.31.2 Examples of strings that are not recognized as valid entity or numeric character references in CommonMark, including missing semicolons and undefined names. ```CommonMark   &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?; ``` ```HTML

    &nbsp &x; &#; &#x; &#87654321; &#abcdef0; &ThisIsNotDefined; &hi?;

    ``` -------------------------------- ### Space Preservation After Shortcut Reference Link Source: https://spec.commonmark.org/0.31.2 A space following a shortcut reference link should be preserved in the output. ```markdown [foo] bar [foo]: /url ``` -------------------------------- ### Strong Emphasis with Double Asterisk - Basic Source: https://spec.commonmark.org/0.31.2 Demonstrates basic strong emphasis using double asterisks. The opening delimiter must not be followed by whitespace. ```markdown **foo bar** ``` ```html

    foo bar

    ``` -------------------------------- ### Case-Insensitive Collapsed Reference Link Matching Source: https://spec.commonmark.org/0.31.2 Link labels for collapsed reference links are case-insensitive. This example shows that '[Foo][]' matches '[foo]: /url'. ```markdown [Foo][] [foo]: /url "title" ``` -------------------------------- ### Link Labels with Escaped Backslash Source: https://spec.commonmark.org/0.31.2 A backslash in a link label must be escaped with another backslash. This example shows a link label with a literal backslash. ```markdown [bar\ ]: [bar\] ``` -------------------------------- ### HTML for Tight Outer List with Loose Sublist Source: https://spec.commonmark.org/0.31.2 HTML output for a tight outer list containing a loose sublist. ```html
    • a
      • b

        c

    • d
    ``` -------------------------------- ### Link Labels with Brackets Source: https://spec.commonmark.org/0.31.2 Link labels cannot contain literal brackets unless they are backslash-escaped. This example shows an unescaped bracket in the label, resulting in no link. ```markdown [foo][ref[] [ref[]: /uri ``` ```markdown [foo][ref[bar]] [ref[bar]]: /uri ``` ```markdown [[[foo]]] [[[foo]]]: /url ``` ```markdown [foo][ref\[] [ref\[]: /uri ``` -------------------------------- ### Nested Unordered Lists Source: https://spec.commonmark.org/0.31.2 Demonstrates correctly indented nested unordered lists. ```markdown - foo - bar - baz - boo ``` -------------------------------- ### Strong Emphasis with Double Underscore - Basic Source: https://spec.commonmark.org/0.31.2 Demonstrates basic strong emphasis using double underscores. The opening delimiter must not be followed by whitespace. ```markdown __foo bar__ ``` ```html

    foo bar

    ``` -------------------------------- ### Indented Block Quote Example Source: https://spec.commonmark.org/0.31.2 Illustrates that block quote markers can be preceded by up to three spaces of indentation. Four spaces will render as a code block. ```markdown > # Foo > bar > baz ``` -------------------------------- ### HTML Declarations Source: https://spec.commonmark.org/0.31.2 Demonstrates the parsing of HTML declarations (DOCTYPE). These are rendered literally. ```markdown foo ``` ```markdown

    foo

    ``` -------------------------------- ### Link with Different Title Quote Styles Source: https://spec.commonmark.org/0.31.2 Illustrates using single quotes, double quotes, and parentheses for link titles. ```Markdown [link](/url "title") [link](/url 'title') [link](/url (title)) ``` -------------------------------- ### Basic HTML Block with Markdown Content Source: https://spec.commonmark.org/0.31.2 Demonstrates a simple HTML block where content inside is interpreted as CommonMark. ```html
    *hi*
    ``` -------------------------------- ### HTML for Tight List with Block Quote Source: https://spec.commonmark.org/0.31.2 HTML rendering of a tight list containing a block quote with internal blank lines. ```html
    • a

      b

    • c
    ``` -------------------------------- ### Both Left and Right-Flanking Delimiter Runs Source: https://spec.commonmark.org/0.31.2 Illustrates delimiter runs that qualify as both left-flanking and right-flanking, allowing for emphasis. ```markdown abc***def "abc"_"def" ``` -------------------------------- ### Case-Insensitive Reference Link Matching Source: https://spec.commonmark.org/0.31.2 Demonstrates that reference link matching is case-insensitive. The link text '[foo]' will match the definition '[BaR]'. ```markdown [foo][BaR] [bar]: /url "title" ``` -------------------------------- ### Case-Insensitive Label Matching Source: https://spec.commonmark.org/0.31.2 Link reference labels are matched case-insensitively. This example shows that a definition with an uppercase label correctly resolves a reference with a lowercase label. ```markdown [FOO]: /url [Foo] ``` -------------------------------- ### Four-Space Rule HTML Output Source: https://spec.commonmark.org/0.31.2 Shows the HTML output generated by the strict four-space rule for the preceding Markdown example, highlighting the separation into distinct lists and paragraphs. ```html
    • foo

    bar

    • baz
    ``` -------------------------------- ### Fenced Code Block with Complex Info String Source: https://spec.commonmark.org/0.31.2 Demonstrates a fenced code block using tildes (~) as delimiters and a complex info string. The info string can include various characters. ```markdown ~~~~ ruby startline=3 $% @#$ def foo(x) return 3 end ~~~~~~~ ``` ```html
    def foo(x)
      return 3
    end
    
    ``` -------------------------------- ### Basic Emphasis with Underscores Source: https://spec.commonmark.org/0.31.2 Demonstrates basic emphasis using single underscores. Excess literal underscores appear outside the emphasis. ```CommonMark foo ___ ``` ```HTML

    foo ___

    ``` ```CommonMark foo _\__ ``` ```HTML

    foo _

    ``` ```CommonMark foo _*_ ``` ```HTML

    foo *

    ``` ```CommonMark foo _____ ``` ```HTML

    foo _____

    ``` -------------------------------- ### HTML Block with Unclosed Open Tag Source: https://spec.commonmark.org/0.31.2 Shows an HTML block starting with an unclosed
    tag. The block continues until a blank line, and subsequent Markdown is parsed normally. ```markdown
    *foo* *bar* ``` ```html tag. This demonstrates that HTML blocks can begin with closing tags and are terminated by a blank line. ```markdown
    *foo* ``` ```html
    ``` -------------------------------- ### Emphasis with Asterisk - Nested and Delimiter Runs Source: https://spec.commonmark.org/0.31.2 Illustrates emphasis within emphasis and the rules for right-flanking delimiter runs. ```markdown *(*foo*)* ``` ```html

    (foo)

    ``` -------------------------------- ### Inline Link Precedence Over Reference Source: https://spec.commonmark.org/0.31.2 Inline links take precedence over reference links. This example shows an inline link with an empty URL, which takes precedence over a defined reference. ```markdown [foo]() [foo]: /url1 ``` ```html

    foo

    ``` -------------------------------- ### Multiple Link Reference Definitions Source: https://spec.commonmark.org/0.31.2 Illustrates the ambiguity when multiple definitions exist for the same link reference, and which definition takes precedence. ```markdown [foo]: /url1 [foo]: /url2 [foo][] ``` -------------------------------- ### Code Span vs. HTML Tag Precedence Source: https://spec.commonmark.org/0.31.2 Illustrates that code spans and HTML tags have the same precedence. This example shows an HTML tag being parsed as code due to the backticks. ```markdown `` ``` ```html

    <a href="">`

    ``` -------------------------------- ### Fenced Code Block with Tildes Source: https://spec.commonmark.org/0.31.2 Demonstrates using at least three tildes to create a fenced code block. This functions identically to backticks. ```markdown ~~~ < > ~~~ ``` ```html
    <
     >
    
    ``` -------------------------------- ### Link Reference Definition with Indentation and Multi-line Destination/Title Source: https://spec.commonmark.org/0.31.2 Demonstrates a link reference definition with leading indentation and a destination/title spanning multiple lines. Note the use of spaces for indentation and line continuation. ```markdown [foo]: /url 'the title' [foo] ``` -------------------------------- ### Nested Emphasis with Different Delimiters Source: https://spec.commonmark.org/0.31.2 Shows how to achieve nested emphasis by using different delimiters for inner and outer emphasis. ```CommonMark **foo** ``` ```HTML

    foo

    ``` ```CommonMark *_foo_* ``` ```HTML

    foo

    ``` ```CommonMark __foo__ ``` ```HTML

    foo

    ``` ```CommonMark _*foo*_ ``` ```HTML

    foo

    ``` -------------------------------- ### Shortcut Reference Link Source: https://spec.commonmark.org/0.31.2 A shortcut reference link uses the format `[label]`. The link text is the parsed content of the label, and the URI and title are taken from the matching reference definition. It's equivalent to `[label][]`. ```markdown [foo] [foo]: /url "title" ``` ```markdown [*foo* bar] [*foo* bar]: /url "title" ``` ```markdown [[*foo* bar]] [*foo* bar]: /url "title" ``` ```markdown [[bar [foo] [foo]: /url ``` -------------------------------- ### Textarea Tag HTML Block Source: https://spec.commonmark.org/0.31.2 Example of a ` ``` -------------------------------- ### Simple Paragraphs Source: https://spec.commonmark.org/0.31.2 Demonstrates the basic structure of paragraphs, where a sequence of non-blank lines forms a paragraph. ```CommonMark aaa bbb ``` -------------------------------- ### Script Tag HTML Block Source: https://spec.commonmark.org/0.31.2 Example of a ` okay ``` -------------------------------- ### HTML for Loose Outer List with Tight Inner List Source: https://spec.commonmark.org/0.31.2 HTML output for a loose outer list containing a tight inner list. ```html
    • foo

      • bar

      baz

    ``` -------------------------------- ### Case-Insensitive Label Matching with Unicode Source: https://spec.commonmark.org/0.31.2 Demonstrates case-insensitive label matching with Unicode characters. The reference '[αγω]' correctly matches the definition '[ΑΓΩ]'. ```markdown [ΑΓΩ]: /φου [αγω] ``` -------------------------------- ### Reference Link - Whitespace Between Text and Label Source: https://spec.commonmark.org/0.31.2 This example demonstrates that whitespace is not allowed between the link text and the link label in reference links, contrasting with Gruber's original Markdown syntax. ```markdown [foo] [bar] [foo]: /url1 [bar]: /url2 ``` -------------------------------- ### Shortcut Reference-style Image Source: https://spec.commonmark.org/0.31.2 A shortcut for reference-style images where the label is implied by the alt text and matches the alt text directly. ```markdown ![foo] [foo]: /url "title" ``` ```html

    foo

    ``` -------------------------------- ### Ordered List with Indentation Source: https://spec.commonmark.org/0.31.2 Illustrates an ordered list with varying indentation levels for its items. ```markdown 1. a 2. b 3. c ``` -------------------------------- ### Image Label Case-Insensitivity Source: https://spec.commonmark.org/0.31.2 Demonstrates that link labels used in image syntax are case-insensitive. ```markdown ![Foo] [foo]: /url "title" ``` ```html

    Foo

    ``` -------------------------------- ### List Items at Different Indentation Levels Source: https://spec.commonmark.org/0.31.2 Demonstrates that list items are treated at the same list level if they are not indented enough to belong to the previous list item, even if indentation varies. ```markdown - a - b ``` -------------------------------- ### List item starting with indented code block Source: https://spec.commonmark.org/0.31.2 Illustrates a list item where the first block is an indented code block. This requires specific indentation rules for the content following the list marker. ```markdown indented code paragraph more code ``` -------------------------------- ### HTML Block with Tag and Blank Lines Source: https://spec.commonmark.org/0.31.2 Illustrates an HTML block where the tag is followed by blank lines, and the content is interpreted as CommonMark. ```html *foo* ``` -------------------------------- ### Basic HTML Block Type 6 Source: https://spec.commonmark.org/0.31.2 An example of a basic HTML block using a tag, demonstrating type 6 HTML block parsing where the block ends at a blank line. ```markdown
    hi
    okay. ``` ```html
    hi
    ``` -------------------------------- ### Run CommonMark Spec Tests Source: https://spec.commonmark.org/0.31.2 Use this command to run conformance tests against a Markdown program using the CommonMark specification file. Ensure the script and spec file paths are correct for your setup. ```bash python test/spec_tests.py --spec spec.txt --program PROGRAM ``` -------------------------------- ### Reference-style Image with Different Case Label Source: https://spec.commonmark.org/0.31.2 Demonstrates that reference labels for images are case-insensitive. ```markdown ![foo][bar] [BAR]: /url ``` ```html

    foo

    ``` -------------------------------- ### Ordered list item with indented code block Source: https://spec.commonmark.org/0.31.2 Shows an ordered list item containing an indented code block. The start number of the ordered list is preserved, and the code block is indented appropriately. ```markdown 10. foo bar ``` -------------------------------- ### Link Label Ending with Closing Bracket Source: https://spec.commonmark.org/0.31.2 A link label is considered to end at the first closing bracket that is not part of a nested, balanced set of brackets. This example shows a link label ending with an asterisk. ```markdown [foo*]: /url *[foo*] ``` ```html

    *foo*

    ``` -------------------------------- ### Nested Strong Emphasis with Same Delimiters Source: https://spec.commonmark.org/0.31.2 Demonstrates that strong emphasis can be nested using the same delimiters (asterisks or underscores). ```CommonMark ****foo**** ``` ```HTML

    foo

    ``` ```CommonMark ____foo____ ``` ```HTML

    foo

    ``` -------------------------------- ### Invalid Link Reference Definition with Blank Line in Title Source: https://spec.commonmark.org/0.31.2 This example shows an invalid link reference definition because the title contains a blank line, which is not permitted. This results in the content being parsed as separate paragraphs. ```markdown [foo]: /url 'title with blank line' [foo] ``` -------------------------------- ### Intraword Emphasis Handling Source: https://spec.commonmark.org/0.31.2 Demonstrates the distinction between internal emphasis using asterisks and the absence of emphasis with internal underscores. ```markdown internal emphasis: foo*bar*baz no emphasis: foo_bar_baz ``` -------------------------------- ### Shortcut Reference-style Image with Formatted Alt Text Source: https://spec.commonmark.org/0.31.2 Shows shortcut reference-style images where the alt text contains inline formatting, rendered as plain text in the alt attribute. ```markdown ![*foo* bar] [*foo* bar]: /url "title" ``` ```html

    foo bar

    ``` -------------------------------- ### Mixed Lazy and Non-Lazy Continuation Source: https://spec.commonmark.org/0.31.2 A block quote demonstrating that laziness applies to lines that would be paragraph continuations. The 'baz' line continues the 'bar' paragraph, and 'foo' starts a new paragraph within the block quote. ```markdown > bar baz > foo ``` -------------------------------- ### HTML for Nested Lists with Multiple Items Source: https://spec.commonmark.org/0.31.2 HTML rendering of nested unordered lists, each containing multiple items. ```html
    • a

      • b
      • c
    • d

      • e
      • f
    ``` -------------------------------- ### HTML for Loose Unordered List with Empty Item Source: https://spec.commonmark.org/0.31.2 HTML output for a loose unordered list that includes an empty item. ```html
    • a

    • c

    ``` -------------------------------- ### Emphasis with Left- and Right-Flanking Underscore Source: https://spec.commonmark.org/0.31.2 Demonstrates that emphasis is allowed when the opening underscore is both left- and right-flanking, provided it is preceded by punctuation. ```markdown foo-_(bar)_ ``` ```html

    foo-(bar)

    ``` -------------------------------- ### Reference Link with Whitespace Normalization Source: https://spec.commonmark.org/0.31.2 Consecutive internal spaces, tabs, and line endings in link labels are treated as a single space for matching purposes. This example shows a reference link where the label 'Foo bar' is normalized. ```markdown [Foo bar]: /url [Baz][Foo bar] ``` -------------------------------- ### HTML for Inline Code Parsing Source: https://spec.commonmark.org/0.31.2 HTML output for an inline code span followed by a literal backtick. ```html

    hilo`

    ``` -------------------------------- ### HTML for Loose List with Multiple Block Elements Source: https://spec.commonmark.org/0.31.2 HTML rendering of a loose list item containing multiple block elements separated by a blank line. ```html
    • a

    • b

      c

    • d

    ```