### Shortcut Reference Link Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Example of shortcut reference link definitions. ```markdown [foo] [bar] [foo]: /url1 [bar]: /url2 ``` -------------------------------- ### HTML Block Parsing Examples Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Examples demonstrating various HTML block types and their interaction with Markdown content. ```markdown -
- foo . ``` ```markdown *foo* .

foo

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

baz

``` ```markdown 1. *bar* . 1. *bar* ``` ```markdown okay .

okay

``` ```markdown '; ?> okay . '; ?>

okay

``` ```markdown . ``` ```markdown okay .

okay

``` ```markdown .
<!-- foo -->
``` ```markdown
.
<div>
``` ```markdown Foo
bar
.

Foo

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

Foo baz

``` ```markdown
*Emphasized* text.
.

Emphasized text.

``` ```markdown
*Emphasized* text.
.
*Emphasized* text.
``` ```markdown
Hi
.
Hi
``` -------------------------------- ### Ordered List Delimiters and Start Number Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Illustrates how different ordered list delimiters ('.' or ')') are handled and how the 'start' attribute is determined by the first list item's number. ```markdown 1. foo 2. bar 3) baz ``` ```html
  1. foo
  2. bar
  1. baz
``` -------------------------------- ### Non-Crashing Example Source: https://github.com/github/cmark-gfm/blob/master/test/extensions.txt This example demonstrates input that should not cause a crash, specifically an email-like string with unusual characters and structure. ```markdown This shouldn't crash everything: (_A_@_.A ``` -------------------------------- ### Incomplete HTML Tag Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Shows an HTML block where the initial tag is not fully formed but starts like a tag. ```html
Hi ``` -------------------------------- ### Valid Ordered List Start Number Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Ordered list start numbers must be nine digits or less. This example shows a valid start number. ```markdown 123456789. ok . ``` ```html
  1. ok
``` -------------------------------- ### Malformed HTML Tag Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates an HTML block with a tag that starts like one but is malformed. ```html
``` ``` ```markdown ~~~ < > ~~~ ``` -------------------------------- ### Delimiter Run Examples Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Illustrates different types of delimiter runs (left-flanking, right-flanking, both, neither) based on surrounding characters and whitespace. ```text ***abc _abc **"abc" _"abc" ``` ```text abc*** abc_ "abc"** "abc"_ ``` ```text abc***def "abc"_"def" ``` ```text abc *** def a _ b ``` -------------------------------- ### Compare AsciiDoc and Markdown list formatting Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Examples demonstrating the difference in syntax and readability between AsciiDoc and Markdown for nested lists and indented blocks. ```text 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. -- ``` ```text 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. ``` -------------------------------- ### Autolink Examples Source: https://github.com/github/cmark-gfm/blob/master/test/extensions.txt Demonstrates various formats that are automatically converted to autolinks, including HTTP, HTTPS, mailto, and XMPP links, as well as internationalized domain names. Also shows how punctuation like periods and parentheses are handled. ```markdown : http://google.com https://google.com http://google.com/å scyther@pokemon.com scy.the_rbe-edr+ill@pokemon.com scyther@pokemon.com. scyther@pokemon.com/ scyther@pokemon.com/beedrill@pokemon.com mailto:scyther@pokemon.com This is a mailto:scyther@pokemon.com mailto:scyther@pokemon.com. mmmmailto:scyther@pokemon.com mailto:scyther@pokemon.com/ mailto:scyther@pokemon.com/message mailto:scyther@pokemon.com/mailto:beedrill@pokemon.com xmpp:scyther@pokemon.com xmpp:scyther@pokemon.com. xmpp:scyther@pokemon.com/message xmpp:scyther@pokemon.com/message. Email me at:scyther@pokemon.com www.github.com www.github.com/á www.google.com/a_b Underscores not allowed in host name www.xxx.yyy._zzz Underscores not allowed in host name www.xxx._yyy.zzz Underscores allowed in domain name www._xxx.yyy.zzz **Autolink and http://inlines** ![http://inline.com/image](http://inline.com/image) a.w@b.c Full stop outside parens shouldn't be included http://google.com/ok. (Full stop inside parens shouldn't be included http://google.com/ok.) "http://google.com" 'http://google.com' http://🍄.ga/ http://x🍄.ga/ ``` ```html

: http://google.com https://google.com

http://google.com/å http://google.com/å

scyther@pokemon.com

scy.the_rbe-edr+ill@pokemon.com

scyther@pokemon.com.

scyther@pokemon.com/

scyther@pokemon.com/beedrill@pokemon.com

mailto:scyther@pokemon.com

This is a mailto:scyther@pokemon.com

