### 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
one
two
| Hi |
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 **
a *
a _
| 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``` -------------------------------- ### 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. ```htmlFoo
bar baz
``` -------------------------------- ### 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" . ``` -------------------------------- ### 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
one
two
**Hello**, _world_. |
**Hello**,world.
(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 ``` ```htmlbar
baz
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 $[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; abcdef0; &ThisIsNotDefined; &hi?; . ``` ```HTML  &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
```
--------------------------------
### 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]
> - 
```
--------------------------------
### 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 ``` ```HTMLfoo 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") . ``` -------------------------------- ### 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. ```htmlfoo
bar
| 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 atag used as an HTML block, which can contain blank lines. ```html``` -------------------------------- ### 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 ``` ```HTMLimport Text.HTML.TagSoup main :: IO () main = print $ parseTags tags
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. ```CommonMarkfoo 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. ```CommonMarkhilo`
``` -------------------------------- ### 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 *-* .foo bar baz
-
``` -------------------------------- ### 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 ``` -------------------------------- ### 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