### Markdown Input Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt This is an example of Markdown input used to demonstrate the parsing process. ```markdown > Lorem ipsum dolor sit amet. > - Qui *quodsi iracundia* > - aliquando id ``` -------------------------------- ### Markdown List Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows the equivalent Markdown syntax for lists, demonstrating readability and nesting. ```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. ``` -------------------------------- ### Delimiter Run Examples: Both Left and Right-Flanking Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Examples of delimiter runs that are both left and right-flanking. ```text abc***def "abc"_"def" ``` -------------------------------- ### Basic Block Quote Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a simple block quote with a heading and paragraphs. Requires a block quote marker ('> ') at the start of each line. ```markdown > # Foo > bar > baz ``` ```html

Foo

bar baz

``` -------------------------------- ### Ordered List Delimiters and Start Number Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates how different ordered list delimiters ('.' or ')') and the starting number of the first item define the resulting HTML ordered list. ```markdown 1. foo 2. bar 3) baz ``` ```html
  1. foo
  2. bar
  1. baz
``` -------------------------------- ### Delimiter Run Examples: Left-Flanking Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Examples of delimiter runs that are left-flanking but not right-flanking. ```text ***abc _abc **"abc" _"abc" ``` -------------------------------- ### Basic HTML Block Example (Type 6) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates a basic HTML block of type 6, starting with '' and ending at a blank line, followed by regular Markdown parsing. ```markdown
hi
okay. . tr
hi

okay.

``` -------------------------------- ### Delimiter Run Examples: Right-Flanking Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Examples of delimiter runs that are right-flanking but not left-flanking. ```text abc*** abc_ "abc"** "abc"_ ``` -------------------------------- ### Local Development Setup Source: https://github.com/gjtorikian/commonmarker/blob/main/README.md These commands are used to set up the Commonmarker gem for local development after cloning the repository. Ensure comrak dependencies are met. ```shell script/bootstrap bundle exec rake compile ``` -------------------------------- ### Basic Table Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a simple table with a header, delimiter row, and data rows. Ensure proper Markdown formatting for tables. ```markdown | foo | bar | | --- | --- | | baz | bim | ``` ```html
foo bar
baz bim
``` -------------------------------- ### URI Autolink Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a basic URI autolink. Ensure the URI is enclosed in angle brackets. ```markdown .

http://foo.bar.baz

``` -------------------------------- ### AsciiDoc List Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates the AsciiDoc syntax for lists, including nested items and indented blocks. ```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. -- ``` -------------------------------- ### Delimiter Run Examples: Neither Left nor Right-Flanking Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Examples of delimiter runs that are neither left nor right-flanking. ```text abc *** def a _ b ``` -------------------------------- ### HTML Block Example with Nested Pre Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates how an HTML block, started by '', is terminated by a blank line, causing nested '
' tags to be treated as literal content within the block.

```markdown
**Hello**,

_world_.
. tr
**Hello**,

world.

``` -------------------------------- ### Extended WWW Autolink Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates recognizing a 'www.' prefixed autolink. The 'http://' scheme is automatically inserted. ```markdown www.commonmark.org ``` ```html

www.commonmark.org

``` -------------------------------- ### Valid ordered list start number (9 digits) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Ordered list start numbers are limited to a maximum of nine digits. This example shows a valid start number. ```markdown 123456789. ok ``` ```html
  1. ok
``` -------------------------------- ### HTML Block Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates how HTML blocks are interpreted, including the use of spaces for indentation and the handling of raw HTML within `
` tags.

```html
Hi
.
<td>
  Hi
</td>
``` -------------------------------- ### Basic HTML Block Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a simple HTML block within Markdown content. ```markdown
- foo .
  • foo
``` -------------------------------- ### List starting with an empty item Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates a list that begins with an empty list item. ```markdown * ``` ```html
``` -------------------------------- ### Ordered list start number with leading zeros Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Leading zeros in ordered list start numbers are permitted and are correctly interpreted. This example shows a valid start number with leading zeros. ```markdown 0. ok ``` ```html
  1. ok
``` -------------------------------- ### List Item Content Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates the expected HTML output for a sequence of lines constituting a list item with various block types. ```markdown ```````````````````````````````` example A paragraph with two lines. indented code > A block quote. .

