### Build and Install cmark with CMake (FreeBSD Example) Source: https://github.com/commonmark/cmark/blob/master/README.md A portable method using CMake to create build environments. This example shows building on FreeBSD, with options for specifying the installation prefix. ```bash cmake -S . -B build # optionally: -DCMAKE_INSTALL_PREFIX=path cmake --build build # executable will be created as build/src/cmark ctest --test-dir build cmake --install build ``` -------------------------------- ### Build and Install cmark with GNU Make Source: https://github.com/commonmark/cmark/blob/master/README.md Use GNU make for a simple build and installation process. The default installation prefix is /usr/local, but can be changed using INSTALL_PREFIX. ```bash make make test make install ``` ```bash make INSTALL_PREFIX=path ``` -------------------------------- ### Install Targets and Package Configuration Files Source: https://github.com/commonmark/cmark/blob/master/src/CMakeLists.txt Installs the 'cmark_exe' executable and 'cmark' library to their respective destinations. Also installs the pkgconfig file and CMake configuration files. ```cmake install(TARGETS cmark_exe cmark EXPORT cmark-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(FILES cmark.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # generate cmark-config.cmake and cmark-config-version.cmake files configure_package_config_file( "cmarkConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/generated/cmark-config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cmark") write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/generated/cmark-config-version.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) # install config and version file install( FILES "${CMAKE_CURRENT_BINARY_DIR}/generated/cmark-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/generated/cmark-config-version.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cmark" ) # install targets file install( EXPORT "cmark-targets" NAMESPACE "cmark::" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cmark" ) ``` -------------------------------- ### CommonMark (Markdown) Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt The equivalent of the AsciiDoc example, demonstrating CommonMark (Markdown) syntax for lists, indentation, and nested structures. ```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. ``` -------------------------------- ### AsciiDoc Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt An example of AsciiDoc syntax for a list with 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. -- ``` -------------------------------- ### Ordered List Item with Start Number Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an ordered list item with a marker '1.' and demonstrates how subsequent lines are indented to align with the list item's content. This example highlights the rule for determining the start number and content indentation. ```CommonMark 1. A paragraph with two lines. indented code > A block quote. ``` -------------------------------- ### Delimiter Runs: Left-Flanking Examples Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Examples of delimiter runs that are left-flanking but not right-flanking, illustrating conditions for opening emphasis. ```text ***abc _abc **"abc" _"abc" ``` -------------------------------- ### Four-Space Rule Example (HTML Output) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows the HTML output corresponding to the four-space rule, where the example is parsed as separate lists. ```html

bar

``` -------------------------------- ### Markdown.pl Two-Space Indentation Example (HTML Output) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows the HTML output for the Markdown.pl two-space indentation example, where 'two' is a continuation paragraph. ```html ``` -------------------------------- ### Ordered list with valid start number Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Ordered list start numbers must be nine digits or less. This example shows a valid start number. ```CommonMark 123456789. ok . ``` -------------------------------- ### Delimiter Runs: Right-Flanking Examples Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Examples of delimiter runs that are right-flanking but not left-flanking, illustrating conditions for closing emphasis. ```text abc*** abc_ "abc"** "abc"_ ``` -------------------------------- ### HTML Block with Non-Standard Tag Start Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates an HTML block starting with a string that resembles a tag but is not standard. ```html
Hi .
Hi
``` -------------------------------- ### Delimiter Runs: Both Left and Right-Flanking Examples Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Examples of delimiter runs that are both left and right-flanking, indicating potential for both opening and closing emphasis. ```text abc***def "abc"_"def" ``` -------------------------------- ### Delimiter Runs: Neither Left nor Right-Flanking Examples Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Examples of delimiter runs that are neither left nor right-flanking, where emphasis is not typically applied. ```text abc *** def a _ b ``` -------------------------------- ### Example of List Item Content Structure Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates the structure of content within a list item, showing how indented code and block quotes are handled. This example demonstrates the basic case of a list item's content. ```CommonMark A paragraph with two lines. indented code > A block quote. ``` -------------------------------- ### Emphasis and Strong Emphasis Examples Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates various combinations of asterisks and underscores for emphasis and strong emphasis, showing how delimiters are parsed. ```markdown **foo*** .