mailto:scyther@pokemon.com.

mmmmailto:scyther@pokemon.com

mailto:scyther@pokemon.com/

mailto:scyther@pokemon.com/message

mailto:scyther@pokemon.com/mailto:beedrill@pokemon.com

xmpp:scyther@pokemon.com

xmpp:scyther@pokemon.com.

xmpp:scyther@pokemon.com/message

xmpp:scyther@pokemon.com/message.

Email me at:scyther@pokemon.com

www.github.com www.github.com/á

www.google.com/a_b

Underscores not allowed in host name www.xxx.yyy._zzz

Underscores not allowed in host name www.xxx._yyy.zzz

Underscores allowed in domain name www._xxx.yyy.zzz

Autolink and http://inlines

http://inline.com/image

a.w@b.c

Full stop outside parens shouldn't be included http://google.com/ok.

(Full stop inside parens shouldn't be included http://google.com/ok.)

"http://google.com"

'http://google.com'

http://🍄.ga/ http://x🍄.ga/

``` -------------------------------- ### Ordered List with Zero Start Number Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Ordered lists can start with '0'. This is a valid start number. ```markdown 0. ok . ``` ```html
  1. ok
``` -------------------------------- ### Basic HTML Block Type 6 Examples Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Examples of standard HTML block structures using common tags like table and div. ```markdown
hi
okay. .
hi

okay.

``` ```markdown
*hello* .
*hello* ``` -------------------------------- ### Build and Run Quadratic Fuzzer Source: https://github.com/github/cmark-gfm/blob/master/fuzz/README.md Use these commands to build and run the quadratic fuzzer. Ensure you have clang and clang++ installed and set as your C and C++ compilers. ```bash mkdir build-fuzz cd build-fuzz cmake -DCMARK_FUZZ_QUADRATIC=ON -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_BUILD_TYPE=Release .. make ../fuzz/fuzzloop.sh ``` -------------------------------- ### Table HTML Block Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Illustrates an HTML block containing a table structure. ```html
foo
. ``` ```html
foo
``` -------------------------------- ### Markdown to Block Structure Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates the transformation of Markdown text into a block structure tree. Shows how lines are processed to create and populate blocks like block_quote, list, and paragraph. ```markdown > Lorem ipsum dolor sit amet. > - Qui *quodsi iracundia* > - aliquando id ``` -------------------------------- ### Markdown Emphasis Examples Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates various ways to achieve strong emphasis and nested emphasis in Markdown using asterisks and underscores. ```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 ``` -------------------------------- ### Install cmark-gfm with custom prefix Source: https://github.com/github/cmark-gfm/blob/master/README.md To change the installation prefix when building cmark-gfm using GNU make, pass the INSTALL_PREFIX variable. ```makefile make INSTALL_PREFIX=path ``` -------------------------------- ### Emphasis Delimiter Matching Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Examples demonstrating how underscore and asterisk delimiters are parsed into HTML emphasis tags. ```markdown foo __\___ .

foo _

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

foo *

``` ```markdown __foo_ .

_foo

``` ```markdown _foo__ .

foo_

``` ```markdown ___foo__ .

_foo

``` ```markdown ____foo_ .

___foo

``` ```markdown __foo___ .

foo_

``` ```markdown _foo____ .

foo___

``` -------------------------------- ### Tilde Code Fence Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates the use of tildes for code fences, including cases with special characters in the fence. ```markdown ```````````````````````````````` example ~~~~~~ aaa ~~~ ~~ .
aaa
~~~ ~~
```````````````````````````````` ``` -------------------------------- ### Unclosed HTML Tag Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates an HTML block with an unclosed tag, showing how the content is rendered. ```html
*foo* *bar* . ``` ```html
*foo*

bar

``` -------------------------------- ### Markdown List Starting with Empty Item Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Illustrates a Markdown list that begins with an empty list item. ```markdown * ``` ```html
``` -------------------------------- ### Markdown Example: Paragraph Followed by Nested Sublist Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt This example illustrates a paragraph followed by a nested sublist, demonstrating how Markdown parsers interpret such structures. ```markdown I need to buy - new shoes - a coat - a plane ticket ``` -------------------------------- ### Nested Code Fence Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates how a nested code fence is handled. The inner fence does not need to match the outer fence's delimiters. ```markdown ```````````````````````````````` example ``` aaa ``` .
aaa
```````````````````````````````` ``` -------------------------------- ### Emphasis Parsing Rules Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Examples illustrating complex parsing scenarios involving mixed delimiters and inline elements. ```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 .

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

``` ```markdown __a .

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

``` -------------------------------- ### HTML Block Starting with Closing Tag Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates that an HTML block can begin with a closing tag. ```markdown
*foo* .
*foo* ``` -------------------------------- ### Invalid Link Reference Definitions Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Examples of syntax that fails to create a valid link reference definition. ```markdown [foo]: /url 'title with blank line' [foo] .

[foo]: /url 'title

with blank line'

[foo]

``` ```markdown [foo]: [foo] .

[foo]:

[foo]

``` ```markdown [foo]: (baz) [foo] .

[foo]: (baz)

[foo]

``` ```markdown [foo]: /url "title" ok .

[foo]: /url "title" ok

``` ```markdown [foo]: /url "title" ok .

"title" ok

``` ```markdown [foo]: /url "title" [foo] .
[foo]: /url "title"

[foo]

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

[foo]

``` -------------------------------- ### Plain text content parsing Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Examples of how special characters, non-ASCII characters, and multiple spaces are handled as plain text. ```markdown hello $.;'there .

hello $.;'there

``` ```markdown Foo χρῆν .

Foo χρῆν

``` ```markdown Multiple spaces .

Multiple spaces

``` -------------------------------- ### HTML Block with Custom Tag Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Illustrates an HTML block starting with a custom tag name, which can be anything. ```html *bar* . ``` ```html *bar* ``` -------------------------------- ### Markdown List Items with Blank Lines Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates how list items starting with a blank line are rendered, including nested code blocks. ```markdown - foo - ``` bar ``` - baz ``` ```html
  • foo
  • bar
    
  • baz
    
``` -------------------------------- ### Markdown Lazy Continuation Lines Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Shows how lazy continuation lines in a list item are handled, preserving nested structures. ```markdown 1. A paragraph with two lines. indented code > A block quote. ``` ```html
  1. A paragraph with two lines.

    indented code
    

    A block quote.

``` -------------------------------- ### HTML Block with Closing Tag Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Demonstrates an HTML block starting with a closing tag. ```html *bar* . ``` ```html *bar* ``` -------------------------------- ### Indented Code Fence Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Shows that an indented code fence is not recognized as a closing fence. ```markdown ```````````````````````````````` example ``` aaa ``` .
aaa
    ```
```````````````````````````````` ``` -------------------------------- ### Partial HTML Tag Example Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Illustrates how cmark-gfm handles HTML blocks with partially formed tags. ```html
  • foo
  • bar
    • baz
    ``` -------------------------------- ### HTML Block with Non-Block-Level Tag Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Shows how to start an HTML block with a non-block-level tag, requiring the tag to be complete and on its own line. ```html *bar* . ``` ```html *bar* ``` -------------------------------- ### Build and Test Commands Source: https://github.com/github/cmark-gfm/blob/master/test/CMakeLists.txt Command-line instructions for building and running tests with verbose output. ```bash cmake --build build --target "test" -- ARGS='-V' ``` -------------------------------- ### Non-Autolink Examples Source: https://github.com/github/cmark-gfm/blob/master/test/extensions.txt Illustrates text patterns that should not be interpreted as autolinks, such as email-like strings with leading/trailing dots or spaces, and specific character combinations. ```markdown These should not link: * @a.b.c@. x * n@. b ``` ```html
    • @a.b.c@. x
    • n@. b
    ``` -------------------------------- ### Invalid Negative Ordered List Start Number Source: https://github.com/github/cmark-gfm/blob/master/test/spec.txt Negative numbers are not valid start numbers for ordered lists. This example shows an invalid negative start number. ```markdown -1. not ok . ``` ```html

    -1. not ok

    ``` -------------------------------- ### Configure Parser and Rendering Options Source: https://context7.com/github/cmark-gfm/llms.txt Shows how to use option flags to control smart punctuation, security settings, source position inclusion, and line break handling. ```c #include #include #include "cmark-gfm.h" int main() { const char *markdown = "\"Hello\" -- Pro-tip: Use --- for em-dashes.\n\n" "\n\n" "[evil](javascript:alert('xss'))\n"; // CMARK_OPT_SMART: Convert straight quotes to curly, --- to em dashes char *smart = cmark_markdown_to_html(markdown, strlen(markdown), CMARK_OPT_SMART); printf("=== Smart Punctuation ===\n%s\n", smart); // Converts "Hello" to curly quotes, -- to en-dash, --- to em-dash free(smart); // CMARK_OPT_UNSAFE: Allow raw HTML and dangerous links (default is safe) char *unsafe = cmark_markdown_to_html(markdown, strlen(markdown), CMARK_OPT_UNSAFE); printf("=== Unsafe Mode ===\n%s\n", unsafe); // Includes raw