A paragraph with two lines.

indented code

A block quote.

```````````````````````````````` ``` -------------------------------- ### Ordered List Item with Start Number Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how an ordered list item is formed and its content, including the assignment of a start number based on the marker. ```markdown ```````````````````````````````` example 1. A paragraph with two lines. indented code > A block quote. .
  1. A paragraph with two lines.

    indented code
    

    A block quote.

```````````````````````````````` ``` -------------------------------- ### Indented HTML Div Start Tag Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates indentation rules for HTML div start tags within blocks. ```markdown
.
<div>
``` -------------------------------- ### List item with adjusted indentation and content Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt This example demonstrates how indentation adjustments allow for list item formation even when content initially appears to be offset. ```markdown - foo bar ``` ```html
  • foo

    bar

``` -------------------------------- ### Basic Strikethrough Usage Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Use double tildes (~~) to wrap text for strikethrough formatting. This example shows basic usage with a simple sentence. ```markdown ~~Hi~~ Hello, world! ``` ```html

Hi Hello, world!

``` -------------------------------- ### Basic Code Span Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a simple inline code span. Delimiters are single backticks. ```markdown ```````````````````````````````` example `foo` .

foo

```````````````````````````````` ``` -------------------------------- ### List item starting with a blank line followed by content Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates that when a list item starts with a blank line, subsequent content on the same line is not considered part of the list item. ```markdown - foo ``` ```html

foo

``` -------------------------------- ### HTML Declarations Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how HTML declarations are parsed and rendered. The example includes a DOCTYPE declaration for an empty element. ```html foo .

foo

``` -------------------------------- ### Markdown Emphasis and Strong Emphasis Examples Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates various combinations of asterisks and underscores for strong emphasis and nested emphasis. ```markdown ***strong emph*** ***strong** in emph* ***emph* in strong** **in strong *emph*** *in emph **strong*** ``` ```markdown *emph *with emph* in it* **strong **with strong** in it** ``` ```markdown internal emphasis: foo*bar*baz no emphasis: foo_bar_baz ``` -------------------------------- ### Render Basic HTML Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Renders a simple HTML string. This is a basic example of text processing. ```html bar ``` -------------------------------- ### Smart Quotes Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/smart_punct.txt Demonstrates conversion of straight double and single quotes to smart quotes. Handles nested quotes. ```markdown "Hello," said the spider. "'Shelob' is my name." ``` ```markdown 'A', 'B', and 'C' are letters. ``` ```markdown 'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.' ``` ```markdown 'He said, "I want to go."'" ``` -------------------------------- ### Invalid ordered list start number (negative) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Negative numbers are not valid start numbers for ordered lists and will be rendered as plain text. ```markdown -1. not ok ``` ```html

-1. not ok

``` -------------------------------- ### List items starting with a blank line Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates list items that begin with a blank line, showing how nested elements like code blocks and block quotes are handled. ```markdown - foo - ``` bar ``` - baz ``` ```html
  • foo
  • bar
    
  • baz
    
``` -------------------------------- ### Nested Emphasis and Strong Emphasis Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates various cases of nesting emphasis and strong emphasis. The examples cover different combinations and their correct rendering. ```markdown _foo __bar__ baz_ .

foo bar baz

``` ```markdown _foo _bar_ baz_ .

foo bar baz

``` ```markdown __foo_ bar_ .

foo bar

``` ```markdown *foo *bar** .

foo bar

``` ```markdown *foo **bar** baz* .

foo bar baz

``` ```markdown *foo**bar**baz* .

foobarbaz

``` -------------------------------- ### Extended URL Autolink Examples Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows recognized extended URL autolinks using 'http://', 'https://', and 'ftp://' schemes. ```markdown http://commonmark.org (Visit https://encrypted.google.com/search?q=Markup+(business)) Anonymous FTP is available at ftp://foo.bar.baz. ``` ```html

http://commonmark.org