foo*

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

foo***

``` ```markdown foo ___ .

foo ___

``` ```markdown foo _\__ .

foo _

``` ```markdown foo _*_ .

foo *

``` ```markdown foo _____ .

foo _____

``` ```markdown foo __\___ .

foo _

``` ```markdown foo __*__ .

foo *

``` ```markdown __foo_ .

_foo

``` ```markdown _foo__ .

foo_

``` ```markdown ___foo__ .

_foo

``` ```markdown ____foo_ .

___foo

``` ```markdown __foo___ .

foo_

``` ```markdown _foo____ .

foo___

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

foo

``` ```markdown *_foo_* .

foo

``` ```markdown __foo__ .

foo

``` ```markdown _*foo*_ .

foo

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

foo

``` ```markdown ____foo____ .

foo

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

foo

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

foo

``` ```markdown _____foo_____ .

foo

``` ```markdown *foo _bar* baz_ .

foo _bar baz_

``` ```markdown *foo __bar *baz bim__ bam* .

foo bar *baz bim bam

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

**foo bar baz

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

*foo bar baz

``` ```markdown *[bar*](/url) .

*bar*

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

_foo bar_

``` ```markdown * .

*

``` ```markdown ** .

**

``` ```markdown __ .

__

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

a *

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

a _

``` ```markdown **a .

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

``` ```markdown __a .

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

``` -------------------------------- ### Simple Two-Paragraph Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a basic CommonMark document with two distinct paragraphs separated by a blank line. ```CommonMark aaa bbb . ``` -------------------------------- ### HTML Block Type 6 Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates a basic HTML block of type 6, starting with an opening tag and ending after a blank line. Shows how Markdown content within the block is treated as literal text. ```CommonMark
hi
okay. . table> hi

okay.

``` -------------------------------- ### Markdown Nested Emphasis Examples Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Examples showing less common but useful patterns for nested emphasis and strong emphasis. ```markdown *emph *with emph* in it* **strong **with strong** in it** ``` -------------------------------- ### URI Autolink Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a basic URI autolink. Ensure the URI is enclosed in angle brackets. ```CommonMark .

http://foo.bar.baz

``` -------------------------------- ### Simple ATX Headings Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Provides examples of simple ATX headings with varying numbers of '#' characters, demonstrating heading levels from 1 to 5. ```markdown # foo ## foo ### foo #### foo ##### foo ``` -------------------------------- ### Ordered list with leading zeros in start number Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Start numbers for ordered lists can begin with zeros. This example shows a valid start number with leading zeros. ```CommonMark 0. ok . ``` -------------------------------- ### Basic Block Quote Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a standard block quote with a heading and paragraphs. ```markdown > # Foo > bar > baz ``` ```html

Foo

bar baz

``` -------------------------------- ### Markdown Input for Block Structure Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt This is the initial Markdown text used to demonstrate the block structure parsing phase. ```markdown > Lorem ipsum dolor sit amet. > - Qui *quodsi iracundia* > - aliquando id ``` -------------------------------- ### Markdown.pl Blockquote Indentation Example (HTML Output) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Presents the HTML output for the Markdown.pl blockquote example, showing 'two' as a continuation paragraph within the list item. ```html
  • one

    two

``` -------------------------------- ### Full Reference Link Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a full reference link, consisting of link text and a link label that matches a separate link reference definition. This is a common way to define links. ```markdown [foo][bar] [bar]: /url "title" .

foo

``` -------------------------------- ### Ordered list with multiple leading zeros in start number Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Multiple leading zeros in an ordered list start number are handled correctly. This example shows a valid start number with multiple leading zeros. ```CommonMark 003. ok . ``` -------------------------------- ### Emphasis and Strong Emphasis Precedence Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Presents an example to question the precedence rules between emphasis and strong emphasis markers. ```markdown *foo *bar* baz* ``` -------------------------------- ### Email Autolink Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a valid email autolink. It is converted to a 'mailto:' link. ```CommonMark .

foo@bar.example.com

``` -------------------------------- ### List Item with Subparagraph Example (Markdown) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows a Markdown example where 'bar' could be interpreted as a subparagraph of the list item, even with less indentation than 'foo'. ```markdown 10. foo bar ``` -------------------------------- ### Markdown.pl Two-Space Indentation Example (Markdown) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how Markdown.pl parses text with less indentation than the list marker as a continuation paragraph. ```markdown - one two ``` -------------------------------- ### Markdown Intraword Emphasis Examples Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Examples illustrating how Markdown handles emphasis within words using asterisks and underscores, and the best practice of using code spans. ```markdown internal emphasis: foo*bar*baz no emphasis: foo_bar_baz ``` -------------------------------- ### List Item Indentation with Spacing Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows how extra spaces between the list marker and content affect indentation. This example demonstrates that 'two' is treated as indented code because it's not sufficiently indented relative to the list item's start. ```CommonMark - one two ``` -------------------------------- ### HTML Block Parsing Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how HTML blocks are parsed, particularly when Markdown-like syntax appears within them. The parser respects the HTML block's boundaries, and regular Markdown parsing resumes after the block. ```CommonMark
**Hello**,

_world_.
. table>
**Hello**,

world.

``` -------------------------------- ### List starting with an empty item Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows a list that begins with an empty list item. ```CommonMark * ``` ```HTML
``` -------------------------------- ### List Interrupting Paragraph (Markdown Example) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt A markdown example showing a list interrupting a paragraph, demonstrating natural list usage. ```markdown I need to buy - new shoes - a coat - a plane ticket ``` -------------------------------- ### Empty ordered list item Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt An example of an empty ordered list item. ```CommonMark 1. foo 2. 3. bar ``` ```HTML
  1. foo
  2. bar
``` -------------------------------- ### Nested Emphasis and Strong Emphasis Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Provides an example of nested strong emphasis within emphasis, demonstrating correct rendering. ```markdown *(**foo**)* .

(foo)

``` -------------------------------- ### Ordered List Delimiter Separation Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows how different ordered list delimiters ('.' and ')') result in separate ordered lists, with the 'start' attribute correctly applied. ```markdown 1. foo 2. bar 3) baz ``` ```html
  1. foo
  2. bar
  1. baz
``` -------------------------------- ### List Item Precedence Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how block-level indicators like list items take precedence over inline indicators like code spans. This example shows a list with two items, not a single list item containing a code span. ```markdown - `one - two` ``` ```html
  • `one
  • two`
``` -------------------------------- ### Markdown.pl Blockquote Indentation Example (Markdown) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates Markdown.pl's handling of indented blockquotes with less indentation for continuation lines. ```markdown > - one > > two ``` -------------------------------- ### Basic Indentation for List Item Content Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how content is placed under a bullet list item based on indentation. This example shows a simple case where 'two' is not indented enough to be part of the list item. ```CommonMark - one two ``` -------------------------------- ### Emphasis Precedence Over Link Text Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an example where emphasis is applied after the link text is determined, illustrating precedence rules. The link label is a shortcut reference. ```CommonMark [foo *bar][ref]* [ref]: /uri ``` -------------------------------- ### Plain Textual Content with Unicode Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Example of parsing plain textual content including Unicode characters. ```markdown Foo χρῆν ``` -------------------------------- ### HTML Block with Inline Tag Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an HTML block with an inline tag like . ```html *bar* ``` -------------------------------- ### List items with blank lines Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates list items that start with a blank line, including nested code blocks and indented content. ```CommonMark - foo - ``` bar ``` - baz ``` ```HTML
  • foo
  • bar
    
  • baz
    
``` -------------------------------- ### Add cmark_exe Executable Source: https://github.com/commonmark/cmark/blob/master/src/CMakeLists.txt Defines the 'cmark_exe' executable target using 'main.c' and links it against the 'cmark' library. Sets output name and installation runtime path. ```cmake add_executable(cmark_exe main.c) cmark_add_compile_options(cmark_exe) set_target_properties(cmark_exe PROPERTIES OUTPUT_NAME "cmark" INSTALL_RPATH "${Base_rpath}") target_link_libraries(cmark_exe PRIVATE cmark) ``` -------------------------------- ### List item starting with a blank line Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates that when a list item begins with a blank line, subsequent content is not part of the list item. ```CommonMark - foo ``` ```HTML