(Visit https://encrypted.google.com/search?q=Markup+(business))

Anonymous FTP is available at ftp://foo.bar.baz.

``` -------------------------------- ### HTML Block with Incomplete Tag Start Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt An HTML tag start that is not a valid tag can still initiate an HTML block if it begins like a tag. ```html
.

foo@bar.example.com

``` -------------------------------- ### Multiple Link Reference Definitions Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Presents a Markdown example with multiple definitions for the same link reference. This highlights the ambiguity in precedence rules when duplicate references exist. ```markdown [foo]: /url1 [foo]: /url2 [foo][] ``` -------------------------------- ### Setext Heading Level 1 and 2 Examples Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates basic setext headings. Level 1 uses '=', Level 2 uses '-'. Inline formatting within the heading text is supported. ```markdown Foo *bar* ========= Foo *bar* --------- ``` ```html

Foo bar

Foo bar

``` -------------------------------- ### Ordered list start number with multiple leading zeros Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Multiple leading zeros in ordered list start numbers are handled correctly, with the number being parsed as its numerical value. ```markdown 003. ok ``` ```html
  1. ok
``` -------------------------------- ### Empty List Item Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows a Markdown list with an empty list item. This example questions the validity and rendering of empty list items. ```markdown * a * * b ``` -------------------------------- ### Markdown Indented Code Block Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates a common Markdown pattern where indented code follows a list item. This example highlights how indentation is measured relative to the list marker and the 'foo' text. ```markdown 1. foo indented code ``` -------------------------------- ### Markdown Inside HTML Block (Table Example) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how blank lines within an HTML table structure are handled. ```markdown
Hi
.
Hi
``` -------------------------------- ### Ordered List as First Block in List Item Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates an ordered list starting within a list item, resulting in nested ordered and unordered lists. ```markdown 1. - 2. foo ``` ```html
      1. foo
``` -------------------------------- ### Invalid ordered list start number (10 digits) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Ordered list start numbers exceeding nine digits are not parsed as list items and are rendered as plain text. ```markdown 1234567890. not ok ``` ```html

1234567890. not ok

``` -------------------------------- ### Fenced Code Block with Tilde Fences Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates the use of tilde (~) characters for fenced code blocks. This example shows how tildes can be used as opening and closing fences, preserving internal content. ```markdown ```````````````````````````````` example ~~~~~~ aaa ~~~ ~~ .
aaa
~~~ ~~
```````````````````````````````` ``` -------------------------------- ### HTML Block with Partial Tag Start Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows an HTML block where the opening tag is split across lines due to whitespace, demonstrating flexibility in tag parsing. ```markdown
. tr
``` -------------------------------- ### Nested Link (Not Allowed) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates that links cannot contain other links. This example shows an invalid nesting attempt. ```markdown [foo [bar](/uri)][ref] [ref]: /uri ``` -------------------------------- ### Markdown.pl Behavior with Hard-Wrapped Numerals Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Example of how Markdown.pl does not interpret hard-wrapped numerals in a paragraph as the start of a list, contrasting with CommonMark's behavior. ```markdown The number of windows in my house is 14. The number of doors is 6. ``` -------------------------------- ### Emphasis and Strong Emphasis Precedence Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows a Markdown example with nested emphasis and strong emphasis markers. This raises questions about the precedence rules for parsing these inline elements. ```markdown *foo *bar* baz* ``` -------------------------------- ### Commonmarker with Parse and Render Options Source: https://github.com/gjtorikian/commonmarker/blob/main/README.md Demonstrates how to pass parse and render options to Commonmarker. Ensure options are provided as a hash dictionary with symbol keys. ```ruby Commonmarker.to_html('"Hi *there*"', options:{ parse: { smart: true }, render: { hardbreaks: false} }) ``` -------------------------------- ### Invalid Autolink with Colon and No Scheme Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows an example that is not an autolink because it contains a colon but does not conform to the absolute URI scheme requirements. ```markdown .

<m:abc>

``` -------------------------------- ### Handle Raw HTML Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates how raw HTML is handled. Ensure proper escaping for PHP within HTML. ```html

foo

``` -------------------------------- ### Table followed by Paragraph Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows that a table is terminated by an empty line, after which a new paragraph can begin. This example includes a table followed by a paragraph. ```markdown | abc | def | | --- | --- | | bar | baz | bar bar ``` ```html
abc def
bar baz
bar

bar

``` -------------------------------- ### Syntax Highlighter with Custom Theme Path Source: https://github.com/gjtorikian/commonmarker/blob/main/README.md Load custom themes for the syntax highlighter by providing a path to a directory containing `.tmtheme` files. ```ruby Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "Monokai", path: "./themes" } }) ``` -------------------------------- ### Changing List Delimiters Starts a New List Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates how changing the list marker (e.g., from '-' to '+') initiates a new list in CommonMark, affecting the HTML output. ```markdown - foo - bar + baz ``` ```html
  • foo
  • bar
  • baz