foo

``` -------------------------------- ### ATX Heading: Escaped '#' character Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt A backslash-escaped '#' character does not start a heading. ```CommonMark \## foo ``` ```HTML

## foo

``` -------------------------------- ### Ordered list with invalid start number Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Ordered list start numbers exceeding nine digits are not rendered as lists. This example shows an invalid start number. ```CommonMark 1234567890. not ok . ``` -------------------------------- ### Configure Version and Package Files Source: https://github.com/commonmark/cmark/blob/master/src/CMakeLists.txt Configures version header and pkg-config files from input templates. Ensures proper versioning and package information for the build. ```cmake configure_file(cmark_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h) configure_file(libcmark.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc @ONLY) ``` -------------------------------- ### Set Include Directories for cmark Source: https://github.com/commonmark/cmark/blob/master/src/CMakeLists.txt Configures interface include directories for the 'cmark' target, specifying paths for installation and build time. ```cmake target_include_directories(cmark INTERFACE $ $ $) ``` -------------------------------- ### Four-Space Rule Example (Markdown) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates a scenario where the four-space rule leads to parsing as multiple lists with an intervening paragraph. ```markdown - foo bar - baz ``` -------------------------------- ### HTML Block with Partial Tag Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates an HTML block starting with an incomplete tag, demonstrating lenient parsing. ```html
(foo)

``` -------------------------------- ### Blank Lines at Document Start and End Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows that blank lines at the beginning and end of a document are ignored. ```CommonMark aaa # aaa . ``` -------------------------------- ### ATX Heading Syntax Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates basic ATX heading syntax with varying numbers of '#' characters. ```CommonMark ###### foo ``` ```HTML

foo

foo

foo

foo

foo
foo
``` -------------------------------- ### Basic Setext Headings (Level 1 and 2) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates the creation of level 1 and level 2 setext headings using '=' and '-' underlines. The content is parsed as CommonMark inline. ```CommonMark Foo *bar* ========= Foo *bar* --------- ``` -------------------------------- ### Ordered list with negative start number Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Negative start numbers are not valid for ordered lists and will be rendered as plain text. ```CommonMark -1. not ok . ``` -------------------------------- ### Invalid Links Due to Unmatched Brackets Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt These examples demonstrate invalid link formats where the opening pointy bracket is not properly matched, resulting in plain text. ```CommonMark [a]( [a](c) ``` -------------------------------- ### URI Autolink with Relative Path Segment Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt An example of a URI autolink that includes a relative path segment. This is parsed as a link. ```CommonMark .

https://../

``` -------------------------------- ### Inline Link with Spaces in URI (Not Allowed without Brackets) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates that spaces within a link destination are not permitted unless the destination is enclosed in angle brackets. This example will render as plain text. ```markdown [link](/my uri) .

[link](/my uri)

``` -------------------------------- ### Indentation for List Item Content (Two Lines) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates how two lines of content are handled within a list item when the second line has additional indentation. This example shows 'two' being correctly placed as a separate paragraph within the list item. ```CommonMark - one two ``` -------------------------------- ### Nonentities and Invalid References Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Provides examples of strings that are not recognized as valid entity or numeric character references, showing how they are treated as literal text. ```CommonMark   &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?; . ``` ```HTML

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

``` -------------------------------- ### List Item Indentation with Spacing (Two Lines) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates how additional indentation for subsequent lines affects content placement within a list item. This example shows 'two' correctly forming a new paragraph under the list item due to sufficient indentation. ```CommonMark - one two ``` -------------------------------- ### Shortcut Reference Link Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a shortcut reference link, where the link text is used as the label and matches a reference definition. ```markdown [foo] [foo]: /url "title" ``` -------------------------------- ### Nested List Interrupting Paragraph (Markdown Example) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Markdown example of a nested list structure where the outer list item contains a paragraph followed by a sublist. ```markdown * I need to buy - new shoes - a coat - a plane ticket ``` -------------------------------- ### Simple Open Tags Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates the parsing of basic HTML open tags with various tag names. ```CommonMark .

``` -------------------------------- ### Ordered list item starting with indented code block Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt An ordered list item starting with an indented code block follows specific indentation rules for its content. ```CommonMark 1. indented code paragraph more code . ``` -------------------------------- ### Empty Fenced Code Block with Empty Info String Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt An example of an empty fenced code block with an empty info string, resulting in an empty code tag. ```html

``` -------------------------------- ### Links and Lists Source: https://github.com/commonmark/cmark/blob/master/fuzz/afl_test_cases/test.md Demonstrates the rendering of links within lists and nested lists. ```markdown > [l](/u "t") > > - [f] > - ![a](/u "t") ``` -------------------------------- ### Run Fuzz Tests with libFuzzer Source: https://github.com/commonmark/cmark/blob/master/README.md Enable and run fuzz testing using libFuzzer, integrated via the GNU Makefile. ```bash make libFuzzer ``` -------------------------------- ### Fenced Code Block Source: https://github.com/commonmark/cmark/blob/master/fuzz/afl_test_cases/test.md Example of a fenced code block with a language identifier. ```markdown ~~~ l☺ cb ~~~ ``` -------------------------------- ### Nested List Item Indentation with Blockquotes Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how indentation rules apply within nested blockquotes for list items. This example shows 'two' correctly indented under the list item despite being within nested blockquotes. ```CommonMark > > 1. one >> >> two ``` -------------------------------- ### Link Reference Definition with HTML Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a link reference definition and its rendering in HTML. ```CommonMark [foo]: /url bar === [foo] . ``` -------------------------------- ### HTML Block with Closing Tag Only Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates an HTML block that starts with only a closing tag. ```html *bar* ``` -------------------------------- ### Illegal Tag Names Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows examples of tag names that do not conform to the specification and are not parsed as HTML. ```CommonMark <33> <__> .

<33> <__>

``` -------------------------------- ### Empty bullet list item Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt An example of an empty bullet list item within a list. ```CommonMark - foo - - bar ``` ```HTML
  • foo
  • bar
``` -------------------------------- ### Link Precedence: Full Reference Over Shortcut Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates that a full reference link takes precedence over a shortcut reference link when both are possible. ```markdown [foo][bar] [foo]: /url1 [bar]: /url2 ``` -------------------------------- ### Basic Emphasis with Underscores Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates simple emphasis using underscores. The opening underscore must not be followed by whitespace. ```CommonMark _foo bar_ .

foo bar

``` -------------------------------- ### Inline Link with Text, URI, and Title Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a basic inline link with all components present. The output shows the rendered HTML anchor tag. ```markdown [link](/uri "title") .

link

``` -------------------------------- ### Cross-compile Windows Binary on Linux with MinGW Source: https://github.com/commonmark/cmark/blob/master/README.md Cross-compile a Windows binary and DLL on a Linux system using the mingw32 compiler. ```bash make mingw ``` -------------------------------- ### HTML Block with Non-Block-Level Tag Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an HTML block starting with a non-block-level tag that must be on its own line. ```html *bar* ``` -------------------------------- ### Basic Emphasis and Strong Emphasis Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates basic nesting of strong emphasis within emphasis. ```markdown *foo **bar*** ``` -------------------------------- ### Alternative Parsing (HTML Output) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Presents an alternative HTML output for the same Markdown, demonstrating a single list with nested elements. ```html
  • foo

    bar

    • baz
``` -------------------------------- ### HTML Block within Table Cell Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt An example of an HTML block contained within a table cell. ```html
foo
``` -------------------------------- ### Basic Fenced Code Block with Tildes Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a simple fenced code block using tildes. The content is treated as literal text. ```markdown ~~~ < > ~~~ ``` -------------------------------- ### HTML Block with Inline End Tag Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt The end tag for an HTML block can appear on the same line as the start tag. ```markdown *foo* .

foo

``` -------------------------------- ### Run cmark Benchmarks Source: https://github.com/commonmark/cmark/blob/master/README.md Execute benchmark tests for cmark using the GNU Makefile. Includes targets for standard and new benchmarks. ```bash make bench ``` ```bash make newbench ``` -------------------------------- ### Illegal Attributes in Closing Tag Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an example of an invalid closing tag that includes attributes, which is not parsed as HTML. ```CommonMark .

</a href="foo">

``` -------------------------------- ### Pre Tag HTML Block Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Example of a
 tag used as an HTML block, which can contain blank lines.

```html

import Text.HTML.TagSoup

main :: IO ()
main = print $ parseTags tags
``` -------------------------------- ### Basic Unordered List Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a simple unordered list with basic list items. ```CommonMark - foo code ``` ```HTML
  • foo

    notcode

  • foo

code
``` -------------------------------- ### Build cmark on Windows with MSVC and NMAKE Source: https://github.com/commonmark/cmark/blob/master/README.md Compile the cmark library and program on Windows using MSVC and NMAKE. ```bash nmake /f Makefile.nmake ``` -------------------------------- ### Illegal Whitespace in Tags Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows examples of incorrect whitespace usage within HTML tags that prevent them from being parsed as HTML. ```CommonMark < a>< foo> .

< a>< foo><bar/ > <foo bar=baz bim!bop />

``` -------------------------------- ### URI Autolink with Host and Port Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates an autolink that includes a hostname and port number. This is parsed as a link. ```CommonMark .

localhost:5001/foo

``` -------------------------------- ### Basic Emphasis with Asterisks Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates simple emphasis using asterisks. The opening asterisk must not be followed by whitespace. ```CommonMark *foo bar* .

foo bar

``` -------------------------------- ### Mixed Smart Quotes and Code Source: https://github.com/commonmark/cmark/blob/master/test/smart_punct.txt Demonstrates how smart punctuation rules apply alongside inline code. ```CommonMark Here is some quoted '`code`' and a "[quoted link](url)". ``` -------------------------------- ### Script Tag HTML Block Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Example of a ``` -------------------------------- ### Bracketed Text Escaped as Link Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows how to escape an opening bracket to render it as literal text, preventing it from being interpreted as the start of a link. ```markdown \[foo] [foo]: /url "title" ``` -------------------------------- ### First Matching Link Reference Definition Used Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates that when multiple link reference definitions exist for the same label, the first one encountered is used. ```CommonMark [foo]: /url1 [foo]: /url2 [bar][foo] ``` -------------------------------- ### HTML Entity References Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates the use of various HTML entity references, including named and extended entities, and their rendered output. ```CommonMark   & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸ . ``` ```HTML

  & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸

``` -------------------------------- ### Basic Reference Link with Unmatched Brackets Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a reference link where the label contains unmatched brackets. The brackets are treated literally. ```markdown [foo][ref[] [ref[]: /uri ``` -------------------------------- ### Style Tag HTML Block Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Example of a ``` -------------------------------- ### URI Autolink with Custom Scheme Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates an autolink using a non-standard URI scheme. The scheme must be followed by a colon. ```CommonMark .

irc://foo.bar:2233/baz

``` -------------------------------- ### Textarea Tag HTML Block Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Example of a ``` -------------------------------- ### Shortcut Reference Link with Inline Formatting Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows a shortcut reference link where the link text contains inline formatting. The formatting is preserved in the rendered link. ```markdown [*foo* bar] [*foo* bar]: /url "title" ``` -------------------------------- ### ATX Heading: Closing '#' length variation Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates that the closing '#' sequence can be of a different length than the opening sequence. ```CommonMark # foo ################################## ##### foo ## ``` ```HTML

foo

foo
``` -------------------------------- ### Unmatched Double Quote Handling Source: https://github.com/commonmark/cmark/blob/master/test/smart_punct.txt Shows how an unmatched straight double quote is converted to a left double quote, especially at the start of a paragraph. ```CommonMark "A paragraph with no closing quote. "Second paragraph by same speaker, in fiction." ``` -------------------------------- ### Invalid Email Autolink with Backslash Escape Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates that backslash escapes do not work within email autolinks. This example is rendered as literal text. ```CommonMark .

<foo+@bar.example.com>

``` -------------------------------- ### ATX Heading: Closing '#' preceded by space Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt The closing '#' sequence must be preceded by a space or tab. ```CommonMark # foo# ``` ```HTML

foo#

``` -------------------------------- ### Link Reference Definition Without Corresponding Link Usage Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Example of a document containing only a link reference definition, which does not render visible content. ```markdown [foo]: /url . ``` -------------------------------- ### Document Tree After Second Line Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates the tree after processing 'sit amet.', demonstrating lazy continuation within the existing paragraph. ```tree -> document -> block_quote -> paragraph "Lorem ipsum dolor\nsit amet." ``` -------------------------------- ### Nested Emphasis and Strong Emphasis (Underscores) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates nesting of strong emphasis within emphasis using underscores. ```markdown _foo __bar__ baz_ .

foo bar baz

``` -------------------------------- ### Tab Expansion in Preformatted Text Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how tabs are preserved as literal characters within preformatted text blocks. ```CommonMark →foo→baz→→bim . ``` ```HTML
foo→baz→→bim
``` -------------------------------- ### Potential Unintended List Capture Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows a case where a numeral '1' followed by a period might still be interpreted as the start of a list, even if unintended. ```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.
``` -------------------------------- ### Basic Text Formatting Source: https://github.com/commonmark/cmark/blob/master/fuzz/afl_test_cases/test.md Illustrates basic text formatting like emphasis, strong text, and code spans. ```markdown t ☺ *b* **em** `c` ≥\& \_e\_ ``` -------------------------------- ### Numbered List as First Block in a List Item Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows a numbered list starting as the first block element within another list item. ```CommonMark 1. - 2. foo ``` ```HTML
      1. foo
``` -------------------------------- ### Create Release Archives Source: https://github.com/commonmark/cmark/blob/master/README.md Generate release tarball and zip archive for cmark using the GNU Makefile. ```bash make archive ``` -------------------------------- ### List item indentation with blank line Source: https://github.com/commonmark/cmark/blob/master/test/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. ```CommonMark - foo ``` ```HTML
  • foo
``` -------------------------------- ### Custom Tag Names Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates the use and parsing of custom tag names within HTML. ```CommonMark Foo .

Foo

``` -------------------------------- ### Case-Insensitive Label Matching (Unicode) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates case-insensitive label matching with Unicode characters. ```markdown [ΑΓΩ]: /φου [αγω] . ``` -------------------------------- ### Link Reference Definition with Title Containing Blank Line (Invalid) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an example where a blank line within a quoted title makes the definition invalid. ```markdown [foo]: /url 'title with blank line' [foo] . ``` -------------------------------- ### Tight List with Code Block Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a tight list where blank lines within a code block do not affect the list's tightness. ```CommonMark - a - ``` b ``` - c ``` ```HTML
  • a
  • b
    
    
    
  • c
``` -------------------------------- ### List item starting with indented code block Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt When the first block in a list item is an indented code block, specific indentation rules apply after the list marker. ```CommonMark indented code paragraph more code . ``` -------------------------------- ### Emphasis with Links Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates nesting emphasis within a link. ```markdown *foo [*bar*](/url)* ``` -------------------------------- ### Block Quote Followed by Paragraph (Blank Line Variant) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt This example demonstrates another case where a blank line after a block quote correctly separates it from a subsequent paragraph. ```CommonMark > bar > baz ``` ```HTML

bar

baz

``` -------------------------------- ### ATX Heading: Empty headings Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt ATX headings can be empty. ```CommonMark ## # ### ### ``` ```HTML

``` -------------------------------- ### List Item Type Separation Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how changing the bullet or ordered list delimiter starts a new list. Different list types are rendered in separate HTML lists. ```markdown - foo - bar + baz ``` ```html
  • foo
  • bar
  • baz
``` -------------------------------- ### HTML Block with Attributes Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates an HTML block with attributes, including multi-line attributes. ```html
``` -------------------------------- ### HTML Block Starting with Closing Tag Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates an HTML block that begins with a closing tag. This is valid and is followed by Markdown content, with the block ending at the subsequent blank line. ```CommonMark
*foo* .
*foo* ``` -------------------------------- ### Collapsed Reference Link Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a collapsed reference link, where the link text and label are identical and followed by empty brackets. ```markdown [foo][] [foo]: /url "title" ``` -------------------------------- ### Link Containing Another Link (Invalid) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an example where a link text attempts to contain another link, which is not allowed in CommonMark. The outer link label is a shortcut reference. ```CommonMark [foo [bar](/uri)][ref] [ref]: /uri ``` -------------------------------- ### Code Span Parsing Example Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how a code span is parsed when adjacent to literal backticks. The content within the backticks is treated as code, and the trailing backtick is rendered literally. ```markdown `hi`lo` ``` ```html

hilo`

``` -------------------------------- ### Link Precedence: Inline Link Over Reference Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates that an inline link takes precedence over a reference link when both are possible. ```markdown [foo]() [foo]: /url1 ``` -------------------------------- ### Shortcut Image Reference with Formatted Description Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt A shortcut image reference with a description containing formatting. The alt text is the plain string content. ```CommonMark ![*foo* bar] [*foo* bar]: /url "title" ``` ```HTML

foo bar

``` -------------------------------- ### Nested Block Quotes (Mixed Markers) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt This example shows nested block quotes with a mix of marker styles, demonstrating how CommonMark handles varying levels of indentation and '>' prefixes. ```CommonMark >>> foo > bar >>baz ``` ```HTML

foo bar baz

``` -------------------------------- ### Thematic Breaks with Mixed Characters (Invalid) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows an example where characters other than spaces or tabs are mixed, preventing it from being recognized as a thematic break and rendering it as italicized text within a paragraph. ```markdown *-* .

-

``` -------------------------------- ### Inline Link with Line Ending in URI (Not Allowed) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates that line endings are not permitted within a link destination, even when enclosed in angle brackets. This example renders as plain text. ```markdown [link](foo bar) .

[link](foo bar)

``` -------------------------------- ### Shortcut Reference Link with Trailing Space Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates that a space following the link text in a shortcut reference link is preserved. ```markdown [foo] bar [foo]: /url ``` -------------------------------- ### Invalid List Item Markers (No Space) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates that a space or tab is required between a list marker and its content for it to be recognized as a list item. These examples show that '-one' and '2.two' are treated as paragraphs. ```CommonMark -one ``` ```CommonMark 2.two ``` -------------------------------- ### Multiple Link Reference Definitions Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Presents a scenario with multiple definitions for the same link reference, asking which definition takes precedence. ```markdown [foo]: /url1 [foo]: /url2 [foo][] ``` -------------------------------- ### List Item Paragraph Wrapping Ambiguity (Example 2) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Shows another list structure that raises questions about how paragraph wrapping rules apply to nested or complex list items. ```markdown 1. one - a - b 2. two ``` -------------------------------- ### Markdown List with Indented Code Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates a common Markdown pattern where an indented code block follows a list item. This example highlights a potential compatibility issue with certain parsing rules. ```markdown 1. foo indented code ``` -------------------------------- ### Reference Link Parsing Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates how adjacent reference-style links are parsed when both labels are defined. Each link is rendered independently. ```markdown [foo][bar][baz] [baz]: /url1 [bar]: /url2 . ``` ```html

foobaz

``` -------------------------------- ### URI Autolink with Uppercase Scheme Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates that URI autolinks are case-insensitive with respect to their scheme. ```CommonMark .

MAILTO:FOO@BAR.BAZ

``` -------------------------------- ### List Item Paragraph Wrapping Ambiguity (Example 1) Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Presents a list structure where the paragraph wrapping rules for list items are unclear, specifically regarding mixed 'loose' and 'tight' list item behaviors. ```markdown 1. one 2. two 3. three ``` -------------------------------- ### Multiple Link Reference Definitions Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates multiple link reference definitions and their subsequent use. ```CommonMark [foo]: /foo-url "foo" [bar]: /bar-url "bar" [baz]: /baz-url [foo], [bar], [baz] . ``` -------------------------------- ### Precedence of Multiple Link Reference Definitions Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Illustrates that if multiple definitions exist for the same label, the first one encountered takes precedence. ```markdown [foo] [foo]: first [foo]: second . ``` -------------------------------- ### Link with Title and Whitespace Source: https://github.com/commonmark/cmark/blob/master/test/spec.txt Demonstrates a link with a title, allowing for spaces and line endings around the destination and title. This adheres to flexible whitespace rules. ```markdown [link]( /uri "title" ) .

link

```