``` -------------------------------- ### Commonmarker with Extensions and Render Options Source: https://github.com/gjtorikian/commonmarker/blob/main/README.md Shows how to enable extensions like footnotes and description lists alongside render options. Extensions are toggled within the 'extension' key. ```ruby Commonmarker.to_html('"Hi *there*"', options: { extension: { footnotes: true, description_lists: true }, render: { hardbreaks: false } }) ``` -------------------------------- ### Inline Link with Space in Unbracketed Destination Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt This example shows that spaces in a link destination are not allowed unless the destination is enclosed in pointy brackets. The output is rendered as plain text. ```markdown [link](/my uri) .

[link](/my uri)

``` -------------------------------- ### Basic Image Syntax Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Standard image syntax with description, URL, and optional title. ```markdown ![foo](/url "title") ``` ```html

foo

``` -------------------------------- ### List item with indented code block and specific start number Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt When an ordered list item starts with an indented code block, the indentation rules apply, and the start number is correctly parsed. ```markdown 10. foo bar ``` ```html
  1. foo

    bar
    
``` -------------------------------- ### Link Label with Escaped Closing Bracket Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows an example where an escaped closing bracket is used within a link label, demonstrating proper escaping. ```markdown [foo][ref\[] ``` -------------------------------- ### HTML Block Starting with Closing Tag Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates an HTML block that begins with a closing tag '
', followed by Markdown content, and then the end of the block. ```markdown
*foo* . tr
*foo* ``` -------------------------------- ### Emphasis with Links and Special Characters Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Examples of emphasis and strong emphasis interacting with Markdown links and special characters like asterisks within code. ```markdown *[bar*](/url) .

*bar*

``` ```markdown _foo [bar_](/url) .

_foo bar_

``` ```markdown * .

*

``` ```markdown ** .

**

``` ```markdown __ .

__

``` ```markdown *a `*`* .

a *

``` ```markdown _a `_`_ .

a _

``` ```markdown **a .

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

``` ```markdown __a .

__ahttp://foo.bar/?q=__

``` -------------------------------- ### Indented HTML Block Start Tag Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows that an HTML comment block start tag can be indented 1-3 spaces, but not 4. ```markdown .
<!-- foo -->
``` -------------------------------- ### Indented Ordered List Markers Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows an example of an ordered list with indented markers. This raises questions about the flexibility and parsing rules for list item markers. ```markdown 8. item 1 9. item 2 10. item 2a ``` -------------------------------- ### List Item Paragraph Tagging Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Presents Markdown examples demonstrating ambiguity in when list items should be wrapped in

tags. This covers scenarios with mixed loose and tight list item structures. ```markdown 1. one 2. two 3. three ``` ```markdown 1. one - a - b 2. two ``` -------------------------------- ### HTML Block with Div and Markdown Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows an HTML block starting with '

' containing Markdown content, followed by a blank line, and then another HTML block. ```markdown
*hello* . tr
*hello* ``` -------------------------------- ### Basic Unordered List Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a simple unordered list. Ensure proper Markdown syntax for list items. ```markdown - a - b - c - d - e - f - g ``` ```html
  • a
  • b
  • c
  • d
  • e
  • f
  • g
``` -------------------------------- ### Multiple Matching Link References Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates that when multiple link reference definitions match, the first one encountered is used. ```markdown [foo]: /url1 [foo]: /url2 [bar][foo] ``` -------------------------------- ### Soft Line Break Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a soft line break, which occurs when a line break is not preceded by two spaces or a backslash. It is rendered as a line ending in HTML. ```markdown foo baz .

foo baz

``` -------------------------------- ### Basic Emphasis and Strong Emphasis Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates basic usage of emphasis and strong emphasis with asterisks. ```markdown foo*bar*baz ``` ```html

foobarbaz

``` -------------------------------- ### Link Label Matching (Non-Parsed) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Explains that link label matching is performed on normalized strings, not parsed inline content. This example shows a non-match due to literal characters. ```markdown [bar][foo\!] [foo!]: /url ``` -------------------------------- ### Unintended List Capture with Starting Number '1' Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Highlights a case where a numeral '1' can unintentionally start a list, even if it's part of a sentence, due to CommonMark's paragraph interruption 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.
``` -------------------------------- ### List Item with Section Heading Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a Markdown list item containing a section heading. This example highlights differences in implementation regarding nested block-level elements within lists. ```markdown - # Heading ``` -------------------------------- ### Basic Strong Emphasis Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates basic usage of strong emphasis with asterisks. ```markdown foo**bar**baz ``` ```html

foobarbaz

``` -------------------------------- ### Emphasis with Underscores Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates basic emphasis using underscores. The opening and closing delimiters must be part of valid delimiter runs. ```Markdown _foo bar_ ``` ```HTML

foo bar

``` -------------------------------- ### HTML Block with Same Line Tags Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows an HTML block where the start and end tags are on the same line. ```markdown *foo* .

foo

``` -------------------------------- ### Basic Fenced Code Block with Tildes Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a simple fenced code block using tildes. The info string specifies the language. ```markdown ~~~ < > ~~~ ``` -------------------------------- ### Simple Image Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Basic image syntax with only description and URL. ```markdown ![foo](train.jpg) ``` ```html

foo

``` -------------------------------- ### Get Source Position of a Node Source: https://github.com/gjtorikian/commonmarker/blob/main/README.md Retrieves the source position (line and column numbers) of a parsed document node. ```ruby doc = Commonmarker.parse("*Hello* world") puts doc.first_child.first_child.source_position # => {:start_line=>1, :start_column=>1, :end_line=>1, :end_column=>7} ``` -------------------------------- ### Table followed by Blockquote Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates that a table is terminated by the first empty line or the start of another block-level element, such as a blockquote. ```markdown | abc | def | | --- | --- | | bar | baz | > bar ``` ```html
abc def
bar baz

bar

``` -------------------------------- ### Run Markdown Spec Tests Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Use this command to run conformance tests against a Markdown program using the spec document and a Python script. ```bash python test/spec_tests.py --spec spec.txt --program PROGRAM ``` -------------------------------- ### HTML Block with Tag Not in Block-Level List Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt To start an HTML block with a tag not in the block-level list, the tag must be complete and on its own line. ```html
*bar* . *bar* ``` -------------------------------- ### Emphasis within Emphasis Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Provides an example of nested emphasis, where an inner set of delimiters is correctly interpreted within an outer set. ```markdown *(*foo*)* .

(foo)

``` -------------------------------- ### Indented Block Quote Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates block quotes where the '>' marker is indented by 1-3 spaces. This is still parsed as a block quote. ```markdown > # Foo > bar > baz ``` ```html

Foo

bar baz

``` -------------------------------- ### Shortcut Image with Inline Formatting Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shortcut image syntax with inline formatting in the description. The label must match the plain text. ```markdown ![*foo* bar] [*foo* bar]: /url "title" ``` ```html

foo bar

``` -------------------------------- ### Indentation for Sublists Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates a Markdown snippet where indentation for sublists is ambiguous. This example highlights a common point of divergence between Markdown parsers. ```markdown paragraph code? ``` -------------------------------- ### Link Reference Definition and Usage Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates how to define and use link references in Markdown. Link reference definitions can appear consecutively without blank lines. ```markdown [foo]: /url bar === [foo] .

bar

foo

``` ```markdown [foo]: /url === [foo] .

===
foo

``` ```markdown [foo]: /foo-url "foo" [bar]: /bar-url "bar" [baz]: /baz-url [foo], [bar], [baz] .

foo, bar, baz

``` ```markdown [foo] > [foo]: /url .

foo

``` ```markdown [foo]: /url . ``` -------------------------------- ### Strikethrough with New Paragraphs Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Strikethrough parsing ceases when a new paragraph is encountered. This example demonstrates how a new paragraph breaks the strikethrough formatting. ```markdown This ~~has a new paragraph~~. ``` ```html

This ~~has a

new paragraph~~.

``` -------------------------------- ### Nonentities and Undefined Entities Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Examples of strings that are not recognized as valid entity or numeric character references. These are typically rendered as literal text, with '&' being escaped. ```CommonMark   &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?; . ``` ```HTML

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

``` -------------------------------- ### Syntax Highlighter with CSS Classes Source: https://github.com/gjtorikian/commonmarker/blob/main/README.md Configure the syntax highlighter to output CSS classes instead of inline styles by setting the theme to an empty string. ```ruby code = <<~CODE ```ruby def hello puts "hello" end CODE Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "" } }) ``` -------------------------------- ### Emphasis with Asterisks Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates basic emphasis using asterisks. The opening and closing delimiters must be part of valid delimiter runs. ```Markdown *foo bar* ``` ```HTML

foo bar

``` -------------------------------- ### Setext Heading with List Item Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a setext heading created from a list item. Ensure the underline character matches the list item's content. ```markdown ```````````````````````````````` example - foo ----- .
  • foo

```````````````````````````````` ``` -------------------------------- ### Syntax Highlighter with Custom Theme Source: https://github.com/gjtorikian/commonmarker/blob/main/README.md Use the syntax highlighter plugin with a specific theme like 'InspiredGitHub'. This applies inline styles for highlighting. ```ruby code = <<~CODE ```ruby def hello puts "hello" end ``` CODE # pass in a theme name from a pre-existing set puts Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "InspiredGitHub" } }) ``` -------------------------------- ### Basic Link with Emphasis and Code Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a link containing emphasis and code elements. The link text can include nested formatting. ```markdown

link foo bar #

``` -------------------------------- ### Tight List with Code Block Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates a tight list where blank lines within a code block do not create list looseness. ```markdown - a - ``` b ``` - c ``` ```html
  • a
  • b
    
    
    
  • c
``` -------------------------------- ### Link Destinations with Fragment Identifiers and Queries Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Link destinations can include fragment identifiers and query parameters. ```markdown [link](#fragment) [link](http://example.com#fragment) [link](http://example.com?foo=3#frag) ) ``` -------------------------------- ### Shortcut Image Syntax Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shortcut image syntax where the label is implicitly the same as the image description text. ```markdown ![foo] [foo]: /url "title" ``` ```html

foo

``` -------------------------------- ### Nested Strong Emphasis within Emphasis Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Example of strong emphasis nested within emphasis, where the inner strong emphasis delimiters are enclosed in parentheses. ```markdown _(__foo__)_ .

(foo)

``` -------------------------------- ### Invalid Link Reference Definition with Blank Line in Title Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt This example demonstrates that a blank line within a quoted title makes the definition invalid. ```markdown [foo]: /url 'title with blank line' [foo] . ``` -------------------------------- ### Tight List with Blockquote Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates a tight list where a blockquote within an item does not create looseness. ```markdown * a > b > * c ``` ```html
  • a

    b

  • c
``` -------------------------------- ### List Interrupting Paragraph (CommonMark Rule) Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows that only lists starting with '1' can interrupt paragraphs in CommonMark to avoid spurious list captures from hard-wrapped numerals. ```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.

``` -------------------------------- ### Combined Emphasis and Strong Emphasis Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates the rendering of combined emphasis and strong emphasis using different delimiter combinations. ```markdown ***foo*** .

foo

``` ```markdown _____foo_____ .

foo

``` -------------------------------- ### List item indentation with blank line Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows that the number of spaces after a list marker does not affect required indentation when the list item starts with a blank line. ```markdown - foo ``` ```html
  • foo
``` -------------------------------- ### Nested Task List Item Rendering Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates the rendering of arbitrarily nested task lists, showing how indentation affects the HTML structure and checkbox states. The `tasklist` extension must be enabled. ```markdown - [x] foo - [ ] bar - [x] baz - [ ] bim ``` ```html
  • foo
    • bar
    • baz
  • bim
``` -------------------------------- ### GFM Tagfilter Extension Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates how the GFM tagfilter extension disallows specific HTML tags by replacing '<' with '<'. Other HTML tags remain untouched. ```markdown <style> <em> <blockquote> <xmp> is disallowed. <XMP> is also disallowed. </blockquote> . <p><strong> <title> <style> <em></p> <blockquote> <xmp> is disallowed. <XMP> is also disallowed. </blockquote> ``` -------------------------------- ### Image as Link Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how an image can be used as the content of a link. This is often used for buttons or icons. ```markdown [![moon](moon.jpg)][ref] [ref]: /uri ``` -------------------------------- ### Initial Document Tree Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt The initial state of the document tree before processing any Markdown input. ```tree -> document ``` -------------------------------- ### Image with Case-Insensitive Label Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates case-insensitivity for labels in shortcut image syntax. ```markdown ![Foo] [foo]: /url "title" ``` ```html <p><img src="/url" alt="Foo" title="title" /></p> ``` -------------------------------- ### Setext Heading with Plain Text Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows a setext heading formed from plain text. The underline must be on a line immediately following the text. ```markdown ```````````````````````````````` example foo --- . <pre><code>foo </code></pre> <hr /> ```````````````````````````````` ``` -------------------------------- ### Strong Emphasis with Quoted Italic Text Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Example of strong emphasis applied to text containing quoted italicized words. The output correctly renders both emphasis types. ```markdown **foo "*bar*" foo** . <p><strong>foo "<em>bar</em>" foo</strong></p> ``` -------------------------------- ### Markdown Blockquote with List Item and Continuation Paragraph Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Example of a Markdown blockquote containing a list item, followed by a continuation paragraph that is less indented than the list marker. ```markdown > - one > > two ``` -------------------------------- ### List item with nested blocks Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt A list item can contain various block elements, including code blocks, paragraphs, and blockquotes. This example shows a typical structure. ```markdown 1. foo ``` bar ``` baz > bam ``` ```html <ol> <li> <p>foo</p> <pre><code>bar </code></pre> <p>baz</p> <blockquote> <p>bam</p> </blockquote> </li> </ol> ``` -------------------------------- ### Mixed Quotes and Code Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/smart_punct.txt Illustrates handling of quoted code blocks and links within smart punctuation context. ```markdown Here is some quoted '`code`' and a "[quoted link](url)". ``` -------------------------------- ### Block Quote Laziness Example Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows the 'laziness' rule where '>' can be omitted before paragraph continuation text. The parser merges subsequent lines into the block quote's paragraph. ```markdown > # Foo > bar baz ``` ```html <blockquote> <h1>Foo</h1> <p>bar baz</p> </blockquote> ``` -------------------------------- ### Handling Blank Lines Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how blank lines at the beginning and end of a document are ignored. Blank lines between block-level elements are also ignored, except for list spacing. ```markdown aaa # aaa . <p>aaa</p> <h1>aaa</h1> ``` -------------------------------- ### Table with Alignment Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how to specify column alignment using colons in the delimiter row. Left alignment is default, use ':' for center or right. ```markdown | abc | defghi | :-: | -----------: | bar | baz ``` ```html <table> <thead> <tr> <th align="center">abc</th> <th align="right">defghi</th> </tr> </thead> <tbody> <tr> <td align="center">bar</td> <td align="right">baz</td> </tr> </tbody> </table> ``` -------------------------------- ### Multiple Blank Lines Between List Items Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates that any number of blank lines can separate list items, and shows the resulting HTML structure with <p> tags for each item. ```markdown - foo - bar - baz ``` ```html <ul> <li> <p>foo</p> </li> <li> <p>bar</p> </li> <li> <p>baz</p> </li> </ul> ``` -------------------------------- ### HTML Processing Instruction Block Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates parsing of a PHP processing instruction as an HTML block. ```markdown <?php echo '>'; ?> okay . <?php echo '>'; ?> <p>okay</p> ``` -------------------------------- ### Image with Reference Label Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Image syntax using a reference label, where the label can be defined later. The rendered alt text is plain. ```markdown ![foo *bar*][foobar] [FOOBAR]: train.jpg "train & tracks" ``` ```html <p><img src="train.jpg" alt="foo bar" title="train & tracks" /></p> ``` -------------------------------- ### Basic Ordered List Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows a basic ordered list. Indentation affects nesting and item grouping. ```markdown 1. a 2. b 3. c ``` ```html <ol> <li> <p>a</p> </li> <li> <p>b</p> </li> <li> <p>c</p> </li> </ol> ``` -------------------------------- ### List item with adjusted indentation Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt When a block begins with 1-3 spaces indent, the indentation can be removed to allow rule #1 (list item formation) to be applied, as shown in this example. ```markdown - foo bar ``` ```html <ul> <li>foo</li> </ul> <p>bar</p> ``` -------------------------------- ### Link Reference Definition in Blockquote Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates a Markdown snippet where a link reference definition appears inside a blockquote. This example probes the scope and placement rules for link references. ```markdown > Blockquote [foo]. > > [foo]: /url ``` -------------------------------- ### Nested Strong Emphasis with Underscores Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Illustrates nesting of strong emphasis using underscores. ```markdown __foo __bar__ baz__ ``` ```html <p><strong>foo bar baz</strong></p> ``` -------------------------------- ### Mixed List Marker Types Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Presents a Markdown example where list markers change from numbers to bullets. This highlights ambiguity regarding whether it's one list or two. ```markdown 1. fee 2. fie - foe - fum ``` -------------------------------- ### Multiple Matching Link Definitions Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt If multiple link reference definitions match a label, the first one encountered takes precedence. ```markdown [foo] [foo]: first [foo]: second . ``` -------------------------------- ### Multiple Strong Emphasis Sections Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how multiple strong emphasis sections are handled when they appear consecutively. The output indicates a single strong emphasis block. ```markdown __foo__bar__baz__ . <p><strong>foo__bar__baz</strong></p> ``` -------------------------------- ### Markdown List Item with Blockquote Indentation Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Shows how a blockquote within a list item should be indented according to Markdown specifications. The exact indentation is not specified but examples suggest a four-space indent. ```markdown - foo > bar ``` -------------------------------- ### Case-Insensitive Link Label Matching Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates that link label matching is case-insensitive. The reference label 'BaR' matches '[bar]'. ```markdown [foo][BaR] [bar]: /url "title" ``` -------------------------------- ### Ordered list item where first block is indented code Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt This example demonstrates an ordered list item where the first content block is an indented code block, adhering to indentation rules. ```markdown 1. indented code paragraph more code ``` ```html <ol> <li> <pre><code>indented code </code></pre> <p>paragraph</p> <pre><code>more code </code></pre> </li> </ol> ``` -------------------------------- ### Generate HTML or CommonMark from Spec Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt This script converts the spec.txt file into HTML or CommonMark format, which can then be further processed. ```bash tools/makespec.py ``` -------------------------------- ### List item with indented code block Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt An indented code block within a list item requires specific indentation relative to the list marker. This example shows a basic case. ```markdown - foo bar ``` ```html <ul> <li> <p>foo</p> <pre><code>bar </code></pre> </li> </ul> ``` -------------------------------- ### Block Structure Precedence Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Indicators of block structure take precedence over inline structure indicators. This example shows a list with two items, not a list item containing a code span. ```markdown - `one - two` . <ul> <li>`one</li> <li>two`</li> </ul> ``` -------------------------------- ### Nested List Items with Correct Indentation Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates correct indentation for nested lists to be recognized as sublists. Incorrect indentation results in separate lists. ```markdown - foo - bar - baz - boo ``` ```html <ul> <li>foo <ul> <li>bar <ul> <li>baz <ul> <li>boo</li> </ul> </li> </ul> </li> </ul> </li> </ul> ``` -------------------------------- ### Emphasis with Underscore Source: https://github.com/gjtorikian/commonmarker/blob/main/test/fixtures/upstream/spec.txt Demonstrates emphasis containing an underscore. ```markdown foo *_* ``` ```html <p>foo <em>_</em></p> ```