From 28e19c009900859c291b6adc209da7b6d939b7d2 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Fri, 8 Mar 2024 23:57:54 +0100 Subject: [PATCH] Preserve markdown indentation (#109) If a chunk includes newlines, preserve any indentation inside the chunk even when trimming --- src/lib.rs | 39 +- src/unstable_markdown.rs | 39 +- tests/markdown.rs | 42 +- ...ingface_markdown@commonmark_spec.md-2.snap | 862 ++++----- ...ingface_markdown@commonmark_spec.md-3.snap | 20 +- ...ggingface_markdown@commonmark_spec.md.snap | 866 ++++++--- ...ingface_markdown@github_flavored.md-2.snap | 20 +- ...ggingface_markdown@github_flavored.md.snap | 47 +- ...ce_markdown_trim@commonmark_spec.md-2.snap | 12 +- ...face_markdown_trim@commonmark_spec.md.snap | 296 +-- ...ce_markdown_trim@github_flavored.md-2.snap | 2 +- ...face_markdown_trim@github_flavored.md.snap | 28 +- ...pshots__markdown@commonmark_spec.md-2.snap | 1686 ++++++++--------- ...pshots__markdown@commonmark_spec.md-3.snap | 82 +- ...napshots__markdown@commonmark_spec.md.snap | 220 ++- ...pshots__markdown@github_flavored.md-2.snap | 54 +- ...napshots__markdown@github_flavored.md.snap | 20 +- ...s__markdown_trim@commonmark_spec.md-2.snap | 88 +- ...ots__markdown_trim@commonmark_spec.md.snap | 335 ++-- ...s__markdown_trim@github_flavored.md-2.snap | 18 +- ...ots__markdown_trim@github_flavored.md.snap | 10 +- ...iktoken_markdown@commonmark_spec.md-2.snap | 527 +++--- ...iktoken_markdown@commonmark_spec.md-3.snap | 10 +- ..._tiktoken_markdown@commonmark_spec.md.snap | 1322 +++++++------ ...iktoken_markdown@github_flavored.md-2.snap | 14 +- ..._tiktoken_markdown@github_flavored.md.snap | 54 +- ...en_markdown_trim@commonmark_spec.md-2.snap | 10 +- ...oken_markdown_trim@commonmark_spec.md.snap | 394 ++-- ...oken_markdown_trim@github_flavored.md.snap | 48 +- 29 files changed, 3809 insertions(+), 3356 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5e23423a..5b629d0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -197,6 +197,7 @@ impl ChunkCapacity for RangeToInclusive { } /// How a particular semantic level relates to surrounding text elements. +#[allow(dead_code)] #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] enum SemanticSplitPosition { /// The semantic level should be included in the previous chunk. @@ -210,6 +211,11 @@ enum SemanticSplitPosition { /// Information required by generic Semantic Levels trait Level: fmt::Debug { fn split_position(&self) -> SemanticSplitPosition; + + /// Whether or not when splitting ranges, whitespace should be included as previous. + fn treat_whitespace_as_previous(&self) -> bool { + false + } } /// Implementation that dictates the semantic split points available. @@ -268,6 +274,18 @@ trait SemanticSplit { text: &'text str, semantic_level: Self::Level, ) -> impl Iterator + 'splitter; + + /// Trim the str and adjust the offset if necessary. + /// This is the default behavior, but custom semantic levels may need different behavior. + fn trim_chunk<'splitter, 'text: 'splitter>( + &'splitter self, + offset: usize, + chunk: &'text str, + ) -> (usize, &'text str) { + // Figure out how many bytes we lose trimming the beginning + let diff = chunk.len() - chunk.trim_start().len(); + (offset + diff, chunk.trim()) + } } /// Returns chunks of text with their byte offsets as an iterator. @@ -314,9 +332,7 @@ where /// If trim chunks is on, trim the str and adjust the offset fn trim_chunk(&self, offset: usize, chunk: &'text str) -> (usize, &'text str) { if self.trim_chunks { - // Figure out how many bytes we lose trimming the beginning - let diff = chunk.len() - chunk.trim_start().len(); - (offset + diff, chunk.trim()) + self.semantic_split.trim_chunk(offset, chunk) } else { (offset, chunk) } @@ -429,13 +445,7 @@ where let chunk = self.text.get(start..self.cursor)?; // Trim whitespace if user requested it - Some(if self.trim_chunks { - // Figure out how many bytes we lose trimming the beginning - let offset = chunk.len() - chunk.trim_start().len(); - (start + offset, chunk.trim()) - } else { - (start, chunk) - }) + Some(self.trim_chunk(start, chunk)) } /// Find the ideal next sections, breaking it up until we find the largest chunk. @@ -551,6 +561,15 @@ fn split_str_by_separator( let prev_section = text .get(cursor..range.start) .expect("invalid character sequence"); + if prev_section.trim().is_empty() + && level.treat_whitespace_as_previous() + { + let section = text + .get(cursor..range.end) + .expect("invalid character sequence"); + cursor = range.end; + return Some(Either::Left(once((offset, section)))); + } let separator = text .get(range.start..range.end) .expect("invalid character sequence"); diff --git a/src/unstable_markdown.rs b/src/unstable_markdown.rs index 552af94c..189b0c3b 100644 --- a/src/unstable_markdown.rs +++ b/src/unstable_markdown.rs @@ -105,7 +105,7 @@ where /// let text = "Some text\n\nfrom a\ndocument"; /// let chunks = splitter.chunks(text, 10).collect::>(); /// - /// assert_eq!(vec!["Some text\n", "\n", "from a\n", "document"], chunks); + /// assert_eq!(vec!["Some text\n", "\nfrom a\n", "document"], chunks); /// ``` pub fn chunks<'splitter, 'text: 'splitter>( &'splitter self, @@ -127,7 +127,7 @@ where /// let text = "Some text\n\nfrom a\ndocument"; /// let chunks = splitter.chunk_indices(text, 10).collect::>(); /// - /// assert_eq!(vec![(0, "Some text\n"), (10, "\n"), (11, "from a\n"), (18, "document")], chunks); + /// assert_eq!(vec![(0, "Some text\n"), (10, "\nfrom a\n"), (18, "document")], chunks); pub fn chunk_indices<'splitter, 'text: 'splitter>( &'splitter self, text: &'text str, @@ -215,6 +215,24 @@ impl Level for SemanticLevel { SemanticLevel::Heading(_) => SemanticSplitPosition::Next, } } + + fn treat_whitespace_as_previous(&self) -> bool { + match self { + SemanticLevel::Char + | SemanticLevel::GraphemeCluster + | SemanticLevel::Word + | SemanticLevel::Sentence + | SemanticLevel::SoftBreak + | SemanticLevel::Text + | SemanticLevel::InlineElement(_) + | SemanticLevel::Rule + | SemanticLevel::Heading(_) + | SemanticLevel::Metadata => false, + SemanticLevel::Block + | SemanticLevel::ContainerBlock(_) + | SemanticLevel::MetaContainer => true, + } + } } /// Captures information about markdown structure for a given text, and their @@ -225,6 +243,8 @@ struct Markdown { ranges: Vec<(SemanticLevel, Range)>, } +const NEWLINES: [char; 2] = ['\n', '\r']; + impl SemanticSplit for Markdown { type Level = SemanticLevel; @@ -337,6 +357,21 @@ impl SemanticSplit for Markdown { .map(move |(i, str)| (offset + i, str)), } } + + fn trim_chunk<'splitter, 'text: 'splitter>( + &'splitter self, + offset: usize, + chunk: &'text str, + ) -> (usize, &'text str) { + // Preserve indentation if we have newlines inside the element + if chunk.trim().contains(NEWLINES) { + let diff = chunk.len() - chunk.trim_start_matches(NEWLINES).len(); + (offset + diff, chunk.trim_start_matches(NEWLINES).trim_end()) + } else { + let diff = chunk.len() - chunk.trim_start().len(); + (offset + diff, chunk.trim()) + } + } } #[cfg(test)] diff --git a/tests/markdown.rs b/tests/markdown.rs index 1a62adfd..91bd4c75 100644 --- a/tests/markdown.rs +++ b/tests/markdown.rs @@ -47,10 +47,7 @@ fn fallsback_to_normal_text_split_if_no_markdown_content() { let chunk_size = 10; let chunks = splitter.chunks(text, chunk_size).collect::>(); - assert_eq!( - ["Some text\n", "\n", "from a\n", "document"].to_vec(), - chunks - ); + assert_eq!(["Some text\n", "\nfrom a\n", "document"].to_vec(), chunks); } #[cfg(feature = "markdown")] @@ -110,3 +107,40 @@ fn subheadings_grouped_with_top_header() { chunks ); } + +#[cfg(feature = "markdown")] +#[test] +fn trimming_doesnt_trim_block_level_indentation_if_multiple_items() { + let splitter = MarkdownSplitter::default().with_trim_chunks(true); + let text = "* Really long list item that is too big to fit\n\n * Some Indented Text\n\n * More Indented Text\n\n"; + let chunk_size = 48; + let chunks = splitter.chunks(text, chunk_size).collect::>(); + + assert_eq!( + [ + "* Really long list item that is too big to fit", + " * Some Indented Text\n\n * More Indented Text" + ] + .to_vec(), + chunks + ); +} + +#[cfg(feature = "markdown")] +#[test] +fn trimming_does_trim_block_level_indentation_if_only_one_item() { + let splitter = MarkdownSplitter::default().with_trim_chunks(true); + let text = "1. Really long list item\n\n 1. Some Indented Text\n\n 2. More Indented Text\n\n"; + let chunk_size = 30; + let chunks = splitter.chunks(text, chunk_size).collect::>(); + + assert_eq!( + [ + "1. Really long list item", + "1. Some Indented Text", + "2. More Indented Text" + ] + .to_vec(), + chunks + ); +} diff --git a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-2.snap b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-2.snap index a15241a3..ba351de0 100644 --- a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-2.snap +++ b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-2.snap @@ -16,272 +16,272 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "5. Can list markers be indented? Can ordered list markers be right-aligned?\n\n ``` markdown\n 8. item 1\n 9. item 2\n 10. item 2a\n ```\n\n6. Is this one list with a thematic break in its second item,\n or two lists separated by a thematic break?\n\n ``` markdown\n * a\n * * * * *\n * b\n ```\n\n7. When list markers change from numbers to bullets, do we have\n two lists or one? (The Markdown syntax description suggests two,\n but the perl scripts and many other implementations produce one.)\n\n ``` markdown\n 1. fee\n 2. fie\n - foe\n - fum\n ```\n\n8. What are the precedence rules for the markers of inline structure?\n For example, is the following a valid link, or does the code span\n take precedence ?\n\n ``` markdown\n [a backtick (`)](/url) and [another backtick (`)](/url).\n ```\n\n" - "9. What are the precedence rules for markers of emphasis and strong\n emphasis? For example, how should the following be parsed?\n\n ``` markdown\n *foo *bar* baz*\n ```\n\n10. What are the precedence rules between block-level and inline-level\n structure? For example, how should the following be parsed?\n\n ``` markdown\n - `a long code span can contain a hyphen like this\n - and it can screw things up`\n ```\n\n11. Can list items include section headings? (`Markdown.pl` does not\n allow this, but does allow blockquotes to include headings.)\n\n ``` markdown\n - # Heading\n ```\n\n12. Can list items be empty?\n\n ``` markdown\n * a\n *\n * b\n ```\n\n13. Can link references be defined inside block quotes or list items?\n\n ``` markdown\n > Blockquote [foo].\n >\n > [foo]: /url\n ```\n\n" - "14. If there are multiple definitions for the same reference, which takes\n precedence?\n\n ``` markdown\n [foo]: /url1\n [foo]: /url2\n\n [foo][]\n ```\n\nIn the absence of a spec, early implementers consulted `Markdown.pl`\nto resolve these ambiguities. But `Markdown.pl` was quite buggy, and\ngave manifestly bad results in many cases, so it was not a\nsatisfactory replacement for a spec.\n\nBecause there is no unambiguous spec, implementations have diverged\nconsiderably. As a result, users are often surprised to find that\na document that renders one way on one system (say, a GitHub wiki)\nrenders differently on another (say, converting to docbook using\npandoc). To make matters worse, because nothing in Markdown counts\nas a \"syntax error,\" the divergence often isn't discovered right away.\n\n" -- "## About this document\n\nThis document attempts to specify Markdown syntax unambiguously.\nIt contains many examples with side-by-side Markdown and\nHTML. These are intended to double as conformance tests. An\naccompanying script `spec_tests.py` can be used to run the tests\nagainst any Markdown program:\n\n python test/spec_tests.py --spec spec.txt --program PROGRAM\n\nSince this document describes how Markdown is to be parsed into\nan abstract syntax tree, it would have made sense to use an abstract\nrepresentation of the syntax tree instead of HTML. But HTML is capable\nof representing the structural distinctions we need to make, and the\nchoice of HTML for the tests makes it possible to run the tests against\nan implementation without writing an abstract syntax tree renderer.\n\n" -- "Note that not every feature of the HTML samples is mandated by\nthe spec. For example, the spec says what counts as a link\ndestination, but it doesn't mandate that non-ASCII characters in\nthe URL be percent-encoded. To use the automatic tests,\nimplementers will need to provide a renderer that conforms to\nthe expectations of the spec examples (percent-encoding\nnon-ASCII characters in URLs). But a conforming implementation\ncan use a different renderer and may choose not to\npercent-encode non-ASCII characters in URLs.\n\nThis document is generated from a text file, `spec.txt`, written\nin Markdown with a small extension for the side-by-side tests.\nThe script `tools/makespec.py` can be used to convert `spec.txt` into\nHTML or CommonMark (which can then be converted into other formats).\n\nIn the examples, the `→` character is used to represent tabs.\n\n" +- "## About this document\n\nThis document attempts to specify Markdown syntax unambiguously.\nIt contains many examples with side-by-side Markdown and\nHTML. These are intended to double as conformance tests. An\naccompanying script `spec_tests.py` can be used to run the tests\nagainst any Markdown program:\n\n python test/spec_tests.py --spec spec.txt --program PROGRAM\n\nSince this document describes how Markdown is to be parsed into\nan abstract syntax tree, it would have made sense to use an abstract\nrepresentation of the syntax tree instead of HTML. But HTML is capable\nof representing the structural distinctions we need to make, and the\nchoice of HTML for the tests makes it possible to run the tests against\nan implementation without writing an abstract syntax tree renderer.\n" +- "\nNote that not every feature of the HTML samples is mandated by\nthe spec. For example, the spec says what counts as a link\ndestination, but it doesn't mandate that non-ASCII characters in\nthe URL be percent-encoded. To use the automatic tests,\nimplementers will need to provide a renderer that conforms to\nthe expectations of the spec examples (percent-encoding\nnon-ASCII characters in URLs). But a conforming implementation\ncan use a different renderer and may choose not to\npercent-encode non-ASCII characters in URLs.\n\nThis document is generated from a text file, `spec.txt`, written\nin Markdown with a small extension for the side-by-side tests.\nThe script `tools/makespec.py` can be used to convert `spec.txt` into\nHTML or CommonMark (which can then be converted into other formats).\n\nIn the examples, the `→` character is used to represent tabs.\n\n" - "# Preliminaries\n\n" -- "## Characters and lines\n\nAny sequence of [characters] is a valid CommonMark\ndocument.\n\nA [character](@) is a Unicode code point. Although some\ncode points (for example, combining accents) do not correspond to\ncharacters in an intuitive sense, all code points count as characters\nfor purposes of this spec.\n\nThis spec does not specify an encoding; it thinks of lines as composed\nof [characters] rather than bytes. A conforming parser may be limited\nto a certain encoding.\n\nA [line](@) is a sequence of zero or more [characters]\nother than line feed (`U+000A`) or carriage return (`U+000D`),\nfollowed by a [line ending] or by the end of file.\n\nA [line ending](@) is a line feed (`U+000A`), a carriage return\n(`U+000D`) not followed by a line feed, or a carriage return and a\nfollowing line feed.\n\nA line containing no characters, or a line containing only spaces\n(`U+0020`) or tabs (`U+0009`), is called a [blank line](@).\n\n" -- "The following definitions of character classes will be used in this spec:\n\nA [Unicode whitespace character](@) is a character in the Unicode `Zs` general\ncategory, or a tab (`U+0009`), line feed (`U+000A`), form feed (`U+000C`), or\ncarriage return (`U+000D`).\n\n[Unicode whitespace](@) is a sequence of one or more\n[Unicode whitespace characters].\n\nA [tab](@) is `U+0009`.\n\nA [space](@) is `U+0020`.\n\nAn [ASCII control character](@) is a character between `U+0000–1F` (both\nincluding) or `U+007F`.\n\n" -- "An [ASCII punctuation character](@)\nis `!`, `\"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`,\n`*`, `+`, `,`, `-`, `.`, `/` (U+0021–2F), \n`:`, `;`, `<`, `=`, `>`, `?`, `@` (U+003A–0040),\n`[`, `\\`, `]`, `^`, `_`, `` ` `` (U+005B–0060), \n`{`, `|`, `}`, or `~` (U+007B–007E).\n\nA [Unicode punctuation character](@) is a character in the Unicode `P`\n(puncuation) or `S` (symbol) general categories.\n\n" -- "## Tabs\n\nTabs in lines are not expanded to [spaces]. However,\nin contexts where spaces help to define block structure,\ntabs behave as if they were replaced by spaces with a tab stop\nof 4 characters.\n\nThus, for example, a tab can be used instead of four spaces\nin an indented code block. (Note, however, that internal\ntabs are passed through as literal tabs, not expanded to\nspaces.)\n\n```````````````````````````````` example\n→foo→baz→→bim\n.\n
foo→baz→→bim\n
\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n →foo→baz→→bim\n.\n
foo→baz→→bim\n
\n````````````````````````````````\n\n```````````````````````````````` example\n a→a\n ὐ→a\n.\n
a→a\nὐ→a\n
\n````````````````````````````````\n\nIn the following example, a continuation paragraph of a list\nitem is indented with a tab; this has exactly the same effect\nas indentation with four spaces would:\n\n" -- "```````````````````````````````` example\n - foo\n\n→bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n```````````````````````````````` example\n- foo\n\n→→bar\n.\n
    \n
  • \n

    foo

    \n
      bar\n
    \n
  • \n
\n````````````````````````````````\n\n" -- "Normally the `>` that begins a block quote may be followed\noptionally by a space, which is not considered part of the\ncontent. In the following case `>` is followed by a tab,\nwhich is treated as if it were expanded into three spaces.\nSince one of these spaces is considered part of the\ndelimiter, `foo` is considered to be indented six spaces\ninside the block quote context, so we get an indented\ncode block starting with two spaces.\n\n```````````````````````````````` example\n>→→foo\n.\n
\n
  foo\n
\n
\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n-→→foo\n.\n
    \n
  • \n
      foo\n
    \n
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n foo\n→bar\n.\n
foo\nbar\n
\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n - foo\n - bar\n→ - baz\n.\n
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz
      • \n
      \n
    • \n
    \n
  • \n
\n````````````````````````````````\n\n```````````````````````````````` example\n#→Foo\n.\n

Foo

\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n*→*→*→\n.\n
\n````````````````````````````````\n\n\n## Insecure characters\n\nFor security reasons, the Unicode character `U+0000` must be replaced\nwith the REPLACEMENT CHARACTER (`U+FFFD`).\n\n\n" -- "## Backslash escapes\n\nAny ASCII punctuation character may be backslash-escaped:\n\n```````````````````````````````` example\n\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n.\n

!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~

\n````````````````````````````````\n\n\nBackslashes before other characters are treated as literal\nbackslashes:\n\n" -- "```````````````````````````````` example\n\\→\\A\\a\\ \\3\\φ\\«\n.\n

\\→\\A\\a\\ \\3\\φ\\«

\n````````````````````````````````\n\n\nEscaped characters are treated as regular characters and do\nnot have their usual Markdown meanings:\n\n" -- "```````````````````````````````` example\n\\*not emphasized*\n\\
not a tag\n\\[not a link](/foo)\n\\`not code`\n1\\. not a list\n\\* not a list\n\\# not a heading\n\\[foo]: /url \"not a reference\"\n\\ö not a character entity\n.\n

*not emphasized*\n<br/> not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url "not a reference"\n&ouml; not a character entity

\n````````````````````````````````\n\n\nIf a backslash is itself escaped, the following character is not:\n\n" -- "```````````````````````````````` example\n\\\\*emphasis*\n.\n

\\emphasis

\n````````````````````````````````\n\n\nA backslash at the end of the line is a [hard line break]:\n\n```````````````````````````````` example\nfoo\\\nbar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nBackslash escapes do not work in code blocks, code spans, autolinks, or\nraw HTML:\n\n" -- "```````````````````````````````` example\n`` \\[\\` ``\n.\n

\\[\\`

\n````````````````````````````````\n\n\n```````````````````````````````` example\n \\[\\]\n.\n
\\[\\]\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n~~~\n\\[\\]\n~~~\n.\n
\\[\\]\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

https://example.com?find=\\*

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\nBut they work in all other contexts, including URLs and link titles,\nlink references, and [info strings] in [fenced code blocks]:\n\n```````````````````````````````` example\n[foo](/bar\\* \"ti\\*tle\")\n.\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo]\n\n[foo]: /bar\\* \"ti\\*tle\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n``` foo\\+bar\nfoo\n```\n.\n
foo\n
\n````````````````````````````````\n\n\n" +- "## Characters and lines\n\nAny sequence of [characters] is a valid CommonMark\ndocument.\n\nA [character](@) is a Unicode code point. Although some\ncode points (for example, combining accents) do not correspond to\ncharacters in an intuitive sense, all code points count as characters\nfor purposes of this spec.\n\nThis spec does not specify an encoding; it thinks of lines as composed\nof [characters] rather than bytes. A conforming parser may be limited\nto a certain encoding.\n\nA [line](@) is a sequence of zero or more [characters]\nother than line feed (`U+000A`) or carriage return (`U+000D`),\nfollowed by a [line ending] or by the end of file.\n\nA [line ending](@) is a line feed (`U+000A`), a carriage return\n(`U+000D`) not followed by a line feed, or a carriage return and a\nfollowing line feed.\n\nA line containing no characters, or a line containing only spaces\n(`U+0020`) or tabs (`U+0009`), is called a [blank line](@).\n" +- "\nThe following definitions of character classes will be used in this spec:\n\nA [Unicode whitespace character](@) is a character in the Unicode `Zs` general\ncategory, or a tab (`U+0009`), line feed (`U+000A`), form feed (`U+000C`), or\ncarriage return (`U+000D`).\n\n[Unicode whitespace](@) is a sequence of one or more\n[Unicode whitespace characters].\n\nA [tab](@) is `U+0009`.\n\nA [space](@) is `U+0020`.\n\nAn [ASCII control character](@) is a character between `U+0000–1F` (both\nincluding) or `U+007F`.\n" +- "\nAn [ASCII punctuation character](@)\nis `!`, `\"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`,\n`*`, `+`, `,`, `-`, `.`, `/` (U+0021–2F), \n`:`, `;`, `<`, `=`, `>`, `?`, `@` (U+003A–0040),\n`[`, `\\`, `]`, `^`, `_`, `` ` `` (U+005B–0060), \n`{`, `|`, `}`, or `~` (U+007B–007E).\n\nA [Unicode punctuation character](@) is a character in the Unicode `P`\n(puncuation) or `S` (symbol) general categories.\n\n" +- "## Tabs\n\nTabs in lines are not expanded to [spaces]. However,\nin contexts where spaces help to define block structure,\ntabs behave as if they were replaced by spaces with a tab stop\nof 4 characters.\n\nThus, for example, a tab can be used instead of four spaces\nin an indented code block. (Note, however, that internal\ntabs are passed through as literal tabs, not expanded to\nspaces.)\n\n```````````````````````````````` example\n→foo→baz→→bim\n.\n
foo→baz→→bim\n
\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n →foo→baz→→bim\n.\n
foo→baz→→bim\n
\n````````````````````````````````\n\n```````````````````````````````` example\n a→a\n ὐ→a\n.\n
a→a\nὐ→a\n
\n````````````````````````````````\n\nIn the following example, a continuation paragraph of a list\nitem is indented with a tab; this has exactly the same effect\nas indentation with four spaces would:\n" +- "\n```````````````````````````````` example\n - foo\n\n→bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n```````````````````````````````` example\n- foo\n\n→→bar\n.\n
    \n
  • \n

    foo

    \n
      bar\n
    \n
  • \n
\n````````````````````````````````" +- "\n\nNormally the `>` that begins a block quote may be followed\noptionally by a space, which is not considered part of the\ncontent. In the following case `>` is followed by a tab,\nwhich is treated as if it were expanded into three spaces.\nSince one of these spaces is considered part of the\ndelimiter, `foo` is considered to be indented six spaces\ninside the block quote context, so we get an indented\ncode block starting with two spaces.\n\n```````````````````````````````` example\n>→→foo\n.\n
\n
  foo\n
\n
\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n-→→foo\n.\n
    \n
  • \n
      foo\n
    \n
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n foo\n→bar\n.\n
foo\nbar\n
\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n - foo\n - bar\n→ - baz\n.\n
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz
      • \n
      \n
    • \n
    \n
  • \n
\n````````````````````````````````\n\n```````````````````````````````` example\n#→Foo\n.\n

Foo

\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n*→*→*→\n.\n
\n````````````````````````````````\n\n\n## Insecure characters\n\nFor security reasons, the Unicode character `U+0000` must be replaced\nwith the REPLACEMENT CHARACTER (`U+FFFD`).\n\n\n" +- "## Backslash escapes\n\nAny ASCII punctuation character may be backslash-escaped:\n\n```````````````````````````````` example\n\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n.\n

!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~

\n````````````````````````````````\n\n\nBackslashes before other characters are treated as literal\nbackslashes:\n" +- "\n```````````````````````````````` example\n\\→\\A\\a\\ \\3\\φ\\«\n.\n

\\→\\A\\a\\ \\3\\φ\\«

\n````````````````````````````````\n\n\nEscaped characters are treated as regular characters and do\nnot have their usual Markdown meanings:\n" +- "\n```````````````````````````````` example\n\\*not emphasized*\n\\
not a tag\n\\[not a link](/foo)\n\\`not code`\n1\\. not a list\n\\* not a list\n\\# not a heading\n\\[foo]: /url \"not a reference\"\n\\ö not a character entity\n.\n

*not emphasized*\n<br/> not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url "not a reference"\n&ouml; not a character entity

\n````````````````````````````````\n\n\nIf a backslash is itself escaped, the following character is not:\n" +- "\n```````````````````````````````` example\n\\\\*emphasis*\n.\n

\\emphasis

\n````````````````````````````````\n\n\nA backslash at the end of the line is a [hard line break]:\n\n```````````````````````````````` example\nfoo\\\nbar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nBackslash escapes do not work in code blocks, code spans, autolinks, or\nraw HTML:\n" +- "\n```````````````````````````````` example\n`` \\[\\` ``\n.\n

\\[\\`

\n````````````````````````````````\n\n\n```````````````````````````````` example\n \\[\\]\n.\n
\\[\\]\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n~~~\n\\[\\]\n~~~\n.\n
\\[\\]\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

https://example.com?find=\\*

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\nBut they work in all other contexts, including URLs and link titles,\nlink references, and [info strings] in [fenced code blocks]:\n\n```````````````````````````````` example\n[foo](/bar\\* \"ti\\*tle\")\n.\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo]\n\n[foo]: /bar\\* \"ti\\*tle\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n``` foo\\+bar\nfoo\n```\n.\n
foo\n
\n````````````````````````````````\n\n\n" - "## Entity and numeric character references\n\nValid HTML entity references and numeric character references\ncan be used in place of the corresponding Unicode character,\nwith the following exceptions:\n\n- Entity and character references are not recognized in code\n blocks and code spans.\n\n- Entity and character references cannot stand in place of\n special characters that define structural elements in\n CommonMark. For example, although `*` can be used\n in place of a literal `*` character, `*` cannot replace\n `*` in emphasis delimiters, bullet list markers, or thematic\n breaks.\n\n" -- "Conforming CommonMark parsers need not store information about\nwhether a particular character was represented in the source\nusing a Unicode character or an entity reference.\n\n[Entity references](@) consist of `&` + any of the valid\nHTML5 entity names + `;`. The\ndocument \nis used as an authoritative source for the valid entity\nreferences and their corresponding code points.\n\n```````````````````````````````` example\n  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n.\n

  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸

\n````````````````````````````````\n\n\n" -- "[Decimal numeric character\nreferences](@)\nconsist of `&#` + a string of 1--7 arabic digits + `;`. A\nnumeric character reference is parsed as the corresponding\nUnicode character. Invalid Unicode code points will be replaced by\nthe REPLACEMENT CHARACTER (`U+FFFD`). For security reasons,\nthe code point `U+0000` will also be replaced by `U+FFFD`.\n\n```````````````````````````````` example\n# Ӓ Ϡ �\n.\n

# Ӓ Ϡ �

\n````````````````````````````````\n\n\n" -- "[Hexadecimal numeric character\nreferences](@) consist of `&#` +\neither `X` or `x` + a string of 1-6 hexadecimal digits + `;`.\nThey too are parsed as the corresponding Unicode character (this\ntime specified with a hexadecimal numeral instead of decimal).\n\n```````````````````````````````` example\n" ആ ಫ\n.\n

" ആ ಫ

\n````````````````````````````````\n\n\nHere are some nonentities:\n\n" -- "```````````````````````````````` example\n  &x; &#; &#x;\n�\n&#abcdef0;\n&ThisIsNotDefined; &hi?;\n.\n

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

\n````````````````````````````````\n\n\nAlthough HTML5 does accept some entity references\nwithout a trailing semicolon (such as `©`), these are not\nrecognized here, because it makes the grammar too ambiguous:\n\n" -- "```````````````````````````````` example\n©\n.\n

&copy

\n````````````````````````````````\n\n\nStrings that are not on the list of HTML5 named entities are not\nrecognized as entity references either:\n\n```````````````````````````````` example\n&MadeUpEntity;\n.\n

&MadeUpEntity;

\n````````````````````````````````\n\n\nEntity and numeric character references are recognized in any\ncontext besides code spans or code blocks, including\nURLs, [link titles], and [fenced code block][] [info strings]:\n\n" -- "```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo](/föö \"föö\")\n.\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo]\n\n[foo]: /föö \"föö\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n``` föö\nfoo\n```\n.\n
foo\n
\n````````````````````````````````\n\n\n" -- "Entity and numeric character references are treated as literal\ntext in code spans and code blocks:\n\n```````````````````````````````` example\n`föö`\n.\n

f&ouml;&ouml;

\n````````````````````````````````\n\n\n```````````````````````````````` example\n föfö\n.\n
f&ouml;f&ouml;\n
\n````````````````````````````````\n\n\n" -- "Entity and numeric character references cannot be used\nin place of symbols indicating structure in CommonMark\ndocuments.\n\n```````````````````````````````` example\n*foo*\n*foo*\n.\n

*foo*\nfoo

\n````````````````````````````````\n\n```````````````````````````````` example\n* foo\n\n* foo\n.\n

* foo

\n
    \n
  • foo
  • \n
\n````````````````````````````````\n\n" -- "```````````````````````````````` example\nfoo bar\n.\n

foo\n\nbar

\n````````````````````````````````\n\n```````````````````````````````` example\n foo\n.\n

→foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[a](url "tit")\n.\n

[a](url "tit")

\n````````````````````````````````\n\n\n\n" +- "Conforming CommonMark parsers need not store information about\nwhether a particular character was represented in the source\nusing a Unicode character or an entity reference.\n\n[Entity references](@) consist of `&` + any of the valid\nHTML5 entity names + `;`. The\ndocument \nis used as an authoritative source for the valid entity\nreferences and their corresponding code points.\n\n```````````````````````````````` example\n  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n.\n

  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸

\n````````````````````````````````" +- "\n\n\n[Decimal numeric character\nreferences](@)\nconsist of `&#` + a string of 1--7 arabic digits + `;`. A\nnumeric character reference is parsed as the corresponding\nUnicode character. Invalid Unicode code points will be replaced by\nthe REPLACEMENT CHARACTER (`U+FFFD`). For security reasons,\nthe code point `U+0000` will also be replaced by `U+FFFD`.\n\n```````````````````````````````` example\n# Ӓ Ϡ �\n.\n

# Ӓ Ϡ �

\n````````````````````````````````" +- "\n\n\n[Hexadecimal numeric character\nreferences](@) consist of `&#` +\neither `X` or `x` + a string of 1-6 hexadecimal digits + `;`.\nThey too are parsed as the corresponding Unicode character (this\ntime specified with a hexadecimal numeral instead of decimal).\n\n```````````````````````````````` example\n" ആ ಫ\n.\n

" ആ ಫ

\n````````````````````````````````\n\n\nHere are some nonentities:\n" +- "\n```````````````````````````````` example\n  &x; &#; &#x;\n�\n&#abcdef0;\n&ThisIsNotDefined; &hi?;\n.\n

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

\n````````````````````````````````\n\n\nAlthough HTML5 does accept some entity references\nwithout a trailing semicolon (such as `©`), these are not\nrecognized here, because it makes the grammar too ambiguous:\n" +- "\n```````````````````````````````` example\n©\n.\n

&copy

\n````````````````````````````````\n\n\nStrings that are not on the list of HTML5 named entities are not\nrecognized as entity references either:\n\n```````````````````````````````` example\n&MadeUpEntity;\n.\n

&MadeUpEntity;

\n````````````````````````````````\n\n\nEntity and numeric character references are recognized in any\ncontext besides code spans or code blocks, including\nURLs, [link titles], and [fenced code block][] [info strings]:\n" +- "\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo](/föö \"föö\")\n.\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo]\n\n[foo]: /föö \"föö\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n``` föö\nfoo\n```\n.\n
foo\n
\n````````````````````````````````" +- "\n\n\nEntity and numeric character references are treated as literal\ntext in code spans and code blocks:\n\n```````````````````````````````` example\n`föö`\n.\n

f&ouml;&ouml;

\n````````````````````````````````\n\n\n```````````````````````````````` example\n föfö\n.\n
f&ouml;f&ouml;\n
\n````````````````````````````````" +- "\n\n\nEntity and numeric character references cannot be used\nin place of symbols indicating structure in CommonMark\ndocuments.\n\n```````````````````````````````` example\n*foo*\n*foo*\n.\n

*foo*\nfoo

\n````````````````````````````````\n\n```````````````````````````````` example\n* foo\n\n* foo\n.\n

* foo

\n
    \n
  • foo
  • \n
\n````````````````````````````````" +- "\n\n```````````````````````````````` example\nfoo bar\n.\n

foo\n\nbar

\n````````````````````````````````\n\n```````````````````````````````` example\n foo\n.\n

→foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[a](url "tit")\n.\n

[a](url "tit")

\n````````````````````````````````\n\n\n\n" - "# Blocks and inlines\n\nWe can think of a document as a sequence of\n[blocks](@)---structural elements like paragraphs, block\nquotations, lists, headings, rules, and code blocks. Some blocks (like\nblock quotes and list items) contain other blocks; others (like\nheadings and paragraphs) contain [inline](@) content---text,\nlinks, emphasized text, images, code spans, and so on.\n\n" -- "## Precedence\n\nIndicators of block structure always take precedence over indicators\nof inline structure. So, for example, the following is a list with\ntwo items, not a list with one item containing a code span:\n\n```````````````````````````````` example\n- `one\n- two`\n.\n
    \n
  • `one
  • \n
  • two`
  • \n
\n````````````````````````````````\n\n\n" -- "This means that parsing can proceed in two steps: first, the block\nstructure of the document can be discerned; second, text lines inside\nparagraphs, headings, and other block constructs can be parsed for inline\nstructure. The second step requires information about link reference\ndefinitions that will be available only at the end of the first\nstep. Note that the first step requires processing lines in sequence,\nbut the second can be parallelized, since the inline parsing of\none block element does not affect the inline parsing of any other.\n\n## Container blocks and leaf blocks\n\nWe can divide blocks into two types:\n[container blocks](#container-blocks),\nwhich can contain other blocks, and [leaf blocks](#leaf-blocks),\nwhich cannot.\n\n" +- "## Precedence\n\nIndicators of block structure always take precedence over indicators\nof inline structure. So, for example, the following is a list with\ntwo items, not a list with one item containing a code span:\n\n```````````````````````````````` example\n- `one\n- two`\n.\n
    \n
  • `one
  • \n
  • two`
  • \n
\n````````````````````````````````" +- "\n\n\nThis means that parsing can proceed in two steps: first, the block\nstructure of the document can be discerned; second, text lines inside\nparagraphs, headings, and other block constructs can be parsed for inline\nstructure. The second step requires information about link reference\ndefinitions that will be available only at the end of the first\nstep. Note that the first step requires processing lines in sequence,\nbut the second can be parallelized, since the inline parsing of\none block element does not affect the inline parsing of any other.\n\n## Container blocks and leaf blocks\n\nWe can divide blocks into two types:\n[container blocks](#container-blocks),\nwhich can contain other blocks, and [leaf blocks](#leaf-blocks),\nwhich cannot.\n\n" - "# Leaf blocks\n\nThis section describes the different kinds of leaf block that make up a\nMarkdown document.\n\n" -- "## Thematic breaks\n\nA line consisting of optionally up to three spaces of indentation, followed by a\nsequence of three or more matching `-`, `_`, or `*` characters, each followed\noptionally by any number of spaces or tabs, forms a\n[thematic break](@).\n\n```````````````````````````````` example\n***\n---\n___\n.\n
\n
\n
\n````````````````````````````````\n\n\nWrong characters:\n\n```````````````````````````````` example\n+++\n.\n

+++

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n===\n.\n

===

\n````````````````````````````````\n\n\nNot enough characters:\n\n```````````````````````````````` example\n--\n**\n__\n.\n

--\n**\n__

\n````````````````````````````````\n\n\nUp to three spaces of indentation are allowed:\n\n" -- "```````````````````````````````` example\n ***\n ***\n ***\n.\n
\n
\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n ***\n.\n
***\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nFoo\n ***\n.\n

Foo\n***

\n````````````````````````````````\n\n\nMore than three characters may be used:\n\n```````````````````````````````` example\n_____________________________________\n.\n
\n````````````````````````````````\n\n\nSpaces and tabs are allowed between the characters:\n\n" -- "```````````````````````````````` example\n - - -\n.\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n ** * ** * ** * **\n.\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- - - -\n.\n
\n````````````````````````````````\n\n\nSpaces and tabs are allowed at the end:\n\n" -- "```````````````````````````````` example\n- - - - \n.\n
\n````````````````````````````````\n\n\nHowever, no other characters may occur in the line:\n\n```````````````````````````````` example\n_ _ _ _ a\n\na------\n\n---a---\n.\n

_ _ _ _ a

\n

a------

\n

---a---

\n````````````````````````````````\n\n\nIt is required that all of the characters other than spaces or tabs be the same.\nSo, this is not a thematic break:\n\n" -- "```````````````````````````````` example\n *-*\n.\n

-

\n````````````````````````````````\n\n\nThematic breaks do not need blank lines before or after:\n\n```````````````````````````````` example\n- foo\n***\n- bar\n.\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n````````````````````````````````\n\n\nThematic breaks can interrupt a paragraph:\n\n" -- "```````````````````````````````` example\nFoo\n***\nbar\n.\n

Foo

\n
\n

bar

\n````````````````````````````````\n\n\nIf a line of dashes that meets the above conditions for being a\nthematic break could also be interpreted as the underline of a [setext\nheading], the interpretation as a\n[setext heading] takes precedence. Thus, for example,\nthis is a setext heading, not a paragraph followed by a thematic break:\n\n```````````````````````````````` example\nFoo\n---\nbar\n.\n

Foo

\n

bar

\n````````````````````````````````\n\n\n" -- "When both a thematic break and a list item are possible\ninterpretations of a line, the thematic break takes precedence:\n\n```````````````````````````````` example\n* Foo\n* * *\n* Bar\n.\n
    \n
  • Foo
  • \n
\n
\n
    \n
  • Bar
  • \n
\n````````````````````````````````\n\n\nIf you want a thematic break in a list item, use a different bullet:\n\n" -- "```````````````````````````````` example\n- Foo\n- * * *\n.\n
    \n
  • Foo
  • \n
  • \n
    \n
  • \n
\n````````````````````````````````\n\n\n" -- "## ATX headings\n\nAn [ATX heading](@)\nconsists of a string of characters, parsed as inline content, between an\nopening sequence of 1--6 unescaped `#` characters and an optional\nclosing sequence of any number of unescaped `#` characters.\nThe opening sequence of `#` characters must be followed by spaces or tabs, or\nby the end of line. The optional closing sequence of `#`s must be preceded by\nspaces or tabs and may be followed by spaces or tabs only. The opening\n`#` character may be preceded by up to three spaces of indentation. The raw\ncontents of the heading are stripped of leading and trailing space or tabs\nbefore being parsed as inline content. The heading level is equal to the number\nof `#` characters in the opening sequence.\n\nSimple headings:\n\n" -- "```````````````````````````````` example\n# foo\n## foo\n### foo\n#### foo\n##### foo\n###### foo\n.\n

foo

\n

foo

\n

foo

\n

foo

\n
foo
\n
foo
\n````````````````````````````````\n\n\nMore than six `#` characters is not a heading:\n\n" -- "```````````````````````````````` example\n####### foo\n.\n

####### foo

\n````````````````````````````````\n\n\nAt least one space or tab is required between the `#` characters and the\nheading's contents, unless the heading is empty. Note that many\nimplementations currently do not require the space. However, the\nspace was required by the\n[original ATX implementation](http://www.aaronsw.com/2002/atx/atx.py),\nand it helps prevent things like the following from being parsed as\nheadings:\n\n" -- "```````````````````````````````` example\n#5 bolt\n\n#hashtag\n.\n

#5 bolt

\n

#hashtag

\n````````````````````````````````\n\n\nThis is not a heading, because the first `#` is escaped:\n\n```````````````````````````````` example\n\\## foo\n.\n

## foo

\n````````````````````````````````\n\n\nContents are parsed as inlines:\n\n" -- "```````````````````````````````` example\n# foo *bar* \\*baz\\*\n.\n

foo bar *baz*

\n````````````````````````````````\n\n\nLeading and trailing spaces or tabs are ignored in parsing inline content:\n\n```````````````````````````````` example\n# foo \n.\n

foo

\n````````````````````````````````\n\n\nUp to three spaces of indentation are allowed:\n\n" -- "```````````````````````````````` example\n ### foo\n ## foo\n # foo\n.\n

foo

\n

foo

\n

foo

\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n # foo\n.\n
# foo\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nfoo\n # bar\n.\n

foo\n# bar

\n````````````````````````````````\n\n\nA closing sequence of `#` characters is optional:\n\n```````````````````````````````` example\n## foo ##\n ### bar ###\n.\n

foo

\n

bar

\n````````````````````````````````\n\n\nIt need not be the same length as the opening sequence:\n\n" -- "```````````````````````````````` example\n# foo ##################################\n##### foo ##\n.\n

foo

\n
foo
\n````````````````````````````````\n\n\nSpaces or tabs are allowed after the closing sequence:\n\n```````````````````````````````` example\n### foo ### \n.\n

foo

\n````````````````````````````````\n\n\n" -- "A sequence of `#` characters with anything but spaces or tabs following it\nis not a closing sequence, but counts as part of the contents of the\nheading:\n\n```````````````````````````````` example\n### foo ### b\n.\n

foo ### b

\n````````````````````````````````\n\n\nThe closing sequence must be preceded by a space or tab:\n\n```````````````````````````````` example\n# foo#\n.\n

foo#

\n````````````````````````````````\n\n\nBackslash-escaped `#` characters do not count as part\nof the closing sequence:\n\n" -- "```````````````````````````````` example\n### foo \\###\n## foo #\\##\n# foo \\#\n.\n

foo ###

\n

foo ###

\n

foo #

\n````````````````````````````````\n\n\nATX headings need not be separated from surrounding content by blank\nlines, and they can interrupt paragraphs:\n\n```````````````````````````````` example\n****\n## foo\n****\n.\n
\n

foo

\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nFoo bar\n# baz\nBar foo\n.\n

Foo bar

\n

baz

\n

Bar foo

\n````````````````````````````````\n\n\nATX headings can be empty:\n\n```````````````````````````````` example\n## \n#\n### ###\n.\n

\n

\n

\n````````````````````````````````\n\n\n" -- "## Setext headings\n\nA [setext heading](@) consists of one or more\nlines of text, not interrupted by a blank line, of which the first line does not\nhave more than 3 spaces of indentation, followed by\na [setext heading underline]. The lines of text must be such\nthat, were they not followed by the setext heading underline,\nthey would be interpreted as a paragraph: they cannot be\ninterpretable as a [code fence], [ATX heading][ATX headings],\n[block quote][block quotes], [thematic break][thematic breaks],\n[list item][list items], or [HTML block][HTML blocks].\n\nA [setext heading underline](@) is a sequence of\n`=` characters or a sequence of `-` characters, with no more than 3\nspaces of indentation and any number of trailing spaces or tabs.\n\n" -- "The heading is a level 1 heading if `=` characters are used in\nthe [setext heading underline], and a level 2 heading if `-`\ncharacters are used. The contents of the heading are the result\nof parsing the preceding lines of text as CommonMark inline\ncontent.\n\nIn general, a setext heading need not be preceded or followed by a\nblank line. However, it cannot interrupt a paragraph, so when a\nsetext heading comes after a paragraph, a blank line is needed between\nthem.\n\nSimple examples:\n\n```````````````````````````````` example\nFoo *bar*\n=========\n\nFoo *bar*\n---------\n.\n

Foo bar

\n

Foo bar

\n````````````````````````````````\n\n\nThe content of the header may span more than one line:\n\n" -- "```````````````````````````````` example\nFoo *bar\nbaz*\n====\n.\n

Foo bar\nbaz

\n````````````````````````````````\n\nThe contents are the result of parsing the headings's raw\ncontent as inlines. The heading's raw content is formed by\nconcatenating the lines and removing initial and final\nspaces or tabs.\n\n```````````````````````````````` example\n Foo *bar\nbaz*→\n====\n.\n

Foo bar\nbaz

\n````````````````````````````````\n\n\nThe underlining can be any length:\n\n" -- "```````````````````````````````` example\nFoo\n-------------------------\n\nFoo\n=\n.\n

Foo

\n

Foo

\n````````````````````````````````\n\n\nThe heading content can be preceded by up to three spaces of indentation, and\nneed not line up with the underlining:\n\n" -- "```````````````````````````````` example\n Foo\n---\n\n Foo\n-----\n\n Foo\n ===\n.\n

Foo

\n

Foo

\n

Foo

\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n Foo\n ---\n\n Foo\n---\n.\n
Foo\n---\n\nFoo\n
\n
\n````````````````````````````````\n\n\n" -- "The setext heading underline can be preceded by up to three spaces of\nindentation, and may have trailing spaces or tabs:\n\n```````````````````````````````` example\nFoo\n ---- \n.\n

Foo

\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\nFoo\n ---\n.\n

Foo\n---

\n````````````````````````````````\n\n\nThe setext heading underline cannot contain internal spaces or tabs:\n\n" -- "```````````````````````````````` example\nFoo\n= =\n\nFoo\n--- -\n.\n

Foo\n= =

\n

Foo

\n
\n````````````````````````````````\n\n\nTrailing spaces or tabs in the content line do not cause a hard line break:\n\n```````````````````````````````` example\nFoo \n-----\n.\n

Foo

\n````````````````````````````````\n\n\nNor does a backslash at the end:\n\n" -- "```````````````````````````````` example\nFoo\\\n----\n.\n

Foo\\

\n````````````````````````````````\n\n\nSince indicators of block structure take precedence over\nindicators of inline structure, the following are setext headings:\n\n" -- "```````````````````````````````` example\n`Foo\n----\n`\n\n\n.\n

`Foo

\n

`

\n

<a title="a lot

\n

of dashes"/>

\n````````````````````````````````\n\n\nThe setext heading underline cannot be a [lazy continuation\nline] in a list item or block quote:\n\n" -- "```````````````````````````````` example\n> Foo\n---\n.\n
\n

Foo

\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> foo\nbar\n===\n.\n
\n

foo\nbar\n===

\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n- Foo\n---\n.\n
    \n
  • Foo
  • \n
\n
\n````````````````````````````````\n\n\nA blank line is needed between a paragraph and a following\nsetext heading, since otherwise the paragraph becomes part\nof the heading's content:\n\n```````````````````````````````` example\nFoo\nBar\n---\n.\n

Foo\nBar

\n````````````````````````````````\n\n\nBut in general a blank line is not required before or after\nsetext headings:\n\n" -- "```````````````````````````````` example\n---\nFoo\n---\nBar\n---\nBaz\n.\n
\n

Foo

\n

Bar

\n

Baz

\n````````````````````````````````\n\n\nSetext headings cannot be empty:\n\n```````````````````````````````` example\n\n====\n.\n

====

\n````````````````````````````````\n\n\nSetext heading text lines must not be interpretable as block\nconstructs other than paragraphs. So, the line of dashes\nin these examples gets interpreted as a thematic break:\n\n" -- "```````````````````````````````` example\n---\n---\n.\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- foo\n-----\n.\n
    \n
  • foo
  • \n
\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n foo\n---\n.\n
foo\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> foo\n-----\n.\n
\n

foo

\n
\n
\n````````````````````````````````\n\n\nIf you want a heading with `> foo` as its literal text, you can\nuse backslash escapes:\n\n" -- "```````````````````````````````` example\n\\> foo\n------\n.\n

> foo

\n````````````````````````````````\n\n\n**Compatibility note:** Most existing Markdown implementations\ndo not allow the text of setext headings to span multiple lines.\nBut there is no consensus about how to interpret\n\n``` markdown\nFoo\nbar\n---\nbaz\n```\n\nOne can find four different interpretations:\n\n1. paragraph \"Foo\", heading \"bar\", paragraph \"baz\"\n2. paragraph \"Foo bar\", thematic break, paragraph \"baz\"\n3. paragraph \"Foo bar --- baz\"\n4. heading \"Foo bar\", paragraph \"baz\"\n\n" -- "We find interpretation 4 most natural, and interpretation 4\nincreases the expressive power of CommonMark, by allowing\nmultiline headings. Authors who want interpretation 1 can\nput a blank line after the first paragraph:\n\n```````````````````````````````` example\nFoo\n\nbar\n---\nbaz\n.\n

Foo

\n

bar

\n

baz

\n````````````````````````````````\n\n\nAuthors who want interpretation 2 can put blank lines around\nthe thematic break,\n\n" -- "```````````````````````````````` example\nFoo\nbar\n\n---\n\nbaz\n.\n

Foo\nbar

\n
\n

baz

\n````````````````````````````````\n\n\nor use a thematic break that cannot count as a [setext heading\nunderline], such as\n\n```````````````````````````````` example\nFoo\nbar\n* * *\nbaz\n.\n

Foo\nbar

\n
\n

baz

\n````````````````````````````````\n\n\nAuthors who want interpretation 3 can use backslash escapes:\n\n" -- "```````````````````````````````` example\nFoo\nbar\n\\---\nbaz\n.\n

Foo\nbar\n---\nbaz

\n````````````````````````````````\n\n\n" -- "## Indented code blocks\n\nAn [indented code block](@) is composed of one or more\n[indented chunks] separated by blank lines.\nAn [indented chunk](@) is a sequence of non-blank lines,\neach preceded by four or more spaces of indentation. The contents of the code\nblock are the literal contents of the lines, including trailing\n[line endings], minus four spaces of indentation.\nAn indented code block has no [info string].\n\nAn indented code block cannot interrupt a paragraph, so there must be\na blank line between a paragraph and a following indented code block.\n(A blank line is not needed, however, between a code block and a following\nparagraph.)\n\n```````````````````````````````` example\n a simple\n indented code block\n.\n
a simple\n  indented code block\n
\n````````````````````````````````\n\n\n" -- "If there is any ambiguity between an interpretation of indentation\nas a code block and as indicating that material belongs to a [list\nitem][list items], the list item interpretation takes precedence:\n\n```````````````````````````````` example\n - foo\n\n bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n1. foo\n\n - bar\n.\n
    \n
  1. \n

    foo

    \n
      \n
    • bar
    • \n
    \n
  2. \n
\n````````````````````````````````\n\n\n\nThe contents of a code block are literal text, and do not get parsed\nas Markdown:\n\n```````````````````````````````` example\n
\n *hi*\n\n - one\n.\n
<a/>\n*hi*\n\n- one\n
\n````````````````````````````````\n\n\nHere we have three chunks separated by blank lines:\n\n" -- "```````````````````````````````` example\n chunk1\n\n chunk2\n \n \n \n chunk3\n.\n
chunk1\n\nchunk2\n\n\n\nchunk3\n
\n````````````````````````````````\n\n\nAny initial spaces or tabs beyond four spaces of indentation will be included in\nthe content, even in interior blank lines:\n\n```````````````````````````````` example\n chunk1\n \n chunk2\n.\n
chunk1\n  \n  chunk2\n
\n````````````````````````````````\n\n\nAn indented code block cannot interrupt a paragraph. (This\nallows hanging indents and the like.)\n\n" -- "```````````````````````````````` example\nFoo\n bar\n\n.\n

Foo\nbar

\n````````````````````````````````\n\n\nHowever, any non-blank line with fewer than four spaces of indentation ends\nthe code block immediately. So a paragraph may occur immediately\nafter indented code:\n\n```````````````````````````````` example\n foo\nbar\n.\n
foo\n
\n

bar

\n````````````````````````````````\n\n\nAnd indented code can occur immediately before and after other kinds of\nblocks:\n\n" -- "```````````````````````````````` example\n# Heading\n foo\nHeading\n------\n foo\n----\n.\n

Heading

\n
foo\n
\n

Heading

\n
foo\n
\n
\n````````````````````````````````\n\n\nThe first line can be preceded by more than four spaces of indentation:\n\n```````````````````````````````` example\n foo\n bar\n.\n
    foo\nbar\n
\n````````````````````````````````\n\n\n" -- "Blank lines preceding or following an indented code block\nare not included in it:\n\n```````````````````````````````` example\n\n \n foo\n \n\n.\n
foo\n
\n````````````````````````````````\n\n\nTrailing spaces or tabs are included in the code block's content:\n\n```````````````````````````````` example\n foo \n.\n
foo  \n
\n````````````````````````````````\n\n\n\n" -- "## Fenced code blocks\n\nA [code fence](@) is a sequence\nof at least three consecutive backtick characters (`` ` ``) or\ntildes (`~`). (Tildes and backticks cannot be mixed.)\nA [fenced code block](@)\nbegins with a code fence, preceded by up to three spaces of indentation.\n\nThe line with the opening code fence may optionally contain some text\nfollowing the code fence; this is trimmed of leading and trailing\nspaces or tabs and called the [info string](@). If the [info string] comes\nafter a backtick fence, it may not contain any backtick\ncharacters. (The reason for this restriction is that otherwise\nsome inline code would be incorrectly interpreted as the\nbeginning of a fenced code block.)\n\n" -- "The content of the code block consists of all subsequent lines, until\na closing [code fence] of the same type as the code block\nbegan with (backticks or tildes), and with at least as many backticks\nor tildes as the opening code fence. If the leading code fence is\npreceded by N spaces of indentation, then up to N spaces of indentation are\nremoved from each line of the content (if present). (If a content line is not\nindented, it is preserved unchanged. If it is indented N spaces or less, all\nof the indentation is removed.)\n\nThe closing code fence may be preceded by up to three spaces of indentation, and\nmay be followed only by spaces or tabs, which are ignored. If the end of the\ncontaining block (or document) is reached and no closing code fence\nhas been found, the code block contains all of the lines after the\nopening code fence until the end of the containing block (or\ndocument). (An alternative spec would require backtracking in the\nevent that a closing code fence is not found. But this makes parsing\nmuch less efficient, and there seems to be no real downside to the\nbehavior described here.)\n\n" -- "A fenced code block may interrupt a paragraph, and does not require\na blank line either before or after.\n\nThe content of a code fence is treated as literal text, not parsed\nas inlines. The first word of the [info string] is typically used to\nspecify the language of the code sample, and rendered in the `class`\nattribute of the `code` tag. However, this spec does not mandate any\nparticular treatment of the [info string].\n\nHere is a simple example with backticks:\n\n```````````````````````````````` example\n```\n<\n >\n```\n.\n
<\n >\n
\n````````````````````````````````\n\n\nWith tildes:\n\n" -- "```````````````````````````````` example\n~~~\n<\n >\n~~~\n.\n
<\n >\n
\n````````````````````````````````\n\nFewer than three backticks is not enough:\n\n```````````````````````````````` example\n``\nfoo\n``\n.\n

foo

\n````````````````````````````````\n\nThe closing code fence must use the same character as the opening\nfence:\n\n" -- "```````````````````````````````` example\n```\naaa\n~~~\n```\n.\n
aaa\n~~~\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~\naaa\n```\n~~~\n.\n
aaa\n```\n
\n````````````````````````````````\n\n\nThe closing code fence must be at least as long as the opening fence:\n\n" -- "```````````````````````````````` example\n````\naaa\n```\n``````\n.\n
aaa\n```\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~~\naaa\n~~~\n~~~~\n.\n
aaa\n~~~\n
\n````````````````````````````````\n\n\nUnclosed code blocks are closed by the end of the document\n(or the enclosing [block quote][block quotes] or [list item][list items]):\n\n" -- "```````````````````````````````` example\n```\n.\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n`````\n\n```\naaa\n.\n
\n```\naaa\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n> ```\n> aaa\n\nbbb\n.\n
\n
aaa\n
\n
\n

bbb

\n````````````````````````````````\n\n\nA code block can have all empty lines as its content:\n\n```````````````````````````````` example\n```\n\n \n```\n.\n
\n  \n
\n````````````````````````````````\n\n\nA code block can be empty:\n\n" -- "```````````````````````````````` example\n```\n```\n.\n
\n````````````````````````````````\n\n\nFences can be indented. If the opening fence is indented,\ncontent lines will have equivalent opening indentation removed,\nif present:\n\n```````````````````````````````` example\n ```\n aaa\naaa\n```\n.\n
aaa\naaa\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n ```\naaa\n aaa\naaa\n ```\n.\n
aaa\naaa\naaa\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n ```\n aaa\n aaa\n aaa\n ```\n.\n
aaa\n aaa\naaa\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n" -- "```````````````````````````````` example\n ```\n aaa\n ```\n.\n
```\naaa\n```\n
\n````````````````````````````````\n\n\nClosing fences may be preceded by up to three spaces of indentation, and their\nindentation need not match that of the opening fence:\n\n```````````````````````````````` example\n```\naaa\n ```\n.\n
aaa\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n ```\naaa\n ```\n.\n
aaa\n
\n````````````````````````````````\n\n\nThis is not a closing fence, because it is indented 4 spaces:\n\n```````````````````````````````` example\n```\naaa\n ```\n.\n
aaa\n    ```\n
\n````````````````````````````````\n\n\n\nCode fences (opening and closing) cannot contain internal spaces or tabs:\n\n" -- "```````````````````````````````` example\n``` ```\naaa\n.\n

\naaa

\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~~~~\naaa\n~~~ ~~\n.\n
aaa\n~~~ ~~\n
\n````````````````````````````````\n\n\nFenced code blocks can interrupt paragraphs, and can be followed\ndirectly by paragraphs, without a blank line between:\n\n" -- "```````````````````````````````` example\nfoo\n```\nbar\n```\nbaz\n.\n

foo

\n
bar\n
\n

baz

\n````````````````````````````````\n\n\nOther blocks can also occur before and after fenced code blocks\nwithout an intervening blank line:\n\n```````````````````````````````` example\nfoo\n---\n~~~\nbar\n~~~\n# baz\n.\n

foo

\n
bar\n
\n

baz

\n````````````````````````````````\n\n\n" -- "An [info string] can be provided after the opening code fence.\nAlthough this spec doesn't mandate any particular treatment of\nthe info string, the first word is typically used to specify\nthe language of the code block. In HTML output, the language is\nnormally indicated by adding a class to the `code` element consisting\nof `language-` followed by the language name.\n\n```````````````````````````````` example\n```ruby\ndef foo(x)\n return 3\nend\n```\n.\n
def foo(x)\n  return 3\nend\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n.\n
def foo(x)\n  return 3\nend\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n````;\n````\n.\n
\n````````````````````````````````\n\n\n[Info strings] for backtick code blocks cannot contain backticks:\n\n" -- "```````````````````````````````` example\n``` aa ```\nfoo\n.\n

aa\nfoo

\n````````````````````````````````\n\n\n[Info strings] for tilde code blocks can contain backticks and tildes:\n\n```````````````````````````````` example\n~~~ aa ``` ~~~\nfoo\n~~~\n.\n
foo\n
\n````````````````````````````````\n\n\nClosing code fences cannot have [info strings]:\n\n" -- "```````````````````````````````` example\n```\n``` aaa\n```\n.\n
``` aaa\n
\n````````````````````````````````\n\n\n\n" +- "## Thematic breaks\n\nA line consisting of optionally up to three spaces of indentation, followed by a\nsequence of three or more matching `-`, `_`, or `*` characters, each followed\noptionally by any number of spaces or tabs, forms a\n[thematic break](@).\n\n```````````````````````````````` example\n***\n---\n___\n.\n
\n
\n
\n````````````````````````````````\n\n\nWrong characters:\n\n```````````````````````````````` example\n+++\n.\n

+++

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n===\n.\n

===

\n````````````````````````````````\n\n\nNot enough characters:\n\n```````````````````````````````` example\n--\n**\n__\n.\n

--\n**\n__

\n````````````````````````````````\n\n\nUp to three spaces of indentation are allowed:\n" +- "\n```````````````````````````````` example\n ***\n ***\n ***\n.\n
\n
\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n ***\n.\n
***\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nFoo\n ***\n.\n

Foo\n***

\n````````````````````````````````\n\n\nMore than three characters may be used:\n\n```````````````````````````````` example\n_____________________________________\n.\n
\n````````````````````````````````\n\n\nSpaces and tabs are allowed between the characters:\n" +- "\n```````````````````````````````` example\n - - -\n.\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n ** * ** * ** * **\n.\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- - - -\n.\n
\n````````````````````````````````\n\n\nSpaces and tabs are allowed at the end:\n" +- "\n```````````````````````````````` example\n- - - - \n.\n
\n````````````````````````````````\n\n\nHowever, no other characters may occur in the line:\n\n```````````````````````````````` example\n_ _ _ _ a\n\na------\n\n---a---\n.\n

_ _ _ _ a

\n

a------

\n

---a---

\n````````````````````````````````\n\n\nIt is required that all of the characters other than spaces or tabs be the same.\nSo, this is not a thematic break:\n" +- "\n```````````````````````````````` example\n *-*\n.\n

-

\n````````````````````````````````\n\n\nThematic breaks do not need blank lines before or after:\n\n```````````````````````````````` example\n- foo\n***\n- bar\n.\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n````````````````````````````````\n\n\nThematic breaks can interrupt a paragraph:\n" +- "\n```````````````````````````````` example\nFoo\n***\nbar\n.\n

Foo

\n
\n

bar

\n````````````````````````````````\n\n\nIf a line of dashes that meets the above conditions for being a\nthematic break could also be interpreted as the underline of a [setext\nheading], the interpretation as a\n[setext heading] takes precedence. Thus, for example,\nthis is a setext heading, not a paragraph followed by a thematic break:\n\n```````````````````````````````` example\nFoo\n---\nbar\n.\n

Foo

\n

bar

\n````````````````````````````````" +- "\n\n\nWhen both a thematic break and a list item are possible\ninterpretations of a line, the thematic break takes precedence:\n\n```````````````````````````````` example\n* Foo\n* * *\n* Bar\n.\n
    \n
  • Foo
  • \n
\n
\n
    \n
  • Bar
  • \n
\n````````````````````````````````\n\n\nIf you want a thematic break in a list item, use a different bullet:\n" +- "\n```````````````````````````````` example\n- Foo\n- * * *\n.\n
    \n
  • Foo
  • \n
  • \n
    \n
  • \n
\n````````````````````````````````\n\n\n" +- "## ATX headings\n\nAn [ATX heading](@)\nconsists of a string of characters, parsed as inline content, between an\nopening sequence of 1--6 unescaped `#` characters and an optional\nclosing sequence of any number of unescaped `#` characters.\nThe opening sequence of `#` characters must be followed by spaces or tabs, or\nby the end of line. The optional closing sequence of `#`s must be preceded by\nspaces or tabs and may be followed by spaces or tabs only. The opening\n`#` character may be preceded by up to three spaces of indentation. The raw\ncontents of the heading are stripped of leading and trailing space or tabs\nbefore being parsed as inline content. The heading level is equal to the number\nof `#` characters in the opening sequence.\n\nSimple headings:\n" +- "\n```````````````````````````````` example\n# foo\n## foo\n### foo\n#### foo\n##### foo\n###### foo\n.\n

foo

\n

foo

\n

foo

\n

foo

\n
foo
\n
foo
\n````````````````````````````````\n\n\nMore than six `#` characters is not a heading:\n" +- "\n```````````````````````````````` example\n####### foo\n.\n

####### foo

\n````````````````````````````````\n\n\nAt least one space or tab is required between the `#` characters and the\nheading's contents, unless the heading is empty. Note that many\nimplementations currently do not require the space. However, the\nspace was required by the\n[original ATX implementation](http://www.aaronsw.com/2002/atx/atx.py),\nand it helps prevent things like the following from being parsed as\nheadings:\n" +- "\n```````````````````````````````` example\n#5 bolt\n\n#hashtag\n.\n

#5 bolt

\n

#hashtag

\n````````````````````````````````\n\n\nThis is not a heading, because the first `#` is escaped:\n\n```````````````````````````````` example\n\\## foo\n.\n

## foo

\n````````````````````````````````\n\n\nContents are parsed as inlines:\n" +- "\n```````````````````````````````` example\n# foo *bar* \\*baz\\*\n.\n

foo bar *baz*

\n````````````````````````````````\n\n\nLeading and trailing spaces or tabs are ignored in parsing inline content:\n\n```````````````````````````````` example\n# foo \n.\n

foo

\n````````````````````````````````\n\n\nUp to three spaces of indentation are allowed:\n" +- "\n```````````````````````````````` example\n ### foo\n ## foo\n # foo\n.\n

foo

\n

foo

\n

foo

\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n # foo\n.\n
# foo\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nfoo\n # bar\n.\n

foo\n# bar

\n````````````````````````````````\n\n\nA closing sequence of `#` characters is optional:\n\n```````````````````````````````` example\n## foo ##\n ### bar ###\n.\n

foo

\n

bar

\n````````````````````````````````\n\n\nIt need not be the same length as the opening sequence:\n" +- "\n```````````````````````````````` example\n# foo ##################################\n##### foo ##\n.\n

foo

\n
foo
\n````````````````````````````````\n\n\nSpaces or tabs are allowed after the closing sequence:\n\n```````````````````````````````` example\n### foo ### \n.\n

foo

\n````````````````````````````````" +- "\n\n\nA sequence of `#` characters with anything but spaces or tabs following it\nis not a closing sequence, but counts as part of the contents of the\nheading:\n\n```````````````````````````````` example\n### foo ### b\n.\n

foo ### b

\n````````````````````````````````\n\n\nThe closing sequence must be preceded by a space or tab:\n\n```````````````````````````````` example\n# foo#\n.\n

foo#

\n````````````````````````````````\n\n\nBackslash-escaped `#` characters do not count as part\nof the closing sequence:\n" +- "\n```````````````````````````````` example\n### foo \\###\n## foo #\\##\n# foo \\#\n.\n

foo ###

\n

foo ###

\n

foo #

\n````````````````````````````````\n\n\nATX headings need not be separated from surrounding content by blank\nlines, and they can interrupt paragraphs:\n\n```````````````````````````````` example\n****\n## foo\n****\n.\n
\n

foo

\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nFoo bar\n# baz\nBar foo\n.\n

Foo bar

\n

baz

\n

Bar foo

\n````````````````````````````````\n\n\nATX headings can be empty:\n\n```````````````````````````````` example\n## \n#\n### ###\n.\n

\n

\n

\n````````````````````````````````\n\n\n" +- "## Setext headings\n\nA [setext heading](@) consists of one or more\nlines of text, not interrupted by a blank line, of which the first line does not\nhave more than 3 spaces of indentation, followed by\na [setext heading underline]. The lines of text must be such\nthat, were they not followed by the setext heading underline,\nthey would be interpreted as a paragraph: they cannot be\ninterpretable as a [code fence], [ATX heading][ATX headings],\n[block quote][block quotes], [thematic break][thematic breaks],\n[list item][list items], or [HTML block][HTML blocks].\n\nA [setext heading underline](@) is a sequence of\n`=` characters or a sequence of `-` characters, with no more than 3\nspaces of indentation and any number of trailing spaces or tabs.\n" +- "\nThe heading is a level 1 heading if `=` characters are used in\nthe [setext heading underline], and a level 2 heading if `-`\ncharacters are used. The contents of the heading are the result\nof parsing the preceding lines of text as CommonMark inline\ncontent.\n\nIn general, a setext heading need not be preceded or followed by a\nblank line. However, it cannot interrupt a paragraph, so when a\nsetext heading comes after a paragraph, a blank line is needed between\nthem.\n\nSimple examples:\n\n```````````````````````````````` example\nFoo *bar*\n=========\n\nFoo *bar*\n---------\n.\n

Foo bar

\n

Foo bar

\n````````````````````````````````\n\n\nThe content of the header may span more than one line:\n" +- "\n```````````````````````````````` example\nFoo *bar\nbaz*\n====\n.\n

Foo bar\nbaz

\n````````````````````````````````\n\nThe contents are the result of parsing the headings's raw\ncontent as inlines. The heading's raw content is formed by\nconcatenating the lines and removing initial and final\nspaces or tabs.\n\n```````````````````````````````` example\n Foo *bar\nbaz*→\n====\n.\n

Foo bar\nbaz

\n````````````````````````````````\n\n\nThe underlining can be any length:\n" +- "\n```````````````````````````````` example\nFoo\n-------------------------\n\nFoo\n=\n.\n

Foo

\n

Foo

\n````````````````````````````````\n\n\nThe heading content can be preceded by up to three spaces of indentation, and\nneed not line up with the underlining:\n" +- "\n```````````````````````````````` example\n Foo\n---\n\n Foo\n-----\n\n Foo\n ===\n.\n

Foo

\n

Foo

\n

Foo

\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n Foo\n ---\n\n Foo\n---\n.\n
Foo\n---\n\nFoo\n
\n
\n````````````````````````````````" +- "\n\n\nThe setext heading underline can be preceded by up to three spaces of\nindentation, and may have trailing spaces or tabs:\n\n```````````````````````````````` example\nFoo\n ---- \n.\n

Foo

\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\nFoo\n ---\n.\n

Foo\n---

\n````````````````````````````````\n\n\nThe setext heading underline cannot contain internal spaces or tabs:\n" +- "\n```````````````````````````````` example\nFoo\n= =\n\nFoo\n--- -\n.\n

Foo\n= =

\n

Foo

\n
\n````````````````````````````````\n\n\nTrailing spaces or tabs in the content line do not cause a hard line break:\n\n```````````````````````````````` example\nFoo \n-----\n.\n

Foo

\n````````````````````````````````\n\n\nNor does a backslash at the end:\n" +- "\n```````````````````````````````` example\nFoo\\\n----\n.\n

Foo\\

\n````````````````````````````````\n\n\nSince indicators of block structure take precedence over\nindicators of inline structure, the following are setext headings:\n" +- "\n```````````````````````````````` example\n`Foo\n----\n`\n\n
\n.\n

`Foo

\n

`

\n

<a title="a lot

\n

of dashes"/>

\n````````````````````````````````\n\n\nThe setext heading underline cannot be a [lazy continuation\nline] in a list item or block quote:\n" +- "\n```````````````````````````````` example\n> Foo\n---\n.\n
\n

Foo

\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> foo\nbar\n===\n.\n
\n

foo\nbar\n===

\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n- Foo\n---\n.\n
    \n
  • Foo
  • \n
\n
\n````````````````````````````````\n\n\nA blank line is needed between a paragraph and a following\nsetext heading, since otherwise the paragraph becomes part\nof the heading's content:\n\n```````````````````````````````` example\nFoo\nBar\n---\n.\n

Foo\nBar

\n````````````````````````````````\n\n\nBut in general a blank line is not required before or after\nsetext headings:\n" +- "\n```````````````````````````````` example\n---\nFoo\n---\nBar\n---\nBaz\n.\n
\n

Foo

\n

Bar

\n

Baz

\n````````````````````````````````\n\n\nSetext headings cannot be empty:\n\n```````````````````````````````` example\n\n====\n.\n

====

\n````````````````````````````````\n\n\nSetext heading text lines must not be interpretable as block\nconstructs other than paragraphs. So, the line of dashes\nin these examples gets interpreted as a thematic break:\n" +- "\n```````````````````````````````` example\n---\n---\n.\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- foo\n-----\n.\n
    \n
  • foo
  • \n
\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n foo\n---\n.\n
foo\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> foo\n-----\n.\n
\n

foo

\n
\n
\n````````````````````````````````\n\n\nIf you want a heading with `> foo` as its literal text, you can\nuse backslash escapes:\n" +- "\n```````````````````````````````` example\n\\> foo\n------\n.\n

> foo

\n````````````````````````````````\n\n\n**Compatibility note:** Most existing Markdown implementations\ndo not allow the text of setext headings to span multiple lines.\nBut there is no consensus about how to interpret\n\n``` markdown\nFoo\nbar\n---\nbaz\n```\n\nOne can find four different interpretations:\n\n1. paragraph \"Foo\", heading \"bar\", paragraph \"baz\"\n2. paragraph \"Foo bar\", thematic break, paragraph \"baz\"\n3. paragraph \"Foo bar --- baz\"\n4. heading \"Foo bar\", paragraph \"baz\"\n\n" +- "We find interpretation 4 most natural, and interpretation 4\nincreases the expressive power of CommonMark, by allowing\nmultiline headings. Authors who want interpretation 1 can\nput a blank line after the first paragraph:\n\n```````````````````````````````` example\nFoo\n\nbar\n---\nbaz\n.\n

Foo

\n

bar

\n

baz

\n````````````````````````````````\n\n\nAuthors who want interpretation 2 can put blank lines around\nthe thematic break,\n" +- "\n```````````````````````````````` example\nFoo\nbar\n\n---\n\nbaz\n.\n

Foo\nbar

\n
\n

baz

\n````````````````````````````````\n\n\nor use a thematic break that cannot count as a [setext heading\nunderline], such as\n\n```````````````````````````````` example\nFoo\nbar\n* * *\nbaz\n.\n

Foo\nbar

\n
\n

baz

\n````````````````````````````````\n\n\nAuthors who want interpretation 3 can use backslash escapes:\n" +- "\n```````````````````````````````` example\nFoo\nbar\n\\---\nbaz\n.\n

Foo\nbar\n---\nbaz

\n````````````````````````````````\n\n\n" +- "## Indented code blocks\n\nAn [indented code block](@) is composed of one or more\n[indented chunks] separated by blank lines.\nAn [indented chunk](@) is a sequence of non-blank lines,\neach preceded by four or more spaces of indentation. The contents of the code\nblock are the literal contents of the lines, including trailing\n[line endings], minus four spaces of indentation.\nAn indented code block has no [info string].\n\nAn indented code block cannot interrupt a paragraph, so there must be\na blank line between a paragraph and a following indented code block.\n(A blank line is not needed, however, between a code block and a following\nparagraph.)\n\n```````````````````````````````` example\n a simple\n indented code block\n.\n
a simple\n  indented code block\n
\n````````````````````````````````" +- "\n\n\nIf there is any ambiguity between an interpretation of indentation\nas a code block and as indicating that material belongs to a [list\nitem][list items], the list item interpretation takes precedence:\n\n```````````````````````````````` example\n - foo\n\n bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n1. foo\n\n - bar\n.\n
    \n
  1. \n

    foo

    \n
      \n
    • bar
    • \n
    \n
  2. \n
\n````````````````````````````````\n\n\n\nThe contents of a code block are literal text, and do not get parsed\nas Markdown:\n\n```````````````````````````````` example\n
\n *hi*\n\n - one\n.\n
<a/>\n*hi*\n\n- one\n
\n````````````````````````````````\n\n\nHere we have three chunks separated by blank lines:\n" +- "\n```````````````````````````````` example\n chunk1\n\n chunk2\n \n \n \n chunk3\n.\n
chunk1\n\nchunk2\n\n\n\nchunk3\n
\n````````````````````````````````\n\n\nAny initial spaces or tabs beyond four spaces of indentation will be included in\nthe content, even in interior blank lines:\n\n```````````````````````````````` example\n chunk1\n \n chunk2\n.\n
chunk1\n  \n  chunk2\n
\n````````````````````````````````\n\n\nAn indented code block cannot interrupt a paragraph. (This\nallows hanging indents and the like.)\n" +- "\n```````````````````````````````` example\nFoo\n bar\n\n.\n

Foo\nbar

\n````````````````````````````````\n\n\nHowever, any non-blank line with fewer than four spaces of indentation ends\nthe code block immediately. So a paragraph may occur immediately\nafter indented code:\n\n```````````````````````````````` example\n foo\nbar\n.\n
foo\n
\n

bar

\n````````````````````````````````\n\n\nAnd indented code can occur immediately before and after other kinds of\nblocks:\n" +- "\n```````````````````````````````` example\n# Heading\n foo\nHeading\n------\n foo\n----\n.\n

Heading

\n
foo\n
\n

Heading

\n
foo\n
\n
\n````````````````````````````````\n\n\nThe first line can be preceded by more than four spaces of indentation:\n\n```````````````````````````````` example\n foo\n bar\n.\n
    foo\nbar\n
\n````````````````````````````````" +- "\n\n\nBlank lines preceding or following an indented code block\nare not included in it:\n\n```````````````````````````````` example\n\n \n foo\n \n\n.\n
foo\n
\n````````````````````````````````\n\n\nTrailing spaces or tabs are included in the code block's content:\n\n```````````````````````````````` example\n foo \n.\n
foo  \n
\n````````````````````````````````\n\n\n\n" +- "## Fenced code blocks\n\nA [code fence](@) is a sequence\nof at least three consecutive backtick characters (`` ` ``) or\ntildes (`~`). (Tildes and backticks cannot be mixed.)\nA [fenced code block](@)\nbegins with a code fence, preceded by up to three spaces of indentation.\n\nThe line with the opening code fence may optionally contain some text\nfollowing the code fence; this is trimmed of leading and trailing\nspaces or tabs and called the [info string](@). If the [info string] comes\nafter a backtick fence, it may not contain any backtick\ncharacters. (The reason for this restriction is that otherwise\nsome inline code would be incorrectly interpreted as the\nbeginning of a fenced code block.)\n" +- "\nThe content of the code block consists of all subsequent lines, until\na closing [code fence] of the same type as the code block\nbegan with (backticks or tildes), and with at least as many backticks\nor tildes as the opening code fence. If the leading code fence is\npreceded by N spaces of indentation, then up to N spaces of indentation are\nremoved from each line of the content (if present). (If a content line is not\nindented, it is preserved unchanged. If it is indented N spaces or less, all\nof the indentation is removed.)\n\nThe closing code fence may be preceded by up to three spaces of indentation, and\nmay be followed only by spaces or tabs, which are ignored. If the end of the\ncontaining block (or document) is reached and no closing code fence\nhas been found, the code block contains all of the lines after the\nopening code fence until the end of the containing block (or\ndocument). (An alternative spec would require backtracking in the\nevent that a closing code fence is not found. But this makes parsing\nmuch less efficient, and there seems to be no real downside to the\nbehavior described here.)\n" +- "\nA fenced code block may interrupt a paragraph, and does not require\na blank line either before or after.\n\nThe content of a code fence is treated as literal text, not parsed\nas inlines. The first word of the [info string] is typically used to\nspecify the language of the code sample, and rendered in the `class`\nattribute of the `code` tag. However, this spec does not mandate any\nparticular treatment of the [info string].\n\nHere is a simple example with backticks:\n\n```````````````````````````````` example\n```\n<\n >\n```\n.\n
<\n >\n
\n````````````````````````````````\n\n\nWith tildes:\n" +- "\n```````````````````````````````` example\n~~~\n<\n >\n~~~\n.\n
<\n >\n
\n````````````````````````````````\n\nFewer than three backticks is not enough:\n\n```````````````````````````````` example\n``\nfoo\n``\n.\n

foo

\n````````````````````````````````\n\nThe closing code fence must use the same character as the opening\nfence:\n" +- "\n```````````````````````````````` example\n```\naaa\n~~~\n```\n.\n
aaa\n~~~\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~\naaa\n```\n~~~\n.\n
aaa\n```\n
\n````````````````````````````````\n\n\nThe closing code fence must be at least as long as the opening fence:\n" +- "\n```````````````````````````````` example\n````\naaa\n```\n``````\n.\n
aaa\n```\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~~\naaa\n~~~\n~~~~\n.\n
aaa\n~~~\n
\n````````````````````````````````\n\n\nUnclosed code blocks are closed by the end of the document\n(or the enclosing [block quote][block quotes] or [list item][list items]):\n" +- "\n```````````````````````````````` example\n```\n.\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n`````\n\n```\naaa\n.\n
\n```\naaa\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n> ```\n> aaa\n\nbbb\n.\n
\n
aaa\n
\n
\n

bbb

\n````````````````````````````````\n\n\nA code block can have all empty lines as its content:\n\n```````````````````````````````` example\n```\n\n \n```\n.\n
\n  \n
\n````````````````````````````````\n\n\nA code block can be empty:\n" +- "\n```````````````````````````````` example\n```\n```\n.\n
\n````````````````````````````````\n\n\nFences can be indented. If the opening fence is indented,\ncontent lines will have equivalent opening indentation removed,\nif present:\n\n```````````````````````````````` example\n ```\n aaa\naaa\n```\n.\n
aaa\naaa\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n ```\naaa\n aaa\naaa\n ```\n.\n
aaa\naaa\naaa\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n ```\n aaa\n aaa\n aaa\n ```\n.\n
aaa\n aaa\naaa\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n" +- "\n```````````````````````````````` example\n ```\n aaa\n ```\n.\n
```\naaa\n```\n
\n````````````````````````````````\n\n\nClosing fences may be preceded by up to three spaces of indentation, and their\nindentation need not match that of the opening fence:\n\n```````````````````````````````` example\n```\naaa\n ```\n.\n
aaa\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n ```\naaa\n ```\n.\n
aaa\n
\n````````````````````````````````\n\n\nThis is not a closing fence, because it is indented 4 spaces:\n\n```````````````````````````````` example\n```\naaa\n ```\n.\n
aaa\n    ```\n
\n````````````````````````````````\n\n\n\nCode fences (opening and closing) cannot contain internal spaces or tabs:\n" +- "\n```````````````````````````````` example\n``` ```\naaa\n.\n

\naaa

\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~~~~\naaa\n~~~ ~~\n.\n
aaa\n~~~ ~~\n
\n````````````````````````````````\n\n\nFenced code blocks can interrupt paragraphs, and can be followed\ndirectly by paragraphs, without a blank line between:\n" +- "\n```````````````````````````````` example\nfoo\n```\nbar\n```\nbaz\n.\n

foo

\n
bar\n
\n

baz

\n````````````````````````````````\n\n\nOther blocks can also occur before and after fenced code blocks\nwithout an intervening blank line:\n\n```````````````````````````````` example\nfoo\n---\n~~~\nbar\n~~~\n# baz\n.\n

foo

\n
bar\n
\n

baz

\n````````````````````````````````" +- "\n\n\nAn [info string] can be provided after the opening code fence.\nAlthough this spec doesn't mandate any particular treatment of\nthe info string, the first word is typically used to specify\nthe language of the code block. In HTML output, the language is\nnormally indicated by adding a class to the `code` element consisting\nof `language-` followed by the language name.\n\n```````````````````````````````` example\n```ruby\ndef foo(x)\n return 3\nend\n```\n.\n
def foo(x)\n  return 3\nend\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n.\n
def foo(x)\n  return 3\nend\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n````;\n````\n.\n
\n````````````````````````````````\n\n\n[Info strings] for backtick code blocks cannot contain backticks:\n" +- "\n```````````````````````````````` example\n``` aa ```\nfoo\n.\n

aa\nfoo

\n````````````````````````````````\n\n\n[Info strings] for tilde code blocks can contain backticks and tildes:\n\n```````````````````````````````` example\n~~~ aa ``` ~~~\nfoo\n~~~\n.\n
foo\n
\n````````````````````````````````\n\n\nClosing code fences cannot have [info strings]:\n" +- "\n```````````````````````````````` example\n```\n``` aaa\n```\n.\n
``` aaa\n
\n````````````````````````````````\n\n\n\n" - "## HTML blocks\n\nAn [HTML block](@) is a group of lines that is treated\nas raw HTML (and will not be escaped in HTML output).\n\nThere are seven kinds of [HTML block], which can be defined by their\nstart and end conditions. The block begins with a line that meets a\n[start condition](@) (after up to three optional spaces of indentation).\nIt ends with the first subsequent line that meets a matching\n[end condition](@), or the last line of the document, or the last line of\nthe [container block](#container-blocks) containing the current HTML\nblock, if no line is encountered that meets the [end condition]. If\nthe first line meets both the [start condition] and the [end\ncondition], the block will contain just that line.\n\n" - "1. **Start condition:** line begins with the string ``, or the end of the line.\\\n**End condition:** line contains an end tag\n``, ``, ``, or `` (case-insensitive; it\nneed not match the start tag).\n\n2. **Start condition:** line begins with the string ``.\n\n3. **Start condition:** line begins with the string ``.\n\n4. **Start condition:** line begins with the string ``.\n\n5. **Start condition:** line begins with the string\n" - "``.\n\n" - "6. **Start condition:** line begins with the string `<` or ``, or\nthe string `/>`.\\\n**End condition:** line is followed by a [blank line].\n\n7. **Start condition:** line begins with a complete [open tag]\n(with any [tag name] other than `pre`, `script`,\n`style`, or `textarea`) or a complete [closing tag],\nfollowed by zero or more spaces and tabs, followed by the end of the line.\\\n**End condition:** line is followed by a [blank line].\n\n" -- "HTML blocks continue until they are closed by their appropriate\n[end condition], or the last line of the document or other [container\nblock](#container-blocks). This means any HTML **within an HTML\nblock** that might otherwise be recognised as a start condition will\nbe ignored by the parser and passed through as-is, without changing\nthe parser's state.\n\nFor instance, `
` within an HTML block started by `` will not affect\nthe parser state; as the HTML block was started in by start condition 6, it\nwill end at any blank line. This can be surprising:\n\n"
-- "```````````````````````````````` example\n
\n
\n**Hello**,\n\n_world_.\n
\n
\n.\n
\n
\n**Hello**,\n

world.\n

\n
\n````````````````````````````````\n\nIn this case, the HTML block is terminated by the blank line — the `**Hello**`\ntext remains verbatim — and regular parsing resumes, with a paragraph,\nemphasised `world` and inline and block HTML following.\n\n" -- "All types of [HTML blocks] except type 7 may interrupt\na paragraph. Blocks of type 7 may not interrupt a paragraph.\n(This restriction is intended to prevent unwanted interpretation\nof long tags inside a wrapped paragraph as starting HTML blocks.)\n\nSome simple examples follow. Here are some basic HTML blocks\nof type 6:\n\n```````````````````````````````` example\n\n \n \n \n
\n hi\n
\n\nokay.\n.\n\n \n \n \n
\n hi\n
\n

okay.

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n
\n*foo*\n````````````````````````````````\n\n\nHere we have two HTML blocks with a Markdown paragraph between them:\n\n" -- "```````````````````````````````` example\n
\n\n*Markdown*\n\n
\n.\n
\n

Markdown

\n
\n````````````````````````````````\n\n\nThe tag on the first line can be partial, as long\nas it is split where there would be whitespace:\n\n```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````\n\n\nAn open tag need not be closed:\n```````````````````````````````` example\n
\n*foo*\n\n*bar*\n.\n
\n*foo*\n

bar

\n````````````````````````````````\n\n\n\nA partial tag need not even be completed (garbage\nin, garbage out):\n\n" -- "```````````````````````````````` example\n
\n.\n\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n
\nfoo\n
\n.\n
\nfoo\n
\n````````````````````````````````\n\n\nEverything until the next blank line or end of document\ngets included in the HTML block. So, in the following\nexample, what looks like a Markdown code block\nis actually part of the HTML block, which continues until a blank\nline or the end of the document is reached:\n\n" -- "```````````````````````````````` example\n
\n``` c\nint x = 33;\n```\n.\n
\n``` c\nint x = 33;\n```\n````````````````````````````````\n\n\nTo start an [HTML block] with a tag that is *not* in the\nlist of block-level tags in (6), you must put the tag by\nitself on the first line (and it must be complete):\n\n" -- "```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\nIn type 7 blocks, the [tag name] can be anything:\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n*bar*\n.\n\n*bar*\n````````````````````````````````\n\n\n" -- "These rules are designed to allow us to work with tags that\ncan function as either block-level or inline-level tags.\nThe `` tag is a nice example. We can surround content with\n`` tags in three different ways. In this case, we get a raw\nHTML block, because the `` tag is on a line by itself:\n\n```````````````````````````````` example\n\n*foo*\n\n.\n\n*foo*\n\n````````````````````````````````\n\n\nIn this case, we get a raw HTML block that just includes\nthe `` tag (because it ends with the following blank\nline). So the contents get interpreted as CommonMark:\n\n" -- "```````````````````````````````` example\n\n\n*foo*\n\n\n.\n\n

foo

\n
\n````````````````````````````````\n\n\nFinally, in this case, the `` tags are interpreted\nas [raw HTML] *inside* the CommonMark paragraph. (Because\nthe tag is not on a line by itself, we get inline HTML\nrather than an [HTML block].)\n\n" -- "```````````````````````````````` example\n*foo*\n.\n

foo

\n````````````````````````````````\n\n\nHTML tags designed to contain literal content\n(`pre`, `script`, `style`, `textarea`), comments, processing instructions,\nand declarations are treated somewhat differently.\nInstead of ending at the first blank line, these blocks\nend at the first line containing a corresponding end tag.\nAs a result, these blocks can contain blank lines:\n\nA pre tag (type 1):\n\n" -- "```````````````````````````````` example\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n.\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n````````````````````````````````\n\n\nA script tag (type 1):\n\n" -- "```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\nA textarea tag (type 1):\n\n" -- "```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\nA style tag (type 1):\n\n```````````````````````````````` example\n\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n.\n\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n````````````````````````````````\n\n\n" -- "If there is no matching end tag, the block will end at the\nend of the document (or the enclosing [block quote][block quotes]\nor [list item][list items]):\n\n```````````````````````````````` example\n\n\nfoo\n.\n\n\nfoo\n````````````````````````````````\n\n\n```````````````````````````````` example\n>
\n> foo\n\nbar\n.\n
\n
\nfoo\n
\n

bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n-
\n- foo\n.\n
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n````````````````````````````````\n\n\nThe end tag can occur on the same line as the start tag:\n\n```````````````````````````````` example\n\n*foo*\n.\n\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*bar*\n*baz*\n.\n*bar*\n

baz

\n````````````````````````````````\n\n\nNote that anything on the last line after the\nend tag will be included in the [HTML block]:\n\n```````````````````````````````` example\n1. *bar*\n.\n1. *bar*\n````````````````````````````````\n\n\nA comment (type 2):\n\n" -- "```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\n\nA processing instruction (type 3):\n\n```````````````````````````````` example\n';\n\n?>\nokay\n.\n';\n\n?>\n

okay

\n````````````````````````````````\n\n\nA declaration (type 4):\n\n" -- "```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\nCDATA (type 5):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\n" -- "The opening tag can be preceded by up to three spaces of indentation, but not\nfour:\n\n```````````````````````````````` example\n \n\n \n.\n \n
<!-- foo -->\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n\n
\n.\n
\n
<div>\n
\n````````````````````````````````\n\n\n" -- "An HTML block of types 1--6 can interrupt a paragraph, and need not be\npreceded by a blank line.\n\n```````````````````````````````` example\nFoo\n
\nbar\n
\n.\n

Foo

\n
\nbar\n
\n````````````````````````````````\n\n\nHowever, a following blank line is needed, except at the end of\na document, and except for blocks of types 1--5, [above][HTML\nblock]:\n\n```````````````````````````````` example\n
\nbar\n
\n*foo*\n.\n
\nbar\n
\n*foo*\n````````````````````````````````\n\n\n" -- "HTML blocks of type 7 cannot interrupt a paragraph:\n\n```````````````````````````````` example\nFoo\n\nbaz\n.\n

Foo\n\nbaz

\n````````````````````````````````\n\n\nThis rule differs from John Gruber's original Markdown syntax\nspecification, which says:\n\n> The only restrictions are that block-level HTML elements —\n> e.g. `
`, ``, `
`, `

`, etc. — must be separated from\n> surrounding content by blank lines, and the start and end tags of the\n> block should not be indented with spaces or tabs.\n\nIn some ways Gruber's rule is more restrictive than the one given\nhere:\n\n" +- "HTML blocks continue until they are closed by their appropriate\n[end condition], or the last line of the document or other [container\nblock](#container-blocks). This means any HTML **within an HTML\nblock** that might otherwise be recognised as a start condition will\nbe ignored by the parser and passed through as-is, without changing\nthe parser's state.\n\nFor instance, `

` within an HTML block started by `
` will not affect\nthe parser state; as the HTML block was started in by start condition 6, it\nwill end at any blank line. This can be surprising:\n" +- "\n```````````````````````````````` example\n
\n
\n**Hello**,\n\n_world_.\n
\n
\n.\n
\n
\n**Hello**,\n

world.\n

\n
\n````````````````````````````````\n\nIn this case, the HTML block is terminated by the blank line — the `**Hello**`\ntext remains verbatim — and regular parsing resumes, with a paragraph,\nemphasised `world` and inline and block HTML following.\n" +- "\nAll types of [HTML blocks] except type 7 may interrupt\na paragraph. Blocks of type 7 may not interrupt a paragraph.\n(This restriction is intended to prevent unwanted interpretation\nof long tags inside a wrapped paragraph as starting HTML blocks.)\n\nSome simple examples follow. Here are some basic HTML blocks\nof type 6:\n\n```````````````````````````````` example\n\n \n \n \n
\n hi\n
\n\nokay.\n.\n\n \n \n \n
\n hi\n
\n

okay.

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n
\n*foo*\n````````````````````````````````\n\n\nHere we have two HTML blocks with a Markdown paragraph between them:\n" +- "\n```````````````````````````````` example\n
\n\n*Markdown*\n\n
\n.\n
\n

Markdown

\n
\n````````````````````````````````\n\n\nThe tag on the first line can be partial, as long\nas it is split where there would be whitespace:\n\n```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````\n\n\nAn open tag need not be closed:\n```````````````````````````````` example\n
\n*foo*\n\n*bar*\n.\n
\n*foo*\n

bar

\n````````````````````````````````\n\n\n\nA partial tag need not even be completed (garbage\nin, garbage out):\n" +- "\n```````````````````````````````` example\n
\n.\n\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n
\nfoo\n
\n.\n
\nfoo\n
\n````````````````````````````````\n\n\nEverything until the next blank line or end of document\ngets included in the HTML block. So, in the following\nexample, what looks like a Markdown code block\nis actually part of the HTML block, which continues until a blank\nline or the end of the document is reached:\n" +- "\n```````````````````````````````` example\n
\n``` c\nint x = 33;\n```\n.\n
\n``` c\nint x = 33;\n```\n````````````````````````````````\n\n\nTo start an [HTML block] with a tag that is *not* in the\nlist of block-level tags in (6), you must put the tag by\nitself on the first line (and it must be complete):\n" +- "\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\nIn type 7 blocks, the [tag name] can be anything:\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n*bar*\n.\n\n*bar*\n````````````````````````````````" +- "\n\n\nThese rules are designed to allow us to work with tags that\ncan function as either block-level or inline-level tags.\nThe `` tag is a nice example. We can surround content with\n`` tags in three different ways. In this case, we get a raw\nHTML block, because the `` tag is on a line by itself:\n\n```````````````````````````````` example\n\n*foo*\n\n.\n\n*foo*\n\n````````````````````````````````\n\n\nIn this case, we get a raw HTML block that just includes\nthe `` tag (because it ends with the following blank\nline). So the contents get interpreted as CommonMark:\n" +- "\n```````````````````````````````` example\n\n\n*foo*\n\n\n.\n\n

foo

\n
\n````````````````````````````````\n\n\nFinally, in this case, the `` tags are interpreted\nas [raw HTML] *inside* the CommonMark paragraph. (Because\nthe tag is not on a line by itself, we get inline HTML\nrather than an [HTML block].)\n" +- "\n```````````````````````````````` example\n*foo*\n.\n

foo

\n````````````````````````````````\n\n\nHTML tags designed to contain literal content\n(`pre`, `script`, `style`, `textarea`), comments, processing instructions,\nand declarations are treated somewhat differently.\nInstead of ending at the first blank line, these blocks\nend at the first line containing a corresponding end tag.\nAs a result, these blocks can contain blank lines:\n\nA pre tag (type 1):\n" +- "\n```````````````````````````````` example\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n.\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n````````````````````````````````\n\n\nA script tag (type 1):\n" +- "\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\nA textarea tag (type 1):\n" +- "\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\nA style tag (type 1):\n\n```````````````````````````````` example\n\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n.\n\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n````````````````````````````````" +- "\n\n\nIf there is no matching end tag, the block will end at the\nend of the document (or the enclosing [block quote][block quotes]\nor [list item][list items]):\n\n```````````````````````````````` example\n\n\nfoo\n.\n\n\nfoo\n````````````````````````````````\n\n\n```````````````````````````````` example\n>
\n> foo\n\nbar\n.\n
\n
\nfoo\n
\n

bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n-
\n- foo\n.\n
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n````````````````````````````````\n\n\nThe end tag can occur on the same line as the start tag:\n\n```````````````````````````````` example\n\n*foo*\n.\n\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*bar*\n*baz*\n.\n*bar*\n

baz

\n````````````````````````````````\n\n\nNote that anything on the last line after the\nend tag will be included in the [HTML block]:\n\n```````````````````````````````` example\n1. *bar*\n.\n1. *bar*\n````````````````````````````````\n\n\nA comment (type 2):\n" +- "\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\n\nA processing instruction (type 3):\n\n```````````````````````````````` example\n';\n\n?>\nokay\n.\n';\n\n?>\n

okay

\n````````````````````````````````\n\n\nA declaration (type 4):\n" +- "\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\nCDATA (type 5):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````" +- "\n\n\nThe opening tag can be preceded by up to three spaces of indentation, but not\nfour:\n\n```````````````````````````````` example\n \n\n \n.\n \n
<!-- foo -->\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n\n
\n.\n
\n
<div>\n
\n````````````````````````````````" +- "\n\n\nAn HTML block of types 1--6 can interrupt a paragraph, and need not be\npreceded by a blank line.\n\n```````````````````````````````` example\nFoo\n
\nbar\n
\n.\n

Foo

\n
\nbar\n
\n````````````````````````````````\n\n\nHowever, a following blank line is needed, except at the end of\na document, and except for blocks of types 1--5, [above][HTML\nblock]:\n\n```````````````````````````````` example\n
\nbar\n
\n*foo*\n.\n
\nbar\n
\n*foo*\n````````````````````````````````" +- "\n\n\nHTML blocks of type 7 cannot interrupt a paragraph:\n\n```````````````````````````````` example\nFoo\n\nbaz\n.\n

Foo\n\nbaz

\n````````````````````````````````\n\n\nThis rule differs from John Gruber's original Markdown syntax\nspecification, which says:\n\n> The only restrictions are that block-level HTML elements —\n> e.g. `
`, ``, `
`, `

`, etc. — must be separated from\n> surrounding content by blank lines, and the start and end tags of the\n> block should not be indented with spaces or tabs.\n\nIn some ways Gruber's rule is more restrictive than the one given\nhere:\n\n" - "- It requires that an HTML block be preceded by a blank line.\n- It does not allow the start tag to be indented.\n- It requires a matching end tag, which it also does not allow to\n be indented.\n\n" -- "Most Markdown implementations (including some of Gruber's own) do not\nrespect all of these restrictions.\n\nThere is one respect, however, in which Gruber's rule is more liberal\nthan the one given here, since it allows blank lines to occur inside\nan HTML block. There are two reasons for disallowing them here.\nFirst, it removes the need to parse balanced tags, which is\nexpensive and can require backtracking from the end of the document\nif no matching end tag is found. Second, it provides a very simple\nand flexible way of including Markdown content inside HTML tags:\nsimply separate the Markdown from the HTML using blank lines:\n\nCompare:\n\n" -- "```````````````````````````````` example\n

\n\n*Emphasized* text.\n\n
\n.\n
\n

Emphasized text.

\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n*Emphasized* text.\n
\n.\n
\n*Emphasized* text.\n
\n````````````````````````````````\n\n\n" -- "Some Markdown implementations have adopted a convention of\ninterpreting content inside tags as text if the open tag has\nthe attribute `markdown=1`. The rule given above seems a simpler and\nmore elegant way of achieving the same expressive power, which is also\nmuch simpler to parse.\n\nThe main potential drawback is that one can no longer paste HTML\nblocks into Markdown documents with 100% reliability. However,\n*in most cases* this will work fine, because the blank lines in\nHTML are usually followed by HTML block tags. For example:\n\n```````````````````````````````` example\n
\n\n\n\n\n\n\n\n
\nHi\n
\n.\n\n\n\n\n
\nHi\n
\n````````````````````````````````\n\n\n" -- "There are problems, however, if the inner tags are indented\n*and* separated by spaces, as then they will be interpreted as\nan indented code block:\n\n```````````````````````````````` example\n\n\n \n\n \n\n \n\n
\n Hi\n
\n.\n\n \n
<td>\n  Hi\n</td>\n
\n \n
\n````````````````````````````````\n\n\nFortunately, blank lines are usually not necessary and can be\ndeleted. The exception is inside `
` tags, but as described\n[above][HTML blocks], raw HTML blocks starting with `
`\n*can* contain blank lines.\n\n"
-- "## Link reference definitions\n\nA [link reference definition](@)\nconsists of a [link label], optionally preceded by up to three spaces of\nindentation, followed\nby a colon (`:`), optional spaces or tabs (including up to one\n[line ending]), a [link destination],\noptional spaces or tabs (including up to one\n[line ending]), and an optional [link\ntitle], which if it is present must be separated\nfrom the [link destination] by spaces or tabs.\nNo further character may occur.\n\nA [link reference definition]\ndoes not correspond to a structural element of a document.  Instead, it\ndefines a label which can be used in [reference links]\nand reference-style [images] elsewhere in the document.  [Link\nreference definitions] can come either before or after the links that use\nthem.\n\n"
-- "```````````````````````````````` example\n[foo]: /url \"title\"\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n [foo]: \n /url \n 'the title' \n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n.\n

Foo*bar]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[Foo bar]:\n\n'title'\n\n[Foo bar]\n.\n

Foo bar

\n````````````````````````````````\n\n\n" -- "The title may extend over multiple lines:\n\n```````````````````````````````` example\n[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nHowever, it may not contain a [blank line]:\n\n" -- "```````````````````````````````` example\n[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n.\n

[foo]: /url 'title

\n

with blank line'

\n

[foo]

\n````````````````````````````````\n\n\nThe title may be omitted:\n\n```````````````````````````````` example\n[foo]:\n/url\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nThe link destination may not be omitted:\n\n" -- "```````````````````````````````` example\n[foo]:\n\n[foo]\n.\n

[foo]:

\n

[foo]

\n````````````````````````````````\n\n However, an empty link destination may be specified using\n angle brackets:\n\n```````````````````````````````` example\n[foo]: <>\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\nThe title must be separated from the link destination by\nspaces or tabs:\n\n" -- "```````````````````````````````` example\n[foo]: (baz)\n\n[foo]\n.\n

[foo]: (baz)

\n

[foo]

\n````````````````````````````````\n\n\nBoth title and destination can contain backslash escapes\nand literal backslashes:\n\n" -- "```````````````````````````````` example\n[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nA link can come before its corresponding definition:\n\n```````````````````````````````` example\n[foo]\n\n[foo]: url\n.\n

foo

\n````````````````````````````````\n\n\n" -- "If there are several matching definitions, the first one takes\nprecedence:\n\n```````````````````````````````` example\n[foo]\n\n[foo]: first\n[foo]: second\n.\n

foo

\n````````````````````````````````\n\n\nAs noted in the section on [Links], matching of labels is\ncase-insensitive (see [matches]).\n\n```````````````````````````````` example\n[FOO]: /url\n\n[Foo]\n.\n

Foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[ΑΓΩ]: /φου\n\n[αγω]\n.\n

αγω

\n````````````````````````````````\n\n\nWhether something is a [link reference definition] is\nindependent of whether the link reference it defines is\nused in the document. Thus, for example, the following\ndocument contains just a link reference definition, and\nno visible content:\n\n```````````````````````````````` example\n[foo]: /url\n.\n````````````````````````````````\n\n\nHere is another one:\n\n" -- "```````````````````````````````` example\n[\nfoo\n]: /url\nbar\n.\n

bar

\n````````````````````````````````\n\n\nThis is not a link reference definition, because there are\ncharacters other than spaces or tabs after the title:\n\n```````````````````````````````` example\n[foo]: /url \"title\" ok\n.\n

[foo]: /url "title" ok

\n````````````````````````````````\n\n\nThis is a link reference definition, but it has no title:\n\n" -- "```````````````````````````````` example\n[foo]: /url\n\"title\" ok\n.\n

"title" ok

\n````````````````````````````````\n\n\nThis is not a link reference definition, because it is indented\nfour spaces:\n\n```````````````````````````````` example\n [foo]: /url \"title\"\n\n[foo]\n.\n
[foo]: /url "title"\n
\n

[foo]

\n````````````````````````````````\n\n\nThis is not a link reference definition, because it occurs inside\na code block:\n\n" -- "```````````````````````````````` example\n```\n[foo]: /url\n```\n\n[foo]\n.\n
[foo]: /url\n
\n

[foo]

\n````````````````````````````````\n\n\nA [link reference definition] cannot interrupt a paragraph.\n\n```````````````````````````````` example\nFoo\n[bar]: /baz\n\n[bar]\n.\n

Foo\n[bar]: /baz

\n

[bar]

\n````````````````````````````````\n\n\n" -- "However, it can directly follow other block elements, such as headings\nand thematic breaks, and it need not be followed by a blank line.\n\n```````````````````````````````` example\n# [Foo]\n[foo]: /url\n> bar\n.\n

Foo

\n
\n

bar

\n
\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n[foo]: /url\nbar\n===\n[foo]\n.\n

bar

\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\n[foo]: /url\n===\n[foo]\n.\n

===\nfoo

\n````````````````````````````````\n\n\nSeveral [link reference definitions]\ncan occur one after another, without intervening blank lines.\n\n" -- "```````````````````````````````` example\n[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n.\n

foo,\nbar,\nbaz

\n````````````````````````````````\n\n\n[Link reference definitions] can occur\ninside block containers, like lists and block quotations. They\naffect the entire document, not just the container in which they\nare defined:\n\n" -- "```````````````````````````````` example\n[foo]\n\n> [foo]: /url\n.\n

foo

\n
\n
\n````````````````````````````````\n\n\n" -- "## Paragraphs\n\nA sequence of non-blank lines that cannot be interpreted as other\nkinds of blocks forms a [paragraph](@).\nThe contents of the paragraph are the result of parsing the\nparagraph's raw content as inlines. The paragraph's raw content\nis formed by concatenating the lines and removing initial and final\nspaces or tabs.\n\nA simple example with two paragraphs:\n\n```````````````````````````````` example\naaa\n\nbbb\n.\n

aaa

\n

bbb

\n````````````````````````````````\n\n\nParagraphs can contain multiple lines, but no blank lines:\n\n" -- "```````````````````````````````` example\naaa\nbbb\n\nccc\nddd\n.\n

aaa\nbbb

\n

ccc\nddd

\n````````````````````````````````\n\n\nMultiple blank lines between paragraphs have no effect:\n\n```````````````````````````````` example\naaa\n\n\nbbb\n.\n

aaa

\n

bbb

\n````````````````````````````````\n\n\nLeading spaces or tabs are skipped:\n\n" -- "```````````````````````````````` example\n aaa\n bbb\n.\n

aaa\nbbb

\n````````````````````````````````\n\n\nLines after the first may be indented any amount, since indented\ncode blocks cannot interrupt paragraphs.\n\n```````````````````````````````` example\naaa\n bbb\n ccc\n.\n

aaa\nbbb\nccc

\n````````````````````````````````\n\n\nHowever, the first line may be preceded by up to three spaces of indentation.\nFour spaces of indentation is too many:\n\n" -- "```````````````````````````````` example\n aaa\nbbb\n.\n

aaa\nbbb

\n````````````````````````````````\n\n\n```````````````````````````````` example\n aaa\nbbb\n.\n
aaa\n
\n

bbb

\n````````````````````````````````\n\n\nFinal spaces or tabs are stripped before inline parsing, so a paragraph\nthat ends with two or more spaces will not end with a [hard line\nbreak]:\n\n" -- "```````````````````````````````` example\naaa \nbbb \n.\n

aaa
\nbbb

\n````````````````````````````````\n\n\n## Blank lines\n\n[Blank lines] between block-level elements are ignored,\nexcept for the role they play in determining whether a [list]\nis [tight] or [loose].\n\nBlank lines at the beginning and end of the document are also ignored.\n\n```````````````````````````````` example\n \n\naaa\n \n\n# aaa\n\n \n.\n

aaa

\n

aaa

\n````````````````````````````````\n\n\n\n" +- "Most Markdown implementations (including some of Gruber's own) do not\nrespect all of these restrictions.\n\nThere is one respect, however, in which Gruber's rule is more liberal\nthan the one given here, since it allows blank lines to occur inside\nan HTML block. There are two reasons for disallowing them here.\nFirst, it removes the need to parse balanced tags, which is\nexpensive and can require backtracking from the end of the document\nif no matching end tag is found. Second, it provides a very simple\nand flexible way of including Markdown content inside HTML tags:\nsimply separate the Markdown from the HTML using blank lines:\n\nCompare:\n" +- "\n```````````````````````````````` example\n
\n\n*Emphasized* text.\n\n
\n.\n
\n

Emphasized text.

\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n*Emphasized* text.\n
\n.\n
\n*Emphasized* text.\n
\n````````````````````````````````" +- "\n\n\nSome Markdown implementations have adopted a convention of\ninterpreting content inside tags as text if the open tag has\nthe attribute `markdown=1`. The rule given above seems a simpler and\nmore elegant way of achieving the same expressive power, which is also\nmuch simpler to parse.\n\nThe main potential drawback is that one can no longer paste HTML\nblocks into Markdown documents with 100% reliability. However,\n*in most cases* this will work fine, because the blank lines in\nHTML are usually followed by HTML block tags. For example:\n\n```````````````````````````````` example\n\n\n\n\n\n\n\n\n
\nHi\n
\n.\n\n\n\n\n
\nHi\n
\n````````````````````````````````" +- "\n\n\nThere are problems, however, if the inner tags are indented\n*and* separated by spaces, as then they will be interpreted as\nan indented code block:\n\n```````````````````````````````` example\n\n\n \n\n \n\n \n\n
\n Hi\n
\n.\n\n \n
<td>\n  Hi\n</td>\n
\n \n
\n````````````````````````````````\n\n\nFortunately, blank lines are usually not necessary and can be\ndeleted. The exception is inside `
` tags, but as described\n[above][HTML blocks], raw HTML blocks starting with `
`\n*can* contain blank lines.\n\n"
+- "## Link reference definitions\n\nA [link reference definition](@)\nconsists of a [link label], optionally preceded by up to three spaces of\nindentation, followed\nby a colon (`:`), optional spaces or tabs (including up to one\n[line ending]), a [link destination],\noptional spaces or tabs (including up to one\n[line ending]), and an optional [link\ntitle], which if it is present must be separated\nfrom the [link destination] by spaces or tabs.\nNo further character may occur.\n\nA [link reference definition]\ndoes not correspond to a structural element of a document.  Instead, it\ndefines a label which can be used in [reference links]\nand reference-style [images] elsewhere in the document.  [Link\nreference definitions] can come either before or after the links that use\nthem.\n"
+- "\n```````````````````````````````` example\n[foo]: /url \"title\"\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n [foo]: \n /url \n 'the title' \n\n[foo]\n.\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n.\n

Foo*bar]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[Foo bar]:\n\n'title'\n\n[Foo bar]\n.\n

Foo bar

\n````````````````````````````````" +- "\n\n\nThe title may extend over multiple lines:\n\n```````````````````````````````` example\n[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nHowever, it may not contain a [blank line]:\n" +- "\n```````````````````````````````` example\n[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n.\n

[foo]: /url 'title

\n

with blank line'

\n

[foo]

\n````````````````````````````````\n\n\nThe title may be omitted:\n\n```````````````````````````````` example\n[foo]:\n/url\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nThe link destination may not be omitted:\n" +- "\n```````````````````````````````` example\n[foo]:\n\n[foo]\n.\n

[foo]:

\n

[foo]

\n````````````````````````````````\n\n However, an empty link destination may be specified using\n angle brackets:\n\n```````````````````````````````` example\n[foo]: <>\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\nThe title must be separated from the link destination by\nspaces or tabs:\n" +- "\n```````````````````````````````` example\n[foo]: (baz)\n\n[foo]\n.\n

[foo]: (baz)

\n

[foo]

\n````````````````````````````````\n\n\nBoth title and destination can contain backslash escapes\nand literal backslashes:\n" +- "\n```````````````````````````````` example\n[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nA link can come before its corresponding definition:\n\n```````````````````````````````` example\n[foo]\n\n[foo]: url\n.\n

foo

\n````````````````````````````````" +- "\n\n\nIf there are several matching definitions, the first one takes\nprecedence:\n\n```````````````````````````````` example\n[foo]\n\n[foo]: first\n[foo]: second\n.\n

foo

\n````````````````````````````````\n\n\nAs noted in the section on [Links], matching of labels is\ncase-insensitive (see [matches]).\n\n```````````````````````````````` example\n[FOO]: /url\n\n[Foo]\n.\n

Foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[ΑΓΩ]: /φου\n\n[αγω]\n.\n

αγω

\n````````````````````````````````\n\n\nWhether something is a [link reference definition] is\nindependent of whether the link reference it defines is\nused in the document. Thus, for example, the following\ndocument contains just a link reference definition, and\nno visible content:\n\n```````````````````````````````` example\n[foo]: /url\n.\n````````````````````````````````\n\n\nHere is another one:\n" +- "\n```````````````````````````````` example\n[\nfoo\n]: /url\nbar\n.\n

bar

\n````````````````````````````````\n\n\nThis is not a link reference definition, because there are\ncharacters other than spaces or tabs after the title:\n\n```````````````````````````````` example\n[foo]: /url \"title\" ok\n.\n

[foo]: /url "title" ok

\n````````````````````````````````\n\n\nThis is a link reference definition, but it has no title:\n" +- "\n```````````````````````````````` example\n[foo]: /url\n\"title\" ok\n.\n

"title" ok

\n````````````````````````````````\n\n\nThis is not a link reference definition, because it is indented\nfour spaces:\n\n```````````````````````````````` example\n [foo]: /url \"title\"\n\n[foo]\n.\n
[foo]: /url "title"\n
\n

[foo]

\n````````````````````````````````\n\n\nThis is not a link reference definition, because it occurs inside\na code block:\n" +- "\n```````````````````````````````` example\n```\n[foo]: /url\n```\n\n[foo]\n.\n
[foo]: /url\n
\n

[foo]

\n````````````````````````````````\n\n\nA [link reference definition] cannot interrupt a paragraph.\n\n```````````````````````````````` example\nFoo\n[bar]: /baz\n\n[bar]\n.\n

Foo\n[bar]: /baz

\n

[bar]

\n````````````````````````````````" +- "\n\n\nHowever, it can directly follow other block elements, such as headings\nand thematic breaks, and it need not be followed by a blank line.\n\n```````````````````````````````` example\n# [Foo]\n[foo]: /url\n> bar\n.\n

Foo

\n
\n

bar

\n
\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n[foo]: /url\nbar\n===\n[foo]\n.\n

bar

\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\n[foo]: /url\n===\n[foo]\n.\n

===\nfoo

\n````````````````````````````````\n\n\nSeveral [link reference definitions]\ncan occur one after another, without intervening blank lines.\n" +- "\n```````````````````````````````` example\n[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n.\n

foo,\nbar,\nbaz

\n````````````````````````````````\n\n\n[Link reference definitions] can occur\ninside block containers, like lists and block quotations. They\naffect the entire document, not just the container in which they\nare defined:\n" +- "\n```````````````````````````````` example\n[foo]\n\n> [foo]: /url\n.\n

foo

\n
\n
\n````````````````````````````````\n\n\n" +- "## Paragraphs\n\nA sequence of non-blank lines that cannot be interpreted as other\nkinds of blocks forms a [paragraph](@).\nThe contents of the paragraph are the result of parsing the\nparagraph's raw content as inlines. The paragraph's raw content\nis formed by concatenating the lines and removing initial and final\nspaces or tabs.\n\nA simple example with two paragraphs:\n\n```````````````````````````````` example\naaa\n\nbbb\n.\n

aaa

\n

bbb

\n````````````````````````````````\n\n\nParagraphs can contain multiple lines, but no blank lines:\n" +- "\n```````````````````````````````` example\naaa\nbbb\n\nccc\nddd\n.\n

aaa\nbbb

\n

ccc\nddd

\n````````````````````````````````\n\n\nMultiple blank lines between paragraphs have no effect:\n\n```````````````````````````````` example\naaa\n\n\nbbb\n.\n

aaa

\n

bbb

\n````````````````````````````````\n\n\nLeading spaces or tabs are skipped:\n" +- "\n```````````````````````````````` example\n aaa\n bbb\n.\n

aaa\nbbb

\n````````````````````````````````\n\n\nLines after the first may be indented any amount, since indented\ncode blocks cannot interrupt paragraphs.\n\n```````````````````````````````` example\naaa\n bbb\n ccc\n.\n

aaa\nbbb\nccc

\n````````````````````````````````\n\n\nHowever, the first line may be preceded by up to three spaces of indentation.\nFour spaces of indentation is too many:\n" +- "\n```````````````````````````````` example\n aaa\nbbb\n.\n

aaa\nbbb

\n````````````````````````````````\n\n\n```````````````````````````````` example\n aaa\nbbb\n.\n
aaa\n
\n

bbb

\n````````````````````````````````\n\n\nFinal spaces or tabs are stripped before inline parsing, so a paragraph\nthat ends with two or more spaces will not end with a [hard line\nbreak]:\n" +- "\n```````````````````````````````` example\naaa \nbbb \n.\n

aaa
\nbbb

\n````````````````````````````````\n\n\n## Blank lines\n\n[Blank lines] between block-level elements are ignored,\nexcept for the role they play in determining whether a [list]\nis [tight] or [loose].\n\nBlank lines at the beginning and end of the document are also ignored.\n\n```````````````````````````````` example\n \n\naaa\n \n\n# aaa\n\n \n.\n

aaa

\n

aaa

\n````````````````````````````````\n\n\n\n" - "# Container blocks\n\nA [container block](#container-blocks) is a block that has other\nblocks as its contents. There are two basic kinds of container blocks:\n[block quotes] and [list items].\n[Lists] are meta-containers for [list items].\n\nWe define the syntax for container blocks recursively. The general\nform of the definition is:\n\n> If X is a sequence of blocks, then the result of\n> transforming X in such-and-such a way is a container of type Y\n> with these blocks as its content.\n\nSo, we explain what counts as a block quote or list item by explaining\nhow these can be *generated* from their contents. This should suffice\nto define the syntax, although it does not give a recipe for *parsing*\nthese constructions. (A recipe is provided below in the section entitled\n[A parsing strategy](#appendix-a-parsing-strategy).)\n\n" - "## Block quotes\n\nA [block quote marker](@),\noptionally preceded by up to three spaces of indentation,\nconsists of (a) the character `>` together with a following space of\nindentation, or (b) a single character `>` not followed by a space of\nindentation.\n\nThe following rules define [block quotes]:\n\n" - "1. **Basic case.** If a string of lines *Ls* constitute a sequence\n of blocks *Bs*, then the result of prepending a [block quote\n marker] to the beginning of each line in *Ls*\n is a [block quote](#block-quotes) containing *Bs*.\n\n2. **Laziness.** If a string of lines *Ls* constitute a [block\n quote](#block-quotes) with contents *Bs*, then the result of deleting\n the initial [block quote marker] from one or\n more lines in which the next character other than a space or tab after the\n [block quote marker] is [paragraph continuation\n text] is a block quote with *Bs* as its content.\n [Paragraph continuation text](@) is text\n that will be parsed as part of the content of a paragraph, but does\n not occur at the beginning of the paragraph.\n\n3. **Consecutiveness.** A document cannot contain two [block\n quotes] in a row unless there is a [blank line] between them.\n\n" -- "Nothing else counts as a [block quote](#block-quotes).\n\nHere is a simple example:\n\n```````````````````````````````` example\n> # Foo\n> bar\n> baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nThe space or tab after the `>` characters can be omitted:\n\n```````````````````````````````` example\n># Foo\n>bar\n> baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\n" -- "The `>` characters can be preceded by up to three spaces of indentation:\n\n```````````````````````````````` example\n > # Foo\n > bar\n > baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n > # Foo\n > bar\n > baz\n.\n
> # Foo\n> bar\n> baz\n
\n````````````````````````````````\n\n\n" -- "The Laziness clause allows us to omit the `>` before\n[paragraph continuation text]:\n\n```````````````````````````````` example\n> # Foo\n> bar\nbaz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nA block quote can contain some lazy and some non-lazy\ncontinuation lines:\n\n```````````````````````````````` example\n> bar\nbaz\n> foo\n.\n
\n

bar\nbaz\nfoo

\n
\n````````````````````````````````\n\n\n" -- "Laziness only applies to lines that would have been continuations of\nparagraphs had they been prepended with [block quote markers].\nFor example, the `> ` cannot be omitted in the second line of\n\n``` markdown\n> foo\n> ---\n```\n\nwithout changing the meaning:\n\n```````````````````````````````` example\n> foo\n---\n.\n
\n

foo

\n
\n
\n````````````````````````````````\n\n\nSimilarly, if we omit the `> ` in the second line of\n\n``` markdown\n> - foo\n> - bar\n```\n\nthen the block quote ends after the first line:\n\n" -- "```````````````````````````````` example\n> - foo\n- bar\n.\n
\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n````````````````````````````````\n\n\nFor the same reason, we can't omit the `> ` in front of\nsubsequent lines of an indented or fenced code block:\n\n" -- "```````````````````````````````` example\n> foo\n bar\n.\n
\n
foo\n
\n
\n
bar\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> ```\nfoo\n```\n.\n
\n
\n
\n

foo

\n
\n````````````````````````````````\n\n\nNote that in the following case, we have a [lazy\ncontinuation line]:\n\n" -- "```````````````````````````````` example\n> foo\n - bar\n.\n
\n

foo\n- bar

\n
\n````````````````````````````````\n\n\nTo see why, note that in\n\n```markdown\n> foo\n> - bar\n```\n\nthe `- bar` is indented too far to start a list, and can't\nbe an indented code block because indented code blocks cannot\ninterrupt paragraphs, so it is [paragraph continuation text].\n\nA block quote can be empty:\n\n```````````````````````````````` example\n>\n.\n
\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n>\n> \n> \n.\n
\n
\n````````````````````````````````\n\n\nA block quote can have initial or final blank lines:\n\n```````````````````````````````` example\n>\n> foo\n> \n.\n
\n

foo

\n
\n````````````````````````````````\n\n\nA blank line always separates block quotes:\n\n" -- "```````````````````````````````` example\n> foo\n\n> bar\n.\n
\n

foo

\n
\n
\n

bar

\n
\n````````````````````````````````\n\n\n(Most current Markdown implementations, including John Gruber's\noriginal `Markdown.pl`, will parse this example as a single block quote\nwith two paragraphs. But it seems better to allow the author to decide\nwhether two block quotes or one are wanted.)\n\nConsecutiveness means that if we put these block quotes together,\nwe get a single block quote:\n\n" -- "```````````````````````````````` example\n> foo\n> bar\n.\n
\n

foo\nbar

\n
\n````````````````````````````````\n\n\nTo get a block quote with two paragraphs, use:\n\n```````````````````````````````` example\n> foo\n>\n> bar\n.\n
\n

foo

\n

bar

\n
\n````````````````````````````````\n\n\nBlock quotes can interrupt paragraphs:\n\n" -- "```````````````````````````````` example\nfoo\n> bar\n.\n

foo

\n
\n

bar

\n
\n````````````````````````````````\n\n\nIn general, blank lines are not needed before or after block\nquotes:\n\n```````````````````````````````` example\n> aaa\n***\n> bbb\n.\n
\n

aaa

\n
\n
\n
\n

bbb

\n
\n````````````````````````````````\n\n\n" -- "However, because of laziness, a blank line is needed between\na block quote and a following paragraph:\n\n```````````````````````````````` example\n> bar\nbaz\n.\n
\n

bar\nbaz

\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> bar\n\nbaz\n.\n
\n

bar

\n
\n

baz

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n> bar\n>\nbaz\n.\n
\n

bar

\n
\n

baz

\n````````````````````````````````\n\n\nIt is a consequence of the Laziness rule that any number\nof initial `>`s may be omitted on a continuation line of a\nnested block quote:\n\n```````````````````````````````` example\n> > > foo\nbar\n.\n
\n
\n
\n

foo\nbar

\n
\n
\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n>>> foo\n> bar\n>>baz\n.\n
\n
\n
\n

foo\nbar\nbaz

\n
\n
\n
\n````````````````````````````````\n\n\nWhen including an indented code block in a block quote,\nremember that the [block quote marker] includes\nboth the `>` and a following space of indentation. So *five spaces* are needed\nafter the `>`:\n\n" -- "```````````````````````````````` example\n> code\n\n> not code\n.\n
\n
code\n
\n
\n
\n

not code

\n
\n````````````````````````````````\n\n\n\n" +- "Nothing else counts as a [block quote](#block-quotes).\n\nHere is a simple example:\n\n```````````````````````````````` example\n> # Foo\n> bar\n> baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nThe space or tab after the `>` characters can be omitted:\n\n```````````````````````````````` example\n># Foo\n>bar\n> baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````" +- "\n\n\nThe `>` characters can be preceded by up to three spaces of indentation:\n\n```````````````````````````````` example\n > # Foo\n > bar\n > baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n > # Foo\n > bar\n > baz\n.\n
> # Foo\n> bar\n> baz\n
\n````````````````````````````````" +- "\n\n\nThe Laziness clause allows us to omit the `>` before\n[paragraph continuation text]:\n\n```````````````````````````````` example\n> # Foo\n> bar\nbaz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nA block quote can contain some lazy and some non-lazy\ncontinuation lines:\n\n```````````````````````````````` example\n> bar\nbaz\n> foo\n.\n
\n

bar\nbaz\nfoo

\n
\n````````````````````````````````" +- "\n\n\nLaziness only applies to lines that would have been continuations of\nparagraphs had they been prepended with [block quote markers].\nFor example, the `> ` cannot be omitted in the second line of\n\n``` markdown\n> foo\n> ---\n```\n\nwithout changing the meaning:\n\n```````````````````````````````` example\n> foo\n---\n.\n
\n

foo

\n
\n
\n````````````````````````````````\n\n\nSimilarly, if we omit the `> ` in the second line of\n\n``` markdown\n> - foo\n> - bar\n```\n\nthen the block quote ends after the first line:\n" +- "\n```````````````````````````````` example\n> - foo\n- bar\n.\n
\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n````````````````````````````````\n\n\nFor the same reason, we can't omit the `> ` in front of\nsubsequent lines of an indented or fenced code block:\n" +- "\n```````````````````````````````` example\n> foo\n bar\n.\n
\n
foo\n
\n
\n
bar\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> ```\nfoo\n```\n.\n
\n
\n
\n

foo

\n
\n````````````````````````````````\n\n\nNote that in the following case, we have a [lazy\ncontinuation line]:\n" +- "\n```````````````````````````````` example\n> foo\n - bar\n.\n
\n

foo\n- bar

\n
\n````````````````````````````````\n\n\nTo see why, note that in\n\n```markdown\n> foo\n> - bar\n```\n\nthe `- bar` is indented too far to start a list, and can't\nbe an indented code block because indented code blocks cannot\ninterrupt paragraphs, so it is [paragraph continuation text].\n\nA block quote can be empty:\n\n```````````````````````````````` example\n>\n.\n
\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n>\n> \n> \n.\n
\n
\n````````````````````````````````\n\n\nA block quote can have initial or final blank lines:\n\n```````````````````````````````` example\n>\n> foo\n> \n.\n
\n

foo

\n
\n````````````````````````````````\n\n\nA blank line always separates block quotes:\n" +- "\n```````````````````````````````` example\n> foo\n\n> bar\n.\n
\n

foo

\n
\n
\n

bar

\n
\n````````````````````````````````\n\n\n(Most current Markdown implementations, including John Gruber's\noriginal `Markdown.pl`, will parse this example as a single block quote\nwith two paragraphs. But it seems better to allow the author to decide\nwhether two block quotes or one are wanted.)\n\nConsecutiveness means that if we put these block quotes together,\nwe get a single block quote:\n" +- "\n```````````````````````````````` example\n> foo\n> bar\n.\n
\n

foo\nbar

\n
\n````````````````````````````````\n\n\nTo get a block quote with two paragraphs, use:\n\n```````````````````````````````` example\n> foo\n>\n> bar\n.\n
\n

foo

\n

bar

\n
\n````````````````````````````````\n\n\nBlock quotes can interrupt paragraphs:\n" +- "\n```````````````````````````````` example\nfoo\n> bar\n.\n

foo

\n
\n

bar

\n
\n````````````````````````````````\n\n\nIn general, blank lines are not needed before or after block\nquotes:\n\n```````````````````````````````` example\n> aaa\n***\n> bbb\n.\n
\n

aaa

\n
\n
\n
\n

bbb

\n
\n````````````````````````````````" +- "\n\n\nHowever, because of laziness, a blank line is needed between\na block quote and a following paragraph:\n\n```````````````````````````````` example\n> bar\nbaz\n.\n
\n

bar\nbaz

\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> bar\n\nbaz\n.\n
\n

bar

\n
\n

baz

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n> bar\n>\nbaz\n.\n
\n

bar

\n
\n

baz

\n````````````````````````````````\n\n\nIt is a consequence of the Laziness rule that any number\nof initial `>`s may be omitted on a continuation line of a\nnested block quote:\n\n```````````````````````````````` example\n> > > foo\nbar\n.\n
\n
\n
\n

foo\nbar

\n
\n
\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n>>> foo\n> bar\n>>baz\n.\n
\n
\n
\n

foo\nbar\nbaz

\n
\n
\n
\n````````````````````````````````\n\n\nWhen including an indented code block in a block quote,\nremember that the [block quote marker] includes\nboth the `>` and a following space of indentation. So *five spaces* are needed\nafter the `>`:\n" +- "\n```````````````````````````````` example\n> code\n\n> not code\n.\n
\n
code\n
\n
\n
\n

not code

\n
\n````````````````````````````````\n\n\n\n" - "## List items\n\nA [list marker](@) is a\n[bullet list marker] or an [ordered list marker].\n\nA [bullet list marker](@)\nis a `-`, `+`, or `*` character.\n\nAn [ordered list marker](@)\nis a sequence of 1--9 arabic digits (`0-9`), followed by either a\n`.` character or a `)` character. (The reason for the length\nlimit is that with 10 digits we start seeing integer overflows\nin some browsers.)\n\nThe following rules define [list items]:\n\n" - "1. **Basic case.** If a sequence of lines *Ls* constitute a sequence of\n blocks *Bs* starting with a character other than a space or tab, and *M* is\n a list marker of width *W* followed by 1 ≤ *N* ≤ 4 spaces of indentation,\n then the result of prepending *M* and the following spaces to the first line\n of *Ls*, and indenting subsequent lines of *Ls* by *W + N* spaces, is a\n list item with *Bs* as its contents. The type of the list item\n (bullet or ordered) is determined by the type of its list marker.\n If the list item is ordered, then it is also assigned a start\n number, based on the ordered list marker.\n\n Exceptions:\n\n 1. When the first list item in a [list] interrupts\n a paragraph---that is, when it starts on a line that would\n otherwise count as [paragraph continuation text]---then (a)\n the lines *Ls* must not begin with a blank line, and (b) if\n the list item is ordered, the start number must be 1.\n 2. " -- "If any line is a [thematic break][thematic breaks] then\n that line is not a list item.\n\nFor example, let *Ls* be the lines\n\n```````````````````````````````` example\nA paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n.\n

A paragraph\nwith two lines.

\n
indented code\n
\n
\n

A block quote.

\n
\n````````````````````````````````\n\n\nAnd let *M* be the marker `1.`, and *N* = 2. Then rule #1 says\nthat the following is an ordered list item with start number 1,\nand the same contents as *Ls*:\n\n" -- "```````````````````````````````` example\n1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nThe most important thing to notice is that the position of\nthe text after the list marker determines how much indentation\nis needed in subsequent blocks in the list item. If the list\nmarker takes up two spaces of indentation, and there are three spaces between\nthe list marker and the next character other than a space or tab, then blocks\nmust be indented five spaces in order to fall under the list\nitem.\n\n" -- "Here are some examples showing how far content must be indented to be\nput under the list item:\n\n```````````````````````````````` example\n- one\n\n two\n.\n
    \n
  • one
  • \n
\n

two

\n````````````````````````````````\n\n\n```````````````````````````````` example\n- one\n\n two\n.\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n - one\n\n two\n.\n
    \n
  • one
  • \n
\n
 two\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n - one\n\n two\n.\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n````````````````````````````````\n\n\n" -- "It is tempting to think of this in terms of columns: the continuation\nblocks must be indented at least to the column of the first character other than\na space or tab after the list marker. However, that is not quite right.\nThe spaces of indentation after the list marker determine how much relative\nindentation is needed. Which column this indentation reaches will depend on\nhow the list item is embedded in other constructions, as shown by\nthis example:\n\n```````````````````````````````` example\n > > 1. one\n>>\n>> two\n.\n
\n
\n
    \n
  1. \n

    one

    \n

    two

    \n
  2. \n
\n
\n
\n````````````````````````````````\n\n\n" -- "Here `two` occurs in the same column as the list marker `1.`,\nbut is actually contained in the list item, because there is\nsufficient indentation after the last containing blockquote marker.\n\nThe converse is also possible. In the following example, the word `two`\noccurs far to the right of the initial text of the list item, `one`, but\nit is not considered part of the list item, because it is not indented\nfar enough past the blockquote marker:\n\n```````````````````````````````` example\n>>- one\n>>\n > > two\n.\n
\n
\n
    \n
  • one
  • \n
\n

two

\n
\n
\n````````````````````````````````\n\n\n" -- "Note that at least one space or tab is needed between the list marker and\nany following content, so these are not list items:\n\n```````````````````````````````` example\n-one\n\n2.two\n.\n

-one

\n

2.two

\n````````````````````````````````\n\n\nA list item may contain blocks that are separated by more than\none blank line.\n\n```````````````````````````````` example\n- foo\n\n\n bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n\nA list item may contain any kind of block:\n\n" -- "```````````````````````````````` example\n1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n.\n
    \n
  1. \n

    foo

    \n
    bar\n
    \n

    baz

    \n
    \n

    bam

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nA list item that contains an indented code block will preserve\nempty lines within the code block verbatim.\n\n" -- "```````````````````````````````` example\n- Foo\n\n bar\n\n\n baz\n.\n
    \n
  • \n

    Foo

    \n
    bar\n\n\nbaz\n
    \n
  • \n
\n````````````````````````````````\n\nNote that ordered list start numbers must be nine digits or less:\n\n```````````````````````````````` example\n123456789. ok\n.\n
    \n
  1. ok
  2. \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n1234567890. not ok\n.\n

1234567890. not ok

\n````````````````````````````````\n\n\nA start number may begin with 0s:\n\n```````````````````````````````` example\n0. ok\n.\n
    \n
  1. ok
  2. \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n003. ok\n.\n
    \n
  1. ok
  2. \n
\n````````````````````````````````\n\n\nA start number may not be negative:\n\n```````````````````````````````` example\n-1. not ok\n.\n

-1. not ok

\n````````````````````````````````\n\n\n\n" +- "If any line is a [thematic break][thematic breaks] then\n that line is not a list item.\n\nFor example, let *Ls* be the lines\n\n```````````````````````````````` example\nA paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n.\n

A paragraph\nwith two lines.

\n
indented code\n
\n
\n

A block quote.

\n
\n````````````````````````````````\n\n\nAnd let *M* be the marker `1.`, and *N* = 2. Then rule #1 says\nthat the following is an ordered list item with start number 1,\nand the same contents as *Ls*:\n" +- "\n```````````````````````````````` example\n1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nThe most important thing to notice is that the position of\nthe text after the list marker determines how much indentation\nis needed in subsequent blocks in the list item. If the list\nmarker takes up two spaces of indentation, and there are three spaces between\nthe list marker and the next character other than a space or tab, then blocks\nmust be indented five spaces in order to fall under the list\nitem.\n" +- "\nHere are some examples showing how far content must be indented to be\nput under the list item:\n\n```````````````````````````````` example\n- one\n\n two\n.\n
    \n
  • one
  • \n
\n

two

\n````````````````````````````````\n\n\n```````````````````````````````` example\n- one\n\n two\n.\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n - one\n\n two\n.\n
    \n
  • one
  • \n
\n
 two\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n - one\n\n two\n.\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n````````````````````````````````" +- "\n\n\nIt is tempting to think of this in terms of columns: the continuation\nblocks must be indented at least to the column of the first character other than\na space or tab after the list marker. However, that is not quite right.\nThe spaces of indentation after the list marker determine how much relative\nindentation is needed. Which column this indentation reaches will depend on\nhow the list item is embedded in other constructions, as shown by\nthis example:\n\n```````````````````````````````` example\n > > 1. one\n>>\n>> two\n.\n
\n
\n
    \n
  1. \n

    one

    \n

    two

    \n
  2. \n
\n
\n
\n````````````````````````````````" +- "\n\n\nHere `two` occurs in the same column as the list marker `1.`,\nbut is actually contained in the list item, because there is\nsufficient indentation after the last containing blockquote marker.\n\nThe converse is also possible. In the following example, the word `two`\noccurs far to the right of the initial text of the list item, `one`, but\nit is not considered part of the list item, because it is not indented\nfar enough past the blockquote marker:\n\n```````````````````````````````` example\n>>- one\n>>\n > > two\n.\n
\n
\n
    \n
  • one
  • \n
\n

two

\n
\n
\n````````````````````````````````" +- "\n\n\nNote that at least one space or tab is needed between the list marker and\nany following content, so these are not list items:\n\n```````````````````````````````` example\n-one\n\n2.two\n.\n

-one

\n

2.two

\n````````````````````````````````\n\n\nA list item may contain blocks that are separated by more than\none blank line.\n\n```````````````````````````````` example\n- foo\n\n\n bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n\nA list item may contain any kind of block:\n" +- "\n```````````````````````````````` example\n1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n.\n
    \n
  1. \n

    foo

    \n
    bar\n
    \n

    baz

    \n
    \n

    bam

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nA list item that contains an indented code block will preserve\nempty lines within the code block verbatim.\n" +- "\n```````````````````````````````` example\n- Foo\n\n bar\n\n\n baz\n.\n
    \n
  • \n

    Foo

    \n
    bar\n\n\nbaz\n
    \n
  • \n
\n````````````````````````````````\n\nNote that ordered list start numbers must be nine digits or less:\n\n```````````````````````````````` example\n123456789. ok\n.\n
    \n
  1. ok
  2. \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n1234567890. not ok\n.\n

1234567890. not ok

\n````````````````````````````````\n\n\nA start number may begin with 0s:\n\n```````````````````````````````` example\n0. ok\n.\n
    \n
  1. ok
  2. \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n003. ok\n.\n
    \n
  1. ok
  2. \n
\n````````````````````````````````\n\n\nA start number may not be negative:\n\n```````````````````````````````` example\n-1. not ok\n.\n

-1. not ok

\n````````````````````````````````\n\n\n\n" - "2. **Item starting with indented code.** If a sequence of lines *Ls*\n constitute a sequence of blocks *Bs* starting with an indented code\n block, and *M* is a list marker of width *W* followed by\n one space of indentation, then the result of prepending *M* and the\n following space to the first line of *Ls*, and indenting subsequent lines\n of *Ls* by *W + 1* spaces, is a list item with *Bs* as its contents.\n If a line is empty, then it need not be indented. The type of the\n list item (bullet or ordered) is determined by the type of its list\n marker. If the list item is ordered, then it is also assigned a\n start number, based on the ordered list marker.\n\n" -- "An indented code block will have to be preceded by four spaces of indentation\nbeyond the edge of the region where text will be included in the list item.\nIn the following case that is 6 spaces:\n\n```````````````````````````````` example\n- foo\n\n bar\n.\n
    \n
  • \n

    foo

    \n
    bar\n
    \n
  • \n
\n````````````````````````````````\n\n\nAnd in this case it is 11 spaces:\n\n" -- "```````````````````````````````` example\n 10. foo\n\n bar\n.\n
    \n
  1. \n

    foo

    \n
    bar\n
    \n
  2. \n
\n````````````````````````````````\n\n\nIf the *first* block in the list item is an indented code block,\nthen by rule #2, the contents must be preceded by *one* space of indentation\nafter the list marker:\n\n" -- "```````````````````````````````` example\n indented code\n\nparagraph\n\n more code\n.\n
indented code\n
\n

paragraph

\n
more code\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n1. indented code\n\n paragraph\n\n more code\n.\n
    \n
  1. \n
    indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n````````````````````````````````\n\n\n" -- "Note that an additional space of indentation is interpreted as space\ninside the code block:\n\n```````````````````````````````` example\n1. indented code\n\n paragraph\n\n more code\n.\n
    \n
  1. \n
     indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n````````````````````````````````\n\n\n" -- "Note that rules #1 and #2 only apply to two cases: (a) cases\nin which the lines to be included in a list item begin with a\ncharacter other than a space or tab, and (b) cases in which\nthey begin with an indented code\nblock. In a case like the following, where the first block begins with\nthree spaces of indentation, the rules do not allow us to form a list item by\nindenting the whole thing and prepending a list marker:\n\n```````````````````````````````` example\n foo\n\nbar\n.\n

foo

\n

bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n- foo\n\n bar\n.\n
    \n
  • foo
  • \n
\n

bar

\n````````````````````````````````\n\n\nThis is not a significant restriction, because when a block is preceded by up to\nthree spaces of indentation, the indentation can always be removed without\na change in interpretation, allowing rule #1 to be applied. So, in\nthe above case:\n\n```````````````````````````````` example\n- foo\n\n bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n\n" +- "An indented code block will have to be preceded by four spaces of indentation\nbeyond the edge of the region where text will be included in the list item.\nIn the following case that is 6 spaces:\n\n```````````````````````````````` example\n- foo\n\n bar\n.\n
    \n
  • \n

    foo

    \n
    bar\n
    \n
  • \n
\n````````````````````````````````\n\n\nAnd in this case it is 11 spaces:\n" +- "\n```````````````````````````````` example\n 10. foo\n\n bar\n.\n
    \n
  1. \n

    foo

    \n
    bar\n
    \n
  2. \n
\n````````````````````````````````\n\n\nIf the *first* block in the list item is an indented code block,\nthen by rule #2, the contents must be preceded by *one* space of indentation\nafter the list marker:\n" +- "\n```````````````````````````````` example\n indented code\n\nparagraph\n\n more code\n.\n
indented code\n
\n

paragraph

\n
more code\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n1. indented code\n\n paragraph\n\n more code\n.\n
    \n
  1. \n
    indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n````````````````````````````````" +- "\n\n\nNote that an additional space of indentation is interpreted as space\ninside the code block:\n\n```````````````````````````````` example\n1. indented code\n\n paragraph\n\n more code\n.\n
    \n
  1. \n
     indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n````````````````````````````````" +- "\n\n\nNote that rules #1 and #2 only apply to two cases: (a) cases\nin which the lines to be included in a list item begin with a\ncharacter other than a space or tab, and (b) cases in which\nthey begin with an indented code\nblock. In a case like the following, where the first block begins with\nthree spaces of indentation, the rules do not allow us to form a list item by\nindenting the whole thing and prepending a list marker:\n\n```````````````````````````````` example\n foo\n\nbar\n.\n

foo

\n

bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n- foo\n\n bar\n.\n
    \n
  • foo
  • \n
\n

bar

\n````````````````````````````````\n\n\nThis is not a significant restriction, because when a block is preceded by up to\nthree spaces of indentation, the indentation can always be removed without\na change in interpretation, allowing rule #1 to be applied. So, in\nthe above case:\n\n```````````````````````````````` example\n- foo\n\n bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n\n" - "3. **Item starting with a blank line.** If a sequence of lines *Ls*\n starting with a single [blank line] constitute a (possibly empty)\n sequence of blocks *Bs*, and *M* is a list marker of width *W*,\n then the result of prepending *M* to the first line of *Ls*, and\n preceding subsequent lines of *Ls* by *W + 1* spaces of indentation, is a\n list item with *Bs* as its contents.\n If a line is empty, then it need not be indented. The type of the\n list item (bullet or ordered) is determined by the type of its list\n marker. If the list item is ordered, then it is also assigned a\n start number, based on the ordered list marker.\n\n" -- "Here are some list items that start with a blank line but are not empty:\n\n```````````````````````````````` example\n-\n foo\n-\n ```\n bar\n ```\n-\n baz\n.\n
    \n
  • foo
  • \n
  • \n
    bar\n
    \n
  • \n
  • \n
    baz\n
    \n
  • \n
\n````````````````````````````````\n\nWhen the list item starts with a blank line, the number of spaces\nfollowing the list marker doesn't change the required indentation:\n\n" -- "```````````````````````````````` example\n- \n foo\n.\n
    \n
  • foo
  • \n
\n````````````````````````````````\n\n\nA list item can begin with at most one blank line.\nIn the following example, `foo` is not part of the list\nitem:\n\n```````````````````````````````` example\n-\n\n foo\n.\n
    \n
  • \n
\n

foo

\n````````````````````````````````\n\n\nHere is an empty bullet list item:\n\n" -- "```````````````````````````````` example\n- foo\n-\n- bar\n.\n
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n````````````````````````````````\n\n\nIt does not matter whether there are spaces or tabs following the [list marker]:\n\n```````````````````````````````` example\n- foo\n- \n- bar\n.\n
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n````````````````````````````````\n\n\nHere is an empty ordered list item:\n\n" -- "```````````````````````````````` example\n1. foo\n2.\n3. bar\n.\n
    \n
  1. foo
  2. \n
  3. \n
  4. bar
  5. \n
\n````````````````````````````````\n\n\nA list may start or end with an empty list item:\n\n```````````````````````````````` example\n*\n.\n
    \n
  • \n
\n````````````````````````````````\n\nHowever, an empty list item cannot interrupt a paragraph:\n\n" -- "```````````````````````````````` example\nfoo\n*\n\nfoo\n1.\n.\n

foo\n*

\n

foo\n1.

\n````````````````````````````````\n\n\n4. **Indentation.** If a sequence of lines *Ls* constitutes a list item\n according to rule #1, #2, or #3, then the result of preceding each line\n of *Ls* by up to three spaces of indentation (the same for each line) also\n constitutes a list item with the same contents and attributes. If a line is\n empty, then it need not be indented.\n\n" -- "Indented one space:\n\n```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nIndented two spaces:\n\n" -- "```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nIndented three spaces:\n\n" -- "```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nFour spaces indent gives a code block:\n\n" -- "```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
\n````````````````````````````````\n\n\n\n5. **Laziness.** If a string of lines *Ls* constitute a [list\n item](#list-items) with contents *Bs*, then the result of deleting\n some or all of the indentation from one or more lines in which the\n next character other than a space or tab after the indentation is\n [paragraph continuation text] is a\n list item with the same contents and attributes. The unindented\n lines are called\n [lazy continuation line](@)s.\n\n" -- "Here is an example with [lazy continuation lines]:\n\n```````````````````````````````` example\n 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nIndentation can be partially deleted:\n\n" -- "```````````````````````````````` example\n 1. A paragraph\n with two lines.\n.\n
    \n
  1. A paragraph\nwith two lines.
  2. \n
\n````````````````````````````````\n\n\nThese examples show how laziness can work in nested structures:\n\n```````````````````````````````` example\n> 1. > Blockquote\ncontinued here.\n.\n
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n> 1. > Blockquote\n> continued here.\n.\n
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n````````````````````````````````\n\n\n\n6. **That's all.** Nothing that is not counted as a list item by rules\n #1--5 counts as a [list item](#list-items).\n\n" -- "The rules for sublists follow from the general rules\n[above][List items]. A sublist must be indented the same number\nof spaces of indentation a paragraph would need to be in order to be included\nin the list item.\n\nSo, in this case we need two spaces indent:\n\n```````````````````````````````` example\n- foo\n - bar\n - baz\n - boo\n.\n
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz\n
          \n
        • boo
        • \n
        \n
      • \n
      \n
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nOne is not enough:\n\n" -- "```````````````````````````````` example\n- foo\n - bar\n - baz\n - boo\n.\n
    \n
  • foo
  • \n
  • bar
  • \n
  • baz
  • \n
  • boo
  • \n
\n````````````````````````````````\n\n\nHere we need four, because the list marker is wider:\n\n```````````````````````````````` example\n10) foo\n - bar\n.\n
    \n
  1. foo\n
      \n
    • bar
    • \n
    \n
  2. \n
\n````````````````````````````````\n\n\n" -- "Three is not enough:\n\n```````````````````````````````` example\n10) foo\n - bar\n.\n
    \n
  1. foo
  2. \n
\n
    \n
  • bar
  • \n
\n````````````````````````````````\n\n\nA list may be the first block in a list item:\n\n```````````````````````````````` example\n- - foo\n.\n
    \n
  • \n
      \n
    • foo
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n1. - 2. foo\n.\n
    \n
  1. \n
      \n
    • \n
        \n
      1. foo
      2. \n
      \n
    • \n
    \n
  2. \n
\n````````````````````````````````\n\n\nA list item can contain a heading:\n\n" -- "```````````````````````````````` example\n- # Foo\n- Bar\n ---\n baz\n.\n
    \n
  • \n

    Foo

    \n
  • \n
  • \n

    Bar

    \nbaz
  • \n
\n````````````````````````````````\n\n\n" +- "Here are some list items that start with a blank line but are not empty:\n\n```````````````````````````````` example\n-\n foo\n-\n ```\n bar\n ```\n-\n baz\n.\n
    \n
  • foo
  • \n
  • \n
    bar\n
    \n
  • \n
  • \n
    baz\n
    \n
  • \n
\n````````````````````````````````\n\nWhen the list item starts with a blank line, the number of spaces\nfollowing the list marker doesn't change the required indentation:\n" +- "\n```````````````````````````````` example\n- \n foo\n.\n
    \n
  • foo
  • \n
\n````````````````````````````````\n\n\nA list item can begin with at most one blank line.\nIn the following example, `foo` is not part of the list\nitem:\n\n```````````````````````````````` example\n-\n\n foo\n.\n
    \n
  • \n
\n

foo

\n````````````````````````````````\n\n\nHere is an empty bullet list item:\n" +- "\n```````````````````````````````` example\n- foo\n-\n- bar\n.\n
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n````````````````````````````````\n\n\nIt does not matter whether there are spaces or tabs following the [list marker]:\n\n```````````````````````````````` example\n- foo\n- \n- bar\n.\n
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n````````````````````````````````\n\n\nHere is an empty ordered list item:\n" +- "\n```````````````````````````````` example\n1. foo\n2.\n3. bar\n.\n
    \n
  1. foo
  2. \n
  3. \n
  4. bar
  5. \n
\n````````````````````````````````\n\n\nA list may start or end with an empty list item:\n\n```````````````````````````````` example\n*\n.\n
    \n
  • \n
\n````````````````````````````````\n\nHowever, an empty list item cannot interrupt a paragraph:\n" +- "\n```````````````````````````````` example\nfoo\n*\n\nfoo\n1.\n.\n

foo\n*

\n

foo\n1.

\n````````````````````````````````\n\n\n4. **Indentation.** If a sequence of lines *Ls* constitutes a list item\n according to rule #1, #2, or #3, then the result of preceding each line\n of *Ls* by up to three spaces of indentation (the same for each line) also\n constitutes a list item with the same contents and attributes. If a line is\n empty, then it need not be indented.\n\n" +- "Indented one space:\n\n```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nIndented two spaces:\n" +- "\n```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nIndented three spaces:\n" +- "\n```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nFour spaces indent gives a code block:\n" +- "\n```````````````````````````````` example\n 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n.\n
1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
\n````````````````````````````````\n\n\n\n5. **Laziness.** If a string of lines *Ls* constitute a [list\n item](#list-items) with contents *Bs*, then the result of deleting\n some or all of the indentation from one or more lines in which the\n next character other than a space or tab after the indentation is\n [paragraph continuation text] is a\n list item with the same contents and attributes. The unindented\n lines are called\n [lazy continuation line](@)s.\n\n" +- "Here is an example with [lazy continuation lines]:\n\n```````````````````````````````` example\n 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n.\n
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n````````````````````````````````\n\n\nIndentation can be partially deleted:\n" +- "\n```````````````````````````````` example\n 1. A paragraph\n with two lines.\n.\n
    \n
  1. A paragraph\nwith two lines.
  2. \n
\n````````````````````````````````\n\n\nThese examples show how laziness can work in nested structures:\n\n```````````````````````````````` example\n> 1. > Blockquote\ncontinued here.\n.\n
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n> 1. > Blockquote\n> continued here.\n.\n
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n````````````````````````````````\n\n\n\n6. **That's all.** Nothing that is not counted as a list item by rules\n #1--5 counts as a [list item](#list-items).\n\n" +- "The rules for sublists follow from the general rules\n[above][List items]. A sublist must be indented the same number\nof spaces of indentation a paragraph would need to be in order to be included\nin the list item.\n\nSo, in this case we need two spaces indent:\n\n```````````````````````````````` example\n- foo\n - bar\n - baz\n - boo\n.\n
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz\n
          \n
        • boo
        • \n
        \n
      • \n
      \n
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nOne is not enough:\n" +- "\n```````````````````````````````` example\n- foo\n - bar\n - baz\n - boo\n.\n
    \n
  • foo
  • \n
  • bar
  • \n
  • baz
  • \n
  • boo
  • \n
\n````````````````````````````````\n\n\nHere we need four, because the list marker is wider:\n\n```````````````````````````````` example\n10) foo\n - bar\n.\n
    \n
  1. foo\n
      \n
    • bar
    • \n
    \n
  2. \n
\n````````````````````````````````" +- "\n\n\nThree is not enough:\n\n```````````````````````````````` example\n10) foo\n - bar\n.\n
    \n
  1. foo
  2. \n
\n
    \n
  • bar
  • \n
\n````````````````````````````````\n\n\nA list may be the first block in a list item:\n\n```````````````````````````````` example\n- - foo\n.\n
    \n
  • \n
      \n
    • foo
    • \n
    \n
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n1. - 2. foo\n.\n
    \n
  1. \n
      \n
    • \n
        \n
      1. foo
      2. \n
      \n
    • \n
    \n
  2. \n
\n````````````````````````````````\n\n\nA list item can contain a heading:\n" +- "\n```````````````````````````````` example\n- # Foo\n- Bar\n ---\n baz\n.\n
    \n
  • \n

    Foo

    \n
  • \n
  • \n

    Bar

    \nbaz
  • \n
\n````````````````````````````````\n\n\n" - "### Motivation\n\nJohn Gruber's Markdown spec says the following about list items:\n\n1. \"List markers typically start at the left margin, but may be indented\n by up to three spaces. List markers must be followed by one or more\n spaces or a tab.\"\n\n2. \"To make lists look nice, you can wrap items with hanging indents....\n But if you don't want to, you don't have to.\"\n\n3. \"List items may consist of multiple paragraphs. Each subsequent\n paragraph in a list item must be indented by either 4 spaces or one\n tab.\"\n\n4. \"It looks nice if you indent every line of the subsequent paragraphs,\n but here again, Markdown will allow you to be lazy.\"\n\n5. \"To put a blockquote within a list item, the blockquote's `>`\n delimiters need to be indented.\"\n\n6. \"To put a code block within a list item, the code block needs to be\n indented twice — 8 spaces or two tabs.\"\n\n" -- "These rules specify that a paragraph under a list item must be indented\nfour spaces (presumably, from the left margin, rather than the start of\nthe list marker, but this is not said), and that code under a list item\nmust be indented eight spaces instead of the usual four. They also say\nthat a block quote must be indented, but not by how much; however, the\nexample given has four spaces indentation. Although nothing is said\nabout other kinds of block-level content, it is certainly reasonable to\ninfer that *all* block elements under a list item, including other\nlists, must be indented four spaces. This principle has been called the\n*four-space rule*.\n\n" -- "The four-space rule is clear and principled, and if the reference\nimplementation `Markdown.pl` had followed it, it probably would have\nbecome the standard. However, `Markdown.pl` allowed paragraphs and\nsublists to start with only two spaces indentation, at least on the\nouter level. Worse, its behavior was inconsistent: a sublist of an\nouter-level list needed two spaces indentation, but a sublist of this\nsublist needed three spaces. It is not surprising, then, that different\nimplementations of Markdown have developed very different rules for\ndetermining what comes under a list item. (Pandoc and python-Markdown,\nfor example, stuck with Gruber's syntax description and the four-space\nrule, while discount, redcarpet, marked, PHP Markdown, and others\nfollowed `Markdown.pl`'s behavior more closely.)\n\n" -- "Unfortunately, given the divergences between implementations, there\nis no way to give a spec for list items that will be guaranteed not\nto break any existing documents. However, the spec given here should\ncorrectly handle lists formatted with either the four-space rule or\nthe more forgiving `Markdown.pl` behavior, provided they are laid out\nin a way that is natural for a human to read.\n\nThe strategy here is to let the width and indentation of the list marker\ndetermine the indentation necessary for blocks to fall under the list\nitem, rather than having a fixed and arbitrary number. The writer can\nthink of the body of the list item as a unit which gets indented to the\nright enough to fit the list marker (and any indentation on the list\nmarker). (The laziness rule, #5, then allows continuation lines to be\nunindented if needed.)\n\nThis rule is superior, we claim, to any rule requiring a fixed level of\nindentation from the margin. The four-space rule is clear but\nunnatural. It is quite unintuitive that\n\n``` markdown\n- foo\n\n bar\n\n - baz\n```\n\n" -- "should be parsed as two lists with an intervening paragraph,\n\n``` html\n
    \n
  • foo
  • \n
\n

bar

\n
    \n
  • baz
  • \n
\n```\n\nas the four-space rule demands, rather than a single list,\n\n``` html\n
    \n
  • \n

    foo

    \n

    bar

    \n
      \n
    • baz
    • \n
    \n
  • \n
\n```\n\nThe choice of four spaces is arbitrary. It can be learned, but it is\nnot likely to be guessed, and it trips up beginners regularly.\n\nWould it help to adopt a two-space rule? The problem is that such\na rule, together with the rule allowing up to three spaces of indentation for\nthe initial list marker, allows text that is indented *less than* the\noriginal list marker to be included in the list item. For example,\n`Markdown.pl` parses\n\n``` markdown\n - one\n\n two\n```\n\n" -- "as a single list item, with `two` a continuation paragraph:\n\n``` html\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n```\n\nand similarly\n\n``` markdown\n> - one\n>\n> two\n```\n\nas\n\n``` html\n
\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n
\n```\n\nThis is extremely unintuitive.\n\nRather than requiring a fixed indent from the margin, we could require\na fixed indent (say, two spaces, or even one space) from the list marker (which\nmay itself be indented). This proposal would remove the last anomaly\ndiscussed. Unlike the spec presented above, it would count the following\nas a list item with a subparagraph, even though the paragraph `bar`\nis not indented as far as the first paragraph `foo`:\n\n``` markdown\n 10. foo\n\n bar \n```\n\n" -- "Arguably this text does read like a list item with `bar` as a subparagraph,\nwhich may count in favor of the proposal. However, on this proposal indented\ncode would have to be indented six spaces after the list marker. And this\nwould break a lot of existing Markdown, which has the pattern:\n\n``` markdown\n1. foo\n\n indented code\n```\n\nwhere the code is indented eight spaces. The spec above, by contrast, will\nparse this text as expected, since the code block's indentation is measured\nfrom the beginning of `foo`.\n\nThe one case that needs special treatment is a list item that *starts*\nwith indented code. How much indentation is required in that case, since\nwe don't have a \"first paragraph\" to measure from? Rule #2 simply stipulates\nthat in such cases, we require one space indentation from the list marker\n(and then the normal four spaces for the indented code). This will match the\nfour-space rule in cases where the list marker plus its initial indentation\ntakes four spaces (a common case), but diverge in other cases.\n\n" -- "## Lists\n\nA [list](@) is a sequence of one or more\nlist items [of the same type]. The list items\nmay be separated by any number of blank lines.\n\nTwo list items are [of the same type](@)\nif they begin with a [list marker] of the same type.\nTwo list markers are of the\nsame type if (a) they are bullet list markers using the same character\n(`-`, `+`, or `*`) or (b) they are ordered list numbers with the same\ndelimiter (either `.` or `)`).\n\nA list is an [ordered list](@)\nif its constituent list items begin with\n[ordered list markers], and a\n[bullet list](@) if its constituent list\nitems begin with [bullet list markers].\n\nThe [start number](@)\nof an [ordered list] is determined by the list number of\nits initial list item. The numbers of subsequent list items are\ndisregarded.\n\n" -- "A list is [loose](@) if any of its constituent\nlist items are separated by blank lines, or if any of its constituent\nlist items directly contain two block-level elements with a blank line\nbetween them. Otherwise a list is [tight](@).\n(The difference in HTML output is that paragraphs in a loose list are\nwrapped in `

` tags, while paragraphs in a tight list are not.)\n\nChanging the bullet or ordered list delimiter starts a new list:\n\n```````````````````````````````` example\n- foo\n- bar\n+ baz\n.\n

    \n
  • foo
  • \n
  • bar
  • \n
\n
    \n
  • baz
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n1. foo\n2. bar\n3) baz\n.\n
    \n
  1. foo
  2. \n
  3. bar
  4. \n
\n
    \n
  1. baz
  2. \n
\n````````````````````````````````\n\n\nIn CommonMark, a list can interrupt a paragraph. That is,\nno blank line is needed to separate a paragraph from a following\nlist:\n\n" -- "```````````````````````````````` example\nFoo\n- bar\n- baz\n.\n

Foo

\n
    \n
  • bar
  • \n
  • baz
  • \n
\n````````````````````````````````\n\n`Markdown.pl` does not allow this, through fear of triggering a list\nvia a numeral in a hard-wrapped line:\n\n``` markdown\nThe number of windows in my house is\n14. The number of doors is 6.\n```\n\nOddly, though, `Markdown.pl` *does* allow a blockquote to\ninterrupt a paragraph, even though the same considerations might\napply.\n\nIn CommonMark, we do allow lists to interrupt paragraphs, for\ntwo reasons. First, it is natural and not uncommon for people\nto start lists without blank lines:\n\n" -- "``` markdown\nI need to buy\n- new shoes\n- a coat\n- a plane ticket\n```\n\nSecond, we are attracted to a\n\n> [principle of uniformity](@):\n> if a chunk of text has a certain\n> meaning, it will continue to have the same meaning when put into a\n> container block (such as a list item or blockquote).\n" -- "\n(Indeed, the spec for [list items] and [block quotes] presupposes\nthis principle.) This principle implies that if\n\n``` markdown\n * I need to buy\n - new shoes\n - a coat\n - a plane ticket\n```\n\nis a list item containing a paragraph followed by a nested sublist,\nas all Markdown implementations agree it is (though the paragraph\nmay be rendered without `

` tags, since the list is \"tight\"),\nthen\n\n``` markdown\nI need to buy\n- new shoes\n- a coat\n- a plane ticket\n```\n\nby itself should be a paragraph followed by a nested sublist.\n\nSince it is well established Markdown practice to allow lists to\ninterrupt paragraphs inside list items, the [principle of\nuniformity] requires us to allow this outside list items as\nwell. ([reStructuredText](https://docutils.sourceforge.net/rst.html)\ntakes a different approach, requiring blank lines before lists\neven inside other list items.)\n\n" -- "In order to solve the problem of unwanted lists in paragraphs with\nhard-wrapped numerals, we allow only lists starting with `1` to\ninterrupt paragraphs. Thus,\n\n```````````````````````````````` example\nThe number of windows in my house is\n14. The number of doors is 6.\n.\n

The number of windows in my house is\n14. The number of doors is 6.

\n````````````````````````````````\n\nWe may still get an unintended result in cases like\n\n" -- "```````````````````````````````` example\nThe number of windows in my house is\n1. The number of doors is 6.\n.\n

The number of windows in my house is

\n
    \n
  1. The number of doors is 6.
  2. \n
\n````````````````````````````````\n\nbut this rule should prevent most spurious list captures.\n\nThere can be any number of blank lines between items:\n\n" -- "```````````````````````````````` example\n- foo\n\n- bar\n\n\n- baz\n.\n
    \n
  • \n

    foo

    \n
  • \n
  • \n

    bar

    \n
  • \n
  • \n

    baz

    \n
  • \n
\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n- foo\n - bar\n - baz\n\n\n bim\n.\n
    \n
  • foo\n
      \n
    • bar\n
        \n
      • \n

        baz

        \n

        bim

        \n
      • \n
      \n
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nTo separate consecutive lists of the same type, or to separate a\nlist from an indented code block that would otherwise be parsed\nas a subparagraph of the final list item, you can insert a blank HTML\ncomment:\n\n" -- "```````````````````````````````` example\n- foo\n- bar\n\n\n\n- baz\n- bim\n.\n
    \n
  • foo
  • \n
  • bar
  • \n
\n\n
    \n
  • baz
  • \n
  • bim
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n- foo\n\n notcode\n\n- foo\n\n\n\n code\n.\n
    \n
  • \n

    foo

    \n

    notcode

    \n
  • \n
  • \n

    foo

    \n
  • \n
\n\n
code\n
\n````````````````````````````````\n\n\nList items need not be indented to the same level. The following\nlist items will be treated as items at the same list level,\nsince none is indented enough to belong to the previous list\nitem:\n\n" -- "```````````````````````````````` example\n- a\n - b\n - c\n - d\n - e\n - f\n- g\n.\n
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d
  • \n
  • e
  • \n
  • f
  • \n
  • g
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n1. a\n\n 2. b\n\n 3. c\n.\n
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
  5. \n

    c

    \n
  6. \n
\n````````````````````````````````\n\nNote, however, that list items may not be preceded by more than\nthree spaces of indentation. Here `- e` is treated as a paragraph continuation\nline, because it is indented more than three spaces:\n\n" -- "```````````````````````````````` example\n- a\n - b\n - c\n - d\n - e\n.\n
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d\n- e
  • \n
\n````````````````````````````````\n\nAnd here, `3. c` is treated as in indented code block,\nbecause it is indented four spaces and preceded by a\nblank line.\n\n" -- "```````````````````````````````` example\n1. a\n\n 2. b\n\n 3. c\n.\n
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
\n
3. c\n
\n````````````````````````````````\n\n\nThis is a loose list, because there is a blank line between\ntwo of the list items:\n\n" -- "```````````````````````````````` example\n- a\n- b\n\n- c\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    c

    \n
  • \n
\n````````````````````````````````\n\n\nSo is this, with a empty second item:\n\n" -- "```````````````````````````````` example\n* a\n*\n\n* c\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n
  • \n

    c

    \n
  • \n
\n````````````````````````````````\n\n\nThese are loose lists, even though there are no blank lines between the items,\nbecause one of the items directly contains two block-level elements\nwith a blank line between them:\n\n" -- "```````````````````````````````` example\n- a\n- b\n\n c\n- d\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n

    c

    \n
  • \n
  • \n

    d

    \n
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n- a\n- b\n\n [ref]: /url\n- d\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    d

    \n
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank lines are in a code block:\n\n" -- "```````````````````````````````` example\n- a\n- ```\n b\n\n\n ```\n- c\n.\n
    \n
  • a
  • \n
  • \n
    b\n\n\n
    \n
  • \n
  • c
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank line is between two\nparagraphs of a sublist. So the sublist is loose while\nthe outer list is tight:\n\n" -- "```````````````````````````````` example\n- a\n - b\n\n c\n- d\n.\n
    \n
  • a\n
      \n
    • \n

      b

      \n

      c

      \n
    • \n
    \n
  • \n
  • d
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank line is inside the\nblock quote:\n\n" -- "```````````````````````````````` example\n* a\n > b\n >\n* c\n.\n
    \n
  • a\n
    \n

    b

    \n
    \n
  • \n
  • c
  • \n
\n````````````````````````````````\n\n\nThis list is tight, because the consecutive block elements\nare not separated by blank lines:\n\n" -- "```````````````````````````````` example\n- a\n > b\n ```\n c\n ```\n- d\n.\n
    \n
  • a\n
    \n

    b

    \n
    \n
    c\n
    \n
  • \n
  • d
  • \n
\n````````````````````````````````\n\n\nA single-paragraph list is tight:\n\n```````````````````````````````` example\n- a\n.\n
    \n
  • a
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n- a\n - b\n.\n
    \n
  • a\n
      \n
    • b
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nThis list is loose, because of the blank line between the\ntwo block elements in the list item:\n\n```````````````````````````````` example\n1. ```\n foo\n ```\n\n bar\n.\n
    \n
  1. \n
    foo\n
    \n

    bar

    \n
  2. \n
\n````````````````````````````````\n\n\nHere the outer list is loose, the inner list tight:\n\n" -- "```````````````````````````````` example\n* foo\n * bar\n\n baz\n.\n
    \n
  • \n

    foo

    \n
      \n
    • bar
    • \n
    \n

    baz

    \n
  • \n
\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n- a\n - b\n - c\n\n- d\n - e\n - f\n.\n
    \n
  • \n

    a

    \n
      \n
    • b
    • \n
    • c
    • \n
    \n
  • \n
  • \n

    d

    \n
      \n
    • e
    • \n
    • f
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\n" +- "These rules specify that a paragraph under a list item must be indented\nfour spaces (presumably, from the left margin, rather than the start of\nthe list marker, but this is not said), and that code under a list item\nmust be indented eight spaces instead of the usual four. They also say\nthat a block quote must be indented, but not by how much; however, the\nexample given has four spaces indentation. Although nothing is said\nabout other kinds of block-level content, it is certainly reasonable to\ninfer that *all* block elements under a list item, including other\nlists, must be indented four spaces. This principle has been called the\n*four-space rule*.\n" +- "\nThe four-space rule is clear and principled, and if the reference\nimplementation `Markdown.pl` had followed it, it probably would have\nbecome the standard. However, `Markdown.pl` allowed paragraphs and\nsublists to start with only two spaces indentation, at least on the\nouter level. Worse, its behavior was inconsistent: a sublist of an\nouter-level list needed two spaces indentation, but a sublist of this\nsublist needed three spaces. It is not surprising, then, that different\nimplementations of Markdown have developed very different rules for\ndetermining what comes under a list item. (Pandoc and python-Markdown,\nfor example, stuck with Gruber's syntax description and the four-space\nrule, while discount, redcarpet, marked, PHP Markdown, and others\nfollowed `Markdown.pl`'s behavior more closely.)\n" +- "\nUnfortunately, given the divergences between implementations, there\nis no way to give a spec for list items that will be guaranteed not\nto break any existing documents. However, the spec given here should\ncorrectly handle lists formatted with either the four-space rule or\nthe more forgiving `Markdown.pl` behavior, provided they are laid out\nin a way that is natural for a human to read.\n\nThe strategy here is to let the width and indentation of the list marker\ndetermine the indentation necessary for blocks to fall under the list\nitem, rather than having a fixed and arbitrary number. The writer can\nthink of the body of the list item as a unit which gets indented to the\nright enough to fit the list marker (and any indentation on the list\nmarker). (The laziness rule, #5, then allows continuation lines to be\nunindented if needed.)\n\nThis rule is superior, we claim, to any rule requiring a fixed level of\nindentation from the margin. The four-space rule is clear but\nunnatural. It is quite unintuitive that\n\n``` markdown\n- foo\n\n bar\n\n - baz\n```" +- "\n\nshould be parsed as two lists with an intervening paragraph,\n\n``` html\n
    \n
  • foo
  • \n
\n

bar

\n
    \n
  • baz
  • \n
\n```\n\nas the four-space rule demands, rather than a single list,\n\n``` html\n
    \n
  • \n

    foo

    \n

    bar

    \n
      \n
    • baz
    • \n
    \n
  • \n
\n```\n\nThe choice of four spaces is arbitrary. It can be learned, but it is\nnot likely to be guessed, and it trips up beginners regularly.\n\nWould it help to adopt a two-space rule? The problem is that such\na rule, together with the rule allowing up to three spaces of indentation for\nthe initial list marker, allows text that is indented *less than* the\noriginal list marker to be included in the list item. For example,\n`Markdown.pl` parses\n\n``` markdown\n - one\n\n two\n```" +- "\n\nas a single list item, with `two` a continuation paragraph:\n\n``` html\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n```\n\nand similarly\n\n``` markdown\n> - one\n>\n> two\n```\n\nas\n\n``` html\n
\n
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n
\n```\n\nThis is extremely unintuitive.\n\nRather than requiring a fixed indent from the margin, we could require\na fixed indent (say, two spaces, or even one space) from the list marker (which\nmay itself be indented). This proposal would remove the last anomaly\ndiscussed. Unlike the spec presented above, it would count the following\nas a list item with a subparagraph, even though the paragraph `bar`\nis not indented as far as the first paragraph `foo`:\n\n``` markdown\n 10. foo\n\n bar \n```" +- "\n\nArguably this text does read like a list item with `bar` as a subparagraph,\nwhich may count in favor of the proposal. However, on this proposal indented\ncode would have to be indented six spaces after the list marker. And this\nwould break a lot of existing Markdown, which has the pattern:\n\n``` markdown\n1. foo\n\n indented code\n```\n\nwhere the code is indented eight spaces. The spec above, by contrast, will\nparse this text as expected, since the code block's indentation is measured\nfrom the beginning of `foo`.\n\nThe one case that needs special treatment is a list item that *starts*\nwith indented code. How much indentation is required in that case, since\nwe don't have a \"first paragraph\" to measure from? Rule #2 simply stipulates\nthat in such cases, we require one space indentation from the list marker\n(and then the normal four spaces for the indented code). This will match the\nfour-space rule in cases where the list marker plus its initial indentation\ntakes four spaces (a common case), but diverge in other cases.\n\n" +- "## Lists\n\nA [list](@) is a sequence of one or more\nlist items [of the same type]. The list items\nmay be separated by any number of blank lines.\n\nTwo list items are [of the same type](@)\nif they begin with a [list marker] of the same type.\nTwo list markers are of the\nsame type if (a) they are bullet list markers using the same character\n(`-`, `+`, or `*`) or (b) they are ordered list numbers with the same\ndelimiter (either `.` or `)`).\n\nA list is an [ordered list](@)\nif its constituent list items begin with\n[ordered list markers], and a\n[bullet list](@) if its constituent list\nitems begin with [bullet list markers].\n\nThe [start number](@)\nof an [ordered list] is determined by the list number of\nits initial list item. The numbers of subsequent list items are\ndisregarded.\n" +- "\nA list is [loose](@) if any of its constituent\nlist items are separated by blank lines, or if any of its constituent\nlist items directly contain two block-level elements with a blank line\nbetween them. Otherwise a list is [tight](@).\n(The difference in HTML output is that paragraphs in a loose list are\nwrapped in `

` tags, while paragraphs in a tight list are not.)\n\nChanging the bullet or ordered list delimiter starts a new list:\n\n```````````````````````````````` example\n- foo\n- bar\n+ baz\n.\n

    \n
  • foo
  • \n
  • bar
  • \n
\n
    \n
  • baz
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n1. foo\n2. bar\n3) baz\n.\n
    \n
  1. foo
  2. \n
  3. bar
  4. \n
\n
    \n
  1. baz
  2. \n
\n````````````````````````````````\n\n\nIn CommonMark, a list can interrupt a paragraph. That is,\nno blank line is needed to separate a paragraph from a following\nlist:\n" +- "\n```````````````````````````````` example\nFoo\n- bar\n- baz\n.\n

Foo

\n
    \n
  • bar
  • \n
  • baz
  • \n
\n````````````````````````````````\n\n`Markdown.pl` does not allow this, through fear of triggering a list\nvia a numeral in a hard-wrapped line:\n\n``` markdown\nThe number of windows in my house is\n14. The number of doors is 6.\n```\n\nOddly, though, `Markdown.pl` *does* allow a blockquote to\ninterrupt a paragraph, even though the same considerations might\napply.\n\nIn CommonMark, we do allow lists to interrupt paragraphs, for\ntwo reasons. First, it is natural and not uncommon for people\nto start lists without blank lines:\n" +- "\n``` markdown\nI need to buy\n- new shoes\n- a coat\n- a plane ticket\n```\n\nSecond, we are attracted to a\n\n> [principle of uniformity](@):\n> if a chunk of text has a certain\n> meaning, it will continue to have the same meaning when put into a\n> container block (such as a list item or blockquote).\n" +- "\n(Indeed, the spec for [list items] and [block quotes] presupposes\nthis principle.) This principle implies that if\n\n``` markdown\n * I need to buy\n - new shoes\n - a coat\n - a plane ticket\n```\n\nis a list item containing a paragraph followed by a nested sublist,\nas all Markdown implementations agree it is (though the paragraph\nmay be rendered without `

` tags, since the list is \"tight\"),\nthen\n\n``` markdown\nI need to buy\n- new shoes\n- a coat\n- a plane ticket\n```\n\nby itself should be a paragraph followed by a nested sublist.\n\nSince it is well established Markdown practice to allow lists to\ninterrupt paragraphs inside list items, the [principle of\nuniformity] requires us to allow this outside list items as\nwell. ([reStructuredText](https://docutils.sourceforge.net/rst.html)\ntakes a different approach, requiring blank lines before lists\neven inside other list items.)\n" +- "\nIn order to solve the problem of unwanted lists in paragraphs with\nhard-wrapped numerals, we allow only lists starting with `1` to\ninterrupt paragraphs. Thus,\n\n```````````````````````````````` example\nThe number of windows in my house is\n14. The number of doors is 6.\n.\n

The number of windows in my house is\n14. The number of doors is 6.

\n````````````````````````````````\n\nWe may still get an unintended result in cases like\n" +- "\n```````````````````````````````` example\nThe number of windows in my house is\n1. The number of doors is 6.\n.\n

The number of windows in my house is

\n
    \n
  1. The number of doors is 6.
  2. \n
\n````````````````````````````````\n\nbut this rule should prevent most spurious list captures.\n\nThere can be any number of blank lines between items:\n" +- "\n```````````````````````````````` example\n- foo\n\n- bar\n\n\n- baz\n.\n
    \n
  • \n

    foo

    \n
  • \n
  • \n

    bar

    \n
  • \n
  • \n

    baz

    \n
  • \n
\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n- foo\n - bar\n - baz\n\n\n bim\n.\n
    \n
  • foo\n
      \n
    • bar\n
        \n
      • \n

        baz

        \n

        bim

        \n
      • \n
      \n
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nTo separate consecutive lists of the same type, or to separate a\nlist from an indented code block that would otherwise be parsed\nas a subparagraph of the final list item, you can insert a blank HTML\ncomment:\n" +- "\n```````````````````````````````` example\n- foo\n- bar\n\n\n\n- baz\n- bim\n.\n
    \n
  • foo
  • \n
  • bar
  • \n
\n\n
    \n
  • baz
  • \n
  • bim
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n- foo\n\n notcode\n\n- foo\n\n\n\n code\n.\n
    \n
  • \n

    foo

    \n

    notcode

    \n
  • \n
  • \n

    foo

    \n
  • \n
\n\n
code\n
\n````````````````````````````````\n\n\nList items need not be indented to the same level. The following\nlist items will be treated as items at the same list level,\nsince none is indented enough to belong to the previous list\nitem:\n" +- "\n```````````````````````````````` example\n- a\n - b\n - c\n - d\n - e\n - f\n- g\n.\n
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d
  • \n
  • e
  • \n
  • f
  • \n
  • g
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n1. a\n\n 2. b\n\n 3. c\n.\n
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
  5. \n

    c

    \n
  6. \n
\n````````````````````````````````\n\nNote, however, that list items may not be preceded by more than\nthree spaces of indentation. Here `- e` is treated as a paragraph continuation\nline, because it is indented more than three spaces:\n" +- "\n```````````````````````````````` example\n- a\n - b\n - c\n - d\n - e\n.\n
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d\n- e
  • \n
\n````````````````````````````````\n\nAnd here, `3. c` is treated as in indented code block,\nbecause it is indented four spaces and preceded by a\nblank line.\n" +- "\n```````````````````````````````` example\n1. a\n\n 2. b\n\n 3. c\n.\n
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
\n
3. c\n
\n````````````````````````````````\n\n\nThis is a loose list, because there is a blank line between\ntwo of the list items:\n" +- "\n```````````````````````````````` example\n- a\n- b\n\n- c\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    c

    \n
  • \n
\n````````````````````````````````\n\n\nSo is this, with a empty second item:\n" +- "\n```````````````````````````````` example\n* a\n*\n\n* c\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n
  • \n

    c

    \n
  • \n
\n````````````````````````````````\n\n\nThese are loose lists, even though there are no blank lines between the items,\nbecause one of the items directly contains two block-level elements\nwith a blank line between them:\n" +- "\n```````````````````````````````` example\n- a\n- b\n\n c\n- d\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n

    c

    \n
  • \n
  • \n

    d

    \n
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n- a\n- b\n\n [ref]: /url\n- d\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    d

    \n
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank lines are in a code block:\n" +- "\n```````````````````````````````` example\n- a\n- ```\n b\n\n\n ```\n- c\n.\n
    \n
  • a
  • \n
  • \n
    b\n\n\n
    \n
  • \n
  • c
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank line is between two\nparagraphs of a sublist. So the sublist is loose while\nthe outer list is tight:\n" +- "\n```````````````````````````````` example\n- a\n - b\n\n c\n- d\n.\n
    \n
  • a\n
      \n
    • \n

      b

      \n

      c

      \n
    • \n
    \n
  • \n
  • d
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank line is inside the\nblock quote:\n" +- "\n```````````````````````````````` example\n* a\n > b\n >\n* c\n.\n
    \n
  • a\n
    \n

    b

    \n
    \n
  • \n
  • c
  • \n
\n````````````````````````````````\n\n\nThis list is tight, because the consecutive block elements\nare not separated by blank lines:\n" +- "\n```````````````````````````````` example\n- a\n > b\n ```\n c\n ```\n- d\n.\n
    \n
  • a\n
    \n

    b

    \n
    \n
    c\n
    \n
  • \n
  • d
  • \n
\n````````````````````````````````\n\n\nA single-paragraph list is tight:\n\n```````````````````````````````` example\n- a\n.\n
    \n
  • a
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n- a\n - b\n.\n
    \n
  • a\n
      \n
    • b
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nThis list is loose, because of the blank line between the\ntwo block elements in the list item:\n\n```````````````````````````````` example\n1. ```\n foo\n ```\n\n bar\n.\n
    \n
  1. \n
    foo\n
    \n

    bar

    \n
  2. \n
\n````````````````````````````````\n\n\nHere the outer list is loose, the inner list tight:\n" +- "\n```````````````````````````````` example\n* foo\n * bar\n\n baz\n.\n
    \n
  • \n

    foo

    \n
      \n
    • bar
    • \n
    \n

    baz

    \n
  • \n
\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n- a\n - b\n - c\n\n- d\n - e\n - f\n.\n
    \n
  • \n

    a

    \n
      \n
    • b
    • \n
    • c
    • \n
    \n
  • \n
  • \n

    d

    \n
      \n
    • e
    • \n
    • f
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\n" - "# Inlines\n\nInlines are parsed sequentially from the beginning of the character\nstream to the end (left to right, in left-to-right languages).\nThus, for example, in\n\n```````````````````````````````` example\n`hi`lo`\n.\n

hilo`

\n````````````````````````````````\n\n`hi` is parsed as code, leaving the backtick at the end as a literal\nbacktick.\n\n\n\n" - "## Code spans\n\nA [backtick string](@)\nis a string of one or more backtick characters (`` ` ``) that is neither\npreceded nor followed by a backtick.\n\nA [code span](@) begins with a backtick string and ends with\na backtick string of equal length. The contents of the code span are\nthe characters between these two backtick strings, normalized in the\nfollowing ways:\n\n- First, [line endings] are converted to [spaces].\n- If the resulting string both begins *and* ends with a [space]\n character, but does not consist entirely of [space]\n characters, a single [space] character is removed from the\n front and back. This allows you to include code that begins\n or ends with backtick characters, which must be separated by\n whitespace from the opening or closing backtick strings.\n\n" -- "This is a simple code span:\n\n```````````````````````````````` example\n`foo`\n.\n

foo

\n````````````````````````````````\n\n\nHere two backticks are used, because the code contains a backtick.\nThis example also illustrates stripping of a single leading and\ntrailing space:\n\n```````````````````````````````` example\n`` foo ` bar ``\n.\n

foo ` bar

\n````````````````````````````````\n\n\nThis example shows the motivation for stripping leading and trailing\nspaces:\n\n" -- "```````````````````````````````` example\n` `` `\n.\n

``

\n````````````````````````````````\n\nNote that only *one* space is stripped:\n\n```````````````````````````````` example\n` `` `\n.\n

``

\n````````````````````````````````\n\nThe stripping only happens if the space is on both\nsides of the string:\n\n" -- "```````````````````````````````` example\n` a`\n.\n

a

\n````````````````````````````````\n\nOnly [spaces], and not [unicode whitespace] in general, are\nstripped in this way:\n\n```````````````````````````````` example\n` b `\n.\n

 b 

\n````````````````````````````````\n\nNo stripping occurs if the code span contains only spaces:\n\n" -- "```````````````````````````````` example\n` `\n` `\n.\n

 \n

\n````````````````````````````````\n\n\n[Line endings] are treated like spaces:\n\n```````````````````````````````` example\n``\nfoo\nbar \nbaz\n``\n.\n

foo bar baz

\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n``\nfoo \n``\n.\n

foo

\n````````````````````````````````\n\n\nInterior spaces are not collapsed:\n\n```````````````````````````````` example\n`foo bar \nbaz`\n.\n

foo bar baz

\n````````````````````````````````\n\nNote that browsers will typically collapse consecutive spaces\nwhen rendering `` elements, so it is recommended that\nthe following CSS be used:\n\n code{white-space: pre-wrap;}\n\n\nNote that backslash escapes do not work in code spans. All backslashes\nare treated literally:\n\n" -- "```````````````````````````````` example\n`foo\\`bar`\n.\n

foo\\bar`

\n````````````````````````````````\n\n\nBackslash escapes are never needed, because one can always choose a\nstring of *n* backtick characters as delimiters, where the code does\nnot contain any strings of exactly *n* backtick characters.\n\n```````````````````````````````` example\n``foo`bar``\n.\n

foo`bar

\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n` foo `` bar `\n.\n

foo `` bar

\n````````````````````````````````\n\n\nCode span backticks have higher precedence than any other inline\nconstructs except HTML tags and autolinks. Thus, for example, this is\nnot parsed as emphasized text, since the second `*` is part of a code\nspan:\n\n```````````````````````````````` example\n*foo`*`\n.\n

*foo*

\n````````````````````````````````\n\n\nAnd this is not parsed as a link:\n\n" -- "```````````````````````````````` example\n[not a `link](/foo`)\n.\n

[not a link](/foo)

\n````````````````````````````````\n\n\nCode spans, HTML tags, and autolinks have the same precedence.\nThus, this is code:\n\n```````````````````````````````` example\n``\n.\n

<a href="">`

\n````````````````````````````````\n\n\nBut this is an HTML tag:\n\n" -- "```````````````````````````````` example\n
`\n.\n

`

\n````````````````````````````````\n\n\nAnd this is code:\n\n```````````````````````````````` example\n``\n.\n

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

\n````````````````````````````````\n\n\nBut this is an autolink:\n\n" -- "```````````````````````````````` example\n`\n.\n

https://foo.bar.`baz`

\n````````````````````````````````\n\n\nWhen a backtick string is not closed by a matching backtick string,\nwe just have literal backticks:\n\n```````````````````````````````` example\n```foo``\n.\n

```foo``

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n`foo\n.\n

`foo

\n````````````````````````````````\n\nThe following case also illustrates the need for opening and\nclosing backtick strings to be equal in length:\n\n```````````````````````````````` example\n`foo``bar``\n.\n

`foobar

\n````````````````````````````````\n\n\n" +- "This is a simple code span:\n\n```````````````````````````````` example\n`foo`\n.\n

foo

\n````````````````````````````````\n\n\nHere two backticks are used, because the code contains a backtick.\nThis example also illustrates stripping of a single leading and\ntrailing space:\n\n```````````````````````````````` example\n`` foo ` bar ``\n.\n

foo ` bar

\n````````````````````````````````\n\n\nThis example shows the motivation for stripping leading and trailing\nspaces:\n" +- "\n```````````````````````````````` example\n` `` `\n.\n

``

\n````````````````````````````````\n\nNote that only *one* space is stripped:\n\n```````````````````````````````` example\n` `` `\n.\n

``

\n````````````````````````````````\n\nThe stripping only happens if the space is on both\nsides of the string:\n" +- "\n```````````````````````````````` example\n` a`\n.\n

a

\n````````````````````````````````\n\nOnly [spaces], and not [unicode whitespace] in general, are\nstripped in this way:\n\n```````````````````````````````` example\n` b `\n.\n

 b 

\n````````````````````````````````\n\nNo stripping occurs if the code span contains only spaces:\n" +- "\n```````````````````````````````` example\n` `\n` `\n.\n

 \n

\n````````````````````````````````\n\n\n[Line endings] are treated like spaces:\n\n```````````````````````````````` example\n``\nfoo\nbar \nbaz\n``\n.\n

foo bar baz

\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n``\nfoo \n``\n.\n

foo

\n````````````````````````````````\n\n\nInterior spaces are not collapsed:\n\n```````````````````````````````` example\n`foo bar \nbaz`\n.\n

foo bar baz

\n````````````````````````````````\n\nNote that browsers will typically collapse consecutive spaces\nwhen rendering `` elements, so it is recommended that\nthe following CSS be used:\n\n code{white-space: pre-wrap;}\n\n\nNote that backslash escapes do not work in code spans. All backslashes\nare treated literally:\n" +- "\n```````````````````````````````` example\n`foo\\`bar`\n.\n

foo\\bar`

\n````````````````````````````````\n\n\nBackslash escapes are never needed, because one can always choose a\nstring of *n* backtick characters as delimiters, where the code does\nnot contain any strings of exactly *n* backtick characters.\n\n```````````````````````````````` example\n``foo`bar``\n.\n

foo`bar

\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n` foo `` bar `\n.\n

foo `` bar

\n````````````````````````````````\n\n\nCode span backticks have higher precedence than any other inline\nconstructs except HTML tags and autolinks. Thus, for example, this is\nnot parsed as emphasized text, since the second `*` is part of a code\nspan:\n\n```````````````````````````````` example\n*foo`*`\n.\n

*foo*

\n````````````````````````````````\n\n\nAnd this is not parsed as a link:\n" +- "\n```````````````````````````````` example\n[not a `link](/foo`)\n.\n

[not a link](/foo)

\n````````````````````````````````\n\n\nCode spans, HTML tags, and autolinks have the same precedence.\nThus, this is code:\n\n```````````````````````````````` example\n``\n.\n

<a href="">`

\n````````````````````````````````\n\n\nBut this is an HTML tag:\n" +- "\n```````````````````````````````` example\n
`\n.\n

`

\n````````````````````````````````\n\n\nAnd this is code:\n\n```````````````````````````````` example\n``\n.\n

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

\n````````````````````````````````\n\n\nBut this is an autolink:\n" +- "\n```````````````````````````````` example\n`\n.\n

https://foo.bar.`baz`

\n````````````````````````````````\n\n\nWhen a backtick string is not closed by a matching backtick string,\nwe just have literal backticks:\n\n```````````````````````````````` example\n```foo``\n.\n

```foo``

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n`foo\n.\n

`foo

\n````````````````````````````````\n\nThe following case also illustrates the need for opening and\nclosing backtick strings to be equal in length:\n\n```````````````````````````````` example\n`foo``bar``\n.\n

`foobar

\n````````````````````````````````\n\n\n" - "## Emphasis and strong emphasis\n\nJohn Gruber's original [Markdown syntax\ndescription](https://daringfireball.net/projects/markdown/syntax#em) says:\n\n> Markdown treats asterisks (`*`) and underscores (`_`) as indicators of\n> emphasis. Text wrapped with one `*` or `_` will be wrapped with an HTML\n> `` tag; double `*`'s or `_`'s will be wrapped with an HTML ``\n> tag.\n" -- "\nThis is enough for most users, but these rules leave much undecided,\nespecially when it comes to nested emphasis. The original\n`Markdown.pl` test suite makes it clear that triple `***` and\n`___` delimiters can be used for strong emphasis, and most\nimplementations have also allowed the following patterns:\n\n``` markdown\n***strong emph***\n***strong** in emph*\n***emph* in strong**\n**in strong *emph***\n*in emph **strong***\n```\n\nThe following patterns are less widely supported, but the intent\nis clear and they are useful (especially in contexts like bibliography\nentries):\n\n``` markdown\n*emph *with emph* in it*\n**strong **with strong** in it**\n```\n\nMany implementations have also restricted intraword emphasis to\nthe `*` forms, to avoid unwanted emphasis in words containing\ninternal underscores. (It is best practice to put these in code\nspans, but users often do not.)\n\n" -- "``` markdown\ninternal emphasis: foo*bar*baz\nno emphasis: foo_bar_baz\n```\n\nThe rules given below capture all of these patterns, while allowing\nfor efficient parsing strategies that do not backtrack.\n\nFirst, some definitions. A [delimiter run](@) is either\na sequence of one or more `*` characters that is not preceded or\nfollowed by a non-backslash-escaped `*` character, or a sequence\nof one or more `_` characters that is not preceded or followed by\na non-backslash-escaped `_` character.\n\nA [left-flanking delimiter run](@) is\na [delimiter run] that is (1) not followed by [Unicode whitespace],\nand either (2a) not followed by a [Unicode punctuation character], or\n(2b) followed by a [Unicode punctuation character] and\npreceded by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace.\n\n" -- "A [right-flanking delimiter run](@) is\na [delimiter run] that is (1) not preceded by [Unicode whitespace],\nand either (2a) not preceded by a [Unicode punctuation character], or\n(2b) preceded by a [Unicode punctuation character] and\nfollowed by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace.\n\nHere are some examples of delimiter runs.\n\n" +- "\nThis is enough for most users, but these rules leave much undecided,\nespecially when it comes to nested emphasis. The original\n`Markdown.pl` test suite makes it clear that triple `***` and\n`___` delimiters can be used for strong emphasis, and most\nimplementations have also allowed the following patterns:\n\n``` markdown\n***strong emph***\n***strong** in emph*\n***emph* in strong**\n**in strong *emph***\n*in emph **strong***\n```\n\nThe following patterns are less widely supported, but the intent\nis clear and they are useful (especially in contexts like bibliography\nentries):\n\n``` markdown\n*emph *with emph* in it*\n**strong **with strong** in it**\n```\n\nMany implementations have also restricted intraword emphasis to\nthe `*` forms, to avoid unwanted emphasis in words containing\ninternal underscores. (It is best practice to put these in code\nspans, but users often do not.)\n" +- "\n``` markdown\ninternal emphasis: foo*bar*baz\nno emphasis: foo_bar_baz\n```\n\nThe rules given below capture all of these patterns, while allowing\nfor efficient parsing strategies that do not backtrack.\n\nFirst, some definitions. A [delimiter run](@) is either\na sequence of one or more `*` characters that is not preceded or\nfollowed by a non-backslash-escaped `*` character, or a sequence\nof one or more `_` characters that is not preceded or followed by\na non-backslash-escaped `_` character.\n\nA [left-flanking delimiter run](@) is\na [delimiter run] that is (1) not followed by [Unicode whitespace],\nand either (2a) not followed by a [Unicode punctuation character], or\n(2b) followed by a [Unicode punctuation character] and\npreceded by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace.\n" +- "\nA [right-flanking delimiter run](@) is\na [delimiter run] that is (1) not preceded by [Unicode whitespace],\nand either (2a) not preceded by a [Unicode punctuation character], or\n(2b) preceded by a [Unicode punctuation character] and\nfollowed by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace.\n\nHere are some examples of delimiter runs.\n\n" - " - left-flanking but not right-flanking:\n\n ```\n ***abc\n _abc\n **\"abc\"\n _\"abc\"\n ```\n\n - right-flanking but not left-flanking:\n\n ```\n abc***\n abc_\n \"abc\"**\n \"abc\"_\n ```\n\n - Both left and right-flanking:\n\n ```\n abc***def\n \"abc\"_\"def\"\n ```\n\n - Neither left nor right-flanking:\n\n ```\n abc *** def\n a _ b\n ```\n\n" - "(The idea of distinguishing left-flanking and right-flanking\ndelimiter runs based on the character before and the character\nafter comes from Roopesh Chander's\n[vfmd](https://web.archive.org/web/20220608143320/http://www.vfmd.org/vfmd-spec/specification/#procedure-for-identifying-emphasis-tags).\nvfmd uses the terminology \"emphasis indicator string\" instead of \"delimiter\nrun,\" and its rules for distinguishing left- and right-flanking runs\nare a bit more complex than the ones given here.)\n\nThe following rules define emphasis and strong emphasis:\n\n" - "1. A single `*` character [can open emphasis](@)\n iff (if and only if) it is part of a [left-flanking delimiter run].\n\n2. A single `_` character [can open emphasis] iff\n it is part of a [left-flanking delimiter run]\n and either (a) not part of a [right-flanking delimiter run]\n or (b) part of a [right-flanking delimiter run]\n preceded by a [Unicode punctuation character].\n\n3. A single `*` character [can close emphasis](@)\n iff it is part of a [right-flanking delimiter run].\n\n4. A single `_` character [can close emphasis] iff\n it is part of a [right-flanking delimiter run]\n and either (a) not part of a [left-flanking delimiter run]\n or (b) part of a [left-flanking delimiter run]\n followed by a [Unicode punctuation character].\n\n5. A double `**` [can open strong emphasis](@)\n" @@ -290,201 +290,201 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "11. A literal `*` character cannot occur at the beginning or end of\n `*`-delimited emphasis or `**`-delimited strong emphasis, unless it\n is backslash-escaped.\n\n12. A literal `_` character cannot occur at the beginning or end of\n `_`-delimited emphasis or `__`-delimited strong emphasis, unless it\n is backslash-escaped.\n\nWhere rules 1--12 above are compatible with multiple parsings,\nthe following principles resolve ambiguity:\n\n" - "13. The number of nestings should be minimized. Thus, for example,\n an interpretation `...` is always preferred to\n `...`.\n\n14. An interpretation `...` is always\n preferred to `...`.\n\n15. When two potential emphasis or strong emphasis spans overlap,\n so that the second begins before the first ends and ends after\n the first ends, the first takes precedence. Thus, for example,\n `*foo _bar* baz_` is parsed as `foo _bar baz_` rather\n than `*foo bar* baz`.\n\n16. When there are two potential emphasis or strong emphasis spans\n with the same closing delimiter, the shorter one (the one that\n opens later) takes precedence. Thus, for example,\n" - " `**foo **bar baz**` is parsed as `**foo bar baz`\n rather than `foo **bar baz`.\n\n17. Inline code spans, links, images, and HTML tags group more tightly\n than emphasis. So, when there is a choice between an interpretation\n that contains one of these elements and one that does not, the\n former always wins. Thus, for example, `*[foo*](bar)` is\n parsed as `*foo*` rather than as\n `[foo](bar)`.\n\n" -- "These rules can be illustrated through a series of examples.\n\nRule 1:\n\n```````````````````````````````` example\n*foo bar*\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `*` is followed by\nwhitespace, and hence not part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na * foo bar*\n.\n

a * foo bar*

\n````````````````````````````````\n\n\n" -- "This is not emphasis, because the opening `*` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na*\"foo\"*\n.\n

a*"foo"*

\n````````````````````````````````\n\n\nUnicode nonbreaking spaces count as whitespace, too:\n\n```````````````````````````````` example\n* a *\n.\n

* a *

\n````````````````````````````````\n\n\nUnicode symbols count as punctuation, too:\n\n" -- "```````````````````````````````` example\n*$*alpha.\n\n*£*bravo.\n\n*€*charlie.\n.\n

*$*alpha.

\n

*£*bravo.

\n

*€*charlie.

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is permitted:\n\n```````````````````````````````` example\nfoo*bar*\n.\n

foobar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n5*6*78\n.\n

5678

\n````````````````````````````````\n\n\nRule 2:\n\n```````````````````````````````` example\n_foo bar_\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is followed by\nwhitespace:\n\n" -- "```````````````````````````````` example\n_ foo bar_\n.\n

_ foo bar_

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na_\"foo\"_\n.\n

a_"foo"_

\n````````````````````````````````\n\n\nEmphasis with `_` is not allowed inside words:\n\n" -- "```````````````````````````````` example\nfoo_bar_\n.\n

foo_bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5_6_78\n.\n

5_6_78

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nпристаням_стремятся_\n.\n

пристаням_стремятся_

\n````````````````````````````````\n\n\nHere `_` does not generate emphasis, because the first delimiter run\nis right-flanking and the second left-flanking:\n\n```````````````````````````````` example\naa_\"bb\"_cc\n.\n

aa_"bb"_cc

\n````````````````````````````````\n\n\n" -- "This is emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-_(bar)_\n.\n

foo-(bar)

\n````````````````````````````````\n\n\nRule 3:\n\nThis is not emphasis, because the closing delimiter does\nnot match the opening delimiter:\n\n```````````````````````````````` example\n_foo*\n.\n

_foo*

\n````````````````````````````````\n\n\nThis is not emphasis, because the closing `*` is preceded by\nwhitespace:\n\n" -- "```````````````````````````````` example\n*foo bar *\n.\n

*foo bar *

\n````````````````````````````````\n\n\nA line ending also counts as whitespace:\n\n```````````````````````````````` example\n*foo bar\n*\n.\n

*foo bar\n*

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `*` is\npreceded by punctuation and followed by an alphanumeric\n(hence it is not part of a [right-flanking delimiter run]:\n\n" -- "```````````````````````````````` example\n*(*foo)\n.\n

*(*foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n\n```````````````````````````````` example\n*(*foo*)*\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is allowed:\n\n" -- "```````````````````````````````` example\n*foo*bar\n.\n

foobar

\n````````````````````````````````\n\n\n\nRule 4:\n\nThis is not emphasis, because the closing `_` is preceded by\nwhitespace:\n\n```````````````````````````````` example\n_foo bar _\n.\n

_foo bar _

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `_` is\npreceded by punctuation and followed by an alphanumeric:\n\n" -- "```````````````````````````````` example\n_(_foo)\n.\n

_(_foo)

\n````````````````````````````````\n\n\nThis is emphasis within emphasis:\n\n```````````````````````````````` example\n_(_foo_)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis is disallowed for `_`:\n\n" -- "```````````````````````````````` example\n_foo_bar\n.\n

_foo_bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_пристаням_стремятся\n.\n

_пристаням_стремятся

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n_foo_bar_baz_\n.\n

foo_bar_baz

\n````````````````````````````````\n\n\nThis is emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n\n```````````````````````````````` example\n_(bar)_.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 5:\n\n" -- "```````````````````````````````` example\n**foo bar**\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n** foo bar**\n.\n

** foo bar**

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `**` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n" -- "```````````````````````````````` example\na**\"foo\"**\n.\n

a**"foo"**

\n````````````````````````````````\n\n\nIntraword strong emphasis with `**` is permitted:\n\n```````````````````````````````` example\nfoo**bar**\n.\n

foobar

\n````````````````````````````````\n\n\nRule 6:\n\n" -- "```````````````````````````````` example\n__foo bar__\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n__ foo bar__\n.\n

__ foo bar__

\n````````````````````````````````\n\n\nA line ending counts as whitespace:\n" -- "```````````````````````````````` example\n__\nfoo bar__\n.\n

__\nfoo bar__

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `__` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na__\"foo\"__\n.\n

a__"foo"__

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n\n" -- "```````````````````````````````` example\nfoo__bar__\n.\n

foo__bar__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5__6__78\n.\n

5__6__78

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nпристаням__стремятся__\n.\n

пристаням__стремятся__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo, __bar__, baz__\n.\n

foo, bar, baz

\n````````````````````````````````\n\n\n" -- "This is strong emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-__(bar)__\n.\n

foo-(bar)

\n````````````````````````````````\n\n\n\nRule 7:\n\nThis is not strong emphasis, because the closing delimiter is preceded\nby whitespace:\n\n```````````````````````````````` example\n**foo bar **\n.\n

**foo bar **

\n````````````````````````````````\n\n\n" -- "(Nor can it be interpreted as an emphasized `*foo bar *`, because of\nRule 11.)\n\nThis is not strong emphasis, because the second `**` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n**(**foo)\n.\n

**(**foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith these examples:\n\n```````````````````````````````` example\n*(**foo**)*\n.\n

(foo)

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n.\n

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n**foo \"*bar*\" foo**\n.\n

foo "bar" foo

\n````````````````````````````````\n\n\nIntraword emphasis:\n\n```````````````````````````````` example\n**foo**bar\n.\n

foobar

\n````````````````````````````````\n\n\nRule 8:\n\nThis is not strong emphasis, because the closing delimiter is\npreceded by whitespace:\n\n" -- "```````````````````````````````` example\n__foo bar __\n.\n

__foo bar __

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the second `__` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n__(__foo)\n.\n

__(__foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n\n" -- "```````````````````````````````` example\n_(__foo__)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n\n```````````````````````````````` example\n__foo__bar\n.\n

__foo__bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n__пристаням__стремятся\n.\n

__пристаням__стремятся

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo__bar__baz__\n.\n

foo__bar__baz

\n````````````````````````````````\n\n\nThis is strong emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n\n" -- "```````````````````````````````` example\n__(bar)__.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 9:\n\nAny nonempty sequence of inline elements can be the contents of an\nemphasized span.\n\n```````````````````````````````` example\n*foo [bar](/url)*\n.\n

foo bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*foo\nbar*\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside emphasis:\n\n```````````````````````````````` example\n_foo __bar__ baz_\n.\n

foo bar baz

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n_foo _bar_ baz_\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo_ bar_\n.\n

foo bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*foo *bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo **bar** baz*\n.\n

foo bar baz

\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n*foo**bar**baz*\n.\n

foobarbaz

\n````````````````````````````````\n\nNote that in the preceding case, the interpretation\n\n``` markdown\n

foobarbaz

\n```\n\n\nis precluded by the condition that a delimiter that\ncan both open and close (like the `*` after `foo`)\ncannot form emphasis if the sum of the lengths of\nthe delimiter runs containing the opening and\nclosing delimiters is a multiple of 3 unless\nboth lengths are multiples of 3.\n\n\nFor the same reason, we don't get two consecutive\nemphasis sections in this example:\n\n" -- "```````````````````````````````` example\n*foo**bar*\n.\n

foo**bar

\n````````````````````````````````\n\n\nThe same condition ensures that the following\ncases are all strong emphasis nested inside\nemphasis, even when the interior whitespace is\nomitted:\n\n\n```````````````````````````````` example\n***foo** bar*\n.\n

foo bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*foo **bar***\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**bar***\n.\n

foobar

\n````````````````````````````````\n\n\nWhen the lengths of the interior closing and opening\ndelimiter runs are *both* multiples of 3, though,\nthey can match to create emphasis:\n\n" -- "```````````````````````````````` example\nfoo***bar***baz\n.\n

foobarbaz

\n````````````````````````````````\n\n```````````````````````````````` example\nfoo******bar*********baz\n.\n

foobar***baz

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n\n" -- "```````````````````````````````` example\n*foo **bar *baz* bim** bop*\n.\n

foo bar baz bim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo [*bar*](/url)*\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n\n" -- "```````````````````````````````` example\n** is not an empty emphasis\n.\n

** is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**** is not an empty strong emphasis\n.\n

**** is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 10:\n\nAny nonempty sequence of inline elements can be the contents of an\nstrongly emphasized span.\n\n" -- "```````````````````````````````` example\n**foo [bar](/url)**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo\nbar**\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside strong emphasis:\n\n" -- "```````````````````````````````` example\n__foo _bar_ baz__\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo __bar__ baz__\n.\n

foo bar baz

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n____foo__ bar__\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo **bar****\n.\n

foo bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n**foo *bar* baz**\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo*bar*baz**\n.\n

foobarbaz

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n***foo* bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo *bar***\n.\n

foo bar

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n\n" -- "```````````````````````````````` example\n**foo *bar **baz**\nbim* bop**\n.\n

foo bar baz\nbim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo [*bar*](/url)**\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n\n" -- "```````````````````````````````` example\n__ is not an empty emphasis\n.\n

__ is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____ is not an empty strong emphasis\n.\n

____ is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 11:\n\n" -- "```````````````````````````````` example\nfoo ***\n.\n

foo ***

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *\\**\n.\n

foo *

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nfoo *_*\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *****\n.\n

foo *****

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nfoo **\\***\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo **_**\n.\n

foo _

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 11 determines\nthat the excess literal `*` characters will appear outside of the\nemphasis, rather than inside it:\n\n" -- "```````````````````````````````` example\n**foo*\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**\n.\n

foo*

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n***foo**\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n****foo*\n.\n

***foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n**foo***\n.\n

foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo****\n.\n

foo***

\n````````````````````````````````\n\n\n\nRule 12:\n\n" -- "```````````````````````````````` example\nfoo ___\n.\n

foo ___

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _\\__\n.\n

foo _

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nfoo _*_\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _____\n.\n

foo _____

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nfoo __\\___\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo __*__\n.\n

foo *

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n__foo_\n.\n

_foo

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 12 determines\nthat the excess literal `_` characters will appear outside of the\nemphasis, rather than inside it:\n\n```````````````````````````````` example\n_foo__\n.\n

foo_

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n___foo__\n.\n

_foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo_\n.\n

___foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n__foo___\n.\n

foo_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo____\n.\n

foo___

\n````````````````````````````````\n\n\nRule 13 implies that if you want emphasis nested directly inside\nemphasis, you must use different delimiters:\n\n" -- "```````````````````````````````` example\n**foo**\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*_foo_*\n.\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n__foo__\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_*foo*_\n.\n

foo

\n````````````````````````````````\n\n\nHowever, strong emphasis within strong emphasis is possible without\nswitching delimiters:\n\n" -- "```````````````````````````````` example\n****foo****\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo____\n.\n

foo

\n````````````````````````````````\n\n\n\nRule 13 can be applied to arbitrarily long sequences of\ndelimiters:\n\n" -- "```````````````````````````````` example\n******foo******\n.\n

foo

\n````````````````````````````````\n\n\nRule 14:\n\n```````````````````````````````` example\n***foo***\n.\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n_____foo_____\n.\n

foo

\n````````````````````````````````\n\n\nRule 15:\n\n```````````````````````````````` example\n*foo _bar* baz_\n.\n

foo _bar baz_

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*foo __bar *baz bim__ bam*\n.\n

foo bar *baz bim bam

\n````````````````````````````````\n\n\nRule 16:\n\n```````````````````````````````` example\n**foo **bar baz**\n.\n

**foo bar baz

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*foo *bar baz*\n.\n

*foo bar baz

\n````````````````````````````````\n\n\nRule 17:\n\n```````````````````````````````` example\n*[bar*](/url)\n.\n

*bar*

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n_foo [bar_](/url)\n.\n

_foo bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*\n.\n

*

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n**\n.\n

**

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__\n.\n

__

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*a `*`*\n.\n

a *

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_a `_`_\n.\n

a _

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n**a\n.\n

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

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n__a\n.\n

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

\n````````````````````````````````\n\n\n\n" +- "These rules can be illustrated through a series of examples.\n\nRule 1:\n\n```````````````````````````````` example\n*foo bar*\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `*` is followed by\nwhitespace, and hence not part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na * foo bar*\n.\n

a * foo bar*

\n````````````````````````````````" +- "\n\n\nThis is not emphasis, because the opening `*` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na*\"foo\"*\n.\n

a*"foo"*

\n````````````````````````````````\n\n\nUnicode nonbreaking spaces count as whitespace, too:\n\n```````````````````````````````` example\n* a *\n.\n

* a *

\n````````````````````````````````\n\n\nUnicode symbols count as punctuation, too:\n" +- "\n```````````````````````````````` example\n*$*alpha.\n\n*£*bravo.\n\n*€*charlie.\n.\n

*$*alpha.

\n

*£*bravo.

\n

*€*charlie.

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is permitted:\n\n```````````````````````````````` example\nfoo*bar*\n.\n

foobar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n5*6*78\n.\n

5678

\n````````````````````````````````\n\n\nRule 2:\n\n```````````````````````````````` example\n_foo bar_\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is followed by\nwhitespace:\n" +- "\n```````````````````````````````` example\n_ foo bar_\n.\n

_ foo bar_

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na_\"foo\"_\n.\n

a_"foo"_

\n````````````````````````````````\n\n\nEmphasis with `_` is not allowed inside words:\n" +- "\n```````````````````````````````` example\nfoo_bar_\n.\n

foo_bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5_6_78\n.\n

5_6_78

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nпристаням_стремятся_\n.\n

пристаням_стремятся_

\n````````````````````````````````\n\n\nHere `_` does not generate emphasis, because the first delimiter run\nis right-flanking and the second left-flanking:\n\n```````````````````````````````` example\naa_\"bb\"_cc\n.\n

aa_"bb"_cc

\n````````````````````````````````" +- "\n\n\nThis is emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-_(bar)_\n.\n

foo-(bar)

\n````````````````````````````````\n\n\nRule 3:\n\nThis is not emphasis, because the closing delimiter does\nnot match the opening delimiter:\n\n```````````````````````````````` example\n_foo*\n.\n

_foo*

\n````````````````````````````````\n\n\nThis is not emphasis, because the closing `*` is preceded by\nwhitespace:\n" +- "\n```````````````````````````````` example\n*foo bar *\n.\n

*foo bar *

\n````````````````````````````````\n\n\nA line ending also counts as whitespace:\n\n```````````````````````````````` example\n*foo bar\n*\n.\n

*foo bar\n*

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `*` is\npreceded by punctuation and followed by an alphanumeric\n(hence it is not part of a [right-flanking delimiter run]:\n" +- "\n```````````````````````````````` example\n*(*foo)\n.\n

*(*foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n\n```````````````````````````````` example\n*(*foo*)*\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is allowed:\n" +- "\n```````````````````````````````` example\n*foo*bar\n.\n

foobar

\n````````````````````````````````\n\n\n\nRule 4:\n\nThis is not emphasis, because the closing `_` is preceded by\nwhitespace:\n\n```````````````````````````````` example\n_foo bar _\n.\n

_foo bar _

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `_` is\npreceded by punctuation and followed by an alphanumeric:\n" +- "\n```````````````````````````````` example\n_(_foo)\n.\n

_(_foo)

\n````````````````````````````````\n\n\nThis is emphasis within emphasis:\n\n```````````````````````````````` example\n_(_foo_)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis is disallowed for `_`:\n" +- "\n```````````````````````````````` example\n_foo_bar\n.\n

_foo_bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_пристаням_стремятся\n.\n

_пристаням_стремятся

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n_foo_bar_baz_\n.\n

foo_bar_baz

\n````````````````````````````````\n\n\nThis is emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n\n```````````````````````````````` example\n_(bar)_.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 5:\n" +- "\n```````````````````````````````` example\n**foo bar**\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n** foo bar**\n.\n

** foo bar**

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `**` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n" +- "\n```````````````````````````````` example\na**\"foo\"**\n.\n

a**"foo"**

\n````````````````````````````````\n\n\nIntraword strong emphasis with `**` is permitted:\n\n```````````````````````````````` example\nfoo**bar**\n.\n

foobar

\n````````````````````````````````\n\n\nRule 6:\n" +- "\n```````````````````````````````` example\n__foo bar__\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n__ foo bar__\n.\n

__ foo bar__

\n````````````````````````````````\n\n\nA line ending counts as whitespace:\n" +- "```````````````````````````````` example\n__\nfoo bar__\n.\n

__\nfoo bar__

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `__` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na__\"foo\"__\n.\n

a__"foo"__

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n" +- "\n```````````````````````````````` example\nfoo__bar__\n.\n

foo__bar__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5__6__78\n.\n

5__6__78

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nпристаням__стремятся__\n.\n

пристаням__стремятся__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo, __bar__, baz__\n.\n

foo, bar, baz

\n````````````````````````````````" +- "\n\n\nThis is strong emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-__(bar)__\n.\n

foo-(bar)

\n````````````````````````````````\n\n\n\nRule 7:\n\nThis is not strong emphasis, because the closing delimiter is preceded\nby whitespace:\n\n```````````````````````````````` example\n**foo bar **\n.\n

**foo bar **

\n````````````````````````````````" +- "\n\n\n(Nor can it be interpreted as an emphasized `*foo bar *`, because of\nRule 11.)\n\nThis is not strong emphasis, because the second `**` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n**(**foo)\n.\n

**(**foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith these examples:\n\n```````````````````````````````` example\n*(**foo**)*\n.\n

(foo)

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n.\n

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n**foo \"*bar*\" foo**\n.\n

foo "bar" foo

\n````````````````````````````````\n\n\nIntraword emphasis:\n\n```````````````````````````````` example\n**foo**bar\n.\n

foobar

\n````````````````````````````````\n\n\nRule 8:\n\nThis is not strong emphasis, because the closing delimiter is\npreceded by whitespace:\n" +- "\n```````````````````````````````` example\n__foo bar __\n.\n

__foo bar __

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the second `__` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n__(__foo)\n.\n

__(__foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n" +- "\n```````````````````````````````` example\n_(__foo__)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n\n```````````````````````````````` example\n__foo__bar\n.\n

__foo__bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n__пристаням__стремятся\n.\n

__пристаням__стремятся

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo__bar__baz__\n.\n

foo__bar__baz

\n````````````````````````````````\n\n\nThis is strong emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n" +- "\n```````````````````````````````` example\n__(bar)__.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 9:\n\nAny nonempty sequence of inline elements can be the contents of an\nemphasized span.\n\n```````````````````````````````` example\n*foo [bar](/url)*\n.\n

foo bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*foo\nbar*\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside emphasis:\n\n```````````````````````````````` example\n_foo __bar__ baz_\n.\n

foo bar baz

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n_foo _bar_ baz_\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo_ bar_\n.\n

foo bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*foo *bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo **bar** baz*\n.\n

foo bar baz

\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n*foo**bar**baz*\n.\n

foobarbaz

\n````````````````````````````````\n\nNote that in the preceding case, the interpretation\n\n``` markdown\n

foobarbaz

\n```\n\n\nis precluded by the condition that a delimiter that\ncan both open and close (like the `*` after `foo`)\ncannot form emphasis if the sum of the lengths of\nthe delimiter runs containing the opening and\nclosing delimiters is a multiple of 3 unless\nboth lengths are multiples of 3.\n\n\nFor the same reason, we don't get two consecutive\nemphasis sections in this example:\n" +- "\n```````````````````````````````` example\n*foo**bar*\n.\n

foo**bar

\n````````````````````````````````\n\n\nThe same condition ensures that the following\ncases are all strong emphasis nested inside\nemphasis, even when the interior whitespace is\nomitted:\n\n\n```````````````````````````````` example\n***foo** bar*\n.\n

foo bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*foo **bar***\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**bar***\n.\n

foobar

\n````````````````````````````````\n\n\nWhen the lengths of the interior closing and opening\ndelimiter runs are *both* multiples of 3, though,\nthey can match to create emphasis:\n" +- "\n```````````````````````````````` example\nfoo***bar***baz\n.\n

foobarbaz

\n````````````````````````````````\n\n```````````````````````````````` example\nfoo******bar*********baz\n.\n

foobar***baz

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n" +- "\n```````````````````````````````` example\n*foo **bar *baz* bim** bop*\n.\n

foo bar baz bim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo [*bar*](/url)*\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n" +- "\n```````````````````````````````` example\n** is not an empty emphasis\n.\n

** is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**** is not an empty strong emphasis\n.\n

**** is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 10:\n\nAny nonempty sequence of inline elements can be the contents of an\nstrongly emphasized span.\n" +- "\n```````````````````````````````` example\n**foo [bar](/url)**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo\nbar**\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside strong emphasis:\n" +- "\n```````````````````````````````` example\n__foo _bar_ baz__\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo __bar__ baz__\n.\n

foo bar baz

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n____foo__ bar__\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo **bar****\n.\n

foo bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n**foo *bar* baz**\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo*bar*baz**\n.\n

foobarbaz

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n***foo* bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo *bar***\n.\n

foo bar

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n" +- "\n```````````````````````````````` example\n**foo *bar **baz**\nbim* bop**\n.\n

foo bar baz\nbim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo [*bar*](/url)**\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n" +- "\n```````````````````````````````` example\n__ is not an empty emphasis\n.\n

__ is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____ is not an empty strong emphasis\n.\n

____ is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 11:\n" +- "\n```````````````````````````````` example\nfoo ***\n.\n

foo ***

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *\\**\n.\n

foo *

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nfoo *_*\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *****\n.\n

foo *****

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nfoo **\\***\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo **_**\n.\n

foo _

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 11 determines\nthat the excess literal `*` characters will appear outside of the\nemphasis, rather than inside it:\n" +- "\n```````````````````````````````` example\n**foo*\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**\n.\n

foo*

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n***foo**\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n****foo*\n.\n

***foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n**foo***\n.\n

foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo****\n.\n

foo***

\n````````````````````````````````\n\n\n\nRule 12:\n" +- "\n```````````````````````````````` example\nfoo ___\n.\n

foo ___

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _\\__\n.\n

foo _

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nfoo _*_\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _____\n.\n

foo _____

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nfoo __\\___\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo __*__\n.\n

foo *

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n__foo_\n.\n

_foo

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 12 determines\nthat the excess literal `_` characters will appear outside of the\nemphasis, rather than inside it:\n\n```````````````````````````````` example\n_foo__\n.\n

foo_

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n___foo__\n.\n

_foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo_\n.\n

___foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n__foo___\n.\n

foo_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo____\n.\n

foo___

\n````````````````````````````````\n\n\nRule 13 implies that if you want emphasis nested directly inside\nemphasis, you must use different delimiters:\n" +- "\n```````````````````````````````` example\n**foo**\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*_foo_*\n.\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n__foo__\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_*foo*_\n.\n

foo

\n````````````````````````````````\n\n\nHowever, strong emphasis within strong emphasis is possible without\nswitching delimiters:\n" +- "\n```````````````````````````````` example\n****foo****\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo____\n.\n

foo

\n````````````````````````````````\n\n\n\nRule 13 can be applied to arbitrarily long sequences of\ndelimiters:\n" +- "\n```````````````````````````````` example\n******foo******\n.\n

foo

\n````````````````````````````````\n\n\nRule 14:\n\n```````````````````````````````` example\n***foo***\n.\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n_____foo_____\n.\n

foo

\n````````````````````````````````\n\n\nRule 15:\n\n```````````````````````````````` example\n*foo _bar* baz_\n.\n

foo _bar baz_

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*foo __bar *baz bim__ bam*\n.\n

foo bar *baz bim bam

\n````````````````````````````````\n\n\nRule 16:\n\n```````````````````````````````` example\n**foo **bar baz**\n.\n

**foo bar baz

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*foo *bar baz*\n.\n

*foo bar baz

\n````````````````````````````````\n\n\nRule 17:\n\n```````````````````````````````` example\n*[bar*](/url)\n.\n

*bar*

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n_foo [bar_](/url)\n.\n

_foo bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*\n.\n

*

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n**\n.\n

**

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__\n.\n

__

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*a `*`*\n.\n

a *

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_a `_`_\n.\n

a _

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n**a\n.\n

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

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n__a\n.\n

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

\n````````````````````````````````\n\n\n\n" - "## Links\n\nA link contains [link text] (the visible text), a [link destination]\n(the URI that is the link destination), and optionally a [link title].\nThere are two basic kinds of links in Markdown. In [inline links] the\ndestination and title are given immediately after the link text. In\n[reference links] the destination and title are defined elsewhere in\nthe document.\n\nA [link text](@) consists of a sequence of zero or more\ninline elements enclosed by square brackets (`[` and `]`). The\nfollowing rules apply:\n\n" - "- Links may not contain other links, at any level of nesting. If\n multiple otherwise valid link definitions appear nested inside each\n other, the inner-most definition is used.\n\n- Brackets are allowed in the [link text] only if (a) they\n are backslash-escaped or (b) they appear as a matched pair of brackets,\n with an open bracket `[`, a sequence of zero or more inlines, and\n a close bracket `]`.\n\n- Backtick [code spans], [autolinks], and raw [HTML tags] bind more tightly\n than the brackets in link text. Thus, for example,\n `` [foo`]` `` could not be a link text, since the second `]`\n is part of a code span.\n\n- The brackets in link text bind more tightly than markers for\n [emphasis and strong emphasis]. Thus, for example, `*[foo*](url)` is a link.\n\nA [link destination](@) consists of either\n\n" - "- a sequence of zero or more characters between an opening `<` and a\n closing `>` that contains no line endings or unescaped\n `<` or `>` characters, or\n\n- a nonempty sequence of characters that does not start with `<`,\n does not include [ASCII control characters][ASCII control character]\n or [space] character, and includes parentheses only if (a) they are\n backslash-escaped or (b) they are part of a balanced pair of\n unescaped parentheses.\n (Implementations may impose limits on parentheses nesting to\n avoid performance issues, but at least three levels of nesting\n should be supported.)\n\nA [link title](@) consists of either\n\n" - "- a sequence of zero or more characters between straight double-quote\n characters (`\"`), including a `\"` character only if it is\n backslash-escaped, or\n\n- a sequence of zero or more characters between straight single-quote\n characters (`'`), including a `'` character only if it is\n backslash-escaped, or\n\n- a sequence of zero or more characters between matching parentheses\n (`(...)`), including a `(` or `)` character only if it is\n backslash-escaped.\n\n" -- "Although [link titles] may span multiple lines, they may not contain\na [blank line].\n\nAn [inline link](@) consists of a [link text] followed immediately\nby a left parenthesis `(`, an optional [link destination], an optional\n[link title], and a right parenthesis `)`.\nThese four components may be separated by spaces, tabs, and up to one line\nending.\nIf both [link destination] and [link title] are present, they *must* be\nseparated by spaces, tabs, and up to one line ending.\n\nThe link's text consists of the inlines contained\nin the [link text] (excluding the enclosing square brackets).\nThe link's URI consists of the link destination, excluding enclosing\n`<...>` if present, with backslash-escapes in effect as described\nabove. The link's title consists of the link title, excluding its\nenclosing delimiters, with backslash-escapes in effect as described\nabove.\n\nHere is a simple inline link:\n\n" -- "```````````````````````````````` example\n[link](/uri \"title\")\n.\n

link

\n````````````````````````````````\n\n\nThe title, the link text and even \nthe destination may be omitted:\n\n```````````````````````````````` example\n[link](/uri)\n.\n

link

\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n[](./target.md)\n.\n

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[link](<>)\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[]()\n.\n

\n````````````````````````````````\n\nThe destination can only contain spaces if it is\nenclosed in pointy brackets:\n\n" -- "```````````````````````````````` example\n[link](/my uri)\n.\n

[link](/my uri)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link](
)\n.\n

link

\n````````````````````````````````\n\nThe destination cannot contain line endings,\neven if enclosed in pointy brackets:\n\n" -- "```````````````````````````````` example\n[link](foo\nbar)\n.\n

[link](foo\nbar)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link]()\n.\n

[link]()

\n````````````````````````````````\n\nThe destination can contain `)` if it is enclosed\nin pointy brackets:\n\n" -- "```````````````````````````````` example\n[a]()\n.\n

a

\n````````````````````````````````\n\nPointy brackets that enclose links must be unescaped:\n\n```````````````````````````````` example\n[link]()\n.\n

[link](<foo>)

\n````````````````````````````````\n\nThese are not links, because the opening pointy bracket\nis not matched properly:\n\n" -- "```````````````````````````````` example\n[a](\n[a](c)\n.\n

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

\n````````````````````````````````\n\nParentheses inside the link destination may be escaped:\n\n```````````````````````````````` example\n[link](\\(foo\\))\n.\n

link

\n````````````````````````````````\n\n" -- "Any number of parentheses are allowed without escaping, as long as they are\nbalanced:\n\n```````````````````````````````` example\n[link](foo(and(bar)))\n.\n

link

\n````````````````````````````````\n\nHowever, if you have unbalanced parentheses, you need to escape or use the\n`<...>` form:\n\n```````````````````````````````` example\n[link](foo(and(bar))\n.\n

[link](foo(and(bar))

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[link](foo\\(and\\(bar\\))\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\n\nParentheses and other symbols can also be escaped, as usual\nin Markdown:\n\n" -- "```````````````````````````````` example\n[link](foo\\)\\:)\n.\n

link

\n````````````````````````````````\n\n\nA link can contain fragment identifiers and queries:\n\n" -- "```````````````````````````````` example\n[link](#fragment)\n\n[link](https://example.com#fragment)\n\n[link](https://example.com?foo=3#frag)\n.\n

link

\n

link

\n

link

\n````````````````````````````````\n\n\nNote that a backslash before a non-escapable character is\njust a backslash:\n\n" -- "```````````````````````````````` example\n[link](foo\\bar)\n.\n

link

\n````````````````````````````````\n\n\nURL-escaping should be left alone inside the destination, as all\nURL-escaped characters are also valid URL characters. Entity and\nnumerical character references in the destination will be parsed\ninto the corresponding Unicode code points, as usual. These may\nbe optionally URL-escaped when written as HTML, but this spec\ndoes not enforce any particular policy for rendering URLs in\nHTML or other formats. Renderers may make different decisions\nabout how to escape or normalize URLs in the output.\n\n" -- "```````````````````````````````` example\n[link](foo%20bä)\n.\n

link

\n````````````````````````````````\n\n\nNote that, because titles can often be parsed as destinations,\nif you try to omit the destination and keep the title, you'll\nget unexpected results:\n\n```````````````````````````````` example\n[link](\"title\")\n.\n

link

\n````````````````````````````````\n\n\n" -- "Titles may be in single quotes, double quotes, or parentheses:\n\n```````````````````````````````` example\n[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n.\n

link\nlink\nlink

\n````````````````````````````````\n\n\nBackslash escapes and entity and numeric character references\nmay be used in titles:\n\n" -- "```````````````````````````````` example\n[link](/url \"title \\\""\")\n.\n

link

\n````````````````````````````````\n\n\nTitles must be separated from the link using spaces, tabs, and up to one line\nending.\nOther [Unicode whitespace] like non-breaking space doesn't work.\n\n" -- "```````````````````````````````` example\n[link](/url \"title\")\n.\n

link

\n````````````````````````````````\n\n\nNested balanced quotes are not allowed without escaping:\n\n```````````````````````````````` example\n[link](/url \"title \"and\" title\")\n.\n

[link](/url "title "and" title")

\n````````````````````````````````\n\n\n" -- "But it is easy to work around this by using a different quote type:\n\n```````````````````````````````` example\n[link](/url 'title \"and\" title')\n.\n

link

\n````````````````````````````````\n\n\n" -- "(Note: `Markdown.pl` did allow double quotes inside a double-quoted\ntitle, and its test suite included a test demonstrating this.\nBut it is hard to see a good rationale for the extra complexity this\nbrings, since there are already many ways---backslash escaping,\nentity and numeric character references, or using a different\nquote type for the enclosing title---to write titles containing\ndouble quotes. `Markdown.pl`'s handling of titles has a number\nof other strange features. For example, it allows single-quoted\ntitles in inline links, but not reference links. And, in\nreference links but not inline links, it allows a title to begin\nwith `\"` and end with `)`. `Markdown.pl` 1.0.1 even allows\ntitles with no closing quotation mark, though 1.0.2b8 does not.\nIt seems preferable to adopt a simple, rational rule that works\nthe same way in inline links and link reference definitions.)\n\nSpaces, tabs, and up to one line ending is allowed around the destination and\ntitle:\n\n" -- "```````````````````````````````` example\n[link]( /uri\n \"title\" )\n.\n

link

\n````````````````````````````````\n\n\nBut it is not allowed between the link text and the\nfollowing parenthesis:\n\n```````````````````````````````` example\n[link] (/uri)\n.\n

[link] (/uri)

\n````````````````````````````````\n\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n\n" -- "```````````````````````````````` example\n[link [foo [bar]]](/uri)\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link] bar](/uri)\n.\n

[link] bar](/uri)

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[link [bar](/uri)\n.\n

[link bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar](/uri)\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n\n" -- "```````````````````````````````` example\n[link *foo **bar** `#`*](/uri)\n.\n

link foo bar #

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[![moon](moon.jpg)](/uri)\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n\n" -- "```````````````````````````````` example\n[foo [bar](/uri)](/uri)\n.\n

[foo bar](/uri)

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo *[bar [baz](/uri)](/uri)*](/uri)\n.\n

[foo [bar baz](/uri)](/uri)

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n![[[foo](uri1)](uri2)](uri3)\n.\n

\"[foo](uri2)\"

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n```````````````````````````````` example\n*[foo*](/uri)\n.\n

*foo*

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo *bar](baz*)\n.\n

foo *bar

\n````````````````````````````````\n\n\nNote that brackets that *aren't* part of links do not take\nprecedence:\n\n```````````````````````````````` example\n*foo [bar* baz]\n.\n

foo [bar baz]

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n\n" -- "```````````````````````````````` example\n[foo \n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`](/uri)`\n.\n

[foo](/uri)

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo\n.\n

[foohttps://example.com/?search=](uri)

\n````````````````````````````````\n\n\nThere are three kinds of [reference link](@)s:\n[full](#full-reference-link), [collapsed](#collapsed-reference-link),\nand [shortcut](#shortcut-reference-link).\n\nA [full reference link](@)\nconsists of a [link text] immediately followed by a [link label]\nthat [matches] a [link reference definition] elsewhere in the document.\n\n" -- "A [link label](@) begins with a left bracket (`[`) and ends\nwith the first right bracket (`]`) that is not backslash-escaped.\nBetween these brackets there must be at least one character that is not a space,\ntab, or line ending.\nUnescaped square bracket characters are not allowed inside the\nopening and closing square brackets of [link labels]. A link\nlabel can have at most 999 characters inside the square\nbrackets.\n\nOne label [matches](@)\nanother just in case their normalized forms are equal. To normalize a\nlabel, strip off the opening and closing brackets,\nperform the *Unicode case fold*, strip leading and trailing\nspaces, tabs, and line endings, and collapse consecutive internal\nspaces, tabs, and line endings to a single space. If there are multiple\nmatching reference link definitions, the one that comes first in the\ndocument is used. (It is desirable in such cases to emit a warning.)\n\nThe link's URI and title are provided by the matching [link\nreference definition].\n\nHere is a simple example:\n\n" -- "```````````````````````````````` example\n[foo][bar]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nThe rules for the [link text] are the same as with\n[inline links]. Thus:\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n\n" -- "```````````````````````````````` example\n[link [foo [bar]]][ref]\n\n[ref]: /uri\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar][ref]\n\n[ref]: /uri\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n\n" -- "```````````````````````````````` example\n[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n.\n

link foo bar #

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n\n" -- "```````````````````````````````` example\n[foo [bar](/uri)][ref]\n\n[ref]: /uri\n.\n

[foo bar]ref

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n.\n

[foo bar baz]ref

\n````````````````````````````````\n\n\n(In the examples above, we have two [shortcut reference links]\ninstead of one [full reference link].)\n\nThe following cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n" -- "```````````````````````````````` example\n*[foo*][ref]\n\n[ref]: /uri\n.\n

*foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar][ref]*\n\n[ref]: /uri\n.\n

foo *bar*

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n\n" -- "```````````````````````````````` example\n[foo \n\n[ref]: /uri\n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`][ref]`\n\n[ref]: /uri\n.\n

[foo][ref]

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo\n\n[ref]: /uri\n.\n

[foohttps://example.com/?search=][ref]

\n````````````````````````````````\n\n\nMatching is case-insensitive:\n\n" -- "```````````````````````````````` example\n[foo][BaR]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nUnicode case fold is used:\n\n```````````````````````````````` example\n[ẞ]\n\n[SS]: /url\n.\n

\n````````````````````````````````\n\n\nConsecutive internal spaces, tabs, and line endings are treated as one space for\npurposes of determining matching:\n\n" -- "```````````````````````````````` example\n[Foo\n bar]: /url\n\n[Baz][Foo bar]\n.\n

Baz

\n````````````````````````````````\n\n\nNo spaces, tabs, or line endings are allowed between the [link text] and the\n[link label]:\n\n```````````````````````````````` example\n[foo] [bar]\n\n[bar]: /url \"title\"\n.\n

[foo] bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[foo]\n[bar]\n\n[bar]: /url \"title\"\n.\n

[foo]\nbar

\n````````````````````````````````\n\n\nThis is a departure from John Gruber's original Markdown syntax\ndescription, which explicitly allows whitespace between the link\ntext and the link label. It brings reference links in line with\n[inline links], which (according to both original Markdown and\nthis spec) cannot have whitespace after the link text. More\nimportantly, it prevents inadvertent capture of consecutive\n[shortcut reference links]. If whitespace is allowed between the\nlink text and the link label, then in the following we will have\na single reference link, not two shortcut reference links, as\nintended:\n\n" -- "``` markdown\n[foo]\n[bar]\n\n[foo]: /url1\n[bar]: /url2\n```\n\n(Note that [shortcut reference links] were introduced by Gruber\nhimself in a beta version of `Markdown.pl`, but never included\nin the official syntax description. Without shortcut reference\nlinks, it is harmless to allow space between the link text and\nlink label; but once shortcut references are introduced, it is\ntoo dangerous to allow this, as it frequently leads to\nunintended results.)\n\nWhen there are multiple matching [link reference definitions],\nthe first is used:\n\n```````````````````````````````` example\n[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n.\n

bar

\n````````````````````````````````\n\n\n" -- "Note that matching is performed on normalized strings, not parsed\ninline content. So the following does not match, even though the\nlabels define equivalent inline content:\n\n```````````````````````````````` example\n[bar][foo\\!]\n\n[foo!]: /url\n.\n

[bar][foo!]

\n````````````````````````````````\n\n\n[Link labels] cannot contain brackets, unless they are\nbackslash-escaped:\n\n" -- "```````````````````````````````` example\n[foo][ref[]\n\n[ref[]: /uri\n.\n

[foo][ref[]

\n

[ref[]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref[bar]]\n\n[ref[bar]]: /uri\n.\n

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[[[foo]]]\n\n[[[foo]]]: /url\n.\n

[[[foo]]]

\n

[[[foo]]]: /url

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref\\[]\n\n[ref\\[]: /uri\n.\n

foo

\n````````````````````````````````\n\n\nNote that in this example `]` is not backslash-escaped:\n\n" -- "```````````````````````````````` example\n[bar\\\\]: /uri\n\n[bar\\\\]\n.\n

bar\\

\n````````````````````````````````\n\n\nA [link label] must contain at least one character that is not a space, tab, or\nline ending:\n\n```````````````````````````````` example\n[]\n\n[]: /uri\n.\n

[]

\n

[]: /uri

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[\n ]\n\n[\n ]: /uri\n.\n

[\n]

\n

[\n]: /uri

\n````````````````````````````````\n\n\nA [collapsed reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument, followed by the string `[]`.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title are\nprovided by the matching reference link definition. Thus,\n`[foo][]` is equivalent to `[foo][foo]`.\n\n" -- "```````````````````````````````` example\n[foo][]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n" -- "```````````````````````````````` example\n[Foo][]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\n\nAs with full reference links, spaces, tabs, or line endings are not\nallowed between the two sets of brackets:\n\n```````````````````````````````` example\n[foo] \n[]\n\n[foo]: /url \"title\"\n.\n

foo\n[]

\n````````````````````````````````\n\n\n" -- "A [shortcut reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument and is not followed by `[]` or a link label.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title\nare provided by the matching link reference definition.\nThus, `[foo]` is equivalent to `[foo][]`.\n\n```````````````````````````````` example\n[foo]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n.\n

[foo bar]

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n[[bar [foo]\n\n[foo]: /url\n.\n

[[bar foo

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n[Foo]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\nA space after the link text should be preserved:\n\n" -- "```````````````````````````````` example\n[foo] bar\n\n[foo]: /url\n.\n

foo bar

\n````````````````````````````````\n\n\nIf you just want bracketed text, you can backslash-escape the\nopening bracket to avoid links:\n\n```````````````````````````````` example\n\\[foo]\n\n[foo]: /url \"title\"\n.\n

[foo]

\n````````````````````````````````\n\n\nNote that this is a link, because a link label ends with the first\nfollowing closing bracket:\n\n" -- "```````````````````````````````` example\n[foo*]: /url\n\n*[foo*]\n.\n

*foo*

\n````````````````````````````````\n\n\nFull and collapsed references take precedence over shortcut\nreferences:\n\n```````````````````````````````` example\n[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n.\n

foo

\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n[foo][]\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````\n\nInline links also take precedence:\n\n```````````````````````````````` example\n[foo]()\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````\n\n" -- "```````````````````````````````` example\n[foo](not a link)\n\n[foo]: /url1\n.\n

foo(not a link)

\n````````````````````````````````\n\nIn the following case `[bar][baz]` is parsed as a reference,\n`[foo]` as normal text:\n\n" -- "```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url\n.\n

[foo]bar

\n````````````````````````````````\n\n\nHere, though, `[foo][bar]` is parsed as a reference, since\n`[bar]` is defined:\n\n" -- "```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n.\n

foobaz

\n````````````````````````````````\n\n\nHere `[foo]` is not parsed as a shortcut reference, because it\nis followed by a link label (even though `[bar]` is not defined):\n\n" -- "```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n.\n

[foo]bar

\n````````````````````````````````\n\n\n\n" -- "## Images\n\nSyntax for images is like the syntax for links, with one\ndifference. Instead of [link text], we have an\n[image description](@). The rules for this are the\nsame as for [link text], except that (a) an\nimage description starts with `![` rather than `[`, and\n(b) an image description may contain links.\nAn image description has inline elements\nas its contents. When an image is rendered to HTML,\nthis is standardly used as the image's `alt` attribute.\n\n```````````````````````````````` example\n![foo](/url \"title\")\n.\n

\"foo\"

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo ![bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n![foo [bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````\n\n\nThough this spec is concerned with parsing, not rendering, it is\nrecommended that in rendering to HTML, only the plain string content\nof the [image description] be used. Note that in\nthe above example, the alt attribute's value is `foo bar`, not `foo\n[bar](/url)` or `foo bar`. Only the plain string\ncontent is rendered, without formatting.\n\n" -- "```````````````````````````````` example\n![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo](train.jpg)\n.\n

\"foo\"

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nMy ![foo bar](/path/to/train.jpg \"title\" )\n.\n

My \"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo]()\n.\n

\"foo\"

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n![](/url)\n.\n

\"\"

\n````````````````````````````````\n\n\nReference-style:\n\n```````````````````````````````` example\n![foo][bar]\n\n[bar]: /url\n.\n

\"foo\"

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n![foo][bar]\n\n[BAR]: /url\n.\n

\"foo\"

\n````````````````````````````````\n\n\nCollapsed:\n\n```````````````````````````````` example\n![foo][]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nThe labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo][]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````\n\n\n" -- "As with reference links, spaces, tabs, and line endings, are not allowed\nbetween the two sets of brackets:\n\n```````````````````````````````` example\n![foo] \n[]\n\n[foo]: /url \"title\"\n.\n

\"foo\"\n[]

\n````````````````````````````````\n\n\nShortcut:\n\n" -- "```````````````````````````````` example\n![foo]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nNote that link labels cannot contain unescaped brackets:\n\n" -- "```````````````````````````````` example\n![[foo]]\n\n[[foo]]: /url \"title\"\n.\n

![[foo]]

\n

[[foo]]: /url "title"

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````\n\n\n" -- "If you just want a literal `!` followed by bracketed text, you can\nbackslash-escape the opening `[`:\n\n```````````````````````````````` example\n!\\[foo]\n\n[foo]: /url \"title\"\n.\n

![foo]

\n````````````````````````````````\n\n\nIf you want a link after a literal `!`, backslash-escape the\n`!`:\n\n" -- "```````````````````````````````` example\n\\![foo]\n\n[foo]: /url \"title\"\n.\n

!foo

\n````````````````````````````````\n\n\n" -- "## Autolinks\n\n[Autolink](@)s are absolute URIs and email addresses inside\n`<` and `>`. They are parsed as links, with the URL or email address\nas the link label.\n\nA [URI autolink](@) consists of `<`, followed by an\n[absolute URI] followed by `>`. It is parsed as\na link to the URI, with the URI as the link's label.\n\nAn [absolute URI](@),\nfor these purposes, consists of a [scheme] followed by a colon (`:`)\nfollowed by zero or more characters other than [ASCII control\ncharacters][ASCII control character], [space], `<`, and `>`.\nIf the URI includes these characters, they must be percent-encoded\n(e.g. `%20` for a space).\n\n" -- "For purposes of this spec, a [scheme](@) is any sequence\nof 2--32 characters beginning with an ASCII letter and followed\nby any combination of ASCII letters, digits, or the symbols plus\n(\"+\"), period (\".\"), or hyphen (\"-\").\n\nHere are some valid autolinks:\n\n```````````````````````````````` example\n\n.\n

http://foo.bar.baz

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n\n.\n

https://foo.bar.baz/test?q=hello&id=22&boolean

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n\n.\n

irc://foo.bar:2233/baz

\n````````````````````````````````\n\n\nUppercase is also fine:\n\n" -- "```````````````````````````````` example\n\n.\n

MAILTO:FOO@BAR.BAZ

\n````````````````````````````````\n\n\nNote that many strings that count as [absolute URIs] for\npurposes of this spec are not valid URIs, because their\nschemes are not registered or because of other problems\nwith their syntax:\n\n" -- "```````````````````````````````` example\n\n.\n

a+b+c:d

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

made-up-scheme://foo,bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n\n.\n

https://../

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

localhost:5001/foo

\n````````````````````````````````\n\n\nSpaces are not allowed in autolinks:\n\n" -- "```````````````````````````````` example\n\n.\n

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

\n````````````````````````````````\n\n\nBackslash-escapes do not work inside autolinks:\n\n```````````````````````````````` example\n\n.\n

https://example.com/\\[\\

\n````````````````````````````````\n\n\n" -- "An [email autolink](@)\nconsists of `<`, followed by an [email address],\nfollowed by `>`. The link's label is the email address,\nand the URL is `mailto:` followed by the email address.\n\nAn [email address](@),\nfor these purposes, is anything that matches\nthe [non-normative regex from the HTML5\nspec](https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-(type=email)):\n\n " -- "/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\n (?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/\n\nExamples of email autolinks:\n\n```````````````````````````````` example\n\n.\n

foo@bar.example.com

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n\n.\n

foo+special@Bar.baz-bar0.com

\n````````````````````````````````\n\n\nBackslash-escapes do not work inside email autolinks:\n\n```````````````````````````````` example\n\n.\n

<foo+@bar.example.com>

\n````````````````````````````````\n\n\nThese are not autolinks:\n\n" -- "```````````````````````````````` example\n<>\n.\n

<>

\n````````````````````````````````\n\n\n```````````````````````````````` example\n< https://foo.bar >\n.\n

< https://foo.bar >

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n\n.\n

<m:abc>

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

<foo.bar.baz>

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nhttps://example.com\n.\n

https://example.com

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo@bar.example.com\n.\n

foo@bar.example.com

\n````````````````````````````````\n\n\n" -- "## Raw HTML\n\nText between `<` and `>` that looks like an HTML tag is parsed as a\nraw HTML tag and will be rendered in HTML without escaping.\nTag and attribute names are not limited to current HTML tags,\nso custom tags (and even, say, DocBook tags) may be used.\n\nHere is the grammar for tags:\n\nA [tag name](@) consists of an ASCII letter\nfollowed by zero or more ASCII letters, digits, or\nhyphens (`-`).\n\nAn [attribute](@) consists of spaces, tabs, and up to one line ending,\nan [attribute name], and an optional\n[attribute value specification].\n\nAn [attribute name](@)\nconsists of an ASCII letter, `_`, or `:`, followed by zero or more ASCII\nletters, digits, `_`, `.`, `:`, or `-`. (Note: This is the XML\nspecification restricted to ASCII. HTML5 is laxer.)\n\n" -- "An [attribute value specification](@)\nconsists of optional spaces, tabs, and up to one line ending,\na `=` character, optional spaces, tabs, and up to one line ending,\nand an [attribute value].\n\nAn [attribute value](@)\nconsists of an [unquoted attribute value],\na [single-quoted attribute value], or a [double-quoted attribute value].\n\nAn [unquoted attribute value](@)\nis a nonempty string of characters not\nincluding spaces, tabs, line endings, `\"`, `'`, `=`, `<`, `>`, or `` ` ``.\n\nA [single-quoted attribute value](@)\nconsists of `'`, zero or more\ncharacters not including `'`, and a final `'`.\n\nA [double-quoted attribute value](@)\nconsists of `\"`, zero or more\ncharacters not including `\"`, and a final `\"`.\n\n" -- "An [open tag](@) consists of a `<` character, a [tag name],\nzero or more [attributes], optional spaces, tabs, and up to one line ending,\nan optional `/` character, and a `>` character.\n\nA [closing tag](@) consists of the string ``.\n\nAn [HTML comment](@) consists of ``, ``, or ``, and `-->` (see the\n[HTML spec](https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state)).\n\nA [processing instruction](@)\nconsists of the string ``, and the string\n`?>`.\n\n" -- "A [declaration](@) consists of the string ``, and the character `>`.\n\nA [CDATA section](@) consists of\nthe string ``, and the string `]]>`.\n\nAn [HTML tag](@) consists of an [open tag], a [closing tag],\nan [HTML comment], a [processing instruction], a [declaration],\nor a [CDATA section].\n\nHere are some simple open tags:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nEmpty elements:\n\n" -- "```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nWhitespace is allowed:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nWith attributes:\n\n" -- "```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nCustom tag names can be used:\n\n" -- "```````````````````````````````` example\nFoo \n.\n

Foo

\n````````````````````````````````\n\n\nIllegal tag names, not parsed as HTML:\n\n```````````````````````````````` example\n<33> <__>\n.\n

<33> <__>

\n````````````````````````````````\n\n\nIllegal attribute names:\n\n" -- "```````````````````````````````` example\n
\n.\n

<a h*#ref="hi">

\n````````````````````````````````\n\n\nIllegal attribute values:\n\n```````````````````````````````` example\n
\n.\n

<a href="hi'> <a href=hi'>

\n````````````````````````````````\n\n\nIllegal whitespace:\n\n" -- "```````````````````````````````` example\n< a><\nfoo>\n\n.\n

< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

\n````````````````````````````````\n\n\nMissing whitespace:\n\n```````````````````````````````` example\n
\n.\n

<a href='bar'title=title>

\n````````````````````````````````\n\n\n" -- "Closing tags:\n\n```````````````````````````````` example\n
\n.\n

\n````````````````````````````````\n\n\nIllegal attributes in closing tag:\n\n```````````````````````````````` example\n\n.\n

</a href="foo">

\n````````````````````````````````\n\n\nComments:\n\n" -- "```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\nfoo foo -->\n\nfoo foo -->\n.\n

foo foo -->

\n

foo foo -->

\n````````````````````````````````\n\n\nProcessing instructions:\n\n" -- "```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nDeclarations:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nCDATA sections:\n\n" -- "```````````````````````````````` example\nfoo &<]]>\n.\n

foo &<]]>

\n````````````````````````````````\n\n\nEntity and numeric character references are preserved in HTML\nattributes:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nBackslash escapes do not work in HTML attributes:\n\n" -- "```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

<a href=""">

\n````````````````````````````````\n\n\n" -- "## Hard line breaks\n\nA line ending (not in a code span or HTML tag) that is preceded\nby two or more spaces and does not occur at the end of a block\nis parsed as a [hard line break](@) (rendered\nin HTML as a `
` tag):\n\n```````````````````````````````` example\nfoo \nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nFor a more visible alternative, a backslash before the\n[line ending] may be used instead of two or more spaces:\n\n" -- "```````````````````````````````` example\nfoo\\\nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nMore than two spaces can be used:\n\n```````````````````````````````` example\nfoo \nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nLeading spaces at the beginning of the next line are ignored:\n\n" -- "```````````````````````````````` example\nfoo \n bar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo\\\n bar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nHard line breaks can occur inside emphasis, links, and other constructs\nthat allow inline content:\n\n" -- "```````````````````````````````` example\n*foo \nbar*\n.\n

foo
\nbar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo\\\nbar*\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nHard line breaks do not occur inside code spans\n\n" -- "```````````````````````````````` example\n`code \nspan`\n.\n

code span

\n````````````````````````````````\n\n\n```````````````````````````````` example\n`code\\\nspan`\n.\n

code\\ span

\n````````````````````````````````\n\n\nor HTML tags:\n\n" -- "```````````````````````````````` example\n
\n.\n

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nHard line breaks are for separating inline content within a block.\nNeither syntax for hard line breaks works at the end of a paragraph or\nother block element:\n\n" -- "```````````````````````````````` example\nfoo\\\n.\n

foo\\

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n### foo\\\n.\n

foo\\

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n### foo \n.\n

foo

\n````````````````````````````````\n\n\n" -- "## Soft line breaks\n\nA regular line ending (not in a code span or HTML tag) that is not\npreceded by two or more spaces or a backslash is parsed as a\n[softbreak](@). (A soft line break may be rendered in HTML either as a\n[line ending] or as a space. The result will be the same in\nbrowsers. In the examples here, a [line ending] will be used.)\n\n```````````````````````````````` example\nfoo\nbaz\n.\n

foo\nbaz

\n````````````````````````````````\n\n\nSpaces at the end of the line and beginning of the next line are\nremoved:\n\n" -- "```````````````````````````````` example\nfoo \n baz\n.\n

foo\nbaz

\n````````````````````````````````\n\n\nA conforming parser may render a soft line break in HTML either as a\nline ending or as a space.\n\nA renderer may also provide an option to render soft line breaks\nas hard line breaks.\n\n" -- "## Textual content\n\nAny characters not given an interpretation by the above rules will\nbe parsed as plain textual content.\n\n```````````````````````````````` example\nhello $.;'there\n.\n

hello $.;'there

\n````````````````````````````````\n\n\n```````````````````````````````` example\nFoo χρῆν\n.\n

Foo χρῆν

\n````````````````````````````````\n\n\nInternal spaces are preserved verbatim:\n\n" -- "```````````````````````````````` example\nMultiple spaces\n.\n

Multiple spaces

\n````````````````````````````````\n\n\n\n\n" +- "Although [link titles] may span multiple lines, they may not contain\na [blank line].\n\nAn [inline link](@) consists of a [link text] followed immediately\nby a left parenthesis `(`, an optional [link destination], an optional\n[link title], and a right parenthesis `)`.\nThese four components may be separated by spaces, tabs, and up to one line\nending.\nIf both [link destination] and [link title] are present, they *must* be\nseparated by spaces, tabs, and up to one line ending.\n\nThe link's text consists of the inlines contained\nin the [link text] (excluding the enclosing square brackets).\nThe link's URI consists of the link destination, excluding enclosing\n`<...>` if present, with backslash-escapes in effect as described\nabove. The link's title consists of the link title, excluding its\nenclosing delimiters, with backslash-escapes in effect as described\nabove.\n\nHere is a simple inline link:\n" +- "\n```````````````````````````````` example\n[link](/uri \"title\")\n.\n

link

\n````````````````````````````````\n\n\nThe title, the link text and even \nthe destination may be omitted:\n\n```````````````````````````````` example\n[link](/uri)\n.\n

link

\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n[](./target.md)\n.\n

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[link](<>)\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[]()\n.\n

\n````````````````````````````````\n\nThe destination can only contain spaces if it is\nenclosed in pointy brackets:\n" +- "\n```````````````````````````````` example\n[link](/my uri)\n.\n

[link](/my uri)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\nThe destination cannot contain line endings,\neven if enclosed in pointy brackets:\n" +- "\n```````````````````````````````` example\n[link](foo\nbar)\n.\n

[link](foo\nbar)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link]()\n.\n

[link]()

\n````````````````````````````````\n\nThe destination can contain `)` if it is enclosed\nin pointy brackets:\n" +- "\n```````````````````````````````` example\n[a]()\n.\n

a

\n````````````````````````````````\n\nPointy brackets that enclose links must be unescaped:\n\n```````````````````````````````` example\n[link]()\n.\n

[link](<foo>)

\n````````````````````````````````\n\nThese are not links, because the opening pointy bracket\nis not matched properly:\n" +- "\n```````````````````````````````` example\n[a](\n[a](c)\n.\n

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

\n````````````````````````````````\n\nParentheses inside the link destination may be escaped:\n\n```````````````````````````````` example\n[link](\\(foo\\))\n.\n

link

\n````````````````````````````````" +- "\n\nAny number of parentheses are allowed without escaping, as long as they are\nbalanced:\n\n```````````````````````````````` example\n[link](foo(and(bar)))\n.\n

link

\n````````````````````````````````\n\nHowever, if you have unbalanced parentheses, you need to escape or use the\n`<...>` form:\n\n```````````````````````````````` example\n[link](foo(and(bar))\n.\n

[link](foo(and(bar))

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[link](foo\\(and\\(bar\\))\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\n\nParentheses and other symbols can also be escaped, as usual\nin Markdown:\n" +- "\n```````````````````````````````` example\n[link](foo\\)\\:)\n.\n

link

\n````````````````````````````````\n\n\nA link can contain fragment identifiers and queries:\n" +- "\n```````````````````````````````` example\n[link](#fragment)\n\n[link](https://example.com#fragment)\n\n[link](https://example.com?foo=3#frag)\n.\n

link

\n

link

\n

link

\n````````````````````````````````\n\n\nNote that a backslash before a non-escapable character is\njust a backslash:\n" +- "\n```````````````````````````````` example\n[link](foo\\bar)\n.\n

link

\n````````````````````````````````\n\n\nURL-escaping should be left alone inside the destination, as all\nURL-escaped characters are also valid URL characters. Entity and\nnumerical character references in the destination will be parsed\ninto the corresponding Unicode code points, as usual. These may\nbe optionally URL-escaped when written as HTML, but this spec\ndoes not enforce any particular policy for rendering URLs in\nHTML or other formats. Renderers may make different decisions\nabout how to escape or normalize URLs in the output.\n" +- "\n```````````````````````````````` example\n[link](foo%20bä)\n.\n

link

\n````````````````````````````````\n\n\nNote that, because titles can often be parsed as destinations,\nif you try to omit the destination and keep the title, you'll\nget unexpected results:\n\n```````````````````````````````` example\n[link](\"title\")\n.\n

link

\n````````````````````````````````" +- "\n\n\nTitles may be in single quotes, double quotes, or parentheses:\n\n```````````````````````````````` example\n[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n.\n

link\nlink\nlink

\n````````````````````````````````\n\n\nBackslash escapes and entity and numeric character references\nmay be used in titles:\n" +- "\n```````````````````````````````` example\n[link](/url \"title \\\""\")\n.\n

link

\n````````````````````````````````\n\n\nTitles must be separated from the link using spaces, tabs, and up to one line\nending.\nOther [Unicode whitespace] like non-breaking space doesn't work.\n" +- "\n```````````````````````````````` example\n[link](/url \"title\")\n.\n

link

\n````````````````````````````````\n\n\nNested balanced quotes are not allowed without escaping:\n\n```````````````````````````````` example\n[link](/url \"title \"and\" title\")\n.\n

[link](/url "title "and" title")

\n````````````````````````````````" +- "\n\n\nBut it is easy to work around this by using a different quote type:\n\n```````````````````````````````` example\n[link](/url 'title \"and\" title')\n.\n

link

\n````````````````````````````````" +- "\n\n\n(Note: `Markdown.pl` did allow double quotes inside a double-quoted\ntitle, and its test suite included a test demonstrating this.\nBut it is hard to see a good rationale for the extra complexity this\nbrings, since there are already many ways---backslash escaping,\nentity and numeric character references, or using a different\nquote type for the enclosing title---to write titles containing\ndouble quotes. `Markdown.pl`'s handling of titles has a number\nof other strange features. For example, it allows single-quoted\ntitles in inline links, but not reference links. And, in\nreference links but not inline links, it allows a title to begin\nwith `\"` and end with `)`. `Markdown.pl` 1.0.1 even allows\ntitles with no closing quotation mark, though 1.0.2b8 does not.\nIt seems preferable to adopt a simple, rational rule that works\nthe same way in inline links and link reference definitions.)\n\nSpaces, tabs, and up to one line ending is allowed around the destination and\ntitle:\n" +- "\n```````````````````````````````` example\n[link]( /uri\n \"title\" )\n.\n

link

\n````````````````````````````````\n\n\nBut it is not allowed between the link text and the\nfollowing parenthesis:\n\n```````````````````````````````` example\n[link] (/uri)\n.\n

[link] (/uri)

\n````````````````````````````````\n\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n" +- "\n```````````````````````````````` example\n[link [foo [bar]]](/uri)\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link] bar](/uri)\n.\n

[link] bar](/uri)

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[link [bar](/uri)\n.\n

[link bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar](/uri)\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n" +- "\n```````````````````````````````` example\n[link *foo **bar** `#`*](/uri)\n.\n

link foo bar #

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[![moon](moon.jpg)](/uri)\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n" +- "\n```````````````````````````````` example\n[foo [bar](/uri)](/uri)\n.\n

[foo bar](/uri)

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo *[bar [baz](/uri)](/uri)*](/uri)\n.\n

[foo [bar baz](/uri)](/uri)

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n![[[foo](uri1)](uri2)](uri3)\n.\n

\"[foo](uri2)\"

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n```````````````````````````````` example\n*[foo*](/uri)\n.\n

*foo*

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo *bar](baz*)\n.\n

foo *bar

\n````````````````````````````````\n\n\nNote that brackets that *aren't* part of links do not take\nprecedence:\n\n```````````````````````````````` example\n*foo [bar* baz]\n.\n

foo [bar baz]

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n" +- "\n```````````````````````````````` example\n[foo \n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`](/uri)`\n.\n

[foo](/uri)

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo\n.\n

[foohttps://example.com/?search=](uri)

\n````````````````````````````````\n\n\nThere are three kinds of [reference link](@)s:\n[full](#full-reference-link), [collapsed](#collapsed-reference-link),\nand [shortcut](#shortcut-reference-link).\n\nA [full reference link](@)\nconsists of a [link text] immediately followed by a [link label]\nthat [matches] a [link reference definition] elsewhere in the document.\n" +- "\nA [link label](@) begins with a left bracket (`[`) and ends\nwith the first right bracket (`]`) that is not backslash-escaped.\nBetween these brackets there must be at least one character that is not a space,\ntab, or line ending.\nUnescaped square bracket characters are not allowed inside the\nopening and closing square brackets of [link labels]. A link\nlabel can have at most 999 characters inside the square\nbrackets.\n\nOne label [matches](@)\nanother just in case their normalized forms are equal. To normalize a\nlabel, strip off the opening and closing brackets,\nperform the *Unicode case fold*, strip leading and trailing\nspaces, tabs, and line endings, and collapse consecutive internal\nspaces, tabs, and line endings to a single space. If there are multiple\nmatching reference link definitions, the one that comes first in the\ndocument is used. (It is desirable in such cases to emit a warning.)\n\nThe link's URI and title are provided by the matching [link\nreference definition].\n\nHere is a simple example:\n" +- "\n```````````````````````````````` example\n[foo][bar]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nThe rules for the [link text] are the same as with\n[inline links]. Thus:\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n" +- "\n```````````````````````````````` example\n[link [foo [bar]]][ref]\n\n[ref]: /uri\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar][ref]\n\n[ref]: /uri\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n" +- "\n```````````````````````````````` example\n[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n.\n

link foo bar #

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n" +- "\n```````````````````````````````` example\n[foo [bar](/uri)][ref]\n\n[ref]: /uri\n.\n

[foo bar]ref

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n.\n

[foo bar baz]ref

\n````````````````````````````````\n\n\n(In the examples above, we have two [shortcut reference links]\ninstead of one [full reference link].)\n\nThe following cases illustrate the precedence of link text grouping over\nemphasis grouping:\n" +- "\n```````````````````````````````` example\n*[foo*][ref]\n\n[ref]: /uri\n.\n

*foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar][ref]*\n\n[ref]: /uri\n.\n

foo *bar*

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n" +- "\n```````````````````````````````` example\n[foo \n\n[ref]: /uri\n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`][ref]`\n\n[ref]: /uri\n.\n

[foo][ref]

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo\n\n[ref]: /uri\n.\n

[foohttps://example.com/?search=][ref]

\n````````````````````````````````\n\n\nMatching is case-insensitive:\n" +- "\n```````````````````````````````` example\n[foo][BaR]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nUnicode case fold is used:\n\n```````````````````````````````` example\n[ẞ]\n\n[SS]: /url\n.\n

\n````````````````````````````````\n\n\nConsecutive internal spaces, tabs, and line endings are treated as one space for\npurposes of determining matching:\n" +- "\n```````````````````````````````` example\n[Foo\n bar]: /url\n\n[Baz][Foo bar]\n.\n

Baz

\n````````````````````````````````\n\n\nNo spaces, tabs, or line endings are allowed between the [link text] and the\n[link label]:\n\n```````````````````````````````` example\n[foo] [bar]\n\n[bar]: /url \"title\"\n.\n

[foo] bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[foo]\n[bar]\n\n[bar]: /url \"title\"\n.\n

[foo]\nbar

\n````````````````````````````````\n\n\nThis is a departure from John Gruber's original Markdown syntax\ndescription, which explicitly allows whitespace between the link\ntext and the link label. It brings reference links in line with\n[inline links], which (according to both original Markdown and\nthis spec) cannot have whitespace after the link text. More\nimportantly, it prevents inadvertent capture of consecutive\n[shortcut reference links]. If whitespace is allowed between the\nlink text and the link label, then in the following we will have\na single reference link, not two shortcut reference links, as\nintended:\n" +- "\n``` markdown\n[foo]\n[bar]\n\n[foo]: /url1\n[bar]: /url2\n```\n\n(Note that [shortcut reference links] were introduced by Gruber\nhimself in a beta version of `Markdown.pl`, but never included\nin the official syntax description. Without shortcut reference\nlinks, it is harmless to allow space between the link text and\nlink label; but once shortcut references are introduced, it is\ntoo dangerous to allow this, as it frequently leads to\nunintended results.)\n\nWhen there are multiple matching [link reference definitions],\nthe first is used:\n\n```````````````````````````````` example\n[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n.\n

bar

\n````````````````````````````````" +- "\n\n\nNote that matching is performed on normalized strings, not parsed\ninline content. So the following does not match, even though the\nlabels define equivalent inline content:\n\n```````````````````````````````` example\n[bar][foo\\!]\n\n[foo!]: /url\n.\n

[bar][foo!]

\n````````````````````````````````\n\n\n[Link labels] cannot contain brackets, unless they are\nbackslash-escaped:\n" +- "\n```````````````````````````````` example\n[foo][ref[]\n\n[ref[]: /uri\n.\n

[foo][ref[]

\n

[ref[]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref[bar]]\n\n[ref[bar]]: /uri\n.\n

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[[[foo]]]\n\n[[[foo]]]: /url\n.\n

[[[foo]]]

\n

[[[foo]]]: /url

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref\\[]\n\n[ref\\[]: /uri\n.\n

foo

\n````````````````````````````````\n\n\nNote that in this example `]` is not backslash-escaped:\n" +- "\n```````````````````````````````` example\n[bar\\\\]: /uri\n\n[bar\\\\]\n.\n

bar\\

\n````````````````````````````````\n\n\nA [link label] must contain at least one character that is not a space, tab, or\nline ending:\n\n```````````````````````````````` example\n[]\n\n[]: /uri\n.\n

[]

\n

[]: /uri

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[\n ]\n\n[\n ]: /uri\n.\n

[\n]

\n

[\n]: /uri

\n````````````````````````````````\n\n\nA [collapsed reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument, followed by the string `[]`.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title are\nprovided by the matching reference link definition. Thus,\n`[foo][]` is equivalent to `[foo][foo]`.\n" +- "\n```````````````````````````````` example\n[foo][]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n" +- "\n```````````````````````````````` example\n[Foo][]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\n\nAs with full reference links, spaces, tabs, or line endings are not\nallowed between the two sets of brackets:\n\n```````````````````````````````` example\n[foo] \n[]\n\n[foo]: /url \"title\"\n.\n

foo\n[]

\n````````````````````````````````" +- "\n\n\nA [shortcut reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument and is not followed by `[]` or a link label.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title\nare provided by the matching link reference definition.\nThus, `[foo]` is equivalent to `[foo][]`.\n\n```````````````````````````````` example\n[foo]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n.\n

[foo bar]

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n[[bar [foo]\n\n[foo]: /url\n.\n

[[bar foo

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n[Foo]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\nA space after the link text should be preserved:\n" +- "\n```````````````````````````````` example\n[foo] bar\n\n[foo]: /url\n.\n

foo bar

\n````````````````````````````````\n\n\nIf you just want bracketed text, you can backslash-escape the\nopening bracket to avoid links:\n\n```````````````````````````````` example\n\\[foo]\n\n[foo]: /url \"title\"\n.\n

[foo]

\n````````````````````````````````\n\n\nNote that this is a link, because a link label ends with the first\nfollowing closing bracket:\n" +- "\n```````````````````````````````` example\n[foo*]: /url\n\n*[foo*]\n.\n

*foo*

\n````````````````````````````````\n\n\nFull and collapsed references take precedence over shortcut\nreferences:\n\n```````````````````````````````` example\n[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n.\n

foo

\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n[foo][]\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````\n\nInline links also take precedence:\n\n```````````````````````````````` example\n[foo]()\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````" +- "\n\n```````````````````````````````` example\n[foo](not a link)\n\n[foo]: /url1\n.\n

foo(not a link)

\n````````````````````````````````\n\nIn the following case `[bar][baz]` is parsed as a reference,\n`[foo]` as normal text:\n" +- "\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url\n.\n

[foo]bar

\n````````````````````````````````\n\n\nHere, though, `[foo][bar]` is parsed as a reference, since\n`[bar]` is defined:\n" +- "\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n.\n

foobaz

\n````````````````````````````````\n\n\nHere `[foo]` is not parsed as a shortcut reference, because it\nis followed by a link label (even though `[bar]` is not defined):\n" +- "\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n.\n

[foo]bar

\n````````````````````````````````\n\n\n\n" +- "## Images\n\nSyntax for images is like the syntax for links, with one\ndifference. Instead of [link text], we have an\n[image description](@). The rules for this are the\nsame as for [link text], except that (a) an\nimage description starts with `![` rather than `[`, and\n(b) an image description may contain links.\nAn image description has inline elements\nas its contents. When an image is rendered to HTML,\nthis is standardly used as the image's `alt` attribute.\n\n```````````````````````````````` example\n![foo](/url \"title\")\n.\n

\"foo\"

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo ![bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n![foo [bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````\n\n\nThough this spec is concerned with parsing, not rendering, it is\nrecommended that in rendering to HTML, only the plain string content\nof the [image description] be used. Note that in\nthe above example, the alt attribute's value is `foo bar`, not `foo\n[bar](/url)` or `foo bar`. Only the plain string\ncontent is rendered, without formatting.\n" +- "\n```````````````````````````````` example\n![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo](train.jpg)\n.\n

\"foo\"

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nMy ![foo bar](/path/to/train.jpg \"title\" )\n.\n

My \"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo]()\n.\n

\"foo\"

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n![](/url)\n.\n

\"\"

\n````````````````````````````````\n\n\nReference-style:\n\n```````````````````````````````` example\n![foo][bar]\n\n[bar]: /url\n.\n

\"foo\"

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n![foo][bar]\n\n[BAR]: /url\n.\n

\"foo\"

\n````````````````````````````````\n\n\nCollapsed:\n\n```````````````````````````````` example\n![foo][]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nThe labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo][]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````" +- "\n\n\nAs with reference links, spaces, tabs, and line endings, are not allowed\nbetween the two sets of brackets:\n\n```````````````````````````````` example\n![foo] \n[]\n\n[foo]: /url \"title\"\n.\n

\"foo\"\n[]

\n````````````````````````````````\n\n\nShortcut:\n" +- "\n```````````````````````````````` example\n![foo]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nNote that link labels cannot contain unescaped brackets:\n" +- "\n```````````````````````````````` example\n![[foo]]\n\n[[foo]]: /url \"title\"\n.\n

![[foo]]

\n

[[foo]]: /url "title"

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````" +- "\n\n\nIf you just want a literal `!` followed by bracketed text, you can\nbackslash-escape the opening `[`:\n\n```````````````````````````````` example\n!\\[foo]\n\n[foo]: /url \"title\"\n.\n

![foo]

\n````````````````````````````````\n\n\nIf you want a link after a literal `!`, backslash-escape the\n`!`:\n" +- "\n```````````````````````````````` example\n\\![foo]\n\n[foo]: /url \"title\"\n.\n

!foo

\n````````````````````````````````\n\n\n" +- "## Autolinks\n\n[Autolink](@)s are absolute URIs and email addresses inside\n`<` and `>`. They are parsed as links, with the URL or email address\nas the link label.\n\nA [URI autolink](@) consists of `<`, followed by an\n[absolute URI] followed by `>`. It is parsed as\na link to the URI, with the URI as the link's label.\n\nAn [absolute URI](@),\nfor these purposes, consists of a [scheme] followed by a colon (`:`)\nfollowed by zero or more characters other than [ASCII control\ncharacters][ASCII control character], [space], `<`, and `>`.\nIf the URI includes these characters, they must be percent-encoded\n(e.g. `%20` for a space).\n" +- "\nFor purposes of this spec, a [scheme](@) is any sequence\nof 2--32 characters beginning with an ASCII letter and followed\nby any combination of ASCII letters, digits, or the symbols plus\n(\"+\"), period (\".\"), or hyphen (\"-\").\n\nHere are some valid autolinks:\n\n```````````````````````````````` example\n\n.\n

http://foo.bar.baz

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n\n.\n

https://foo.bar.baz/test?q=hello&id=22&boolean

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n\n.\n

irc://foo.bar:2233/baz

\n````````````````````````````````\n\n\nUppercase is also fine:\n" +- "\n```````````````````````````````` example\n\n.\n

MAILTO:FOO@BAR.BAZ

\n````````````````````````````````\n\n\nNote that many strings that count as [absolute URIs] for\npurposes of this spec are not valid URIs, because their\nschemes are not registered or because of other problems\nwith their syntax:\n" +- "\n```````````````````````````````` example\n\n.\n

a+b+c:d

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

made-up-scheme://foo,bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n\n.\n

https://../

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

localhost:5001/foo

\n````````````````````````````````\n\n\nSpaces are not allowed in autolinks:\n" +- "\n```````````````````````````````` example\n\n.\n

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

\n````````````````````````````````\n\n\nBackslash-escapes do not work inside autolinks:\n\n```````````````````````````````` example\n\n.\n

https://example.com/\\[\\

\n````````````````````````````````" +- "\n\n\nAn [email autolink](@)\nconsists of `<`, followed by an [email address],\nfollowed by `>`. The link's label is the email address,\nand the URL is `mailto:` followed by the email address.\n\nAn [email address](@),\nfor these purposes, is anything that matches\nthe [non-normative regex from the HTML5\nspec](https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-(type=email)):\n" +- "\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\n (?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/\n\nExamples of email autolinks:\n\n```````````````````````````````` example\n\n.\n

foo@bar.example.com

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n\n.\n

foo+special@Bar.baz-bar0.com

\n````````````````````````````````\n\n\nBackslash-escapes do not work inside email autolinks:\n\n```````````````````````````````` example\n\n.\n

<foo+@bar.example.com>

\n````````````````````````````````\n\n\nThese are not autolinks:\n" +- "\n```````````````````````````````` example\n<>\n.\n

<>

\n````````````````````````````````\n\n\n```````````````````````````````` example\n< https://foo.bar >\n.\n

< https://foo.bar >

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n\n.\n

<m:abc>

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

<foo.bar.baz>

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nhttps://example.com\n.\n

https://example.com

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo@bar.example.com\n.\n

foo@bar.example.com

\n````````````````````````````````\n\n\n" +- "## Raw HTML\n\nText between `<` and `>` that looks like an HTML tag is parsed as a\nraw HTML tag and will be rendered in HTML without escaping.\nTag and attribute names are not limited to current HTML tags,\nso custom tags (and even, say, DocBook tags) may be used.\n\nHere is the grammar for tags:\n\nA [tag name](@) consists of an ASCII letter\nfollowed by zero or more ASCII letters, digits, or\nhyphens (`-`).\n\nAn [attribute](@) consists of spaces, tabs, and up to one line ending,\nan [attribute name], and an optional\n[attribute value specification].\n\nAn [attribute name](@)\nconsists of an ASCII letter, `_`, or `:`, followed by zero or more ASCII\nletters, digits, `_`, `.`, `:`, or `-`. (Note: This is the XML\nspecification restricted to ASCII. HTML5 is laxer.)\n" +- "\nAn [attribute value specification](@)\nconsists of optional spaces, tabs, and up to one line ending,\na `=` character, optional spaces, tabs, and up to one line ending,\nand an [attribute value].\n\nAn [attribute value](@)\nconsists of an [unquoted attribute value],\na [single-quoted attribute value], or a [double-quoted attribute value].\n\nAn [unquoted attribute value](@)\nis a nonempty string of characters not\nincluding spaces, tabs, line endings, `\"`, `'`, `=`, `<`, `>`, or `` ` ``.\n\nA [single-quoted attribute value](@)\nconsists of `'`, zero or more\ncharacters not including `'`, and a final `'`.\n\nA [double-quoted attribute value](@)\nconsists of `\"`, zero or more\ncharacters not including `\"`, and a final `\"`.\n" +- "\nAn [open tag](@) consists of a `<` character, a [tag name],\nzero or more [attributes], optional spaces, tabs, and up to one line ending,\nan optional `/` character, and a `>` character.\n\nA [closing tag](@) consists of the string ``.\n\nAn [HTML comment](@) consists of ``, ``, or ``, and `-->` (see the\n[HTML spec](https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state)).\n\nA [processing instruction](@)\nconsists of the string ``, and the string\n`?>`.\n" +- "\nA [declaration](@) consists of the string ``, and the character `>`.\n\nA [CDATA section](@) consists of\nthe string ``, and the string `]]>`.\n\nAn [HTML tag](@) consists of an [open tag], a [closing tag],\nan [HTML comment], a [processing instruction], a [declaration],\nor a [CDATA section].\n\nHere are some simple open tags:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nEmpty elements:\n" +- "\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nWhitespace is allowed:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nWith attributes:\n" +- "\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nCustom tag names can be used:\n" +- "\n```````````````````````````````` example\nFoo \n.\n

Foo

\n````````````````````````````````\n\n\nIllegal tag names, not parsed as HTML:\n\n```````````````````````````````` example\n<33> <__>\n.\n

<33> <__>

\n````````````````````````````````\n\n\nIllegal attribute names:\n" +- "\n```````````````````````````````` example\n
\n.\n

<a h*#ref="hi">

\n````````````````````````````````\n\n\nIllegal attribute values:\n\n```````````````````````````````` example\n
\n.\n

<a href="hi'> <a href=hi'>

\n````````````````````````````````\n\n\nIllegal whitespace:\n" +- "\n```````````````````````````````` example\n< a><\nfoo>\n\n.\n

< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

\n````````````````````````````````\n\n\nMissing whitespace:\n\n```````````````````````````````` example\n
\n.\n

<a href='bar'title=title>

\n````````````````````````````````" +- "\n\n\nClosing tags:\n\n```````````````````````````````` example\n
\n.\n

\n````````````````````````````````\n\n\nIllegal attributes in closing tag:\n\n```````````````````````````````` example\n\n.\n

</a href="foo">

\n````````````````````````````````\n\n\nComments:\n" +- "\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\nfoo foo -->\n\nfoo foo -->\n.\n

foo foo -->

\n

foo foo -->

\n````````````````````````````````\n\n\nProcessing instructions:\n" +- "\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nDeclarations:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nCDATA sections:\n" +- "\n```````````````````````````````` example\nfoo &<]]>\n.\n

foo &<]]>

\n````````````````````````````````\n\n\nEntity and numeric character references are preserved in HTML\nattributes:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nBackslash escapes do not work in HTML attributes:\n" +- "\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

<a href=""">

\n````````````````````````````````\n\n\n" +- "## Hard line breaks\n\nA line ending (not in a code span or HTML tag) that is preceded\nby two or more spaces and does not occur at the end of a block\nis parsed as a [hard line break](@) (rendered\nin HTML as a `
` tag):\n\n```````````````````````````````` example\nfoo \nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nFor a more visible alternative, a backslash before the\n[line ending] may be used instead of two or more spaces:\n" +- "\n```````````````````````````````` example\nfoo\\\nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nMore than two spaces can be used:\n\n```````````````````````````````` example\nfoo \nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nLeading spaces at the beginning of the next line are ignored:\n" +- "\n```````````````````````````````` example\nfoo \n bar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo\\\n bar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nHard line breaks can occur inside emphasis, links, and other constructs\nthat allow inline content:\n" +- "\n```````````````````````````````` example\n*foo \nbar*\n.\n

foo
\nbar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo\\\nbar*\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nHard line breaks do not occur inside code spans\n" +- "\n```````````````````````````````` example\n`code \nspan`\n.\n

code span

\n````````````````````````````````\n\n\n```````````````````````````````` example\n`code\\\nspan`\n.\n

code\\ span

\n````````````````````````````````\n\n\nor HTML tags:\n" +- "\n```````````````````````````````` example\n
\n.\n

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nHard line breaks are for separating inline content within a block.\nNeither syntax for hard line breaks works at the end of a paragraph or\nother block element:\n" +- "\n```````````````````````````````` example\nfoo\\\n.\n

foo\\

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n### foo\\\n.\n

foo\\

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n### foo \n.\n

foo

\n````````````````````````````````\n\n\n" +- "## Soft line breaks\n\nA regular line ending (not in a code span or HTML tag) that is not\npreceded by two or more spaces or a backslash is parsed as a\n[softbreak](@). (A soft line break may be rendered in HTML either as a\n[line ending] or as a space. The result will be the same in\nbrowsers. In the examples here, a [line ending] will be used.)\n\n```````````````````````````````` example\nfoo\nbaz\n.\n

foo\nbaz

\n````````````````````````````````\n\n\nSpaces at the end of the line and beginning of the next line are\nremoved:\n" +- "\n```````````````````````````````` example\nfoo \n baz\n.\n

foo\nbaz

\n````````````````````````````````\n\n\nA conforming parser may render a soft line break in HTML either as a\nline ending or as a space.\n\nA renderer may also provide an option to render soft line breaks\nas hard line breaks.\n\n" +- "## Textual content\n\nAny characters not given an interpretation by the above rules will\nbe parsed as plain textual content.\n\n```````````````````````````````` example\nhello $.;'there\n.\n

hello $.;'there

\n````````````````````````````````\n\n\n```````````````````````````````` example\nFoo χρῆν\n.\n

Foo χρῆν

\n````````````````````````````````\n\n\nInternal spaces are preserved verbatim:\n" +- "\n```````````````````````````````` example\nMultiple spaces\n.\n

Multiple spaces

\n````````````````````````````````\n\n\n\n\n" - "# Appendix: A parsing strategy\n\nIn this appendix we describe some features of the parsing strategy\nused in the CommonMark reference implementations.\n\n" - "## Overview\n\nParsing has two phases:\n\n1. In the first phase, lines of input are consumed and the block\nstructure of the document---its division into paragraphs, block quotes,\nlist items, and so on---is constructed. Text is assigned to these\nblocks but not parsed. Link reference definitions are parsed and a\nmap of links is constructed.\n\n2. In the second phase, the raw text contents of paragraphs and headings\nare parsed into sequences of Markdown inline elements (strings,\ncode spans, links, emphasis, and so on), using the map of link\nreferences constructed in phase 1.\n\n" - "At each point in processing, the document is represented as a tree of\n**blocks**. The root of the tree is a `document` block. The `document`\nmay have any number of other blocks as **children**. These children\nmay, in turn, have other blocks as children. The last child of a block\nis normally considered **open**, meaning that subsequent lines of input\ncan alter its contents. (Blocks that are not open are **closed**.)\nHere, for example, is a possible document tree, with the open blocks\nmarked by arrows:\n\n``` tree\n-> document\n -> block_quote\n paragraph\n \"Lorem ipsum dolor\\nsit amet.\"\n -> list (type=bullet tight=true bullet_char=-)\n list_item\n paragraph\n \"Qui *quodsi iracundia*\"\n -> list_item\n -> paragraph\n \"aliquando id\"\n```\n\n" - "## Phase 1: block structure\n\nEach line that is processed has an effect on this tree. The line is\nanalyzed and, depending on its contents, the document may be altered\nin one or more of the following ways:\n\n1. One or more open blocks may be closed.\n2. One or more new blocks may be created as children of the\n last open block.\n3. Text may be added to the last (deepest) open block remaining\n on the tree.\n\nOnce a line has been incorporated into the tree in this way,\nit can be discarded, so input can be read in a stream.\n\nFor each line, we follow this procedure:\n\n" - "1. First we iterate through the open blocks, starting with the\nroot document, and descending through last children down to the last\nopen block. Each block imposes a condition that the line must satisfy\nif the block is to remain open. For example, a block quote requires a\n`>` character. A paragraph requires a non-blank line.\nIn this phase we may match all or just some of the open\nblocks. But we cannot close unmatched blocks yet, because we may have a\n[lazy continuation line].\n\n2. Next, after consuming the continuation markers for existing\nblocks, we look for new block starts (e.g. `>` for a block quote).\nIf we encounter a new block start, we close any blocks unmatched\nin step 1 before creating the new block as a child of the last\nmatched container block.\n\n3. Finally, we look at the remainder of the line (after block\nmarkers like `>`, list markers, and indentation have been consumed).\nThis is text that can be incorporated into the last open\nblock (a paragraph, code block, heading, or raw HTML).\n\n" -- "Setext headings are formed when we see a line of a paragraph\nthat is a [setext heading underline].\n\nReference link definitions are detected when a paragraph is closed;\nthe accumulated text lines are parsed to see if they begin with\none or more reference link definitions. Any remainder becomes a\nnormal paragraph.\n\nWe can see how this works by considering how the tree above is\ngenerated by four lines of Markdown:\n\n``` markdown\n> Lorem ipsum dolor\nsit amet.\n> - Qui *quodsi iracundia*\n> - aliquando id\n```\n\nAt the outset, our document model is just\n\n``` tree\n-> document\n```\n\nThe first line of our text,\n\n``` markdown\n> Lorem ipsum dolor\n```\n\ncauses a `block_quote` block to be created as a child of our\nopen `document` block, and a `paragraph` block as a child of\nthe `block_quote`. Then the text is added to the last open\nblock, the `paragraph`:\n\n``` tree\n-> document\n -> block_quote\n -> paragraph\n \"Lorem ipsum dolor\"\n```\n\nThe next line,\n\n" -- "``` markdown\nsit amet.\n```\n\nis a \"lazy continuation\" of the open `paragraph`, so it gets added\nto the paragraph's text:\n\n``` tree\n-> document\n -> block_quote\n -> paragraph\n \"Lorem ipsum dolor\\nsit amet.\"\n```\n\nThe third line,\n\n``` markdown\n> - Qui *quodsi iracundia*\n```\n\ncauses the `paragraph` block to be closed, and a new `list` block\nopened as a child of the `block_quote`. A `list_item` is also\nadded as a child of the `list`, and a `paragraph` as a child of\nthe `list_item`. The text is then added to the new `paragraph`:\n\n``` tree\n-> document\n -> block_quote\n paragraph\n \"Lorem ipsum dolor\\nsit amet.\"\n -> list (type=bullet tight=true bullet_char=-)\n -> list_item\n -> paragraph\n \"Qui *quodsi iracundia*\"\n```\n\nThe fourth line,\n\n" -- "``` markdown\n> - aliquando id\n```\n\ncauses the `list_item` (and its child the `paragraph`) to be closed,\nand a new `list_item` opened up as child of the `list`. A `paragraph`\nis added as a child of the new `list_item`, to contain the text.\nWe thus obtain the final tree:\n\n``` tree\n-> document\n -> block_quote\n paragraph\n \"Lorem ipsum dolor\\nsit amet.\"\n -> list (type=bullet tight=true bullet_char=-)\n list_item\n paragraph\n \"Qui *quodsi iracundia*\"\n -> list_item\n -> paragraph\n \"aliquando id\"\n```\n\n" +- "Setext headings are formed when we see a line of a paragraph\nthat is a [setext heading underline].\n\nReference link definitions are detected when a paragraph is closed;\nthe accumulated text lines are parsed to see if they begin with\none or more reference link definitions. Any remainder becomes a\nnormal paragraph.\n\nWe can see how this works by considering how the tree above is\ngenerated by four lines of Markdown:\n\n``` markdown\n> Lorem ipsum dolor\nsit amet.\n> - Qui *quodsi iracundia*\n> - aliquando id\n```\n\nAt the outset, our document model is just\n\n``` tree\n-> document\n```\n\nThe first line of our text,\n\n``` markdown\n> Lorem ipsum dolor\n```\n\ncauses a `block_quote` block to be created as a child of our\nopen `document` block, and a `paragraph` block as a child of\nthe `block_quote`. Then the text is added to the last open\nblock, the `paragraph`:\n\n``` tree\n-> document\n -> block_quote\n -> paragraph\n \"Lorem ipsum dolor\"\n```\n\nThe next line,\n" +- "\n``` markdown\nsit amet.\n```\n\nis a \"lazy continuation\" of the open `paragraph`, so it gets added\nto the paragraph's text:\n\n``` tree\n-> document\n -> block_quote\n -> paragraph\n \"Lorem ipsum dolor\\nsit amet.\"\n```\n\nThe third line,\n\n``` markdown\n> - Qui *quodsi iracundia*\n```\n\ncauses the `paragraph` block to be closed, and a new `list` block\nopened as a child of the `block_quote`. A `list_item` is also\nadded as a child of the `list`, and a `paragraph` as a child of\nthe `list_item`. The text is then added to the new `paragraph`:\n\n``` tree\n-> document\n -> block_quote\n paragraph\n \"Lorem ipsum dolor\\nsit amet.\"\n -> list (type=bullet tight=true bullet_char=-)\n -> list_item\n -> paragraph\n \"Qui *quodsi iracundia*\"\n```\n\nThe fourth line,\n" +- "\n``` markdown\n> - aliquando id\n```\n\ncauses the `list_item` (and its child the `paragraph`) to be closed,\nand a new `list_item` opened up as child of the `list`. A `paragraph`\nis added as a child of the new `list_item`, to contain the text.\nWe thus obtain the final tree:\n\n``` tree\n-> document\n -> block_quote\n paragraph\n \"Lorem ipsum dolor\\nsit amet.\"\n -> list (type=bullet tight=true bullet_char=-)\n list_item\n paragraph\n \"Qui *quodsi iracundia*\"\n -> list_item\n -> paragraph\n \"aliquando id\"\n```\n\n" - "## Phase 2: inline structure\n\nOnce all of the input has been parsed, all open blocks are closed.\n\nWe then \"walk the tree,\" visiting every node, and parse raw\nstring contents of paragraphs and headings as inlines. At this\npoint we have seen all the link reference definitions, so we can\nresolve reference links as we go.\n\n``` tree\ndocument\n block_quote\n paragraph\n str \"Lorem ipsum dolor\"\n softbreak\n str \"sit amet.\"\n list (type=bullet tight=true bullet_char=-)\n list_item\n paragraph\n str \"Qui \"\n emph\n str \"quodsi iracundia\"\n list_item\n paragraph\n str \"aliquando id\"\n```\n\nNotice how the [line ending] in the first paragraph has\nbeen parsed as a `softbreak`, and the asterisks in the first list item\nhave become an `emph`.\n\n" - "### An algorithm for parsing nested emphasis and links\n\nBy far the trickiest part of inline parsing is handling emphasis,\nstrong emphasis, links, and images. This is done using the following\nalgorithm.\n\nWhen we're parsing inlines and we hit either\n\n- a run of `*` or `_` characters, or\n- a `[` or `![`\n\nwe insert a text node with these symbols as its literal content, and we\nadd a pointer to this text node to the [delimiter stack](@).\n\nThe [delimiter stack] is a doubly linked list. Each\nelement contains a pointer to a text node, plus information about\n\n- the type of delimiter (`[`, `![`, `*`, `_`)\n- the number of delimiters,\n- whether the delimiter is \"active\" (all are active to start), and\n- whether the delimiter is a potential opener, a potential closer,\n or both (which depends on what sort of characters precede\n and follow the delimiters).\n\n" - "When we hit a `]` character, we call the *look for link or image*\nprocedure (see below).\n\nWhen we hit the end of the input, we call the *process emphasis*\nprocedure (see below), with `stack_bottom` = NULL.\n\n" diff --git a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-3.snap b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-3.snap index 0db6653b..47689f1f 100644 --- a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-3.snap +++ b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md-3.snap @@ -13,8 +13,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "## Indented code blocks\n\nAn [indented code block](@) is composed of one or more\n[indented chunks] separated by blank lines.\nAn [indented chunk](@) is a sequence of non-blank lines,\neach preceded by four or more spaces of indentation. The contents of the code\nblock are the literal contents of the lines, including trailing\n[line endings], minus four spaces of indentation.\nAn indented code block has no [info string].\n\nAn indented code block cannot interrupt a paragraph, so there must be\na blank line between a paragraph and a following indented code block.\n(A blank line is not needed, however, between a code block and a following\nparagraph.)\n\n```````````````````````````````` example\n a simple\n indented code block\n.\n
a simple\n  indented code block\n
\n````````````````````````````````\n\n\nIf there is any ambiguity between an interpretation of indentation\nas a code block and as indicating that material belongs to a [list\nitem][list items], the list item interpretation takes precedence:\n\n```````````````````````````````` example\n - foo\n\n bar\n.\n
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n1. foo\n\n - bar\n.\n
    \n
  1. \n

    foo

    \n
      \n
    • bar
    • \n
    \n
  2. \n
\n````````````````````````````````\n\n\n\nThe contents of a code block are literal text, and do not get parsed\nas Markdown:\n\n```````````````````````````````` example\n
\n *hi*\n\n - one\n.\n
<a/>\n*hi*\n\n- one\n
\n````````````````````````````````\n\n\nHere we have three chunks separated by blank lines:\n\n```````````````````````````````` example\n chunk1\n\n chunk2\n \n \n \n chunk3\n.\n
chunk1\n\nchunk2\n\n\n\nchunk3\n
\n````````````````````````````````\n\n\nAny initial spaces or tabs beyond four spaces of indentation will be included in\nthe content, even in interior blank lines:\n\n```````````````````````````````` example\n chunk1\n \n chunk2\n.\n
chunk1\n  \n  chunk2\n
\n````````````````````````````````\n\n\nAn indented code block cannot interrupt a paragraph. (This\nallows hanging indents and the like.)\n\n```````````````````````````````` example\nFoo\n bar\n\n.\n

Foo\nbar

\n````````````````````````````````\n\n\nHowever, any non-blank line with fewer than four spaces of indentation ends\nthe code block immediately. So a paragraph may occur immediately\nafter indented code:\n\n```````````````````````````````` example\n foo\nbar\n.\n
foo\n
\n

bar

\n````````````````````````````````\n\n\nAnd indented code can occur immediately before and after other kinds of\nblocks:\n\n```````````````````````````````` example\n# Heading\n foo\nHeading\n------\n foo\n----\n.\n

Heading

\n
foo\n
\n

Heading

\n
foo\n
\n
\n````````````````````````````````\n\n\nThe first line can be preceded by more than four spaces of indentation:\n\n```````````````````````````````` example\n foo\n bar\n.\n
    foo\nbar\n
\n````````````````````````````````\n\n\nBlank lines preceding or following an indented code block\nare not included in it:\n\n```````````````````````````````` example\n\n \n foo\n \n\n.\n
foo\n
\n````````````````````````````````\n\n\nTrailing spaces or tabs are included in the code block's content:\n\n```````````````````````````````` example\n foo \n.\n
foo  \n
\n````````````````````````````````\n\n\n\n" - "## Fenced code blocks\n\nA [code fence](@) is a sequence\nof at least three consecutive backtick characters (`` ` ``) or\ntildes (`~`). (Tildes and backticks cannot be mixed.)\nA [fenced code block](@)\nbegins with a code fence, preceded by up to three spaces of indentation.\n\nThe line with the opening code fence may optionally contain some text\nfollowing the code fence; this is trimmed of leading and trailing\nspaces or tabs and called the [info string](@). If the [info string] comes\nafter a backtick fence, it may not contain any backtick\ncharacters. (The reason for this restriction is that otherwise\nsome inline code would be incorrectly interpreted as the\nbeginning of a fenced code block.)\n\nThe content of the code block consists of all subsequent lines, until\na closing [code fence] of the same type as the code block\nbegan with (backticks or tildes), and with at least as many backticks\nor tildes as the opening code fence. If the leading code fence is\npreceded by N spaces of indentation, then up to N spaces of indentation are\nremoved from each line of the content (if present). (If a content line is not\nindented, it is preserved unchanged. If it is indented N spaces or less, all\nof the indentation is removed.)\n\nThe closing code fence may be preceded by up to three spaces of indentation, and\nmay be followed only by spaces or tabs, which are ignored. If the end of the\ncontaining block (or document) is reached and no closing code fence\nhas been found, the code block contains all of the lines after the\nopening code fence until the end of the containing block (or\ndocument). (An alternative spec would require backtracking in the\nevent that a closing code fence is not found. But this makes parsing\nmuch less efficient, and there seems to be no real downside to the\nbehavior described here.)\n\nA fenced code block may interrupt a paragraph, and does not require\na blank line either before or after.\n\nThe content of a code fence is treated as literal text, not parsed\nas inlines. The first word of the [info string] is typically used to\nspecify the language of the code sample, and rendered in the `class`\nattribute of the `code` tag. However, this spec does not mandate any\nparticular treatment of the [info string].\n\nHere is a simple example with backticks:\n\n```````````````````````````````` example\n```\n<\n >\n```\n.\n
<\n >\n
\n````````````````````````````````\n\n\nWith tildes:\n\n```````````````````````````````` example\n~~~\n<\n >\n~~~\n.\n
<\n >\n
\n````````````````````````````````\n\nFewer than three backticks is not enough:\n\n```````````````````````````````` example\n``\nfoo\n``\n.\n

foo

\n````````````````````````````````\n\nThe closing code fence must use the same character as the opening\nfence:\n\n```````````````````````````````` example\n```\naaa\n~~~\n```\n.\n
aaa\n~~~\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~\naaa\n```\n~~~\n.\n
aaa\n```\n
\n````````````````````````````````\n\n\nThe closing code fence must be at least as long as the opening fence:\n\n```````````````````````````````` example\n````\naaa\n```\n``````\n.\n
aaa\n```\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~~\naaa\n~~~\n~~~~\n.\n
aaa\n~~~\n
\n````````````````````````````````\n\n\nUnclosed code blocks are closed by the end of the document\n(or the enclosing [block quote][block quotes] or [list item][list items]):\n\n```````````````````````````````` example\n```\n.\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n`````\n\n```\naaa\n.\n
\n```\naaa\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> ```\n> aaa\n\nbbb\n.\n
\n
aaa\n
\n
\n

bbb

\n````````````````````````````````\n\n\nA code block can have all empty lines as its content:\n\n```````````````````````````````` example\n```\n\n \n```\n.\n
\n  \n
\n````````````````````````````````\n\n\nA code block can be empty:\n\n```````````````````````````````` example\n```\n```\n.\n
\n````````````````````````````````\n\n\nFences can be indented. If the opening fence is indented,\ncontent lines will have equivalent opening indentation removed,\nif present:\n\n```````````````````````````````` example\n ```\n aaa\naaa\n```\n.\n
aaa\naaa\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n ```\naaa\n aaa\naaa\n ```\n.\n
aaa\naaa\naaa\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n ```\n aaa\n aaa\n aaa\n ```\n.\n
aaa\n aaa\naaa\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n ```\n aaa\n ```\n.\n
```\naaa\n```\n
\n````````````````````````````````\n\n\nClosing fences may be preceded by up to three spaces of indentation, and their\nindentation need not match that of the opening fence:\n\n```````````````````````````````` example\n```\naaa\n ```\n.\n
aaa\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n ```\naaa\n ```\n.\n
aaa\n
\n````````````````````````````````\n\n\nThis is not a closing fence, because it is indented 4 spaces:\n\n```````````````````````````````` example\n```\naaa\n ```\n.\n
aaa\n    ```\n
\n````````````````````````````````\n\n\n\nCode fences (opening and closing) cannot contain internal spaces or tabs:\n\n```````````````````````````````` example\n``` ```\naaa\n.\n

\naaa

\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~~~~\naaa\n~~~ ~~\n.\n
aaa\n~~~ ~~\n
\n````````````````````````````````\n\n\nFenced code blocks can interrupt paragraphs, and can be followed\ndirectly by paragraphs, without a blank line between:\n\n```````````````````````````````` example\nfoo\n```\nbar\n```\nbaz\n.\n

foo

\n
bar\n
\n

baz

\n````````````````````````````````\n\n\nOther blocks can also occur before and after fenced code blocks\nwithout an intervening blank line:\n\n```````````````````````````````` example\nfoo\n---\n~~~\nbar\n~~~\n# baz\n.\n

foo

\n
bar\n
\n

baz

\n````````````````````````````````\n\n\nAn [info string] can be provided after the opening code fence.\nAlthough this spec doesn't mandate any particular treatment of\nthe info string, the first word is typically used to specify\nthe language of the code block. In HTML output, the language is\nnormally indicated by adding a class to the `code` element consisting\nof `language-` followed by the language name.\n\n```````````````````````````````` example\n```ruby\ndef foo(x)\n return 3\nend\n```\n.\n
def foo(x)\n  return 3\nend\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n.\n
def foo(x)\n  return 3\nend\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n````;\n````\n.\n
\n````````````````````````````````\n\n\n[Info strings] for backtick code blocks cannot contain backticks:\n\n```````````````````````````````` example\n``` aa ```\nfoo\n.\n

aa\nfoo

\n````````````````````````````````\n\n\n[Info strings] for tilde code blocks can contain backticks and tildes:\n\n```````````````````````````````` example\n~~~ aa ``` ~~~\nfoo\n~~~\n.\n
foo\n
\n````````````````````````````````\n\n\nClosing code fences cannot have [info strings]:\n\n```````````````````````````````` example\n```\n``` aaa\n```\n.\n
``` aaa\n
\n````````````````````````````````\n\n\n\n" - "## HTML blocks\n\nAn [HTML block](@) is a group of lines that is treated\nas raw HTML (and will not be escaped in HTML output).\n\nThere are seven kinds of [HTML block], which can be defined by their\nstart and end conditions. The block begins with a line that meets a\n[start condition](@) (after up to three optional spaces of indentation).\nIt ends with the first subsequent line that meets a matching\n[end condition](@), or the last line of the document, or the last line of\nthe [container block](#container-blocks) containing the current HTML\nblock, if no line is encountered that meets the [end condition]. If\nthe first line meets both the [start condition] and the [end\ncondition], the block will contain just that line.\n\n1. **Start condition:** line begins with the string ``, or the end of the line.\\\n**End condition:** line contains an end tag\n`
`, ``, ``, or `` (case-insensitive; it\nneed not match the start tag).\n\n2. **Start condition:** line begins with the string ``.\n\n3. **Start condition:** line begins with the string ``.\n\n4. **Start condition:** line begins with the string ``.\n\n5. **Start condition:** line begins with the string\n``.\n\n6. **Start condition:** line begins with the string `<` or ``, or\nthe string `/>`.\\\n**End condition:** line is followed by a [blank line].\n\n7. **Start condition:** line begins with a complete [open tag]\n(with any [tag name] other than `pre`, `script`,\n`style`, or `textarea`) or a complete [closing tag],\nfollowed by zero or more spaces and tabs, followed by the end of the line.\\\n**End condition:** line is followed by a [blank line].\n\n" -- "HTML blocks continue until they are closed by their appropriate\n[end condition], or the last line of the document or other [container\nblock](#container-blocks). This means any HTML **within an HTML\nblock** that might otherwise be recognised as a start condition will\nbe ignored by the parser and passed through as-is, without changing\nthe parser's state.\n\nFor instance, `
` within an HTML block started by `` will not affect\nthe parser state; as the HTML block was started in by start condition 6, it\nwill end at any blank line. This can be surprising:\n\n```````````````````````````````` example\n
\n
\n**Hello**,\n\n_world_.\n
\n
\n.\n
\n
\n**Hello**,\n

world.\n

\n
\n````````````````````````````````\n\nIn this case, the HTML block is terminated by the blank line — the `**Hello**`\ntext remains verbatim — and regular parsing resumes, with a paragraph,\nemphasised `world` and inline and block HTML following.\n\nAll types of [HTML blocks] except type 7 may interrupt\na paragraph. Blocks of type 7 may not interrupt a paragraph.\n(This restriction is intended to prevent unwanted interpretation\nof long tags inside a wrapped paragraph as starting HTML blocks.)\n\nSome simple examples follow. Here are some basic HTML blocks\nof type 6:\n\n```````````````````````````````` example\n\n \n \n \n
\n hi\n
\n\nokay.\n.\n\n \n \n \n
\n hi\n
\n

okay.

\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n*foo*\n````````````````````````````````\n\n\nHere we have two HTML blocks with a Markdown paragraph between them:\n\n```````````````````````````````` example\n
\n\n*Markdown*\n\n
\n.\n
\n

Markdown

\n
\n````````````````````````````````\n\n\nThe tag on the first line can be partial, as long\nas it is split where there would be whitespace:\n\n```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````\n\n\nAn open tag need not be closed:\n```````````````````````````````` example\n
\n*foo*\n\n*bar*\n.\n
\n*foo*\n

bar

\n````````````````````````````````\n\n\n\nA partial tag need not even be completed (garbage\nin, garbage out):\n\n```````````````````````````````` example\n
\n.\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\nfoo\n
\n.\n
\nfoo\n
\n````````````````````````````````\n\n\nEverything until the next blank line or end of document\ngets included in the HTML block. So, in the following\nexample, what looks like a Markdown code block\nis actually part of the HTML block, which continues until a blank\nline or the end of the document is reached:\n\n```````````````````````````````` example\n
\n``` c\nint x = 33;\n```\n.\n
\n``` c\nint x = 33;\n```\n````````````````````````````````\n\n\nTo start an [HTML block] with a tag that is *not* in the\nlist of block-level tags in (6), you must put the tag by\nitself on the first line (and it must be complete):\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\nIn type 7 blocks, the [tag name] can be anything:\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n*bar*\n.\n\n*bar*\n````````````````````````````````\n\n\nThese rules are designed to allow us to work with tags that\ncan function as either block-level or inline-level tags.\nThe `` tag is a nice example. We can surround content with\n`` tags in three different ways. In this case, we get a raw\nHTML block, because the `` tag is on a line by itself:\n\n```````````````````````````````` example\n\n*foo*\n\n.\n\n*foo*\n\n````````````````````````````````\n\n\nIn this case, we get a raw HTML block that just includes\nthe `` tag (because it ends with the following blank\nline). So the contents get interpreted as CommonMark:\n\n```````````````````````````````` example\n\n\n*foo*\n\n\n.\n\n

foo

\n
\n````````````````````````````````\n\n\nFinally, in this case, the `` tags are interpreted\nas [raw HTML] *inside* the CommonMark paragraph. (Because\nthe tag is not on a line by itself, we get inline HTML\nrather than an [HTML block].)\n\n```````````````````````````````` example\n*foo*\n.\n

foo

\n````````````````````````````````\n\n\nHTML tags designed to contain literal content\n(`pre`, `script`, `style`, `textarea`), comments, processing instructions,\nand declarations are treated somewhat differently.\nInstead of ending at the first blank line, these blocks\nend at the first line containing a corresponding end tag.\nAs a result, these blocks can contain blank lines:\n\nA pre tag (type 1):\n\n```````````````````````````````` example\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n.\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n````````````````````````````````\n\n\nA script tag (type 1):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\nA textarea tag (type 1):\n\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\nA style tag (type 1):\n\n```````````````````````````````` example\n\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n.\n\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n````````````````````````````````\n\n\nIf there is no matching end tag, the block will end at the\nend of the document (or the enclosing [block quote][block quotes]\nor [list item][list items]):\n\n```````````````````````````````` example\n\n\nfoo\n.\n\n\nfoo\n````````````````````````````````\n\n\n```````````````````````````````` example\n>
\n> foo\n\nbar\n.\n
\n
\nfoo\n
\n

bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n-
\n- foo\n.\n
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n````````````````````````````````\n\n\nThe end tag can occur on the same line as the start tag:\n\n```````````````````````````````` example\n\n*foo*\n.\n\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n*bar*\n*baz*\n.\n*bar*\n

baz

\n````````````````````````````````\n\n\nNote that anything on the last line after the\nend tag will be included in the [HTML block]:\n\n```````````````````````````````` example\n1. *bar*\n.\n1. *bar*\n````````````````````````````````\n\n\nA comment (type 2):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\n\nA processing instruction (type 3):\n\n```````````````````````````````` example\n';\n\n?>\nokay\n.\n';\n\n?>\n

okay

\n````````````````````````````````\n\n\nA declaration (type 4):\n\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\nCDATA (type 5):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\nThe opening tag can be preceded by up to three spaces of indentation, but not\nfour:\n\n```````````````````````````````` example\n \n\n \n.\n \n
<!-- foo -->\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n\n
\n.\n
\n
<div>\n
\n````````````````````````````````\n\n\nAn HTML block of types 1--6 can interrupt a paragraph, and need not be\npreceded by a blank line.\n\n```````````````````````````````` example\nFoo\n
\nbar\n
\n.\n

Foo

\n
\nbar\n
\n````````````````````````````````\n\n\nHowever, a following blank line is needed, except at the end of\na document, and except for blocks of types 1--5, [above][HTML\nblock]:\n\n```````````````````````````````` example\n
\nbar\n
\n*foo*\n.\n
\nbar\n
\n*foo*\n````````````````````````````````\n\n\nHTML blocks of type 7 cannot interrupt a paragraph:\n\n```````````````````````````````` example\nFoo\n\nbaz\n.\n

Foo\n\nbaz

\n````````````````````````````````\n\n\nThis rule differs from John Gruber's original Markdown syntax\nspecification, which says:\n\n> The only restrictions are that block-level HTML elements —\n> e.g. `
`, ``, `
`, `

`, etc. — must be separated from\n> surrounding content by blank lines, and the start and end tags of the\n> block should not be indented with spaces or tabs.\n\nIn some ways Gruber's rule is more restrictive than the one given\nhere:\n\n- It requires that an HTML block be preceded by a blank line.\n- It does not allow the start tag to be indented.\n- It requires a matching end tag, which it also does not allow to\n be indented.\n\nMost Markdown implementations (including some of Gruber's own) do not\nrespect all of these restrictions.\n\nThere is one respect, however, in which Gruber's rule is more liberal\nthan the one given here, since it allows blank lines to occur inside\nan HTML block. There are two reasons for disallowing them here.\nFirst, it removes the need to parse balanced tags, which is\nexpensive and can require backtracking from the end of the document\nif no matching end tag is found. Second, it provides a very simple\nand flexible way of including Markdown content inside HTML tags:\nsimply separate the Markdown from the HTML using blank lines:\n\nCompare:\n\n```````````````````````````````` example\n

\n\n*Emphasized* text.\n\n
\n.\n
\n

Emphasized text.

\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n*Emphasized* text.\n
\n.\n
\n*Emphasized* text.\n
\n````````````````````````````````\n\n\nSome Markdown implementations have adopted a convention of\ninterpreting content inside tags as text if the open tag has\nthe attribute `markdown=1`. The rule given above seems a simpler and\nmore elegant way of achieving the same expressive power, which is also\nmuch simpler to parse.\n\nThe main potential drawback is that one can no longer paste HTML\nblocks into Markdown documents with 100% reliability. However,\n*in most cases* this will work fine, because the blank lines in\nHTML are usually followed by HTML block tags. For example:\n\n```````````````````````````````` example\n
\n\n\n\n\n\n\n\n
\nHi\n
\n.\n\n\n\n\n
\nHi\n
\n````````````````````````````````\n\n\nThere are problems, however, if the inner tags are indented\n*and* separated by spaces, as then they will be interpreted as\nan indented code block:\n\n```````````````````````````````` example\n\n\n \n\n \n\n \n\n
\n Hi\n
\n.\n\n \n
<td>\n  Hi\n</td>\n
\n \n
\n````````````````````````````````\n\n\nFortunately, blank lines are usually not necessary and can be\ndeleted. The exception is inside `
` tags, but as described\n[above][HTML blocks], raw HTML blocks starting with `
`\n*can* contain blank lines.\n\n"
+- "HTML blocks continue until they are closed by their appropriate\n[end condition], or the last line of the document or other [container\nblock](#container-blocks).  This means any HTML **within an HTML\nblock** that might otherwise be recognised as a start condition will\nbe ignored by the parser and passed through as-is, without changing\nthe parser's state.\n\nFor instance, `
` within an HTML block started by `` will not affect\nthe parser state; as the HTML block was started in by start condition 6, it\nwill end at any blank line. This can be surprising:\n\n```````````````````````````````` example\n
\n
\n**Hello**,\n\n_world_.\n
\n
\n.\n
\n
\n**Hello**,\n

world.\n

\n
\n````````````````````````````````\n\nIn this case, the HTML block is terminated by the blank line — the `**Hello**`\ntext remains verbatim — and regular parsing resumes, with a paragraph,\nemphasised `world` and inline and block HTML following.\n\nAll types of [HTML blocks] except type 7 may interrupt\na paragraph. Blocks of type 7 may not interrupt a paragraph.\n(This restriction is intended to prevent unwanted interpretation\nof long tags inside a wrapped paragraph as starting HTML blocks.)\n\nSome simple examples follow. Here are some basic HTML blocks\nof type 6:\n\n```````````````````````````````` example\n\n \n \n \n
\n hi\n
\n\nokay.\n.\n\n \n \n \n
\n hi\n
\n

okay.

\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n*foo*\n````````````````````````````````\n\n\nHere we have two HTML blocks with a Markdown paragraph between them:\n\n```````````````````````````````` example\n
\n\n*Markdown*\n\n
\n.\n
\n

Markdown

\n
\n````````````````````````````````\n\n\nThe tag on the first line can be partial, as long\nas it is split where there would be whitespace:\n\n```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n
\n.\n
\n
\n````````````````````````````````\n\n\nAn open tag need not be closed:\n```````````````````````````````` example\n
\n*foo*\n\n*bar*\n.\n
\n*foo*\n

bar

\n````````````````````````````````\n\n\n\nA partial tag need not even be completed (garbage\nin, garbage out):\n\n```````````````````````````````` example\n
\n.\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\nfoo\n
\n.\n
\nfoo\n
\n````````````````````````````````\n\n\nEverything until the next blank line or end of document\ngets included in the HTML block. So, in the following\nexample, what looks like a Markdown code block\nis actually part of the HTML block, which continues until a blank\nline or the end of the document is reached:\n\n```````````````````````````````` example\n
\n``` c\nint x = 33;\n```\n.\n
\n``` c\nint x = 33;\n```\n````````````````````````````````\n\n\nTo start an [HTML block] with a tag that is *not* in the\nlist of block-level tags in (6), you must put the tag by\nitself on the first line (and it must be complete):\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\nIn type 7 blocks, the [tag name] can be anything:\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n*bar*\n\n.\n\n*bar*\n\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n*bar*\n.\n\n*bar*\n````````````````````````````````\n\n\nThese rules are designed to allow us to work with tags that\ncan function as either block-level or inline-level tags.\nThe `` tag is a nice example. We can surround content with\n`` tags in three different ways. In this case, we get a raw\nHTML block, because the `` tag is on a line by itself:\n\n```````````````````````````````` example\n\n*foo*\n\n.\n\n*foo*\n\n````````````````````````````````\n\n\nIn this case, we get a raw HTML block that just includes\nthe `` tag (because it ends with the following blank\nline). So the contents get interpreted as CommonMark:\n\n```````````````````````````````` example\n\n\n*foo*\n\n\n.\n\n

foo

\n
\n````````````````````````````````\n\n\nFinally, in this case, the `` tags are interpreted\nas [raw HTML] *inside* the CommonMark paragraph. (Because\nthe tag is not on a line by itself, we get inline HTML\nrather than an [HTML block].)\n\n```````````````````````````````` example\n*foo*\n.\n

foo

\n````````````````````````````````\n\n\nHTML tags designed to contain literal content\n(`pre`, `script`, `style`, `textarea`), comments, processing instructions,\nand declarations are treated somewhat differently.\nInstead of ending at the first blank line, these blocks\nend at the first line containing a corresponding end tag.\nAs a result, these blocks can contain blank lines:\n\nA pre tag (type 1):\n\n```````````````````````````````` example\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n.\n
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n````````````````````````````````\n\n\nA script tag (type 1):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\nA textarea tag (type 1):\n\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\nA style tag (type 1):\n\n```````````````````````````````` example\n\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n.\n\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n````````````````````````````````\n\n\nIf there is no matching end tag, the block will end at the\nend of the document (or the enclosing [block quote][block quotes]\nor [list item][list items]):\n\n```````````````````````````````` example\n\n\nfoo\n.\n\n\nfoo\n````````````````````````````````\n\n\n```````````````````````````````` example\n>
\n> foo\n\nbar\n.\n
\n
\nfoo\n
\n

bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n-
\n- foo\n.\n
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n````````````````````````````````\n\n\nThe end tag can occur on the same line as the start tag:\n\n```````````````````````````````` example\n\n*foo*\n.\n\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n*bar*\n*baz*\n.\n*bar*\n

baz

\n````````````````````````````````\n\n\nNote that anything on the last line after the\nend tag will be included in the [HTML block]:\n\n```````````````````````````````` example\n1. *bar*\n.\n1. *bar*\n````````````````````````````````\n\n\nA comment (type 2):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\n\nA processing instruction (type 3):\n\n```````````````````````````````` example\n';\n\n?>\nokay\n.\n';\n\n?>\n

okay

\n````````````````````````````````\n\n\nA declaration (type 4):\n\n```````````````````````````````` example\n\n.\n\n````````````````````````````````\n\n\nCDATA (type 5):\n\n```````````````````````````````` example\n\nokay\n.\n\n

okay

\n````````````````````````````````\n\n\nThe opening tag can be preceded by up to three spaces of indentation, but not\nfour:\n\n```````````````````````````````` example\n \n\n \n.\n \n
<!-- foo -->\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n\n
\n.\n
\n
<div>\n
\n````````````````````````````````\n\n\nAn HTML block of types 1--6 can interrupt a paragraph, and need not be\npreceded by a blank line.\n\n```````````````````````````````` example\nFoo\n
\nbar\n
\n.\n

Foo

\n
\nbar\n
\n````````````````````````````````\n\n\nHowever, a following blank line is needed, except at the end of\na document, and except for blocks of types 1--5, [above][HTML\nblock]:\n\n```````````````````````````````` example\n
\nbar\n
\n*foo*\n.\n
\nbar\n
\n*foo*\n````````````````````````````````\n\n\nHTML blocks of type 7 cannot interrupt a paragraph:\n\n```````````````````````````````` example\nFoo\n\nbaz\n.\n

Foo\n\nbaz

\n````````````````````````````````\n\n\nThis rule differs from John Gruber's original Markdown syntax\nspecification, which says:\n\n> The only restrictions are that block-level HTML elements —\n> e.g. `
`, ``, `
`, `

`, etc. — must be separated from\n> surrounding content by blank lines, and the start and end tags of the\n> block should not be indented with spaces or tabs.\n\nIn some ways Gruber's rule is more restrictive than the one given\nhere:\n\n- It requires that an HTML block be preceded by a blank line.\n- It does not allow the start tag to be indented.\n- It requires a matching end tag, which it also does not allow to\n be indented.\n\nMost Markdown implementations (including some of Gruber's own) do not\nrespect all of these restrictions.\n\nThere is one respect, however, in which Gruber's rule is more liberal\nthan the one given here, since it allows blank lines to occur inside\nan HTML block. There are two reasons for disallowing them here.\nFirst, it removes the need to parse balanced tags, which is\nexpensive and can require backtracking from the end of the document\nif no matching end tag is found. Second, it provides a very simple\nand flexible way of including Markdown content inside HTML tags:\nsimply separate the Markdown from the HTML using blank lines:\n\nCompare:\n\n```````````````````````````````` example\n

\n\n*Emphasized* text.\n\n
\n.\n
\n

Emphasized text.

\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n
\n*Emphasized* text.\n
\n.\n
\n*Emphasized* text.\n
\n````````````````````````````````\n\n\nSome Markdown implementations have adopted a convention of\ninterpreting content inside tags as text if the open tag has\nthe attribute `markdown=1`. The rule given above seems a simpler and\nmore elegant way of achieving the same expressive power, which is also\nmuch simpler to parse.\n\nThe main potential drawback is that one can no longer paste HTML\nblocks into Markdown documents with 100% reliability. However,\n*in most cases* this will work fine, because the blank lines in\nHTML are usually followed by HTML block tags. For example:\n\n```````````````````````````````` example\n
\n\n\n\n\n\n\n\n
\nHi\n
\n.\n\n\n\n\n
\nHi\n
\n````````````````````````````````\n\n\nThere are problems, however, if the inner tags are indented\n*and* separated by spaces, as then they will be interpreted as\nan indented code block:\n\n```````````````````````````````` example\n\n\n \n\n \n\n \n\n
\n Hi\n
\n.\n\n \n
<td>\n  Hi\n</td>\n
\n \n
\n````````````````````````````````\n\n\nFortunately, blank lines are usually not necessary and can be\ndeleted. The exception is inside `
` tags, but as described\n[above][HTML blocks], raw HTML blocks starting with `
`\n*can* contain blank lines.\n\n"
 - "## Link reference definitions\n\nA [link reference definition](@)\nconsists of a [link label], optionally preceded by up to three spaces of\nindentation, followed\nby a colon (`:`), optional spaces or tabs (including up to one\n[line ending]), a [link destination],\noptional spaces or tabs (including up to one\n[line ending]), and an optional [link\ntitle], which if it is present must be separated\nfrom the [link destination] by spaces or tabs.\nNo further character may occur.\n\nA [link reference definition]\ndoes not correspond to a structural element of a document.  Instead, it\ndefines a label which can be used in [reference links]\nand reference-style [images] elsewhere in the document.  [Link\nreference definitions] can come either before or after the links that use\nthem.\n\n```````````````````````````````` example\n[foo]: /url \"title\"\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n [foo]: \n /url \n 'the title' \n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n.\n

Foo*bar]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[Foo bar]:\n\n'title'\n\n[Foo bar]\n.\n

Foo bar

\n````````````````````````````````\n\n\nThe title may extend over multiple lines:\n\n```````````````````````````````` example\n[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nHowever, it may not contain a [blank line]:\n\n```````````````````````````````` example\n[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n.\n

[foo]: /url 'title

\n

with blank line'

\n

[foo]

\n````````````````````````````````\n\n\nThe title may be omitted:\n\n```````````````````````````````` example\n[foo]:\n/url\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nThe link destination may not be omitted:\n\n```````````````````````````````` example\n[foo]:\n\n[foo]\n.\n

[foo]:

\n

[foo]

\n````````````````````````````````\n\n However, an empty link destination may be specified using\n angle brackets:\n\n```````````````````````````````` example\n[foo]: <>\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\nThe title must be separated from the link destination by\nspaces or tabs:\n\n```````````````````````````````` example\n[foo]: (baz)\n\n[foo]\n.\n

[foo]: (baz)

\n

[foo]

\n````````````````````````````````\n\n\nBoth title and destination can contain backslash escapes\nand literal backslashes:\n\n```````````````````````````````` example\n[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n.\n

foo

\n````````````````````````````````\n\n\nA link can come before its corresponding definition:\n\n```````````````````````````````` example\n[foo]\n\n[foo]: url\n.\n

foo

\n````````````````````````````````\n\n\nIf there are several matching definitions, the first one takes\nprecedence:\n\n```````````````````````````````` example\n[foo]\n\n[foo]: first\n[foo]: second\n.\n

foo

\n````````````````````````````````\n\n\nAs noted in the section on [Links], matching of labels is\ncase-insensitive (see [matches]).\n\n```````````````````````````````` example\n[FOO]: /url\n\n[Foo]\n.\n

Foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[ΑΓΩ]: /φου\n\n[αγω]\n.\n

αγω

\n````````````````````````````````\n\n\nWhether something is a [link reference definition] is\nindependent of whether the link reference it defines is\nused in the document. Thus, for example, the following\ndocument contains just a link reference definition, and\nno visible content:\n\n```````````````````````````````` example\n[foo]: /url\n.\n````````````````````````````````\n\n\nHere is another one:\n\n```````````````````````````````` example\n[\nfoo\n]: /url\nbar\n.\n

bar

\n````````````````````````````````\n\n\nThis is not a link reference definition, because there are\ncharacters other than spaces or tabs after the title:\n\n```````````````````````````````` example\n[foo]: /url \"title\" ok\n.\n

[foo]: /url "title" ok

\n````````````````````````````````\n\n\nThis is a link reference definition, but it has no title:\n\n```````````````````````````````` example\n[foo]: /url\n\"title\" ok\n.\n

"title" ok

\n````````````````````````````````\n\n\nThis is not a link reference definition, because it is indented\nfour spaces:\n\n```````````````````````````````` example\n [foo]: /url \"title\"\n\n[foo]\n.\n
[foo]: /url "title"\n
\n

[foo]

\n````````````````````````````````\n\n\nThis is not a link reference definition, because it occurs inside\na code block:\n\n```````````````````````````````` example\n```\n[foo]: /url\n```\n\n[foo]\n.\n
[foo]: /url\n
\n

[foo]

\n````````````````````````````````\n\n\nA [link reference definition] cannot interrupt a paragraph.\n\n```````````````````````````````` example\nFoo\n[bar]: /baz\n\n[bar]\n.\n

Foo\n[bar]: /baz

\n

[bar]

\n````````````````````````````````\n\n\nHowever, it can directly follow other block elements, such as headings\nand thematic breaks, and it need not be followed by a blank line.\n\n```````````````````````````````` example\n# [Foo]\n[foo]: /url\n> bar\n.\n

Foo

\n
\n

bar

\n
\n````````````````````````````````\n\n```````````````````````````````` example\n[foo]: /url\nbar\n===\n[foo]\n.\n

bar

\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\n[foo]: /url\n===\n[foo]\n.\n

===\nfoo

\n````````````````````````````````\n\n\nSeveral [link reference definitions]\ncan occur one after another, without intervening blank lines.\n\n```````````````````````````````` example\n[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n.\n

foo,\nbar,\nbaz

\n````````````````````````````````\n\n\n[Link reference definitions] can occur\ninside block containers, like lists and block quotations. They\naffect the entire document, not just the container in which they\nare defined:\n\n```````````````````````````````` example\n[foo]\n\n> [foo]: /url\n.\n

foo

\n
\n
\n````````````````````````````````\n\n\n" - "## Paragraphs\n\nA sequence of non-blank lines that cannot be interpreted as other\nkinds of blocks forms a [paragraph](@).\nThe contents of the paragraph are the result of parsing the\nparagraph's raw content as inlines. The paragraph's raw content\nis formed by concatenating the lines and removing initial and final\nspaces or tabs.\n\nA simple example with two paragraphs:\n\n```````````````````````````````` example\naaa\n\nbbb\n.\n

aaa

\n

bbb

\n````````````````````````````````\n\n\nParagraphs can contain multiple lines, but no blank lines:\n\n```````````````````````````````` example\naaa\nbbb\n\nccc\nddd\n.\n

aaa\nbbb

\n

ccc\nddd

\n````````````````````````````````\n\n\nMultiple blank lines between paragraphs have no effect:\n\n```````````````````````````````` example\naaa\n\n\nbbb\n.\n

aaa

\n

bbb

\n````````````````````````````````\n\n\nLeading spaces or tabs are skipped:\n\n```````````````````````````````` example\n aaa\n bbb\n.\n

aaa\nbbb

\n````````````````````````````````\n\n\nLines after the first may be indented any amount, since indented\ncode blocks cannot interrupt paragraphs.\n\n```````````````````````````````` example\naaa\n bbb\n ccc\n.\n

aaa\nbbb\nccc

\n````````````````````````````````\n\n\nHowever, the first line may be preceded by up to three spaces of indentation.\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n aaa\nbbb\n.\n

aaa\nbbb

\n````````````````````````````````\n\n\n```````````````````````````````` example\n aaa\nbbb\n.\n
aaa\n
\n

bbb

\n````````````````````````````````\n\n\nFinal spaces or tabs are stripped before inline parsing, so a paragraph\nthat ends with two or more spaces will not end with a [hard line\nbreak]:\n\n```````````````````````````````` example\naaa \nbbb \n.\n

aaa
\nbbb

\n````````````````````````````````\n\n\n## Blank lines\n\n[Blank lines] between block-level elements are ignored,\nexcept for the role they play in determining whether a [list]\nis [tight] or [loose].\n\nBlank lines at the beginning and end of the document are also ignored.\n\n```````````````````````````````` example\n \n\naaa\n \n\n# aaa\n\n \n.\n

aaa

\n

aaa

\n````````````````````````````````\n\n\n\n" - "# Container blocks\n\nA [container block](#container-blocks) is a block that has other\nblocks as its contents. There are two basic kinds of container blocks:\n[block quotes] and [list items].\n[Lists] are meta-containers for [list items].\n\nWe define the syntax for container blocks recursively. The general\nform of the definition is:\n\n> If X is a sequence of blocks, then the result of\n> transforming X in such-and-such a way is a container of type Y\n> with these blocks as its content.\n\nSo, we explain what counts as a block quote or list item by explaining\nhow these can be *generated* from their contents. This should suffice\nto define the syntax, although it does not give a recipe for *parsing*\nthese constructions. (A recipe is provided below in the section entitled\n[A parsing strategy](#appendix-a-parsing-strategy).)\n\n## Block quotes\n\nA [block quote marker](@),\noptionally preceded by up to three spaces of indentation,\nconsists of (a) the character `>` together with a following space of\nindentation, or (b) a single character `>` not followed by a space of\nindentation.\n\nThe following rules define [block quotes]:\n\n1. **Basic case.** If a string of lines *Ls* constitute a sequence\n of blocks *Bs*, then the result of prepending a [block quote\n marker] to the beginning of each line in *Ls*\n is a [block quote](#block-quotes) containing *Bs*.\n\n2. **Laziness.** If a string of lines *Ls* constitute a [block\n quote](#block-quotes) with contents *Bs*, then the result of deleting\n the initial [block quote marker] from one or\n more lines in which the next character other than a space or tab after the\n [block quote marker] is [paragraph continuation\n text] is a block quote with *Bs* as its content.\n [Paragraph continuation text](@) is text\n that will be parsed as part of the content of a paragraph, but does\n not occur at the beginning of the paragraph.\n\n3. **Consecutiveness.** A document cannot contain two [block\n quotes] in a row unless there is a [blank line] between them.\n\nNothing else counts as a [block quote](#block-quotes).\n\nHere is a simple example:\n\n```````````````````````````````` example\n> # Foo\n> bar\n> baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nThe space or tab after the `>` characters can be omitted:\n\n```````````````````````````````` example\n># Foo\n>bar\n> baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nThe `>` characters can be preceded by up to three spaces of indentation:\n\n```````````````````````````````` example\n > # Foo\n > bar\n > baz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nFour spaces of indentation is too many:\n\n```````````````````````````````` example\n > # Foo\n > bar\n > baz\n.\n
> # Foo\n> bar\n> baz\n
\n````````````````````````````````\n\n\nThe Laziness clause allows us to omit the `>` before\n[paragraph continuation text]:\n\n```````````````````````````````` example\n> # Foo\n> bar\nbaz\n.\n
\n

Foo

\n

bar\nbaz

\n
\n````````````````````````````````\n\n\nA block quote can contain some lazy and some non-lazy\ncontinuation lines:\n\n```````````````````````````````` example\n> bar\nbaz\n> foo\n.\n
\n

bar\nbaz\nfoo

\n
\n````````````````````````````````\n\n\nLaziness only applies to lines that would have been continuations of\nparagraphs had they been prepended with [block quote markers].\nFor example, the `> ` cannot be omitted in the second line of\n\n``` markdown\n> foo\n> ---\n```\n\nwithout changing the meaning:\n\n```````````````````````````````` example\n> foo\n---\n.\n
\n

foo

\n
\n
\n````````````````````````````````\n\n\nSimilarly, if we omit the `> ` in the second line of\n\n``` markdown\n> - foo\n> - bar\n```\n\nthen the block quote ends after the first line:\n\n```````````````````````````````` example\n> - foo\n- bar\n.\n
\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n````````````````````````````````\n\n\nFor the same reason, we can't omit the `> ` in front of\nsubsequent lines of an indented or fenced code block:\n\n```````````````````````````````` example\n> foo\n bar\n.\n
\n
foo\n
\n
\n
bar\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> ```\nfoo\n```\n.\n
\n
\n
\n

foo

\n
\n````````````````````````````````\n\n\nNote that in the following case, we have a [lazy\ncontinuation line]:\n\n```````````````````````````````` example\n> foo\n - bar\n.\n
\n

foo\n- bar

\n
\n````````````````````````````````\n\n\nTo see why, note that in\n\n```markdown\n> foo\n> - bar\n```\n\nthe `- bar` is indented too far to start a list, and can't\nbe an indented code block because indented code blocks cannot\ninterrupt paragraphs, so it is [paragraph continuation text].\n\nA block quote can be empty:\n\n```````````````````````````````` example\n>\n.\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n>\n> \n> \n.\n
\n
\n````````````````````````````````\n\n\nA block quote can have initial or final blank lines:\n\n```````````````````````````````` example\n>\n> foo\n> \n.\n
\n

foo

\n
\n````````````````````````````````\n\n\nA blank line always separates block quotes:\n\n```````````````````````````````` example\n> foo\n\n> bar\n.\n
\n

foo

\n
\n
\n

bar

\n
\n````````````````````````````````\n\n\n(Most current Markdown implementations, including John Gruber's\noriginal `Markdown.pl`, will parse this example as a single block quote\nwith two paragraphs. But it seems better to allow the author to decide\nwhether two block quotes or one are wanted.)\n\nConsecutiveness means that if we put these block quotes together,\nwe get a single block quote:\n\n```````````````````````````````` example\n> foo\n> bar\n.\n
\n

foo\nbar

\n
\n````````````````````````````````\n\n\nTo get a block quote with two paragraphs, use:\n\n```````````````````````````````` example\n> foo\n>\n> bar\n.\n
\n

foo

\n

bar

\n
\n````````````````````````````````\n\n\nBlock quotes can interrupt paragraphs:\n\n```````````````````````````````` example\nfoo\n> bar\n.\n

foo

\n
\n

bar

\n
\n````````````````````````````````\n\n\nIn general, blank lines are not needed before or after block\nquotes:\n\n```````````````````````````````` example\n> aaa\n***\n> bbb\n.\n
\n

aaa

\n
\n
\n
\n

bbb

\n
\n````````````````````````````````\n\n\nHowever, because of laziness, a blank line is needed between\na block quote and a following paragraph:\n\n```````````````````````````````` example\n> bar\nbaz\n.\n
\n

bar\nbaz

\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n> bar\n\nbaz\n.\n
\n

bar

\n
\n

baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n> bar\n>\nbaz\n.\n
\n

bar

\n
\n

baz

\n````````````````````````````````\n\n\nIt is a consequence of the Laziness rule that any number\nof initial `>`s may be omitted on a continuation line of a\nnested block quote:\n\n```````````````````````````````` example\n> > > foo\nbar\n.\n
\n
\n
\n

foo\nbar

\n
\n
\n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n>>> foo\n> bar\n>>baz\n.\n
\n
\n
\n

foo\nbar\nbaz

\n
\n
\n
\n````````````````````````````````\n\n\nWhen including an indented code block in a block quote,\nremember that the [block quote marker] includes\nboth the `>` and a following space of indentation. So *five spaces* are needed\nafter the `>`:\n\n```````````````````````````````` example\n> code\n\n> not code\n.\n
\n
code\n
\n
\n
\n

not code

\n
\n````````````````````````````````\n\n\n\n" @@ -25,15 +25,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n(Indeed, the spec for [list items] and [block quotes] presupposes\nthis principle.) This principle implies that if\n\n``` markdown\n * I need to buy\n - new shoes\n - a coat\n - a plane ticket\n```\n\nis a list item containing a paragraph followed by a nested sublist,\nas all Markdown implementations agree it is (though the paragraph\nmay be rendered without `

` tags, since the list is \"tight\"),\nthen\n\n``` markdown\nI need to buy\n- new shoes\n- a coat\n- a plane ticket\n```\n\nby itself should be a paragraph followed by a nested sublist.\n\nSince it is well established Markdown practice to allow lists to\ninterrupt paragraphs inside list items, the [principle of\nuniformity] requires us to allow this outside list items as\nwell. ([reStructuredText](https://docutils.sourceforge.net/rst.html)\ntakes a different approach, requiring blank lines before lists\neven inside other list items.)\n\nIn order to solve the problem of unwanted lists in paragraphs with\nhard-wrapped numerals, we allow only lists starting with `1` to\ninterrupt paragraphs. Thus,\n\n```````````````````````````````` example\nThe number of windows in my house is\n14. The number of doors is 6.\n.\n

The number of windows in my house is\n14. The number of doors is 6.

\n````````````````````````````````\n\nWe may still get an unintended result in cases like\n\n```````````````````````````````` example\nThe number of windows in my house is\n1. The number of doors is 6.\n.\n

The number of windows in my house is

\n
    \n
  1. The number of doors is 6.
  2. \n
\n````````````````````````````````\n\nbut this rule should prevent most spurious list captures.\n\nThere can be any number of blank lines between items:\n\n```````````````````````````````` example\n- foo\n\n- bar\n\n\n- baz\n.\n
    \n
  • \n

    foo

    \n
  • \n
  • \n

    bar

    \n
  • \n
  • \n

    baz

    \n
  • \n
\n````````````````````````````````\n\n```````````````````````````````` example\n- foo\n - bar\n - baz\n\n\n bim\n.\n
    \n
  • foo\n
      \n
    • bar\n
        \n
      • \n

        baz

        \n

        bim

        \n
      • \n
      \n
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nTo separate consecutive lists of the same type, or to separate a\nlist from an indented code block that would otherwise be parsed\nas a subparagraph of the final list item, you can insert a blank HTML\ncomment:\n\n```````````````````````````````` example\n- foo\n- bar\n\n\n\n- baz\n- bim\n.\n
    \n
  • foo
  • \n
  • bar
  • \n
\n\n
    \n
  • baz
  • \n
  • bim
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- foo\n\n notcode\n\n- foo\n\n\n\n code\n.\n
    \n
  • \n

    foo

    \n

    notcode

    \n
  • \n
  • \n

    foo

    \n
  • \n
\n\n
code\n
\n````````````````````````````````\n\n\nList items need not be indented to the same level. The following\nlist items will be treated as items at the same list level,\nsince none is indented enough to belong to the previous list\nitem:\n\n```````````````````````````````` example\n- a\n - b\n - c\n - d\n - e\n - f\n- g\n.\n
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d
  • \n
  • e
  • \n
  • f
  • \n
  • g
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n1. a\n\n 2. b\n\n 3. c\n.\n
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
  5. \n

    c

    \n
  6. \n
\n````````````````````````````````\n\nNote, however, that list items may not be preceded by more than\nthree spaces of indentation. Here `- e` is treated as a paragraph continuation\nline, because it is indented more than three spaces:\n\n```````````````````````````````` example\n- a\n - b\n - c\n - d\n - e\n.\n
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d\n- e
  • \n
\n````````````````````````````````\n\nAnd here, `3. c` is treated as in indented code block,\nbecause it is indented four spaces and preceded by a\nblank line.\n\n```````````````````````````````` example\n1. a\n\n 2. b\n\n 3. c\n.\n
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
\n
3. c\n
\n````````````````````````````````\n\n\nThis is a loose list, because there is a blank line between\ntwo of the list items:\n\n```````````````````````````````` example\n- a\n- b\n\n- c\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    c

    \n
  • \n
\n````````````````````````````````\n\n\nSo is this, with a empty second item:\n\n```````````````````````````````` example\n* a\n*\n\n* c\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n
  • \n

    c

    \n
  • \n
\n````````````````````````````````\n\n\nThese are loose lists, even though there are no blank lines between the items,\nbecause one of the items directly contains two block-level elements\nwith a blank line between them:\n\n```````````````````````````````` example\n- a\n- b\n\n c\n- d\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n

    c

    \n
  • \n
  • \n

    d

    \n
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- a\n- b\n\n [ref]: /url\n- d\n.\n
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    d

    \n
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank lines are in a code block:\n\n```````````````````````````````` example\n- a\n- ```\n b\n\n\n ```\n- c\n.\n
    \n
  • a
  • \n
  • \n
    b\n\n\n
    \n
  • \n
  • c
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank line is between two\nparagraphs of a sublist. So the sublist is loose while\nthe outer list is tight:\n\n```````````````````````````````` example\n- a\n - b\n\n c\n- d\n.\n
    \n
  • a\n
      \n
    • \n

      b

      \n

      c

      \n
    • \n
    \n
  • \n
  • d
  • \n
\n````````````````````````````````\n\n\nThis is a tight list, because the blank line is inside the\nblock quote:\n\n```````````````````````````````` example\n* a\n > b\n >\n* c\n.\n
    \n
  • a\n
    \n

    b

    \n
    \n
  • \n
  • c
  • \n
\n````````````````````````````````\n\n\nThis list is tight, because the consecutive block elements\nare not separated by blank lines:\n\n```````````````````````````````` example\n- a\n > b\n ```\n c\n ```\n- d\n.\n
    \n
  • a\n
    \n

    b

    \n
    \n
    c\n
    \n
  • \n
  • d
  • \n
\n````````````````````````````````\n\n\nA single-paragraph list is tight:\n\n```````````````````````````````` example\n- a\n.\n
    \n
  • a
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- a\n - b\n.\n
    \n
  • a\n
      \n
    • b
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\nThis list is loose, because of the blank line between the\ntwo block elements in the list item:\n\n```````````````````````````````` example\n1. ```\n foo\n ```\n\n bar\n.\n
    \n
  1. \n
    foo\n
    \n

    bar

    \n
  2. \n
\n````````````````````````````````\n\n\nHere the outer list is loose, the inner list tight:\n\n```````````````````````````````` example\n* foo\n * bar\n\n baz\n.\n
    \n
  • \n

    foo

    \n
      \n
    • bar
    • \n
    \n

    baz

    \n
  • \n
\n````````````````````````````````\n\n\n```````````````````````````````` example\n- a\n - b\n - c\n\n- d\n - e\n - f\n.\n
    \n
  • \n

    a

    \n
      \n
    • b
    • \n
    • c
    • \n
    \n
  • \n
  • \n

    d

    \n
      \n
    • e
    • \n
    • f
    • \n
    \n
  • \n
\n````````````````````````````````\n\n\n" - "# Inlines\n\nInlines are parsed sequentially from the beginning of the character\nstream to the end (left to right, in left-to-right languages).\nThus, for example, in\n\n```````````````````````````````` example\n`hi`lo`\n.\n

hilo`

\n````````````````````````````````\n\n`hi` is parsed as code, leaving the backtick at the end as a literal\nbacktick.\n\n\n\n## Code spans\n\nA [backtick string](@)\nis a string of one or more backtick characters (`` ` ``) that is neither\npreceded nor followed by a backtick.\n\nA [code span](@) begins with a backtick string and ends with\na backtick string of equal length. The contents of the code span are\nthe characters between these two backtick strings, normalized in the\nfollowing ways:\n\n- First, [line endings] are converted to [spaces].\n- If the resulting string both begins *and* ends with a [space]\n character, but does not consist entirely of [space]\n characters, a single [space] character is removed from the\n front and back. This allows you to include code that begins\n or ends with backtick characters, which must be separated by\n whitespace from the opening or closing backtick strings.\n\nThis is a simple code span:\n\n```````````````````````````````` example\n`foo`\n.\n

foo

\n````````````````````````````````\n\n\nHere two backticks are used, because the code contains a backtick.\nThis example also illustrates stripping of a single leading and\ntrailing space:\n\n```````````````````````````````` example\n`` foo ` bar ``\n.\n

foo ` bar

\n````````````````````````````````\n\n\nThis example shows the motivation for stripping leading and trailing\nspaces:\n\n```````````````````````````````` example\n` `` `\n.\n

``

\n````````````````````````````````\n\nNote that only *one* space is stripped:\n\n```````````````````````````````` example\n` `` `\n.\n

``

\n````````````````````````````````\n\nThe stripping only happens if the space is on both\nsides of the string:\n\n```````````````````````````````` example\n` a`\n.\n

a

\n````````````````````````````````\n\nOnly [spaces], and not [unicode whitespace] in general, are\nstripped in this way:\n\n```````````````````````````````` example\n` b `\n.\n

 b 

\n````````````````````````````````\n\nNo stripping occurs if the code span contains only spaces:\n\n```````````````````````````````` example\n` `\n` `\n.\n

 \n

\n````````````````````````````````\n\n\n[Line endings] are treated like spaces:\n\n```````````````````````````````` example\n``\nfoo\nbar \nbaz\n``\n.\n

foo bar baz

\n````````````````````````````````\n\n```````````````````````````````` example\n``\nfoo \n``\n.\n

foo

\n````````````````````````````````\n\n\nInterior spaces are not collapsed:\n\n```````````````````````````````` example\n`foo bar \nbaz`\n.\n

foo bar baz

\n````````````````````````````````\n\nNote that browsers will typically collapse consecutive spaces\nwhen rendering `` elements, so it is recommended that\nthe following CSS be used:\n\n code{white-space: pre-wrap;}\n\n\nNote that backslash escapes do not work in code spans. All backslashes\nare treated literally:\n\n```````````````````````````````` example\n`foo\\`bar`\n.\n

foo\\bar`

\n````````````````````````````````\n\n\nBackslash escapes are never needed, because one can always choose a\nstring of *n* backtick characters as delimiters, where the code does\nnot contain any strings of exactly *n* backtick characters.\n\n```````````````````````````````` example\n``foo`bar``\n.\n

foo`bar

\n````````````````````````````````\n\n```````````````````````````````` example\n` foo `` bar `\n.\n

foo `` bar

\n````````````````````````````````\n\n\nCode span backticks have higher precedence than any other inline\nconstructs except HTML tags and autolinks. Thus, for example, this is\nnot parsed as emphasized text, since the second `*` is part of a code\nspan:\n\n```````````````````````````````` example\n*foo`*`\n.\n

*foo*

\n````````````````````````````````\n\n\nAnd this is not parsed as a link:\n\n```````````````````````````````` example\n[not a `link](/foo`)\n.\n

[not a link](/foo)

\n````````````````````````````````\n\n\nCode spans, HTML tags, and autolinks have the same precedence.\nThus, this is code:\n\n```````````````````````````````` example\n``\n.\n

<a href="">`

\n````````````````````````````````\n\n\nBut this is an HTML tag:\n\n```````````````````````````````` example\n
`\n.\n

`

\n````````````````````````````````\n\n\nAnd this is code:\n\n```````````````````````````````` example\n``\n.\n

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

\n````````````````````````````````\n\n\nBut this is an autolink:\n\n```````````````````````````````` example\n`\n.\n

https://foo.bar.`baz`

\n````````````````````````````````\n\n\nWhen a backtick string is not closed by a matching backtick string,\nwe just have literal backticks:\n\n```````````````````````````````` example\n```foo``\n.\n

```foo``

\n````````````````````````````````\n\n\n```````````````````````````````` example\n`foo\n.\n

`foo

\n````````````````````````````````\n\nThe following case also illustrates the need for opening and\nclosing backtick strings to be equal in length:\n\n```````````````````````````````` example\n`foo``bar``\n.\n

`foobar

\n````````````````````````````````\n\n\n" - "## Emphasis and strong emphasis\n\nJohn Gruber's original [Markdown syntax\ndescription](https://daringfireball.net/projects/markdown/syntax#em) says:\n\n> Markdown treats asterisks (`*`) and underscores (`_`) as indicators of\n> emphasis. Text wrapped with one `*` or `_` will be wrapped with an HTML\n> `` tag; double `*`'s or `_`'s will be wrapped with an HTML ``\n> tag.\n\nThis is enough for most users, but these rules leave much undecided,\nespecially when it comes to nested emphasis. The original\n`Markdown.pl` test suite makes it clear that triple `***` and\n`___` delimiters can be used for strong emphasis, and most\nimplementations have also allowed the following patterns:\n\n``` markdown\n***strong emph***\n***strong** in emph*\n***emph* in strong**\n**in strong *emph***\n*in emph **strong***\n```\n\nThe following patterns are less widely supported, but the intent\nis clear and they are useful (especially in contexts like bibliography\nentries):\n\n``` markdown\n*emph *with emph* in it*\n**strong **with strong** in it**\n```\n\nMany implementations have also restricted intraword emphasis to\nthe `*` forms, to avoid unwanted emphasis in words containing\ninternal underscores. (It is best practice to put these in code\nspans, but users often do not.)\n\n``` markdown\ninternal emphasis: foo*bar*baz\nno emphasis: foo_bar_baz\n```\n\nThe rules given below capture all of these patterns, while allowing\nfor efficient parsing strategies that do not backtrack.\n\nFirst, some definitions. A [delimiter run](@) is either\na sequence of one or more `*` characters that is not preceded or\nfollowed by a non-backslash-escaped `*` character, or a sequence\nof one or more `_` characters that is not preceded or followed by\na non-backslash-escaped `_` character.\n\nA [left-flanking delimiter run](@) is\na [delimiter run] that is (1) not followed by [Unicode whitespace],\nand either (2a) not followed by a [Unicode punctuation character], or\n(2b) followed by a [Unicode punctuation character] and\npreceded by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace.\n\nA [right-flanking delimiter run](@) is\na [delimiter run] that is (1) not preceded by [Unicode whitespace],\nand either (2a) not preceded by a [Unicode punctuation character], or\n(2b) preceded by a [Unicode punctuation character] and\nfollowed by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace.\n\nHere are some examples of delimiter runs.\n\n - left-flanking but not right-flanking:\n\n ```\n ***abc\n _abc\n **\"abc\"\n _\"abc\"\n ```\n\n - right-flanking but not left-flanking:\n\n ```\n abc***\n abc_\n \"abc\"**\n \"abc\"_\n ```\n\n - Both left and right-flanking:\n\n ```\n abc***def\n \"abc\"_\"def\"\n ```\n\n - Neither left nor right-flanking:\n\n ```\n abc *** def\n a _ b\n ```\n\n(The idea of distinguishing left-flanking and right-flanking\ndelimiter runs based on the character before and the character\nafter comes from Roopesh Chander's\n[vfmd](https://web.archive.org/web/20220608143320/http://www.vfmd.org/vfmd-spec/specification/#procedure-for-identifying-emphasis-tags).\nvfmd uses the terminology \"emphasis indicator string\" instead of \"delimiter\nrun,\" and its rules for distinguishing left- and right-flanking runs\nare a bit more complex than the ones given here.)\n\nThe following rules define emphasis and strong emphasis:\n\n1. A single `*` character [can open emphasis](@)\n iff (if and only if) it is part of a [left-flanking delimiter run].\n\n2. A single `_` character [can open emphasis] iff\n it is part of a [left-flanking delimiter run]\n and either (a) not part of a [right-flanking delimiter run]\n or (b) part of a [right-flanking delimiter run]\n preceded by a [Unicode punctuation character].\n\n3. A single `*` character [can close emphasis](@)\n iff it is part of a [right-flanking delimiter run].\n\n4. A single `_` character [can close emphasis] iff\n it is part of a [right-flanking delimiter run]\n and either (a) not part of a [left-flanking delimiter run]\n or (b) part of a [left-flanking delimiter run]\n followed by a [Unicode punctuation character].\n\n5. A double `**` [can open strong emphasis](@)\n iff it is part of a [left-flanking delimiter run].\n\n6. A double `__` [can open strong emphasis] iff\n it is part of a [left-flanking delimiter run]\n and either (a) not part of a [right-flanking delimiter run]\n or (b) part of a [right-flanking delimiter run]\n preceded by a [Unicode punctuation character].\n\n7. A double `**` [can close strong emphasis](@)\n iff it is part of a [right-flanking delimiter run].\n\n8. A double `__` [can close strong emphasis] iff\n it is part of a [right-flanking delimiter run]\n and either (a) not part of a [left-flanking delimiter run]\n or (b) part of a [left-flanking delimiter run]\n followed by a [Unicode punctuation character].\n\n9. Emphasis begins with a delimiter that [can open emphasis] and ends\n with a delimiter that [can close emphasis], and that uses the same\n character (`_` or `*`) as the opening delimiter. The\n opening and closing delimiters must belong to separate\n [delimiter runs]. If one of the delimiters can both\n open and close emphasis, then the sum of the lengths of the\n delimiter runs containing the opening and closing delimiters\n must not be a multiple of 3 unless both lengths are\n multiples of 3.\n\n10. Strong emphasis begins with a delimiter that\n [can open strong emphasis] and ends with a delimiter that\n [can close strong emphasis], and that uses the same character\n (`_` or `*`) as the opening delimiter. The\n opening and closing delimiters must belong to separate\n [delimiter runs]. If one of the delimiters can both open\n and close strong emphasis, then the sum of the lengths of\n the delimiter runs containing the opening and closing\n delimiters must not be a multiple of 3 unless both lengths\n are multiples of 3.\n\n11. A literal `*` character cannot occur at the beginning or end of\n `*`-delimited emphasis or `**`-delimited strong emphasis, unless it\n is backslash-escaped.\n\n12. A literal `_` character cannot occur at the beginning or end of\n `_`-delimited emphasis or `__`-delimited strong emphasis, unless it\n is backslash-escaped.\n\nWhere rules 1--12 above are compatible with multiple parsings,\nthe following principles resolve ambiguity:\n\n13. The number of nestings should be minimized. Thus, for example,\n an interpretation `...` is always preferred to\n `...`.\n\n14. An interpretation `...` is always\n preferred to `...`.\n\n15. When two potential emphasis or strong emphasis spans overlap,\n so that the second begins before the first ends and ends after\n the first ends, the first takes precedence. Thus, for example,\n `*foo _bar* baz_` is parsed as `foo _bar baz_` rather\n than `*foo bar* baz`.\n\n16. When there are two potential emphasis or strong emphasis spans\n with the same closing delimiter, the shorter one (the one that\n opens later) takes precedence. Thus, for example,\n `**foo **bar baz**` is parsed as `**foo bar baz`\n rather than `foo **bar baz`.\n\n17. Inline code spans, links, images, and HTML tags group more tightly\n than emphasis. So, when there is a choice between an interpretation\n that contains one of these elements and one that does not, the\n former always wins. Thus, for example, `*[foo*](bar)` is\n parsed as `*foo*` rather than as\n `[foo](bar)`.\n\n" -- "These rules can be illustrated through a series of examples.\n\nRule 1:\n\n```````````````````````````````` example\n*foo bar*\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `*` is followed by\nwhitespace, and hence not part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na * foo bar*\n.\n

a * foo bar*

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `*` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na*\"foo\"*\n.\n

a*"foo"*

\n````````````````````````````````\n\n\nUnicode nonbreaking spaces count as whitespace, too:\n\n```````````````````````````````` example\n* a *\n.\n

* a *

\n````````````````````````````````\n\n\nUnicode symbols count as punctuation, too:\n\n```````````````````````````````` example\n*$*alpha.\n\n*£*bravo.\n\n*€*charlie.\n.\n

*$*alpha.

\n

*£*bravo.

\n

*€*charlie.

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is permitted:\n\n```````````````````````````````` example\nfoo*bar*\n.\n

foobar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5*6*78\n.\n

5678

\n````````````````````````````````\n\n\nRule 2:\n\n```````````````````````````````` example\n_foo bar_\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is followed by\nwhitespace:\n\n```````````````````````````````` example\n_ foo bar_\n.\n

_ foo bar_

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na_\"foo\"_\n.\n

a_"foo"_

\n````````````````````````````````\n\n\nEmphasis with `_` is not allowed inside words:\n\n```````````````````````````````` example\nfoo_bar_\n.\n

foo_bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5_6_78\n.\n

5_6_78

\n````````````````````````````````\n\n\n```````````````````````````````` example\nпристаням_стремятся_\n.\n

пристаням_стремятся_

\n````````````````````````````````\n\n\nHere `_` does not generate emphasis, because the first delimiter run\nis right-flanking and the second left-flanking:\n\n```````````````````````````````` example\naa_\"bb\"_cc\n.\n

aa_"bb"_cc

\n````````````````````````````````\n\n\nThis is emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-_(bar)_\n.\n

foo-(bar)

\n````````````````````````````````\n\n\nRule 3:\n\nThis is not emphasis, because the closing delimiter does\nnot match the opening delimiter:\n\n```````````````````````````````` example\n_foo*\n.\n

_foo*

\n````````````````````````````````\n\n\nThis is not emphasis, because the closing `*` is preceded by\nwhitespace:\n\n```````````````````````````````` example\n*foo bar *\n.\n

*foo bar *

\n````````````````````````````````\n\n\nA line ending also counts as whitespace:\n\n```````````````````````````````` example\n*foo bar\n*\n.\n

*foo bar\n*

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `*` is\npreceded by punctuation and followed by an alphanumeric\n(hence it is not part of a [right-flanking delimiter run]:\n\n```````````````````````````````` example\n*(*foo)\n.\n

*(*foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n\n```````````````````````````````` example\n*(*foo*)*\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is allowed:\n\n```````````````````````````````` example\n*foo*bar\n.\n

foobar

\n````````````````````````````````\n\n\n\nRule 4:\n\nThis is not emphasis, because the closing `_` is preceded by\nwhitespace:\n\n```````````````````````````````` example\n_foo bar _\n.\n

_foo bar _

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `_` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n_(_foo)\n.\n

_(_foo)

\n````````````````````````````````\n\n\nThis is emphasis within emphasis:\n\n```````````````````````````````` example\n_(_foo_)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis is disallowed for `_`:\n\n```````````````````````````````` example\n_foo_bar\n.\n

_foo_bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_пристаням_стремятся\n.\n

_пристаням_стремятся

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo_bar_baz_\n.\n

foo_bar_baz

\n````````````````````````````````\n\n\nThis is emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n\n```````````````````````````````` example\n_(bar)_.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 5:\n\n```````````````````````````````` example\n**foo bar**\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n** foo bar**\n.\n

** foo bar**

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `**` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na**\"foo\"**\n.\n

a**"foo"**

\n````````````````````````````````\n\n\nIntraword strong emphasis with `**` is permitted:\n\n```````````````````````````````` example\nfoo**bar**\n.\n

foobar

\n````````````````````````````````\n\n\nRule 6:\n\n```````````````````````````````` example\n__foo bar__\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n__ foo bar__\n.\n

__ foo bar__

\n````````````````````````````````\n\n\nA line ending counts as whitespace:\n```````````````````````````````` example\n__\nfoo bar__\n.\n

__\nfoo bar__

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `__` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na__\"foo\"__\n.\n

a__"foo"__

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n\n```````````````````````````````` example\nfoo__bar__\n.\n

foo__bar__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5__6__78\n.\n

5__6__78

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\nпристаням__стремятся__\n.\n

пристаням__стремятся__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo, __bar__, baz__\n.\n

foo, bar, baz

\n````````````````````````````````\n\n\nThis is strong emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-__(bar)__\n.\n

foo-(bar)

\n````````````````````````````````\n\n\n\nRule 7:\n\nThis is not strong emphasis, because the closing delimiter is preceded\nby whitespace:\n\n```````````````````````````````` example\n**foo bar **\n.\n

**foo bar **

\n````````````````````````````````\n\n\n(Nor can it be interpreted as an emphasized `*foo bar *`, because of\nRule 11.)\n\nThis is not strong emphasis, because the second `**` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n**(**foo)\n.\n

**(**foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith these examples:\n\n```````````````````````````````` example\n*(**foo**)*\n.\n

(foo)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n.\n

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo \"*bar*\" foo**\n.\n

foo "bar" foo

\n````````````````````````````````\n\n\nIntraword emphasis:\n\n```````````````````````````````` example\n**foo**bar\n.\n

foobar

\n````````````````````````````````\n\n\nRule 8:\n\nThis is not strong emphasis, because the closing delimiter is\npreceded by whitespace:\n\n```````````````````````````````` example\n__foo bar __\n.\n

__foo bar __

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the second `__` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n__(__foo)\n.\n

__(__foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n\n```````````````````````````````` example\n_(__foo__)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n\n```````````````````````````````` example\n__foo__bar\n.\n

__foo__bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__пристаням__стремятся\n.\n

__пристаням__стремятся

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo__bar__baz__\n.\n

foo__bar__baz

\n````````````````````````````````\n\n\nThis is strong emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n\n```````````````````````````````` example\n__(bar)__.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 9:\n\nAny nonempty sequence of inline elements can be the contents of an\nemphasized span.\n\n```````````````````````````````` example\n*foo [bar](/url)*\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo\nbar*\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside emphasis:\n\n```````````````````````````````` example\n_foo __bar__ baz_\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo _bar_ baz_\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo_ bar_\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo *bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo **bar** baz*\n.\n

foo bar baz

\n````````````````````````````````\n\n```````````````````````````````` example\n*foo**bar**baz*\n.\n

foobarbaz

\n````````````````````````````````\n\nNote that in the preceding case, the interpretation\n\n``` markdown\n

foobarbaz

\n```\n\n\nis precluded by the condition that a delimiter that\ncan both open and close (like the `*` after `foo`)\ncannot form emphasis if the sum of the lengths of\nthe delimiter runs containing the opening and\nclosing delimiters is a multiple of 3 unless\nboth lengths are multiples of 3.\n\n\nFor the same reason, we don't get two consecutive\nemphasis sections in this example:\n\n```````````````````````````````` example\n*foo**bar*\n.\n

foo**bar

\n````````````````````````````````\n\n\nThe same condition ensures that the following\ncases are all strong emphasis nested inside\nemphasis, even when the interior whitespace is\nomitted:\n\n\n```````````````````````````````` example\n***foo** bar*\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo **bar***\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**bar***\n.\n

foobar

\n````````````````````````````````\n\n\nWhen the lengths of the interior closing and opening\ndelimiter runs are *both* multiples of 3, though,\nthey can match to create emphasis:\n\n```````````````````````````````` example\nfoo***bar***baz\n.\n

foobarbaz

\n````````````````````````````````\n\n```````````````````````````````` example\nfoo******bar*********baz\n.\n

foobar***baz

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n\n```````````````````````````````` example\n*foo **bar *baz* bim** bop*\n.\n

foo bar baz bim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo [*bar*](/url)*\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n\n```````````````````````````````` example\n** is not an empty emphasis\n.\n

** is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**** is not an empty strong emphasis\n.\n

**** is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 10:\n\nAny nonempty sequence of inline elements can be the contents of an\nstrongly emphasized span.\n\n```````````````````````````````` example\n**foo [bar](/url)**\n.\n

foo bar

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n**foo\nbar**\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside strong emphasis:\n\n```````````````````````````````` example\n__foo _bar_ baz__\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo __bar__ baz__\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo__ bar__\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo **bar****\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo *bar* baz**\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo*bar*baz**\n.\n

foobarbaz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n***foo* bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo *bar***\n.\n

foo bar

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n\n```````````````````````````````` example\n**foo *bar **baz**\nbim* bop**\n.\n

foo bar baz\nbim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo [*bar*](/url)**\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n\n```````````````````````````````` example\n__ is not an empty emphasis\n.\n

__ is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____ is not an empty strong emphasis\n.\n

____ is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 11:\n\n```````````````````````````````` example\nfoo ***\n.\n

foo ***

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *\\**\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *_*\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *****\n.\n

foo *****

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo **\\***\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo **_**\n.\n

foo _

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 11 determines\nthat the excess literal `*` characters will appear outside of the\nemphasis, rather than inside it:\n\n```````````````````````````````` example\n**foo*\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**\n.\n

foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n***foo**\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n****foo*\n.\n

***foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo***\n.\n

foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo****\n.\n

foo***

\n````````````````````````````````\n\n\n\nRule 12:\n\n```````````````````````````````` example\nfoo ___\n.\n

foo ___

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _\\__\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _*_\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _____\n.\n

foo _____

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo __\\___\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo __*__\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo_\n.\n

_foo

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 12 determines\nthat the excess literal `_` characters will appear outside of the\nemphasis, rather than inside it:\n\n```````````````````````````````` example\n_foo__\n.\n

foo_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n___foo__\n.\n

_foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo_\n.\n

___foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo___\n.\n

foo_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo____\n.\n

foo___

\n````````````````````````````````\n\n\nRule 13 implies that if you want emphasis nested directly inside\nemphasis, you must use different delimiters:\n\n```````````````````````````````` example\n**foo**\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*_foo_*\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo__\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_*foo*_\n.\n

foo

\n````````````````````````````````\n\n\nHowever, strong emphasis within strong emphasis is possible without\nswitching delimiters:\n\n```````````````````````````````` example\n****foo****\n.\n

foo

\n````````````````````````````````\n\n\n" -- "```````````````````````````````` example\n____foo____\n.\n

foo

\n````````````````````````````````\n\n\n\nRule 13 can be applied to arbitrarily long sequences of\ndelimiters:\n\n```````````````````````````````` example\n******foo******\n.\n

foo

\n````````````````````````````````\n\n\nRule 14:\n\n```````````````````````````````` example\n***foo***\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_____foo_____\n.\n

foo

\n````````````````````````````````\n\n\nRule 15:\n\n```````````````````````````````` example\n*foo _bar* baz_\n.\n

foo _bar baz_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo __bar *baz bim__ bam*\n.\n

foo bar *baz bim bam

\n````````````````````````````````\n\n\nRule 16:\n\n```````````````````````````````` example\n**foo **bar baz**\n.\n

**foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo *bar baz*\n.\n

*foo bar baz

\n````````````````````````````````\n\n\nRule 17:\n\n```````````````````````````````` example\n*[bar*](/url)\n.\n

*bar*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo [bar_](/url)\n.\n

_foo bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*\n.\n

*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**\n.\n

**

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__\n.\n

__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*a `*`*\n.\n

a *

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_a `_`_\n.\n

a _

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**a\n.\n

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

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__a\n.\n

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

\n````````````````````````````````\n\n\n\n" +- "These rules can be illustrated through a series of examples.\n\nRule 1:\n\n```````````````````````````````` example\n*foo bar*\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `*` is followed by\nwhitespace, and hence not part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na * foo bar*\n.\n

a * foo bar*

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `*` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na*\"foo\"*\n.\n

a*"foo"*

\n````````````````````````````````\n\n\nUnicode nonbreaking spaces count as whitespace, too:\n\n```````````````````````````````` example\n* a *\n.\n

* a *

\n````````````````````````````````\n\n\nUnicode symbols count as punctuation, too:\n\n```````````````````````````````` example\n*$*alpha.\n\n*£*bravo.\n\n*€*charlie.\n.\n

*$*alpha.

\n

*£*bravo.

\n

*€*charlie.

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is permitted:\n\n```````````````````````````````` example\nfoo*bar*\n.\n

foobar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5*6*78\n.\n

5678

\n````````````````````````````````\n\n\nRule 2:\n\n```````````````````````````````` example\n_foo bar_\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is followed by\nwhitespace:\n\n```````````````````````````````` example\n_ foo bar_\n.\n

_ foo bar_

\n````````````````````````````````\n\n\nThis is not emphasis, because the opening `_` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na_\"foo\"_\n.\n

a_"foo"_

\n````````````````````````````````\n\n\nEmphasis with `_` is not allowed inside words:\n\n```````````````````````````````` example\nfoo_bar_\n.\n

foo_bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5_6_78\n.\n

5_6_78

\n````````````````````````````````\n\n\n```````````````````````````````` example\nпристаням_стремятся_\n.\n

пристаням_стремятся_

\n````````````````````````````````\n\n\nHere `_` does not generate emphasis, because the first delimiter run\nis right-flanking and the second left-flanking:\n\n```````````````````````````````` example\naa_\"bb\"_cc\n.\n

aa_"bb"_cc

\n````````````````````````````````\n\n\nThis is emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-_(bar)_\n.\n

foo-(bar)

\n````````````````````````````````\n\n\nRule 3:\n\nThis is not emphasis, because the closing delimiter does\nnot match the opening delimiter:\n\n```````````````````````````````` example\n_foo*\n.\n

_foo*

\n````````````````````````````````\n\n\nThis is not emphasis, because the closing `*` is preceded by\nwhitespace:\n\n```````````````````````````````` example\n*foo bar *\n.\n

*foo bar *

\n````````````````````````````````\n\n\nA line ending also counts as whitespace:\n\n```````````````````````````````` example\n*foo bar\n*\n.\n

*foo bar\n*

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `*` is\npreceded by punctuation and followed by an alphanumeric\n(hence it is not part of a [right-flanking delimiter run]:\n\n```````````````````````````````` example\n*(*foo)\n.\n

*(*foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n\n```````````````````````````````` example\n*(*foo*)*\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis with `*` is allowed:\n\n```````````````````````````````` example\n*foo*bar\n.\n

foobar

\n````````````````````````````````\n\n\n\nRule 4:\n\nThis is not emphasis, because the closing `_` is preceded by\nwhitespace:\n\n```````````````````````````````` example\n_foo bar _\n.\n

_foo bar _

\n````````````````````````````````\n\n\nThis is not emphasis, because the second `_` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n_(_foo)\n.\n

_(_foo)

\n````````````````````````````````\n\n\nThis is emphasis within emphasis:\n\n```````````````````````````````` example\n_(_foo_)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword emphasis is disallowed for `_`:\n\n```````````````````````````````` example\n_foo_bar\n.\n

_foo_bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_пристаням_стремятся\n.\n

_пристаням_стремятся

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo_bar_baz_\n.\n

foo_bar_baz

\n````````````````````````````````\n\n\nThis is emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n\n```````````````````````````````` example\n_(bar)_.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 5:\n\n```````````````````````````````` example\n**foo bar**\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n** foo bar**\n.\n

** foo bar**

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `**` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na**\"foo\"**\n.\n

a**"foo"**

\n````````````````````````````````\n\n\nIntraword strong emphasis with `**` is permitted:\n\n```````````````````````````````` example\nfoo**bar**\n.\n

foobar

\n````````````````````````````````\n\n\nRule 6:\n\n```````````````````````````````` example\n__foo bar__\n.\n

foo bar

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening delimiter is\nfollowed by whitespace:\n\n```````````````````````````````` example\n__ foo bar__\n.\n

__ foo bar__

\n````````````````````````````````\n\n\nA line ending counts as whitespace:\n```````````````````````````````` example\n__\nfoo bar__\n.\n

__\nfoo bar__

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the opening `__` is preceded\nby an alphanumeric and followed by punctuation:\n\n```````````````````````````````` example\na__\"foo\"__\n.\n

a__"foo"__

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n\n```````````````````````````````` example\nfoo__bar__\n.\n

foo__bar__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n5__6__78\n.\n

5__6__78

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\nпристаням__стремятся__\n.\n

пристаням__стремятся__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo, __bar__, baz__\n.\n

foo, bar, baz

\n````````````````````````````````\n\n\nThis is strong emphasis, even though the opening delimiter is\nboth left- and right-flanking, because it is preceded by\npunctuation:\n\n```````````````````````````````` example\nfoo-__(bar)__\n.\n

foo-(bar)

\n````````````````````````````````\n\n\n\nRule 7:\n\nThis is not strong emphasis, because the closing delimiter is preceded\nby whitespace:\n\n```````````````````````````````` example\n**foo bar **\n.\n

**foo bar **

\n````````````````````````````````\n\n\n(Nor can it be interpreted as an emphasized `*foo bar *`, because of\nRule 11.)\n\nThis is not strong emphasis, because the second `**` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n**(**foo)\n.\n

**(**foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith these examples:\n\n```````````````````````````````` example\n*(**foo**)*\n.\n

(foo)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n.\n

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo \"*bar*\" foo**\n.\n

foo "bar" foo

\n````````````````````````````````\n\n\nIntraword emphasis:\n\n```````````````````````````````` example\n**foo**bar\n.\n

foobar

\n````````````````````````````````\n\n\nRule 8:\n\nThis is not strong emphasis, because the closing delimiter is\npreceded by whitespace:\n\n```````````````````````````````` example\n__foo bar __\n.\n

__foo bar __

\n````````````````````````````````\n\n\nThis is not strong emphasis, because the second `__` is\npreceded by punctuation and followed by an alphanumeric:\n\n```````````````````````````````` example\n__(__foo)\n.\n

__(__foo)

\n````````````````````````````````\n\n\nThe point of this restriction is more easily appreciated\nwith this example:\n\n```````````````````````````````` example\n_(__foo__)_\n.\n

(foo)

\n````````````````````````````````\n\n\nIntraword strong emphasis is forbidden with `__`:\n\n```````````````````````````````` example\n__foo__bar\n.\n

__foo__bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__пристаням__стремятся\n.\n

__пристаням__стремятся

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo__bar__baz__\n.\n

foo__bar__baz

\n````````````````````````````````\n\n\nThis is strong emphasis, even though the closing delimiter is\nboth left- and right-flanking, because it is followed by\npunctuation:\n\n```````````````````````````````` example\n__(bar)__.\n.\n

(bar).

\n````````````````````````````````\n\n\nRule 9:\n\nAny nonempty sequence of inline elements can be the contents of an\nemphasized span.\n\n```````````````````````````````` example\n*foo [bar](/url)*\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo\nbar*\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside emphasis:\n\n```````````````````````````````` example\n_foo __bar__ baz_\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo _bar_ baz_\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo_ bar_\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo *bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo **bar** baz*\n.\n

foo bar baz

\n````````````````````````````````\n\n```````````````````````````````` example\n*foo**bar**baz*\n.\n

foobarbaz

\n````````````````````````````````\n\nNote that in the preceding case, the interpretation\n\n``` markdown\n

foobarbaz

\n```\n\n\nis precluded by the condition that a delimiter that\ncan both open and close (like the `*` after `foo`)\ncannot form emphasis if the sum of the lengths of\nthe delimiter runs containing the opening and\nclosing delimiters is a multiple of 3 unless\nboth lengths are multiples of 3.\n\n\nFor the same reason, we don't get two consecutive\nemphasis sections in this example:\n\n```````````````````````````````` example\n*foo**bar*\n.\n

foo**bar

\n````````````````````````````````\n\n\nThe same condition ensures that the following\ncases are all strong emphasis nested inside\nemphasis, even when the interior whitespace is\nomitted:\n\n\n```````````````````````````````` example\n***foo** bar*\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo **bar***\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**bar***\n.\n

foobar

\n````````````````````````````````\n\n\nWhen the lengths of the interior closing and opening\ndelimiter runs are *both* multiples of 3, though,\nthey can match to create emphasis:\n\n```````````````````````````````` example\nfoo***bar***baz\n.\n

foobarbaz

\n````````````````````````````````\n\n```````````````````````````````` example\nfoo******bar*********baz\n.\n

foobar***baz

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n\n```````````````````````````````` example\n*foo **bar *baz* bim** bop*\n.\n

foo bar baz bim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo [*bar*](/url)*\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n\n```````````````````````````````` example\n** is not an empty emphasis\n.\n

** is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**** is not an empty strong emphasis\n.\n

**** is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 10:\n\nAny nonempty sequence of inline elements can be the contents of an\nstrongly emphasized span.\n\n```````````````````````````````` example\n**foo [bar](/url)**\n.\n

foo bar

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n**foo\nbar**\n.\n

foo\nbar

\n````````````````````````````````\n\n\nIn particular, emphasis and strong emphasis can be nested\ninside strong emphasis:\n\n```````````````````````````````` example\n__foo _bar_ baz__\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo __bar__ baz__\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo__ bar__\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo **bar****\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo *bar* baz**\n.\n

foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo*bar*baz**\n.\n

foobarbaz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n***foo* bar**\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo *bar***\n.\n

foo bar

\n````````````````````````````````\n\n\nIndefinite levels of nesting are possible:\n\n```````````````````````````````` example\n**foo *bar **baz**\nbim* bop**\n.\n

foo bar baz\nbim bop

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo [*bar*](/url)**\n.\n

foo bar

\n````````````````````````````````\n\n\nThere can be no empty emphasis or strong emphasis:\n\n```````````````````````````````` example\n__ is not an empty emphasis\n.\n

__ is not an empty emphasis

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____ is not an empty strong emphasis\n.\n

____ is not an empty strong emphasis

\n````````````````````````````````\n\n\n\nRule 11:\n\n```````````````````````````````` example\nfoo ***\n.\n

foo ***

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *\\**\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *_*\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo *****\n.\n

foo *****

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo **\\***\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo **_**\n.\n

foo _

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 11 determines\nthat the excess literal `*` characters will appear outside of the\nemphasis, rather than inside it:\n\n```````````````````````````````` example\n**foo*\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo**\n.\n

foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n***foo**\n.\n

*foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n****foo*\n.\n

***foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**foo***\n.\n

foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo****\n.\n

foo***

\n````````````````````````````````\n\n\n\nRule 12:\n\n```````````````````````````````` example\nfoo ___\n.\n

foo ___

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _\\__\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _*_\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo _____\n.\n

foo _____

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo __\\___\n.\n

foo _

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo __*__\n.\n

foo *

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo_\n.\n

_foo

\n````````````````````````````````\n\n\nNote that when delimiters do not match evenly, Rule 12 determines\nthat the excess literal `_` characters will appear outside of the\nemphasis, rather than inside it:\n\n```````````````````````````````` example\n_foo__\n.\n

foo_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n___foo__\n.\n

_foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n____foo_\n.\n

___foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo___\n.\n

foo_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo____\n.\n

foo___

\n````````````````````````````````\n\n\nRule 13 implies that if you want emphasis nested directly inside\nemphasis, you must use different delimiters:\n\n```````````````````````````````` example\n**foo**\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*_foo_*\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__foo__\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_*foo*_\n.\n

foo

\n````````````````````````````````\n\n\nHowever, strong emphasis within strong emphasis is possible without\nswitching delimiters:\n\n```````````````````````````````` example\n****foo****\n.\n

foo

\n````````````````````````````````" +- "\n\n\n```````````````````````````````` example\n____foo____\n.\n

foo

\n````````````````````````````````\n\n\n\nRule 13 can be applied to arbitrarily long sequences of\ndelimiters:\n\n```````````````````````````````` example\n******foo******\n.\n

foo

\n````````````````````````````````\n\n\nRule 14:\n\n```````````````````````````````` example\n***foo***\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_____foo_____\n.\n

foo

\n````````````````````````````````\n\n\nRule 15:\n\n```````````````````````````````` example\n*foo _bar* baz_\n.\n

foo _bar baz_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo __bar *baz bim__ bam*\n.\n

foo bar *baz bim bam

\n````````````````````````````````\n\n\nRule 16:\n\n```````````````````````````````` example\n**foo **bar baz**\n.\n

**foo bar baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo *bar baz*\n.\n

*foo bar baz

\n````````````````````````````````\n\n\nRule 17:\n\n```````````````````````````````` example\n*[bar*](/url)\n.\n

*bar*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_foo [bar_](/url)\n.\n

_foo bar_

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*\n.\n

*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**\n.\n

**

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__\n.\n

__

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*a `*`*\n.\n

a *

\n````````````````````````````````\n\n\n```````````````````````````````` example\n_a `_`_\n.\n

a _

\n````````````````````````````````\n\n\n```````````````````````````````` example\n**a\n.\n

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

\n````````````````````````````````\n\n\n```````````````````````````````` example\n__a\n.\n

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

\n````````````````````````````````\n\n\n\n" - "## Links\n\nA link contains [link text] (the visible text), a [link destination]\n(the URI that is the link destination), and optionally a [link title].\nThere are two basic kinds of links in Markdown. In [inline links] the\ndestination and title are given immediately after the link text. In\n[reference links] the destination and title are defined elsewhere in\nthe document.\n\nA [link text](@) consists of a sequence of zero or more\ninline elements enclosed by square brackets (`[` and `]`). The\nfollowing rules apply:\n\n- Links may not contain other links, at any level of nesting. If\n multiple otherwise valid link definitions appear nested inside each\n other, the inner-most definition is used.\n\n- Brackets are allowed in the [link text] only if (a) they\n are backslash-escaped or (b) they appear as a matched pair of brackets,\n with an open bracket `[`, a sequence of zero or more inlines, and\n a close bracket `]`.\n\n- Backtick [code spans], [autolinks], and raw [HTML tags] bind more tightly\n than the brackets in link text. Thus, for example,\n `` [foo`]` `` could not be a link text, since the second `]`\n is part of a code span.\n\n- The brackets in link text bind more tightly than markers for\n [emphasis and strong emphasis]. Thus, for example, `*[foo*](url)` is a link.\n\nA [link destination](@) consists of either\n\n- a sequence of zero or more characters between an opening `<` and a\n closing `>` that contains no line endings or unescaped\n `<` or `>` characters, or\n\n- a nonempty sequence of characters that does not start with `<`,\n does not include [ASCII control characters][ASCII control character]\n or [space] character, and includes parentheses only if (a) they are\n backslash-escaped or (b) they are part of a balanced pair of\n unescaped parentheses.\n (Implementations may impose limits on parentheses nesting to\n avoid performance issues, but at least three levels of nesting\n should be supported.)\n\nA [link title](@) consists of either\n\n- a sequence of zero or more characters between straight double-quote\n characters (`\"`), including a `\"` character only if it is\n backslash-escaped, or\n\n- a sequence of zero or more characters between straight single-quote\n characters (`'`), including a `'` character only if it is\n backslash-escaped, or\n\n- a sequence of zero or more characters between matching parentheses\n (`(...)`), including a `(` or `)` character only if it is\n backslash-escaped.\n\n" -- "Although [link titles] may span multiple lines, they may not contain\na [blank line].\n\nAn [inline link](@) consists of a [link text] followed immediately\nby a left parenthesis `(`, an optional [link destination], an optional\n[link title], and a right parenthesis `)`.\nThese four components may be separated by spaces, tabs, and up to one line\nending.\nIf both [link destination] and [link title] are present, they *must* be\nseparated by spaces, tabs, and up to one line ending.\n\nThe link's text consists of the inlines contained\nin the [link text] (excluding the enclosing square brackets).\nThe link's URI consists of the link destination, excluding enclosing\n`<...>` if present, with backslash-escapes in effect as described\nabove. The link's title consists of the link title, excluding its\nenclosing delimiters, with backslash-escapes in effect as described\nabove.\n\nHere is a simple inline link:\n\n```````````````````````````````` example\n[link](/uri \"title\")\n.\n

link

\n````````````````````````````````\n\n\nThe title, the link text and even \nthe destination may be omitted:\n\n```````````````````````````````` example\n[link](/uri)\n.\n

link

\n````````````````````````````````\n\n```````````````````````````````` example\n[](./target.md)\n.\n

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link](<>)\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[]()\n.\n

\n````````````````````````````````\n\nThe destination can only contain spaces if it is\nenclosed in pointy brackets:\n\n```````````````````````````````` example\n[link](/my uri)\n.\n

[link](/my uri)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link](
)\n.\n

link

\n````````````````````````````````\n\nThe destination cannot contain line endings,\neven if enclosed in pointy brackets:\n\n```````````````````````````````` example\n[link](foo\nbar)\n.\n

[link](foo\nbar)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link]()\n.\n

[link]()

\n````````````````````````````````\n\nThe destination can contain `)` if it is enclosed\nin pointy brackets:\n\n```````````````````````````````` example\n[a]()\n.\n

a

\n````````````````````````````````\n\nPointy brackets that enclose links must be unescaped:\n\n```````````````````````````````` example\n[link]()\n.\n

[link](<foo>)

\n````````````````````````````````\n\nThese are not links, because the opening pointy bracket\nis not matched properly:\n\n```````````````````````````````` example\n[a](\n[a](c)\n.\n

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

\n````````````````````````````````\n\nParentheses inside the link destination may be escaped:\n\n```````````````````````````````` example\n[link](\\(foo\\))\n.\n

link

\n````````````````````````````````\n\nAny number of parentheses are allowed without escaping, as long as they are\nbalanced:\n\n```````````````````````````````` example\n[link](foo(and(bar)))\n.\n

link

\n````````````````````````````````\n\nHowever, if you have unbalanced parentheses, you need to escape or use the\n`<...>` form:\n\n```````````````````````````````` example\n[link](foo(and(bar))\n.\n

[link](foo(and(bar))

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link](foo\\(and\\(bar\\))\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\n\nParentheses and other symbols can also be escaped, as usual\nin Markdown:\n\n```````````````````````````````` example\n[link](foo\\)\\:)\n.\n

link

\n````````````````````````````````\n\n\nA link can contain fragment identifiers and queries:\n\n```````````````````````````````` example\n[link](#fragment)\n\n[link](https://example.com#fragment)\n\n[link](https://example.com?foo=3#frag)\n.\n

link

\n

link

\n

link

\n````````````````````````````````\n\n\nNote that a backslash before a non-escapable character is\njust a backslash:\n\n```````````````````````````````` example\n[link](foo\\bar)\n.\n

link

\n````````````````````````````````\n\n\nURL-escaping should be left alone inside the destination, as all\nURL-escaped characters are also valid URL characters. Entity and\nnumerical character references in the destination will be parsed\ninto the corresponding Unicode code points, as usual. These may\nbe optionally URL-escaped when written as HTML, but this spec\ndoes not enforce any particular policy for rendering URLs in\nHTML or other formats. Renderers may make different decisions\nabout how to escape or normalize URLs in the output.\n\n```````````````````````````````` example\n[link](foo%20bä)\n.\n

link

\n````````````````````````````````\n\n\nNote that, because titles can often be parsed as destinations,\nif you try to omit the destination and keep the title, you'll\nget unexpected results:\n\n```````````````````````````````` example\n[link](\"title\")\n.\n

link

\n````````````````````````````````\n\n\nTitles may be in single quotes, double quotes, or parentheses:\n\n```````````````````````````````` example\n[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n.\n

link\nlink\nlink

\n````````````````````````````````\n\n\nBackslash escapes and entity and numeric character references\nmay be used in titles:\n\n```````````````````````````````` example\n[link](/url \"title \\\""\")\n.\n

link

\n````````````````````````````````\n\n\nTitles must be separated from the link using spaces, tabs, and up to one line\nending.\nOther [Unicode whitespace] like non-breaking space doesn't work.\n\n```````````````````````````````` example\n[link](/url \"title\")\n.\n

link

\n````````````````````````````````\n\n\nNested balanced quotes are not allowed without escaping:\n\n```````````````````````````````` example\n[link](/url \"title \"and\" title\")\n.\n

[link](/url "title "and" title")

\n````````````````````````````````\n\n\nBut it is easy to work around this by using a different quote type:\n\n```````````````````````````````` example\n[link](/url 'title \"and\" title')\n.\n

link

\n````````````````````````````````\n\n\n(Note: `Markdown.pl` did allow double quotes inside a double-quoted\ntitle, and its test suite included a test demonstrating this.\nBut it is hard to see a good rationale for the extra complexity this\nbrings, since there are already many ways---backslash escaping,\nentity and numeric character references, or using a different\nquote type for the enclosing title---to write titles containing\ndouble quotes. `Markdown.pl`'s handling of titles has a number\nof other strange features. For example, it allows single-quoted\ntitles in inline links, but not reference links. And, in\nreference links but not inline links, it allows a title to begin\nwith `\"` and end with `)`. `Markdown.pl` 1.0.1 even allows\ntitles with no closing quotation mark, though 1.0.2b8 does not.\nIt seems preferable to adopt a simple, rational rule that works\nthe same way in inline links and link reference definitions.)\n\nSpaces, tabs, and up to one line ending is allowed around the destination and\ntitle:\n\n```````````````````````````````` example\n[link]( /uri\n \"title\" )\n.\n

link

\n````````````````````````````````\n\n\n" -- "But it is not allowed between the link text and the\nfollowing parenthesis:\n\n```````````````````````````````` example\n[link] (/uri)\n.\n

[link] (/uri)

\n````````````````````````````````\n\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n\n```````````````````````````````` example\n[link [foo [bar]]](/uri)\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link] bar](/uri)\n.\n

[link] bar](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link [bar](/uri)\n.\n

[link bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar](/uri)\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n\n```````````````````````````````` example\n[link *foo **bar** `#`*](/uri)\n.\n

link foo bar #

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[![moon](moon.jpg)](/uri)\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n\n```````````````````````````````` example\n[foo [bar](/uri)](/uri)\n.\n

[foo bar](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *[bar [baz](/uri)](/uri)*](/uri)\n.\n

[foo [bar baz](/uri)](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![[[foo](uri1)](uri2)](uri3)\n.\n

\"[foo](uri2)\"

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n```````````````````````````````` example\n*[foo*](/uri)\n.\n

*foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar](baz*)\n.\n

foo *bar

\n````````````````````````````````\n\n\nNote that brackets that *aren't* part of links do not take\nprecedence:\n\n```````````````````````````````` example\n*foo [bar* baz]\n.\n

foo [bar baz]

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n\n```````````````````````````````` example\n[foo \n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`](/uri)`\n.\n

[foo](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo\n.\n

[foohttps://example.com/?search=](uri)

\n````````````````````````````````\n\n\nThere are three kinds of [reference link](@)s:\n[full](#full-reference-link), [collapsed](#collapsed-reference-link),\nand [shortcut](#shortcut-reference-link).\n\nA [full reference link](@)\nconsists of a [link text] immediately followed by a [link label]\nthat [matches] a [link reference definition] elsewhere in the document.\n\nA [link label](@) begins with a left bracket (`[`) and ends\nwith the first right bracket (`]`) that is not backslash-escaped.\nBetween these brackets there must be at least one character that is not a space,\ntab, or line ending.\nUnescaped square bracket characters are not allowed inside the\nopening and closing square brackets of [link labels]. A link\nlabel can have at most 999 characters inside the square\nbrackets.\n\nOne label [matches](@)\nanother just in case their normalized forms are equal. To normalize a\nlabel, strip off the opening and closing brackets,\nperform the *Unicode case fold*, strip leading and trailing\nspaces, tabs, and line endings, and collapse consecutive internal\nspaces, tabs, and line endings to a single space. If there are multiple\nmatching reference link definitions, the one that comes first in the\ndocument is used. (It is desirable in such cases to emit a warning.)\n\nThe link's URI and title are provided by the matching [link\nreference definition].\n\nHere is a simple example:\n\n```````````````````````````````` example\n[foo][bar]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nThe rules for the [link text] are the same as with\n[inline links]. Thus:\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n\n```````````````````````````````` example\n[link [foo [bar]]][ref]\n\n[ref]: /uri\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar][ref]\n\n[ref]: /uri\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n\n```````````````````````````````` example\n[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n.\n

link foo bar #

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n\n```````````````````````````````` example\n[foo [bar](/uri)][ref]\n\n[ref]: /uri\n.\n

[foo bar]ref

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n.\n

[foo bar baz]ref

\n````````````````````````````````\n\n\n(In the examples above, we have two [shortcut reference links]\ninstead of one [full reference link].)\n\nThe following cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n```````````````````````````````` example\n*[foo*][ref]\n\n[ref]: /uri\n.\n

*foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar][ref]*\n\n[ref]: /uri\n.\n

foo *bar*

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n\n```````````````````````````````` example\n[foo \n\n[ref]: /uri\n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`][ref]`\n\n[ref]: /uri\n.\n

[foo][ref]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo\n\n[ref]: /uri\n.\n

[foohttps://example.com/?search=][ref]

\n````````````````````````````````\n\n\nMatching is case-insensitive:\n\n```````````````````````````````` example\n[foo][BaR]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nUnicode case fold is used:\n\n```````````````````````````````` example\n[ẞ]\n\n[SS]: /url\n.\n

\n````````````````````````````````\n\n\n" -- "Consecutive internal spaces, tabs, and line endings are treated as one space for\npurposes of determining matching:\n\n```````````````````````````````` example\n[Foo\n bar]: /url\n\n[Baz][Foo bar]\n.\n

Baz

\n````````````````````````````````\n\n\nNo spaces, tabs, or line endings are allowed between the [link text] and the\n[link label]:\n\n```````````````````````````````` example\n[foo] [bar]\n\n[bar]: /url \"title\"\n.\n

[foo] bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo]\n[bar]\n\n[bar]: /url \"title\"\n.\n

[foo]\nbar

\n````````````````````````````````\n\n\nThis is a departure from John Gruber's original Markdown syntax\ndescription, which explicitly allows whitespace between the link\ntext and the link label. It brings reference links in line with\n[inline links], which (according to both original Markdown and\nthis spec) cannot have whitespace after the link text. More\nimportantly, it prevents inadvertent capture of consecutive\n[shortcut reference links]. If whitespace is allowed between the\nlink text and the link label, then in the following we will have\na single reference link, not two shortcut reference links, as\nintended:\n\n``` markdown\n[foo]\n[bar]\n\n[foo]: /url1\n[bar]: /url2\n```\n\n(Note that [shortcut reference links] were introduced by Gruber\nhimself in a beta version of `Markdown.pl`, but never included\nin the official syntax description. Without shortcut reference\nlinks, it is harmless to allow space between the link text and\nlink label; but once shortcut references are introduced, it is\ntoo dangerous to allow this, as it frequently leads to\nunintended results.)\n\nWhen there are multiple matching [link reference definitions],\nthe first is used:\n\n```````````````````````````````` example\n[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n.\n

bar

\n````````````````````````````````\n\n\nNote that matching is performed on normalized strings, not parsed\ninline content. So the following does not match, even though the\nlabels define equivalent inline content:\n\n```````````````````````````````` example\n[bar][foo\\!]\n\n[foo!]: /url\n.\n

[bar][foo!]

\n````````````````````````````````\n\n\n[Link labels] cannot contain brackets, unless they are\nbackslash-escaped:\n\n```````````````````````````````` example\n[foo][ref[]\n\n[ref[]: /uri\n.\n

[foo][ref[]

\n

[ref[]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref[bar]]\n\n[ref[bar]]: /uri\n.\n

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[[foo]]]\n\n[[[foo]]]: /url\n.\n

[[[foo]]]

\n

[[[foo]]]: /url

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref\\[]\n\n[ref\\[]: /uri\n.\n

foo

\n````````````````````````````````\n\n\nNote that in this example `]` is not backslash-escaped:\n\n```````````````````````````````` example\n[bar\\\\]: /uri\n\n[bar\\\\]\n.\n

bar\\

\n````````````````````````````````\n\n\nA [link label] must contain at least one character that is not a space, tab, or\nline ending:\n\n```````````````````````````````` example\n[]\n\n[]: /uri\n.\n

[]

\n

[]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[\n ]\n\n[\n ]: /uri\n.\n

[\n]

\n

[\n]: /uri

\n````````````````````````````````\n\n\nA [collapsed reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument, followed by the string `[]`.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title are\nprovided by the matching reference link definition. Thus,\n`[foo][]` is equivalent to `[foo][foo]`.\n\n```````````````````````````````` example\n[foo][]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n[Foo][]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\n\nAs with full reference links, spaces, tabs, or line endings are not\nallowed between the two sets of brackets:\n\n```````````````````````````````` example\n[foo] \n[]\n\n[foo]: /url \"title\"\n.\n

foo\n[]

\n````````````````````````````````\n\n\nA [shortcut reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument and is not followed by `[]` or a link label.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title\nare provided by the matching link reference definition.\nThus, `[foo]` is equivalent to `[foo][]`.\n\n```````````````````````````````` example\n[foo]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n.\n

[foo bar]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[bar [foo]\n\n[foo]: /url\n.\n

[[bar foo

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n[Foo]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\nA space after the link text should be preserved:\n\n```````````````````````````````` example\n[foo] bar\n\n[foo]: /url\n.\n

foo bar

\n````````````````````````````````\n\n\nIf you just want bracketed text, you can backslash-escape the\nopening bracket to avoid links:\n\n```````````````````````````````` example\n\\[foo]\n\n[foo]: /url \"title\"\n.\n

[foo]

\n````````````````````````````````\n\n\nNote that this is a link, because a link label ends with the first\nfollowing closing bracket:\n\n```````````````````````````````` example\n[foo*]: /url\n\n*[foo*]\n.\n

*foo*

\n````````````````````````````````\n\n\nFull and collapsed references take precedence over shortcut\nreferences:\n\n```````````````````````````````` example\n[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n.\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\n[foo][]\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````\n\nInline links also take precedence:\n\n```````````````````````````````` example\n[foo]()\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\n[foo](not a link)\n\n[foo]: /url1\n.\n

foo(not a link)

\n````````````````````````````````\n\nIn the following case `[bar][baz]` is parsed as a reference,\n`[foo]` as normal text:\n\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url\n.\n

[foo]bar

\n````````````````````````````````\n\n\nHere, though, `[foo][bar]` is parsed as a reference, since\n`[bar]` is defined:\n\n" -- "```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n.\n

foobaz

\n````````````````````````````````\n\n\nHere `[foo]` is not parsed as a shortcut reference, because it\nis followed by a link label (even though `[bar]` is not defined):\n\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n.\n

[foo]bar

\n````````````````````````````````\n\n\n\n## Images\n\nSyntax for images is like the syntax for links, with one\ndifference. Instead of [link text], we have an\n[image description](@). The rules for this are the\nsame as for [link text], except that (a) an\nimage description starts with `![` rather than `[`, and\n(b) an image description may contain links.\nAn image description has inline elements\nas its contents. When an image is rendered to HTML,\nthis is standardly used as the image's `alt` attribute.\n\n```````````````````````````````` example\n![foo](/url \"title\")\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo ![bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo [bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````\n\n\nThough this spec is concerned with parsing, not rendering, it is\nrecommended that in rendering to HTML, only the plain string content\nof the [image description] be used. Note that in\nthe above example, the alt attribute's value is `foo bar`, not `foo\n[bar](/url)` or `foo bar`. Only the plain string\ncontent is rendered, without formatting.\n\n```````````````````````````````` example\n![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo](train.jpg)\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\nMy ![foo bar](/path/to/train.jpg \"title\" )\n.\n

My \"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo]()\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![](/url)\n.\n

\"\"

\n````````````````````````````````\n\n\nReference-style:\n\n```````````````````````````````` example\n![foo][bar]\n\n[bar]: /url\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo][bar]\n\n[BAR]: /url\n.\n

\"foo\"

\n````````````````````````````````\n\n\nCollapsed:\n\n```````````````````````````````` example\n![foo][]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nThe labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo][]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````\n\n\nAs with reference links, spaces, tabs, and line endings, are not allowed\nbetween the two sets of brackets:\n\n```````````````````````````````` example\n![foo] \n[]\n\n[foo]: /url \"title\"\n.\n

\"foo\"\n[]

\n````````````````````````````````\n\n\nShortcut:\n\n```````````````````````````````` example\n![foo]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nNote that link labels cannot contain unescaped brackets:\n\n```````````````````````````````` example\n![[foo]]\n\n[[foo]]: /url \"title\"\n.\n

![[foo]]

\n

[[foo]]: /url "title"

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````\n\n\nIf you just want a literal `!` followed by bracketed text, you can\nbackslash-escape the opening `[`:\n\n```````````````````````````````` example\n!\\[foo]\n\n[foo]: /url \"title\"\n.\n

![foo]

\n````````````````````````````````\n\n\nIf you want a link after a literal `!`, backslash-escape the\n`!`:\n\n```````````````````````````````` example\n\\![foo]\n\n[foo]: /url \"title\"\n.\n

!foo

\n````````````````````````````````\n\n\n" +- "Although [link titles] may span multiple lines, they may not contain\na [blank line].\n\nAn [inline link](@) consists of a [link text] followed immediately\nby a left parenthesis `(`, an optional [link destination], an optional\n[link title], and a right parenthesis `)`.\nThese four components may be separated by spaces, tabs, and up to one line\nending.\nIf both [link destination] and [link title] are present, they *must* be\nseparated by spaces, tabs, and up to one line ending.\n\nThe link's text consists of the inlines contained\nin the [link text] (excluding the enclosing square brackets).\nThe link's URI consists of the link destination, excluding enclosing\n`<...>` if present, with backslash-escapes in effect as described\nabove. The link's title consists of the link title, excluding its\nenclosing delimiters, with backslash-escapes in effect as described\nabove.\n\nHere is a simple inline link:\n\n```````````````````````````````` example\n[link](/uri \"title\")\n.\n

link

\n````````````````````````````````\n\n\nThe title, the link text and even \nthe destination may be omitted:\n\n```````````````````````````````` example\n[link](/uri)\n.\n

link

\n````````````````````````````````\n\n```````````````````````````````` example\n[](./target.md)\n.\n

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link](<>)\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[]()\n.\n

\n````````````````````````````````\n\nThe destination can only contain spaces if it is\nenclosed in pointy brackets:\n\n```````````````````````````````` example\n[link](/my uri)\n.\n

[link](/my uri)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\nThe destination cannot contain line endings,\neven if enclosed in pointy brackets:\n\n```````````````````````````````` example\n[link](foo\nbar)\n.\n

[link](foo\nbar)

\n````````````````````````````````\n\n```````````````````````````````` example\n[link]()\n.\n

[link]()

\n````````````````````````````````\n\nThe destination can contain `)` if it is enclosed\nin pointy brackets:\n\n```````````````````````````````` example\n[a]()\n.\n

a

\n````````````````````````````````\n\nPointy brackets that enclose links must be unescaped:\n\n```````````````````````````````` example\n[link]()\n.\n

[link](<foo>)

\n````````````````````````````````\n\nThese are not links, because the opening pointy bracket\nis not matched properly:\n\n```````````````````````````````` example\n[a](\n[a](c)\n.\n

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

\n````````````````````````````````\n\nParentheses inside the link destination may be escaped:\n\n```````````````````````````````` example\n[link](\\(foo\\))\n.\n

link

\n````````````````````````````````\n\nAny number of parentheses are allowed without escaping, as long as they are\nbalanced:\n\n```````````````````````````````` example\n[link](foo(and(bar)))\n.\n

link

\n````````````````````````````````\n\nHowever, if you have unbalanced parentheses, you need to escape or use the\n`<...>` form:\n\n```````````````````````````````` example\n[link](foo(and(bar))\n.\n

[link](foo(and(bar))

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link](foo\\(and\\(bar\\))\n.\n

link

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link]()\n.\n

link

\n````````````````````````````````\n\n\nParentheses and other symbols can also be escaped, as usual\nin Markdown:\n\n```````````````````````````````` example\n[link](foo\\)\\:)\n.\n

link

\n````````````````````````````````\n\n\nA link can contain fragment identifiers and queries:\n\n```````````````````````````````` example\n[link](#fragment)\n\n[link](https://example.com#fragment)\n\n[link](https://example.com?foo=3#frag)\n.\n

link

\n

link

\n

link

\n````````````````````````````````\n\n\nNote that a backslash before a non-escapable character is\njust a backslash:\n\n```````````````````````````````` example\n[link](foo\\bar)\n.\n

link

\n````````````````````````````````\n\n\nURL-escaping should be left alone inside the destination, as all\nURL-escaped characters are also valid URL characters. Entity and\nnumerical character references in the destination will be parsed\ninto the corresponding Unicode code points, as usual. These may\nbe optionally URL-escaped when written as HTML, but this spec\ndoes not enforce any particular policy for rendering URLs in\nHTML or other formats. Renderers may make different decisions\nabout how to escape or normalize URLs in the output.\n\n```````````````````````````````` example\n[link](foo%20bä)\n.\n

link

\n````````````````````````````````\n\n\nNote that, because titles can often be parsed as destinations,\nif you try to omit the destination and keep the title, you'll\nget unexpected results:\n\n```````````````````````````````` example\n[link](\"title\")\n.\n

link

\n````````````````````````````````\n\n\nTitles may be in single quotes, double quotes, or parentheses:\n\n```````````````````````````````` example\n[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n.\n

link\nlink\nlink

\n````````````````````````````````\n\n\nBackslash escapes and entity and numeric character references\nmay be used in titles:\n\n```````````````````````````````` example\n[link](/url \"title \\\""\")\n.\n

link

\n````````````````````````````````\n\n\nTitles must be separated from the link using spaces, tabs, and up to one line\nending.\nOther [Unicode whitespace] like non-breaking space doesn't work.\n\n```````````````````````````````` example\n[link](/url \"title\")\n.\n

link

\n````````````````````````````````\n\n\nNested balanced quotes are not allowed without escaping:\n\n```````````````````````````````` example\n[link](/url \"title \"and\" title\")\n.\n

[link](/url "title "and" title")

\n````````````````````````````````\n\n\nBut it is easy to work around this by using a different quote type:\n\n```````````````````````````````` example\n[link](/url 'title \"and\" title')\n.\n

link

\n````````````````````````````````\n\n\n(Note: `Markdown.pl` did allow double quotes inside a double-quoted\ntitle, and its test suite included a test demonstrating this.\nBut it is hard to see a good rationale for the extra complexity this\nbrings, since there are already many ways---backslash escaping,\nentity and numeric character references, or using a different\nquote type for the enclosing title---to write titles containing\ndouble quotes. `Markdown.pl`'s handling of titles has a number\nof other strange features. For example, it allows single-quoted\ntitles in inline links, but not reference links. And, in\nreference links but not inline links, it allows a title to begin\nwith `\"` and end with `)`. `Markdown.pl` 1.0.1 even allows\ntitles with no closing quotation mark, though 1.0.2b8 does not.\nIt seems preferable to adopt a simple, rational rule that works\nthe same way in inline links and link reference definitions.)\n\nSpaces, tabs, and up to one line ending is allowed around the destination and\ntitle:\n\n```````````````````````````````` example\n[link]( /uri\n \"title\" )\n.\n

link

\n````````````````````````````````" +- "\n\n\nBut it is not allowed between the link text and the\nfollowing parenthesis:\n\n```````````````````````````````` example\n[link] (/uri)\n.\n

[link] (/uri)

\n````````````````````````````````\n\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n\n```````````````````````````````` example\n[link [foo [bar]]](/uri)\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link] bar](/uri)\n.\n

[link] bar](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link [bar](/uri)\n.\n

[link bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar](/uri)\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n\n```````````````````````````````` example\n[link *foo **bar** `#`*](/uri)\n.\n

link foo bar #

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[![moon](moon.jpg)](/uri)\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n\n```````````````````````````````` example\n[foo [bar](/uri)](/uri)\n.\n

[foo bar](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *[bar [baz](/uri)](/uri)*](/uri)\n.\n

[foo [bar baz](/uri)](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![[[foo](uri1)](uri2)](uri3)\n.\n

\"[foo](uri2)\"

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n```````````````````````````````` example\n*[foo*](/uri)\n.\n

*foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar](baz*)\n.\n

foo *bar

\n````````````````````````````````\n\n\nNote that brackets that *aren't* part of links do not take\nprecedence:\n\n```````````````````````````````` example\n*foo [bar* baz]\n.\n

foo [bar baz]

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n\n```````````````````````````````` example\n[foo \n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`](/uri)`\n.\n

[foo](/uri)

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo\n.\n

[foohttps://example.com/?search=](uri)

\n````````````````````````````````\n\n\nThere are three kinds of [reference link](@)s:\n[full](#full-reference-link), [collapsed](#collapsed-reference-link),\nand [shortcut](#shortcut-reference-link).\n\nA [full reference link](@)\nconsists of a [link text] immediately followed by a [link label]\nthat [matches] a [link reference definition] elsewhere in the document.\n\nA [link label](@) begins with a left bracket (`[`) and ends\nwith the first right bracket (`]`) that is not backslash-escaped.\nBetween these brackets there must be at least one character that is not a space,\ntab, or line ending.\nUnescaped square bracket characters are not allowed inside the\nopening and closing square brackets of [link labels]. A link\nlabel can have at most 999 characters inside the square\nbrackets.\n\nOne label [matches](@)\nanother just in case their normalized forms are equal. To normalize a\nlabel, strip off the opening and closing brackets,\nperform the *Unicode case fold*, strip leading and trailing\nspaces, tabs, and line endings, and collapse consecutive internal\nspaces, tabs, and line endings to a single space. If there are multiple\nmatching reference link definitions, the one that comes first in the\ndocument is used. (It is desirable in such cases to emit a warning.)\n\nThe link's URI and title are provided by the matching [link\nreference definition].\n\nHere is a simple example:\n\n```````````````````````````````` example\n[foo][bar]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nThe rules for the [link text] are the same as with\n[inline links]. Thus:\n\nThe link text may contain balanced brackets, but not unbalanced ones,\nunless they are escaped:\n\n```````````````````````````````` example\n[link [foo [bar]]][ref]\n\n[ref]: /uri\n.\n

link [foo [bar]]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[link \\[bar][ref]\n\n[ref]: /uri\n.\n

link [bar

\n````````````````````````````````\n\n\nThe link text may contain inline content:\n\n```````````````````````````````` example\n[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n.\n

link foo bar #

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n.\n

\"moon\"

\n````````````````````````````````\n\n\nHowever, links may not contain other links, at any level of nesting.\n\n```````````````````````````````` example\n[foo [bar](/uri)][ref]\n\n[ref]: /uri\n.\n

[foo bar]ref

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n.\n

[foo bar baz]ref

\n````````````````````````````````\n\n\n(In the examples above, we have two [shortcut reference links]\ninstead of one [full reference link].)\n\nThe following cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n```````````````````````````````` example\n*[foo*][ref]\n\n[ref]: /uri\n.\n

*foo*

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo *bar][ref]*\n\n[ref]: /uri\n.\n

foo *bar*

\n````````````````````````````````\n\n\nThese cases illustrate the precedence of HTML tags, code spans,\nand autolinks over link grouping:\n\n```````````````````````````````` example\n[foo \n\n[ref]: /uri\n.\n

[foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo`][ref]`\n\n[ref]: /uri\n.\n

[foo][ref]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo\n\n[ref]: /uri\n.\n

[foohttps://example.com/?search=][ref]

\n````````````````````````````````\n\n\nMatching is case-insensitive:\n\n```````````````````````````````` example\n[foo][BaR]\n\n[bar]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\nUnicode case fold is used:\n\n```````````````````````````````` example\n[ẞ]\n\n[SS]: /url\n.\n

\n````````````````````````````````" +- "\n\n\nConsecutive internal spaces, tabs, and line endings are treated as one space for\npurposes of determining matching:\n\n```````````````````````````````` example\n[Foo\n bar]: /url\n\n[Baz][Foo bar]\n.\n

Baz

\n````````````````````````````````\n\n\nNo spaces, tabs, or line endings are allowed between the [link text] and the\n[link label]:\n\n```````````````````````````````` example\n[foo] [bar]\n\n[bar]: /url \"title\"\n.\n

[foo] bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo]\n[bar]\n\n[bar]: /url \"title\"\n.\n

[foo]\nbar

\n````````````````````````````````\n\n\nThis is a departure from John Gruber's original Markdown syntax\ndescription, which explicitly allows whitespace between the link\ntext and the link label. It brings reference links in line with\n[inline links], which (according to both original Markdown and\nthis spec) cannot have whitespace after the link text. More\nimportantly, it prevents inadvertent capture of consecutive\n[shortcut reference links]. If whitespace is allowed between the\nlink text and the link label, then in the following we will have\na single reference link, not two shortcut reference links, as\nintended:\n\n``` markdown\n[foo]\n[bar]\n\n[foo]: /url1\n[bar]: /url2\n```\n\n(Note that [shortcut reference links] were introduced by Gruber\nhimself in a beta version of `Markdown.pl`, but never included\nin the official syntax description. Without shortcut reference\nlinks, it is harmless to allow space between the link text and\nlink label; but once shortcut references are introduced, it is\ntoo dangerous to allow this, as it frequently leads to\nunintended results.)\n\nWhen there are multiple matching [link reference definitions],\nthe first is used:\n\n```````````````````````````````` example\n[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n.\n

bar

\n````````````````````````````````\n\n\nNote that matching is performed on normalized strings, not parsed\ninline content. So the following does not match, even though the\nlabels define equivalent inline content:\n\n```````````````````````````````` example\n[bar][foo\\!]\n\n[foo!]: /url\n.\n

[bar][foo!]

\n````````````````````````````````\n\n\n[Link labels] cannot contain brackets, unless they are\nbackslash-escaped:\n\n```````````````````````````````` example\n[foo][ref[]\n\n[ref[]: /uri\n.\n

[foo][ref[]

\n

[ref[]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref[bar]]\n\n[ref[bar]]: /uri\n.\n

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[[foo]]]\n\n[[[foo]]]: /url\n.\n

[[[foo]]]

\n

[[[foo]]]: /url

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[foo][ref\\[]\n\n[ref\\[]: /uri\n.\n

foo

\n````````````````````````````````\n\n\nNote that in this example `]` is not backslash-escaped:\n\n```````````````````````````````` example\n[bar\\\\]: /uri\n\n[bar\\\\]\n.\n

bar\\

\n````````````````````````````````\n\n\nA [link label] must contain at least one character that is not a space, tab, or\nline ending:\n\n```````````````````````````````` example\n[]\n\n[]: /uri\n.\n

[]

\n

[]: /uri

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[\n ]\n\n[\n ]: /uri\n.\n

[\n]

\n

[\n]: /uri

\n````````````````````````````````\n\n\nA [collapsed reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument, followed by the string `[]`.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title are\nprovided by the matching reference link definition. Thus,\n`[foo][]` is equivalent to `[foo][foo]`.\n\n```````````````````````````````` example\n[foo][]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n[Foo][]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\n\nAs with full reference links, spaces, tabs, or line endings are not\nallowed between the two sets of brackets:\n\n```````````````````````````````` example\n[foo] \n[]\n\n[foo]: /url \"title\"\n.\n

foo\n[]

\n````````````````````````````````\n\n\nA [shortcut reference link](@)\nconsists of a [link label] that [matches] a\n[link reference definition] elsewhere in the\ndocument and is not followed by `[]` or a link label.\nThe contents of the link label are parsed as inlines,\nwhich are used as the link's text. The link's URI and title\nare provided by the matching link reference definition.\nThus, `[foo]` is equivalent to `[foo][]`.\n\n```````````````````````````````` example\n[foo]\n\n[foo]: /url \"title\"\n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

foo bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n.\n

[foo bar]

\n````````````````````````````````\n\n\n```````````````````````````````` example\n[[bar [foo]\n\n[foo]: /url\n.\n

[[bar foo

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n[Foo]\n\n[foo]: /url \"title\"\n.\n

Foo

\n````````````````````````````````\n\n\nA space after the link text should be preserved:\n\n```````````````````````````````` example\n[foo] bar\n\n[foo]: /url\n.\n

foo bar

\n````````````````````````````````\n\n\nIf you just want bracketed text, you can backslash-escape the\nopening bracket to avoid links:\n\n```````````````````````````````` example\n\\[foo]\n\n[foo]: /url \"title\"\n.\n

[foo]

\n````````````````````````````````\n\n\nNote that this is a link, because a link label ends with the first\nfollowing closing bracket:\n\n```````````````````````````````` example\n[foo*]: /url\n\n*[foo*]\n.\n

*foo*

\n````````````````````````````````\n\n\nFull and collapsed references take precedence over shortcut\nreferences:\n\n```````````````````````````````` example\n[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n.\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\n[foo][]\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````\n\nInline links also take precedence:\n\n```````````````````````````````` example\n[foo]()\n\n[foo]: /url1\n.\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\n[foo](not a link)\n\n[foo]: /url1\n.\n

foo(not a link)

\n````````````````````````````````\n\nIn the following case `[bar][baz]` is parsed as a reference,\n`[foo]` as normal text:\n\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url\n.\n

[foo]bar

\n````````````````````````````````\n\n\nHere, though, `[foo][bar]` is parsed as a reference, since\n`[bar]` is defined:\n" +- "\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n.\n

foobaz

\n````````````````````````````````\n\n\nHere `[foo]` is not parsed as a shortcut reference, because it\nis followed by a link label (even though `[bar]` is not defined):\n\n```````````````````````````````` example\n[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n.\n

[foo]bar

\n````````````````````````````````\n\n\n\n## Images\n\nSyntax for images is like the syntax for links, with one\ndifference. Instead of [link text], we have an\n[image description](@). The rules for this are the\nsame as for [link text], except that (a) an\nimage description starts with `![` rather than `[`, and\n(b) an image description may contain links.\nAn image description has inline elements\nas its contents. When an image is rendered to HTML,\nthis is standardly used as the image's `alt` attribute.\n\n```````````````````````````````` example\n![foo](/url \"title\")\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo ![bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo [bar](/url)](/url2)\n.\n

\"foo

\n````````````````````````````````\n\n\nThough this spec is concerned with parsing, not rendering, it is\nrecommended that in rendering to HTML, only the plain string content\nof the [image description] be used. Note that in\nthe above example, the alt attribute's value is `foo bar`, not `foo\n[bar](/url)` or `foo bar`. Only the plain string\ncontent is rendered, without formatting.\n\n```````````````````````````````` example\n![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n.\n

\"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo](train.jpg)\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\nMy ![foo bar](/path/to/train.jpg \"title\" )\n.\n

My \"foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo]()\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![](/url)\n.\n

\"\"

\n````````````````````````````````\n\n\nReference-style:\n\n```````````````````````````````` example\n![foo][bar]\n\n[bar]: /url\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![foo][bar]\n\n[BAR]: /url\n.\n

\"foo\"

\n````````````````````````````````\n\n\nCollapsed:\n\n```````````````````````````````` example\n![foo][]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nThe labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo][]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````\n\n\nAs with reference links, spaces, tabs, and line endings, are not allowed\nbetween the two sets of brackets:\n\n```````````````````````````````` example\n![foo] \n[]\n\n[foo]: /url \"title\"\n.\n

\"foo\"\n[]

\n````````````````````````````````\n\n\nShortcut:\n\n```````````````````````````````` example\n![foo]\n\n[foo]: /url \"title\"\n.\n

\"foo\"

\n````````````````````````````````\n\n\n```````````````````````````````` example\n![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n.\n

\"foo

\n````````````````````````````````\n\n\nNote that link labels cannot contain unescaped brackets:\n\n```````````````````````````````` example\n![[foo]]\n\n[[foo]]: /url \"title\"\n.\n

![[foo]]

\n

[[foo]]: /url "title"

\n````````````````````````````````\n\n\nThe link labels are case-insensitive:\n\n```````````````````````````````` example\n![Foo]\n\n[foo]: /url \"title\"\n.\n

\"Foo\"

\n````````````````````````````````\n\n\nIf you just want a literal `!` followed by bracketed text, you can\nbackslash-escape the opening `[`:\n\n```````````````````````````````` example\n!\\[foo]\n\n[foo]: /url \"title\"\n.\n

![foo]

\n````````````````````````````````\n\n\nIf you want a link after a literal `!`, backslash-escape the\n`!`:\n\n```````````````````````````````` example\n\\![foo]\n\n[foo]: /url \"title\"\n.\n

!foo

\n````````````````````````````````\n\n\n" - "## Autolinks\n\n[Autolink](@)s are absolute URIs and email addresses inside\n`<` and `>`. They are parsed as links, with the URL or email address\nas the link label.\n\nA [URI autolink](@) consists of `<`, followed by an\n[absolute URI] followed by `>`. It is parsed as\na link to the URI, with the URI as the link's label.\n\nAn [absolute URI](@),\nfor these purposes, consists of a [scheme] followed by a colon (`:`)\nfollowed by zero or more characters other than [ASCII control\ncharacters][ASCII control character], [space], `<`, and `>`.\nIf the URI includes these characters, they must be percent-encoded\n(e.g. `%20` for a space).\n\nFor purposes of this spec, a [scheme](@) is any sequence\nof 2--32 characters beginning with an ASCII letter and followed\nby any combination of ASCII letters, digits, or the symbols plus\n(\"+\"), period (\".\"), or hyphen (\"-\").\n\nHere are some valid autolinks:\n\n```````````````````````````````` example\n\n.\n

http://foo.bar.baz

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

https://foo.bar.baz/test?q=hello&id=22&boolean

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

irc://foo.bar:2233/baz

\n````````````````````````````````\n\n\nUppercase is also fine:\n\n```````````````````````````````` example\n\n.\n

MAILTO:FOO@BAR.BAZ

\n````````````````````````````````\n\n\nNote that many strings that count as [absolute URIs] for\npurposes of this spec are not valid URIs, because their\nschemes are not registered or because of other problems\nwith their syntax:\n\n```````````````````````````````` example\n\n.\n

a+b+c:d

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

made-up-scheme://foo,bar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

https://../

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

localhost:5001/foo

\n````````````````````````````````\n\n\nSpaces are not allowed in autolinks:\n\n```````````````````````````````` example\n\n.\n

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

\n````````````````````````````````\n\n\nBackslash-escapes do not work inside autolinks:\n\n```````````````````````````````` example\n\n.\n

https://example.com/\\[\\

\n````````````````````````````````\n\n\nAn [email autolink](@)\nconsists of `<`, followed by an [email address],\nfollowed by `>`. The link's label is the email address,\nand the URL is `mailto:` followed by the email address.\n\nAn [email address](@),\nfor these purposes, is anything that matches\nthe [non-normative regex from the HTML5\nspec](https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-(type=email)):\n\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\n (?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/\n\nExamples of email autolinks:\n\n```````````````````````````````` example\n\n.\n

foo@bar.example.com

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

foo+special@Bar.baz-bar0.com

\n````````````````````````````````\n\n\nBackslash-escapes do not work inside email autolinks:\n\n```````````````````````````````` example\n\n.\n

<foo+@bar.example.com>

\n````````````````````````````````\n\n\nThese are not autolinks:\n\n```````````````````````````````` example\n<>\n.\n

<>

\n````````````````````````````````\n\n\n```````````````````````````````` example\n< https://foo.bar >\n.\n

< https://foo.bar >

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

<m:abc>

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

<foo.bar.baz>

\n````````````````````````````````\n\n\n```````````````````````````````` example\nhttps://example.com\n.\n

https://example.com

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo@bar.example.com\n.\n

foo@bar.example.com

\n````````````````````````````````\n\n\n" - "## Raw HTML\n\nText between `<` and `>` that looks like an HTML tag is parsed as a\nraw HTML tag and will be rendered in HTML without escaping.\nTag and attribute names are not limited to current HTML tags,\nso custom tags (and even, say, DocBook tags) may be used.\n\nHere is the grammar for tags:\n\nA [tag name](@) consists of an ASCII letter\nfollowed by zero or more ASCII letters, digits, or\nhyphens (`-`).\n\nAn [attribute](@) consists of spaces, tabs, and up to one line ending,\nan [attribute name], and an optional\n[attribute value specification].\n\nAn [attribute name](@)\nconsists of an ASCII letter, `_`, or `:`, followed by zero or more ASCII\nletters, digits, `_`, `.`, `:`, or `-`. (Note: This is the XML\nspecification restricted to ASCII. HTML5 is laxer.)\n\nAn [attribute value specification](@)\nconsists of optional spaces, tabs, and up to one line ending,\na `=` character, optional spaces, tabs, and up to one line ending,\nand an [attribute value].\n\nAn [attribute value](@)\nconsists of an [unquoted attribute value],\na [single-quoted attribute value], or a [double-quoted attribute value].\n\nAn [unquoted attribute value](@)\nis a nonempty string of characters not\nincluding spaces, tabs, line endings, `\"`, `'`, `=`, `<`, `>`, or `` ` ``.\n\nA [single-quoted attribute value](@)\nconsists of `'`, zero or more\ncharacters not including `'`, and a final `'`.\n\nA [double-quoted attribute value](@)\nconsists of `\"`, zero or more\ncharacters not including `\"`, and a final `\"`.\n\nAn [open tag](@) consists of a `<` character, a [tag name],\nzero or more [attributes], optional spaces, tabs, and up to one line ending,\nan optional `/` character, and a `>` character.\n\nA [closing tag](@) consists of the string ``.\n\nAn [HTML comment](@) consists of ``, ``, or ``, and `-->` (see the\n[HTML spec](https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state)).\n\nA [processing instruction](@)\nconsists of the string ``, and the string\n`?>`.\n\nA [declaration](@) consists of the string ``, and the character `>`.\n\nA [CDATA section](@) consists of\nthe string ``, and the string `]]>`.\n\nAn [HTML tag](@) consists of an [open tag], a [closing tag],\nan [HTML comment], a [processing instruction], a [declaration],\nor a [CDATA section].\n\nHere are some simple open tags:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nEmpty elements:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nWhitespace is allowed:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nWith attributes:\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nCustom tag names can be used:\n\n```````````````````````````````` example\nFoo \n.\n

Foo

\n````````````````````````````````\n\n\nIllegal tag names, not parsed as HTML:\n\n```````````````````````````````` example\n<33> <__>\n.\n

<33> <__>

\n````````````````````````````````\n\n\nIllegal attribute names:\n\n```````````````````````````````` example\n
\n.\n

<a h*#ref="hi">

\n````````````````````````````````\n\n\nIllegal attribute values:\n\n```````````````````````````````` example\n
\n.\n

<a href="hi'> <a href=hi'>

\n````````````````````````````````\n\n\nIllegal whitespace:\n\n```````````````````````````````` example\n< a><\nfoo>\n\n.\n

< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

\n````````````````````````````````\n\n\nMissing whitespace:\n\n```````````````````````````````` example\n
\n.\n

<a href='bar'title=title>

\n````````````````````````````````\n\n\nClosing tags:\n\n```````````````````````````````` example\n
\n.\n

\n````````````````````````````````\n\n\nIllegal attributes in closing tag:\n\n```````````````````````````````` example\n\n.\n

</a href="foo">

\n````````````````````````````````\n\n\nComments:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n```````````````````````````````` example\nfoo foo -->\n\nfoo foo -->\n.\n

foo foo -->

\n

foo foo -->

\n````````````````````````````````\n\n\nProcessing instructions:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nDeclarations:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nCDATA sections:\n\n```````````````````````````````` example\nfoo &<]]>\n.\n

foo &<]]>

\n````````````````````````````````\n\n\nEntity and numeric character references are preserved in HTML\nattributes:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\nBackslash escapes do not work in HTML attributes:\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

<a href=""">

\n````````````````````````````````\n\n\n" - "## Hard line breaks\n\nA line ending (not in a code span or HTML tag) that is preceded\nby two or more spaces and does not occur at the end of a block\nis parsed as a [hard line break](@) (rendered\nin HTML as a `
` tag):\n\n```````````````````````````````` example\nfoo \nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nFor a more visible alternative, a backslash before the\n[line ending] may be used instead of two or more spaces:\n\n```````````````````````````````` example\nfoo\\\nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nMore than two spaces can be used:\n\n```````````````````````````````` example\nfoo \nbaz\n.\n

foo
\nbaz

\n````````````````````````````````\n\n\nLeading spaces at the beginning of the next line are ignored:\n\n```````````````````````````````` example\nfoo \n bar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo\\\n bar\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nHard line breaks can occur inside emphasis, links, and other constructs\nthat allow inline content:\n\n```````````````````````````````` example\n*foo \nbar*\n.\n

foo
\nbar

\n````````````````````````````````\n\n\n```````````````````````````````` example\n*foo\\\nbar*\n.\n

foo
\nbar

\n````````````````````````````````\n\n\nHard line breaks do not occur inside code spans\n\n```````````````````````````````` example\n`code \nspan`\n.\n

code span

\n````````````````````````````````\n\n\n```````````````````````````````` example\n`code\\\nspan`\n.\n

code\\ span

\n````````````````````````````````\n\n\nor HTML tags:\n\n```````````````````````````````` example\n
\n.\n

\n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

\n````````````````````````````````\n\n\nHard line breaks are for separating inline content within a block.\nNeither syntax for hard line breaks works at the end of a paragraph or\nother block element:\n\n```````````````````````````````` example\nfoo\\\n.\n

foo\\

\n````````````````````````````````\n\n\n```````````````````````````````` example\nfoo \n.\n

foo

\n````````````````````````````````\n\n\n```````````````````````````````` example\n### foo\\\n.\n

foo\\

\n````````````````````````````````\n\n\n```````````````````````````````` example\n### foo \n.\n

foo

\n````````````````````````````````\n\n\n## Soft line breaks\n\nA regular line ending (not in a code span or HTML tag) that is not\npreceded by two or more spaces or a backslash is parsed as a\n[softbreak](@). (A soft line break may be rendered in HTML either as a\n[line ending] or as a space. The result will be the same in\nbrowsers. In the examples here, a [line ending] will be used.)\n\n```````````````````````````````` example\nfoo\nbaz\n.\n

foo\nbaz

\n````````````````````````````````\n\n\nSpaces at the end of the line and beginning of the next line are\nremoved:\n\n```````````````````````````````` example\nfoo \n baz\n.\n

foo\nbaz

\n````````````````````````````````\n\n\nA conforming parser may render a soft line break in HTML either as a\nline ending or as a space.\n\nA renderer may also provide an option to render soft line breaks\nas hard line breaks.\n\n## Textual content\n\nAny characters not given an interpretation by the above rules will\nbe parsed as plain textual content.\n\n```````````````````````````````` example\nhello $.;'there\n.\n

hello $.;'there

\n````````````````````````````````\n\n\n```````````````````````````````` example\nFoo χρῆν\n.\n

Foo χρῆν

\n````````````````````````````````\n\n\nInternal spaces are preserved verbatim:\n\n```````````````````````````````` example\nMultiple spaces\n.\n

Multiple spaces

\n````````````````````````````````\n\n\n\n\n" diff --git a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md.snap b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md.snap index 5ce4abfd..cd84420e 100644 --- a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md.snap +++ b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@commonmark_spec.md.snap @@ -112,8 +112,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - " tags? Can a list be partially \"loose\" and partially\n \"tight\"" - "? What should we do with a list like this?\n\n " - "``` markdown\n 1. one\n\n 2. two\n 3. three\n" -- " ```\n\n Or this?\n\n " -- "``` markdown\n 1. one\n - a\n\n - b\n 2. two\n" +- " ```\n\n Or this?\n" +- "\n ``` markdown\n 1. one\n - a\n\n - b\n 2. two\n" - " ```\n\n " - "(There are some relevant comments by John Gruber\n" - " [here](https://web.archive.org/web/" @@ -156,12 +156,10 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "12. Can list items be empty?\n\n ``` markdown\n * a\n *\n" - " * b\n ```\n\n" - "13. Can link references be defined inside block quotes or list items?\n\n" -- " " -- "``` markdown\n > Blockquote [foo].\n >\n" +- " ``` markdown\n > Blockquote [foo].\n >\n" - " > [foo]: /url\n ```\n\n" - "14. If there are multiple definitions for the same reference, which takes\n precedence?\n\n" -- " " -- "``` markdown\n [foo]: /url1\n" +- " ``` markdown\n [foo]: /url1\n" - " [foo]: /url2\n\n [foo][]\n" - " ```\n\n" - "In the absence of a spec, early implementers consulted `" @@ -213,8 +211,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "In the examples, the `→` character is used to represent tabs.\n\n" - "# Preliminaries\n\n" - "## Characters and lines\n\n" -- "Any sequence of [characters] is a valid CommonMark\ndocument.\n\n" -- "A [character](@) is a Unicode code point. " +- "Any sequence of [characters] is a valid CommonMark\ndocument.\n" +- "\nA [character](@) is a Unicode code point. " - "Although some\ncode points (for example, combining accents) do not correspond to\n" - "characters in an intuitive sense, all code points count as characters\n" - "for purposes of this spec.\n\n" @@ -233,7 +231,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "A line containing no characters, or a line containing only spaces\n" - "(`U+0020`) or tabs (`U+" - "0009`), is called a [blank line](@).\n\n" -- "The following definitions of character classes will be used in this spec:\n\n" +- "The following definitions of character classes will be used in this spec:\n" +- "\n" - "A [Unicode whitespace character](@) is a character in " - "the Unicode `Zs` general\ncategory, or a tab (" - "`U+0009`), line feed (`U+000A" @@ -241,8 +240,9 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "), or\ncarriage return (`U+000D`).\n\n" - "[Unicode whitespace](@) is a sequence of one or " - "more\n[Unicode whitespace characters].\n\n" -- "A [tab](@) is `U+0009`.\n\n" -- "A [space](@) is `U+0020`.\n\n" +- "A [tab](@) is `U+0009`.\n" +- "\nA [space](@) is `U+0020`.\n" +- "\n" - "An [ASCII control character](@) is a character between `" - "U+0000–1F` (both\nincluding) or " - "`U+007F`.\n\n" @@ -373,7 +373,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "be replaced\nwith the REPLACEMENT CHARACTER (" - "`U+FFFD`).\n\n\n" - "## Backslash escapes\n\n" -- "Any ASCII punctuation character may be backslash-escaped:\n\n" +- "Any ASCII punctuation character may be backslash-escaped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -388,7 +389,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "?@[\\]^_`{|}~

\n" - "````````````````" - "````````````````\n\n\n" -- "Backslashes before other characters are treated as literal\nbackslashes:\n\n" +- "Backslashes before other characters are treated as literal\nbackslashes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -416,7 +418,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "&ouml; not a character entity

\n" - "````````````````" - "````````````````\n\n\n" -- "If a backslash is itself escaped, the following character is not:\n\n" +- "If a backslash is itself escaped, the following character is not:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -568,7 +571,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

" ആ ಫ

\n" - "````````````````" - "````````````````\n\n\n" -- "Here are some nonentities:\n\n" +- "Here are some nonentities:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -754,7 +758,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
\n
\n" - "````````````````" - "````````````````\n\n\n" -- "Wrong characters:\n\n" +- "Wrong characters:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n+++\n.\n

+++

\n" @@ -765,7 +770,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "example\n===\n.\n

===

\n" - "````````````````" - "````````````````\n\n\n" -- "Not enough characters:\n\n" +- "Not enough characters:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -773,7 +779,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "__

\n" - "````````````````" - "````````````````\n\n\n" -- "Up to three spaces of indentation are allowed:\n\n" +- "Up to three spaces of indentation are allowed:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -781,7 +788,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
\n
\n" - "````````````````" - "````````````````\n\n\n" -- "Four spaces of indentation is too many:\n\n" +- "Four spaces of indentation is too many:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -796,7 +804,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "***

\n" - "````````````````" - "````````````````\n\n\n" -- "More than three characters may be used:\n\n" +- "More than three characters may be used:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -805,7 +814,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "_____\n.\n
\n" - "````````````````" - "````````````````\n\n\n" -- "Spaces and tabs are allowed between the characters:\n\n" +- "Spaces and tabs are allowed between the characters:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n - - -\n.\n
\n" @@ -823,13 +833,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "example\n- - - -\n.\n
\n" - "````````````````" - "````````````````\n\n\n" -- "Spaces and tabs are allowed at the end:\n\n" +- "Spaces and tabs are allowed at the end:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n- - - - \n.\n
\n" - "````````````````" - "````````````````\n\n\n" -- "However, no other characters may occur in the line:\n\n" +- "However, no other characters may occur in the line:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -849,7 +861,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

-

\n" - "````````````````" - "````````````````\n\n\n" -- "Thematic breaks do not need blank lines before or after:\n\n" +- "Thematic breaks do not need blank lines before or after:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -859,7 +872,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • bar
  • \n\n" - "````````````````" - "````````````````\n\n\n" -- "Thematic breaks can interrupt a paragraph:\n\n" +- "Thematic breaks can interrupt a paragraph:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -917,7 +931,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "contents of the heading are stripped of leading and trailing space or tabs\n" - "before being parsed as inline content. " - "The heading level is equal to the number\nof `#`" -- " characters in the opening sequence.\n\nSimple headings:\n\n" +- " characters in the opening sequence.\n\nSimple headings:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -932,7 +947,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    foo
    \n" - "````````````````" - "````````````````\n\n\n" -- "More than six `#` characters is not a heading:\n\n" +- "More than six `#` characters is not a heading:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -956,7 +972,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    #hashtag

    \n" - "````````````````" - "````````````````\n\n\n" -- "This is not a heading, because the first `#` is escaped:\n\n" +- "This is not a heading, because the first `#` is escaped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -964,7 +981,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    ## foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Contents are parsed as inlines:\n\n" +- "Contents are parsed as inlines:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -973,13 +991,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz*\n" - "````````````````" - "````````````````\n\n\n" -- "Leading and trailing spaces or tabs are ignored in parsing inline content:\n\n" +- "Leading and trailing spaces or tabs are ignored in parsing inline content:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n# foo \n.\n

    foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Up to three spaces of indentation are allowed:\n\n" +- "Up to three spaces of indentation are allowed:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -989,7 +1009,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Four spaces of indentation is too many:\n\n" +- "Four spaces of indentation is too many:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1003,7 +1024,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "foo\n # bar\n.\n

    foo\n# bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "A closing sequence of `#` characters is optional:\n\n" +- "A closing sequence of `#` characters is optional:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1012,7 +1034,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "It need not be the same length as the opening sequence:\n\n" +- "It need not be the same length as the opening sequence:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1023,7 +1046,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    foo
    \n" - "````````````````" - "````````````````\n\n\n" -- "Spaces or tabs are allowed after the closing sequence:\n\n" +- "Spaces or tabs are allowed after the closing sequence:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1041,7 +1065,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    foo ### b

    \n" - "````````````````" - "````````````````\n\n\n" -- "The closing sequence must be preceded by a space or tab:\n\n" +- "The closing sequence must be preceded by a space or tab:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1080,7 +1105,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    Bar foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "ATX headings can be empty:\n\n" +- "ATX headings can be empty:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1113,7 +1139,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "In general, a setext heading need not be preceded or followed by a\n" - "blank line. However, it cannot interrupt a paragraph, so when a\n" - "setext heading comes after a paragraph, a blank line is needed between\n" -- "them.\n\nSimple examples:\n\n" +- "them.\n\nSimple examples:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1125,7 +1152,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "h2>\n" - "````````````````" - "````````````````\n\n\n" -- "The content of the header may span more than one line:\n\n" +- "The content of the header may span more than one line:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1145,7 +1173,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz
    \n" - "````````````````" - "````````````````\n\n\n" -- "The underlining can be any length:\n\n" +- "The underlining can be any length:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1167,7 +1196,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    Foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Four spaces of indentation is too many:\n\n" +- "Four spaces of indentation is too many:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1185,7 +1215,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    Foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Four spaces of indentation is too many:\n\n" +- "Four spaces of indentation is too many:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1193,7 +1224,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "---

    \n" - "````````````````" - "````````````````\n\n\n" -- "The setext heading underline cannot contain internal spaces or tabs:\n\n" +- "The setext heading underline cannot contain internal spaces or tabs:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1211,7 +1243,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    Foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Nor does a backslash at the end:\n\n" +- "Nor does a backslash at the end:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1281,7 +1314,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    Baz

    \n" - "````````````````" - "````````````````\n\n\n" -- "Setext headings cannot be empty:\n\n" +- "Setext headings cannot be empty:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1333,8 +1367,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "**Compatibility note:** Most existing Markdown implementations\n" - "do not allow the text of setext headings to span multiple lines.\n" - "But there is no consensus about how to interpret\n\n" -- "``` markdown\nFoo\nbar\n---\nbaz\n```\n\n" -- "One can find four different interpretations:\n\n" +- "``` markdown\nFoo\nbar\n---\nbaz\n```" +- "\n\nOne can find four different interpretations:\n\n" - "1. paragraph \"Foo\", heading \"bar\", paragraph \"" - "baz\"\n" - "2. paragraph \"Foo bar\", thematic break, paragraph \"" @@ -1353,7 +1387,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    baz

    \n" - "````````````````" - "````````````````\n\n\n" -- "Authors who want interpretation 2 can put blank lines around\nthe thematic break,\n\n" +- "Authors who want interpretation 2 can put blank lines around\nthe thematic break,\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1372,7 +1407,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    baz

    \n" - "````````````````" - "````````````````\n\n\n" -- "Authors who want interpretation 3 can use backslash escapes:\n\n" +- "Authors who want interpretation 3 can use backslash escapes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1431,7 +1467,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "*hi*\n\n- one\n
    \n" - "````````````````" - "````````````````\n\n\n" -- "Here we have three chunks separated by blank lines:\n\n" +- "Here we have three chunks separated by blank lines:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1465,7 +1502,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n

    bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "And indented code can occur immediately before and after other kinds of\nblocks:\n\n" +- "And indented code can occur immediately before and after other kinds of\nblocks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1477,7 +1515,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "The first line can be preceded by more than four spaces of indentation:\n\n" +- "The first line can be preceded by more than four spaces of indentation:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1494,7 +1533,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "Trailing spaces or tabs are included in the code block's content:\n\n" +- "Trailing spaces or tabs are included in the code block's content:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1549,7 +1589,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - " is typically used to\nspecify the language of the code sample, and rendered in the " - "`class`\nattribute of the `code`" - " tag. However, this spec does not mandate any\nparticular treatment of the [" -- "info string].\n\nHere is a simple example with backticks:\n\n" +- "info string].\n\nHere is a simple example with backticks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1558,7 +1599,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "With tildes:\n\n" +- "With tildes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1567,7 +1609,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n" -- "Fewer than three backticks is not enough:\n\n" +- "Fewer than three backticks is not enough:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1575,7 +1618,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    foo

    \n" - "````````````````" - "````````````````\n\n" -- "The closing code fence must use the same character as the opening\nfence:\n\n" +- "The closing code fence must use the same character as the opening\nfence:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1592,7 +1636,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "The closing code fence must be at least as long as the opening fence:\n\n" +- "The closing code fence must be at least as long as the opening fence:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1635,7 +1680,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n

    bbb

    \n" - "````````````````" - "````````````````\n\n\n" -- "A code block can have all empty lines as its content:\n\n" +- "A code block can have all empty lines as its content:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1643,7 +1689,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "A code block can be empty:\n\n" +- "A code block can be empty:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1678,7 +1725,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "Four spaces of indentation is too many:\n\n" +- "Four spaces of indentation is too many:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1703,7 +1751,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    aaa\n
    \n" - "````````````````" - "````````````````\n\n\n" -- "This is not a closing fence, because it is indented 4 spaces:\n\n" +- "This is not a closing fence, because it is indented 4 spaces:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1712,7 +1761,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n\n" -- "Code fences (opening and closing) cannot contain internal spaces or tabs:\n\n" +- "Code fences (opening and closing) cannot contain internal spaces or tabs:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1783,7 +1833,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">
    \n" - "````````````````" - "````````````````\n\n\n" -- "[Info strings] for backtick code blocks cannot contain backticks:\n\n" +- "[Info strings] for backtick code blocks cannot contain backticks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1803,7 +1854,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "Closing code fences cannot have [info strings]:\n\n" +- "Closing code fences cannot have [info strings]:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1942,7 +1994,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n *hello*\n \n" - "````````````````" - "````````````````\n\n\n" -- "A block can also start with a closing tag:\n\n" +- "A block can also start with a closing tag:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1950,7 +2003,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "*foo*\n" - "````````````````" - "````````````````\n\n\n" -- "Here we have two HTML blocks with a Markdown paragraph between them:\n\n" +- "Here we have two HTML blocks with a Markdown paragraph between them:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -1989,7 +2043,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    bar

    \n" - "````````````````" - "````````````````\n\n\n\n" -- "A partial tag need not even be completed (garbage\nin, garbage out):\n\n" +- "A partial tag need not even be completed (garbage\nin, garbage out):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2059,7 +2114,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "*bar*\n
    \n" - "````````````````" - "````````````````\n\n\n" -- "In type 7 blocks, the [tag name] can be anything:\n\n" +- "In type 7 blocks, the [tag name] can be anything:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2126,7 +2182,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "Instead of ending at the first blank line, these blocks\n" - "end at the first line containing a corresponding end tag.\n" - "As a result, these blocks can contain blank lines:\n\n" -- "A pre tag (type 1):\n\n" +- "A pre tag (type 1):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2142,7 +2199,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n

    okay

    \n" - "````````````````" - "````````````````\n\n\n" -- "A script tag (type 1):\n\n" +- "A script tag (type 1):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2157,7 +2215,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    okay

    \n" - "````````````````" - "````````````````\n\n\n" -- "A textarea tag (type 1):\n\n" +- "A textarea tag (type 1):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2166,7 +2225,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "_bar_\n\n\n" - "````````````````" - "````````````````\n\n" -- "A style tag (type 1):\n\n" +- "A style tag (type 1):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2204,7 +2264,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • foo
  • \n\n" - "````````````````" - "````````````````\n\n\n" -- "The end tag can occur on the same line as the start tag:\n\n" +- "The end tag can occur on the same line as the start tag:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2231,7 +2292,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "1. *bar*\n" - "````````````````" - "````````````````\n\n\n" -- "A comment (type 2):\n\n" +- "A comment (type 2):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2240,7 +2302,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    okay

    \n" - "````````````````" - "````````````````\n\n\n\n" -- "A processing instruction (type 3):\n\n" +- "A processing instruction (type 3):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2249,7 +2312,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    okay

    \n" - "````````````````" - "````````````````\n\n\n" -- "A declaration (type 4):\n\n" +- "A declaration (type 4):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2257,7 +2321,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "DOCTYPE html>\n" - "````````````````" - "````````````````\n\n\n" -- "CDATA (type 5):\n\n" +- "CDATA (type 5):\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2310,7 +2375,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \nbar\n
    \n*foo*\n" - "````````````````" - "````````````````\n\n\n" -- "HTML blocks of type 7 cannot interrupt a paragraph:\n\n" +- "HTML blocks of type 7 cannot interrupt a paragraph:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2344,7 +2410,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "if no matching end tag is found. Second, it provides a very simple\n" - "and flexible way of including Markdown content inside HTML tags:\n" - "simply separate the Markdown from the HTML using blank lines:\n\n" -- "Compare:\n\n" +- "Compare:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2455,7 +2522,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "The title may extend over multiple lines:\n\n" +- "The title may extend over multiple lines:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2466,7 +2534,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\">foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "However, it may not contain a [blank line]:\n\n" +- "However, it may not contain a [blank line]:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2477,7 +2546,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    [foo]

    \n" - "````````````````" - "````````````````\n\n\n" -- "The title may be omitted:\n\n" +- "The title may be omitted:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2486,7 +2556,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "The link destination may not be omitted:\n\n" +- "The link destination may not be omitted:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2495,7 +2566,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    [foo]

    \n" - "````````````````" - "````````````````\n\n " -- "However, an empty link destination may be specified using\n angle brackets:\n\n" +- "However, an empty link destination may be specified using\n angle brackets:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2504,7 +2576,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "a>

    \n" - "````````````````" - "````````````````\n\n" -- "The title must be separated from the link destination by\nspaces or tabs:\n\n" +- "The title must be separated from the link destination by\nspaces or tabs:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2514,7 +2587,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/p>\n

    [foo]

    \n" - "````````````````" - "````````````````\n\n\n" -- "Both title and destination can contain backslash escapes\nand literal backslashes:\n\n" +- "Both title and destination can contain backslash escapes\nand literal backslashes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2526,7 +2600,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "A link can come before its corresponding definition:\n\n" +- "A link can come before its corresponding definition:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2535,7 +2610,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "If there are several matching definitions, the first one takes\nprecedence:\n\n" +- "If there are several matching definitions, the first one takes\nprecedence:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2573,7 +2649,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "example\n[foo]: /url\n.\n" - "````````````````" - "````````````````\n\n\n" -- "Here is another one:\n\n" +- "Here is another one:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2591,7 +2668,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "title" ok

    \n" - "````````````````" - "````````````````\n\n\n" -- "This is a link reference definition, but it has no title:\n\n" +- "This is a link reference definition, but it has no title:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2612,7 +2690,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    [foo]

    \n" - "````````````````" - "````````````````\n\n\n" -- "This is not a link reference definition, because it occurs inside\na code block:\n\n" +- "This is not a link reference definition, because it occurs inside\na code block:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2623,7 +2702,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    [foo]

    \n" - "````````````````" - "````````````````\n\n\n" -- "A [link reference definition] cannot interrupt a paragraph.\n\n" +- "A [link reference definition] cannot interrupt a paragraph.\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2697,7 +2777,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ".\nThe contents of the paragraph are the result of parsing the\nparagraph'" - "s raw content as inlines. The paragraph's raw content\n" - "is formed by concatenating the lines and removing initial and final\n" -- "spaces or tabs.\n\nA simple example with two paragraphs:\n\n" +- "spaces or tabs.\n\nA simple example with two paragraphs:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2705,7 +2786,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    bbb

    \n" - "````````````````" - "````````````````\n\n\n" -- "Paragraphs can contain multiple lines, but no blank lines:\n\n" +- "Paragraphs can contain multiple lines, but no blank lines:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2714,7 +2796,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "ddd

    \n" - "````````````````" - "````````````````\n\n\n" -- "Multiple blank lines between paragraphs have no effect:\n\n" +- "Multiple blank lines between paragraphs have no effect:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2722,7 +2805,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    bbb

    \n" - "````````````````" - "````````````````\n\n\n" -- "Leading spaces or tabs are skipped:\n\n" +- "Leading spaces or tabs are skipped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2768,7 +2852,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "[Blank lines] between block-level elements are ignored,\n" - "except for the role they play in determining whether a [list]\nis [tight" - "] or [loose].\n\n" -- "Blank lines at the beginning and end of the document are also ignored.\n\n" +- "Blank lines at the beginning and end of the document are also ignored.\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2822,8 +2907,9 @@ input_file: tests/inputs/markdown/commonmark_spec.md - 3. **Consecutiveness. - "** A document cannot contain two [block\n quotes]" - " in a row unless there is a [blank line] between them.\n\n" -- "Nothing else counts as a [block quote](#block-quotes).\n\n" -- "Here is a simple example:\n\n" +- "Nothing else counts as a [block quote](#block-quotes).\n" +- "\nHere is a simple example:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2832,7 +2918,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz

    \n\n" - "````````````````" - "````````````````\n\n\n" -- "The space or tab after the `>` characters can be omitted:\n\n" +- "The space or tab after the `>` characters can be omitted:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2851,7 +2938,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz

    \n\n" - "````````````````" - "````````````````\n\n\n" -- "Four spaces of indentation is too many:\n\n" +- "Four spaces of indentation is too many:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2871,7 +2959,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz

    \n\n" - "````````````````" - "````````````````\n\n\n" -- "A block quote can contain some lazy and some non-lazy\ncontinuation lines:\n\n" +- "A block quote can contain some lazy and some non-lazy\ncontinuation lines:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2883,8 +2972,9 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "Laziness only applies to lines that would have been continuations of\n" - "paragraphs had they been prepended with [block quote markers].\n" - "For example, the `> ` cannot be omitted in the second line of\n\n" -- "``` markdown\n> foo\n> ---\n```\n\n" -- "without changing the meaning:\n\n" +- "``` markdown\n> foo\n> ---\n```" +- "\n\nwithout changing the meaning:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2893,9 +2983,10 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "Similarly, if we omit the `> ` in the second line of\n\n" -- "``` markdown\n> - foo\n> - bar\n```\n\n" -- "then the block quote ends after the first line:\n\n" +- "Similarly, if we omit the `> ` in the second line of\n" +- "\n``` markdown\n> - foo\n> - bar\n```" +- "\n\nthen the block quote ends after the first line:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2925,7 +3016,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "Note that in the following case, we have a [lazy\ncontinuation line]:\n\n" +- "Note that in the following case, we have a [lazy\ncontinuation line]:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2934,13 +3026,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "To see why, note that in\n\n" -- "```markdown\n> foo\n> - bar\n```\n\n" +- "To see why, note that in\n" +- "\n```markdown\n> foo\n> - bar\n```" +- "\n\n" - "the `- bar` is indented too far to start a list, " - "and can't\n" - "be an indented code block because indented code blocks cannot\n" - "interrupt paragraphs, so it is [paragraph continuation text].\n\n" -- "A block quote can be empty:\n\n" +- "A block quote can be empty:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n>\n.\n
    \n
    \n" @@ -2953,7 +3047,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "A block quote can have initial or final blank lines:\n\n" +- "A block quote can have initial or final blank lines:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2961,7 +3056,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    foo

    \n\n" - "````````````````" - "````````````````\n\n\n" -- "A blank line always separates block quotes:\n\n" +- "A blank line always separates block quotes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2986,7 +3082,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "To get a block quote with two paragraphs, use:\n\n" +- "To get a block quote with two paragraphs, use:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -2995,7 +3092,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    bar

    \n\n" - "````````````````" - "````````````````\n\n\n" -- "Block quotes can interrupt paragraphs:\n\n" +- "Block quotes can interrupt paragraphs:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3004,7 +3102,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "In general, blank lines are not needed before or after block\nquotes:\n\n" +- "In general, blank lines are not needed before or after block\nquotes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3108,7 +3207,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "2. " - "If any line is a [thematic break][thematic breaks] then\n " - "that line is not a list item.\n\n" -- "For example, let *Ls* be the lines\n\n" +- "For example, let *Ls* be the lines\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3226,7 +3326,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    2.two

    \n" - "````````````````" - "````````````````\n\n\n" -- "A list item may contain blocks that are separated by more than\none blank line.\n\n" +- "A list item may contain blocks that are separated by more than\none blank line.\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3236,7 +3337,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "A list item may contain any kind of block:\n\n" +- "A list item may contain any kind of block:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3260,7 +3362,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n" -- "Note that ordered list start numbers must be nine digits or less:\n\n" +- "Note that ordered list start numbers must be nine digits or less:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3276,7 +3379,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    1234567890. not ok

    \n" - "````````````````" - "````````````````\n\n\n" -- "A start number may begin with 0s:\n\n" +- "A start number may begin with 0s:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3291,7 +3395,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • ok
  • \n\n" - "````````````````" - "````````````````\n\n\n" -- "A start number may not be negative:\n\n" +- "A start number may not be negative:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3326,7 +3431,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "And in this case it is 11 spaces:\n\n" +- "And in this case it is 11 spaces:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3420,7 +3526,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "list item (bullet or ordered) is determined by the type of its list\n " - "marker. If the list item is ordered, then it is also assigned a\n " - "start number, based on the ordered list marker.\n\n" -- "Here are some list items that start with a blank line but are not empty:\n\n" +- "Here are some list items that start with a blank line but are not empty:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3452,7 +3559,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n

    foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Here is an empty bullet list item:\n\n" +- "Here is an empty bullet list item:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3473,7 +3581,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • bar
  • \n\n" - "````````````````" - "````````````````\n\n\n" -- "Here is an empty ordered list item:\n\n" +- "Here is an empty ordered list item:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3483,7 +3592,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • bar
  • \n\n" - "````````````````" - "````````````````\n\n\n" -- "A list may start or end with an empty list item:\n\n" +- "A list may start or end with an empty list item:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3491,7 +3601,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n" -- "However, an empty list item cannot interrupt a paragraph:\n\n" +- "However, an empty list item cannot interrupt a paragraph:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3507,7 +3618,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - " by up to three spaces of indentation (the same for each line) " - "also\n constitutes a list item with the same contents and attributes. If a line is\n " - "empty, then it need not be indented.\n\n" -- "Indented one space:\n\n" +- "Indented one space:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3521,7 +3633,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "Indented two spaces:\n\n" +- "Indented two spaces:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3535,7 +3648,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "Indented three spaces:\n\n" +- "Indented three spaces:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3549,7 +3663,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "Four spaces indent gives a code block:\n\n" +- "Four spaces indent gives a code block:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3568,7 +3683,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "paragraph continuation text] is a\n " - "list item with the same contents and attributes. The unindented\n lines are called\n " - "[lazy continuation line](@)s.\n\n" -- "Here is an example with [lazy continuation lines]:\n\n" +- "Here is an example with [lazy continuation lines]:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3582,7 +3698,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "Indentation can be partially deleted:\n\n" +- "Indentation can be partially deleted:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3591,7 +3708,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "These examples show how laziness can work in nested structures:\n\n" +- "These examples show how laziness can work in nested structures:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3623,7 +3741,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ". A sublist must be indented the same number\n" - "of spaces of indentation a paragraph would need to be in order to be " - "included\nin the list item.\n\n" -- "So, in this case we need two spaces indent:\n\n" +- "So, in this case we need two spaces indent:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3635,7 +3754,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n\n\n" - "````````````````" - "````````````````\n\n\n" -- "One is not enough:\n\n" +- "One is not enough:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3646,7 +3766,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • boo
  • \n\n" - "````````````````" - "````````````````\n\n\n" -- "Here we need four, because the list marker is wider:\n\n" +- "Here we need four, because the list marker is wider:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3656,7 +3777,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n\n" - "````````````````" - "````````````````\n\n\n" -- "Three is not enough:\n\n" +- "Three is not enough:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3666,7 +3788,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "A list may be the first block in a list item:\n\n" +- "A list may be the first block in a list item:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3685,7 +3808,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n\n" -- "A list item can contain a heading:\n\n" +- "A list item can contain a heading:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3767,15 +3891,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "This rule is superior, we claim, to any rule requiring a fixed level of\n" - "indentation from the margin. The four-space rule is clear but\n" - "unnatural. It is quite unintuitive that\n\n" -- "``` markdown\n- foo\n\n bar\n\n - baz\n```\n\n" -- "should be parsed as two lists with an intervening paragraph,\n\n" -- "``` html\n
      \n" +- "``` markdown\n- foo\n\n bar\n\n - baz\n```" +- "\n\nshould be parsed as two lists with an intervening paragraph,\n" +- "\n``` html\n
        \n" - "
      • foo
      • \n
      \n" - "

      bar

      \n
        \n" - "
      • baz
      • \n
      \n" - "```\n\n" -- "as the four-space rule demands, rather than a single list,\n\n" -- "``` html\n
        \n
      • \n" +- "as the four-space rule demands, rather than a single list,\n" +- "\n``` html\n
          \n
        • \n" - "

          foo

          \n" - "

          bar

          \n
            \n" - "
          • baz
          • \n
          \n" @@ -3788,18 +3912,18 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "*less than*" - " the\noriginal list marker to be included in the list item. For example,\n" - "`Markdown.pl` parses\n\n" -- "``` markdown\n - one\n\n two\n```\n\n" -- "as a single list item, with `two` a continuation paragraph:\n\n" -- "``` html\n
            \n
          • \n" +- "``` markdown\n - one\n\n two\n```" +- "\n\nas a single list item, with `two` a continuation paragraph:\n" +- "\n``` html\n
              \n
            • \n" - "

              one

              \n

              two

              \n" -- "
            • \n
            \n```\n\nand similarly\n\n" -- "``` markdown\n> - one\n>\n> two\n```\n\nas\n\n" -- "``` html\n
            \n
              \n" +- "\n
            \n```\n\nand similarly\n" +- "\n``` markdown\n> - one\n>\n> two\n```\n\nas\n" +- "\n``` html\n
            \n
              \n" - "
            • \n

              one

              \n" - "

              two

              \n
            • \n" - "
            \n
            \n```\n\n" -- "This is extremely unintuitive.\n\n" -- "Rather than requiring a fixed indent from the margin, we could require\n" +- "This is extremely unintuitive.\n" +- "\nRather than requiring a fixed indent from the margin, we could require\n" - "a fixed indent (say, two spaces, or even one space) from " - "the list marker (which\n" - "may itself be indented). " @@ -3808,15 +3932,16 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "as a list item with a subparagraph, even though the paragraph " - "`bar`\nis not indented as far as the first paragraph " - "`foo`:\n\n" -- "``` markdown\n 10. foo\n\n bar \n```\n\n" +- "``` markdown\n 10. foo\n\n bar \n```" +- "\n\n" - "Arguably this text does read like a list item with `bar` " - "as a subparagraph,\n" - "which may count in favor of the proposal. " - "However, on this proposal indented\n" - "code would have to be indented six spaces after the list marker. " - "And this\nwould break a lot of existing Markdown, which has the pattern:\n\n" -- "``` markdown\n1. foo\n\n indented code\n```\n\n" -- "where the code is indented eight spaces. " +- "``` markdown\n1. foo\n\n indented code\n```" +- "\n\nwhere the code is indented eight spaces. " - "The spec above, by contrast, will\n" - "parse this text as expected, since the code block's indentation " - "is measured\nfrom the beginning of `foo`.\n\n" @@ -3857,7 +3982,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "(The difference in HTML output is that paragraphs in a loose list " - "are\nwrapped in `

            `" - " tags, while paragraphs in a tight list are not.)\n\n" -- "Changing the bullet or ordered list delimiter starts a new list:\n\n" +- "Changing the bullet or ordered list delimiter starts a new list:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3915,8 +4041,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "tight\"),\nthen\n\n" - "``` markdown\nI need to buy\n- new shoes\n- a coat\n" - "- a plane ticket\n```\n\n" -- "by itself should be a paragraph followed by a nested sublist.\n\n" -- "Since it is well established Markdown practice to allow lists to\n" +- "by itself should be a paragraph followed by a nested sublist.\n" +- "\nSince it is well established Markdown practice to allow lists to\n" - "interrupt paragraphs inside list items, the [principle of\nuniformity]" - " requires us to allow this outside list items as\nwell. (" - "[reStructuredText](https://" @@ -3935,7 +4061,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "The number of doors is 6.

            \n" - "````````````````" - "````````````````\n\n" -- "We may still get an unintended result in cases like\n\n" +- "We may still get an unintended result in cases like\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -3947,8 +4074,9 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n" - "````````````````" - "````````````````\n\n" -- "but this rule should prevent most spurious list captures.\n\n" -- "There can be any number of blank lines between items:\n\n" +- "but this rule should prevent most spurious list captures.\n" +- "\nThere can be any number of blank lines between items:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4067,7 +4195,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
          \n" - "````````````````" - "````````````````\n\n\n" -- "So is this, with a empty second item:\n\n" +- "So is this, with a empty second item:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4103,7 +4232,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
        • \n
        \n" - "````````````````" - "````````````````\n\n\n" -- "This is a tight list, because the blank lines are in a code block:\n\n" +- "This is a tight list, because the blank lines are in a code block:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4127,7 +4257,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
      • d
      • \n
      \n" - "````````````````" - "````````````````\n\n\n" -- "This is a tight list, because the blank line is inside the\nblock quote:\n\n" +- "This is a tight list, because the blank line is inside the\nblock quote:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4150,7 +4281,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    \n" - "````````````````" - "````````````````\n\n\n" -- "A single-paragraph list is tight:\n\n" +- "A single-paragraph list is tight:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4177,7 +4309,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n\n" - "````````````````" - "````````````````\n\n\n" -- "Here the outer list is loose, the inner list tight:\n\n" +- "Here the outer list is loose, the inner list tight:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4230,7 +4363,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "front and back. This allows you to include code that begins\n " - "or ends with backtick characters, which must be separated by\n " - "whitespace from the opening or closing backtick strings.\n\n" -- "This is a simple code span:\n\n" +- "This is a simple code span:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4248,7 +4382,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "p>\n" - "````````````````" - "````````````````\n\n\n" -- "This example shows the motivation for stripping leading and trailing\nspaces:\n\n" +- "This example shows the motivation for stripping leading and trailing\nspaces:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4256,7 +4391,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    ``

    \n" - "````````````````" - "````````````````\n\n" -- "Note that only *one* space is stripped:\n\n" +- "Note that only *one* space is stripped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4264,7 +4400,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    ``

    \n" - "````````````````" - "````````````````\n\n" -- "The stripping only happens if the space is on both\nsides of the string:\n\n" +- "The stripping only happens if the space is on both\nsides of the string:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4281,7 +4418,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

     b 

    \n" - "````````````````" - "````````````````\n\n" -- "No stripping occurs if the code span contains only spaces:\n\n" +- "No stripping occurs if the code span contains only spaces:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4289,7 +4427,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "[Line endings] are treated like spaces:\n\n" +- "[Line endings] are treated like spaces:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4305,7 +4444,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Interior spaces are not collapsed:\n\n" +- "Interior spaces are not collapsed:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4317,8 +4457,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "Note that browsers will typically collapse consecutive spaces\n" - "when rendering ``" - " elements, so it is recommended that\nthe following CSS be used:\n\n " -- "code{white-space: pre-wrap;}\n\n\n" -- "Note that backslash escapes do not work in code spans. All backslashes\n" +- "code{white-space: pre-wrap;}\n" +- "\n\nNote that backslash escapes do not work in code spans. All backslashes\n" - "are treated literally:\n\n" - "````````````````" - "```````````````` " @@ -4360,7 +4500,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "p>\n" - "````````````````" - "````````````````\n\n\n" -- "And this is not parsed as a link:\n\n" +- "And this is not parsed as a link:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4380,7 +4521,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ";`

    \n" - "````````````````" - "````````````````\n\n\n" -- "But this is an HTML tag:\n\n" +- "But this is an HTML tag:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4389,7 +4531,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "p>\n" - "````````````````" - "````````````````\n\n\n" -- "And this is code:\n\n" +- "And this is code:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4400,7 +4543,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "But this is an autolink:\n\n" +- "But this is an autolink:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4621,7 +4765,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "`*foo*<" - "/a>` rather than as\n " - "`[foo](bar)`" -- ".\n\nThese rules can be illustrated through a series of examples.\n\nRule 1:\n\n" +- ".\n\nThese rules can be illustrated through a series of examples.\n\nRule 1:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4651,13 +4796,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ";*

    \n" - "````````````````" - "````````````````\n\n\n" -- "Unicode nonbreaking spaces count as whitespace, too:\n\n" +- "Unicode nonbreaking spaces count as whitespace, too:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n* a *\n.\n

    * a *

    \n" - "````````````````" - "````````````````\n\n\n" -- "Unicode symbols count as punctuation, too:\n\n" +- "Unicode symbols count as punctuation, too:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4668,7 +4815,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    *€*charlie.

    \n" - "````````````````" - "````````````````\n\n\n" -- "Intraword emphasis with `*` is permitted:\n\n" +- "Intraword emphasis with `*` is permitted:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4685,7 +4833,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "Rule 2:\n\n" +- "Rule 2:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4713,7 +4862,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ";_

    \n" - "````````````````" - "````````````````\n\n\n" -- "Emphasis with `_` is not allowed inside words:\n\n" +- "Emphasis with `_` is not allowed inside words:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4759,8 +4909,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Rule 3:\n\n" -- "This is not emphasis, because the closing delimiter does\n" +- "Rule 3:\n" +- "\nThis is not emphasis, because the closing delimiter does\n" - "not match the opening delimiter:\n\n" - "````````````````" - "```````````````` " @@ -4777,7 +4927,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    *foo bar *

    \n" - "````````````````" - "````````````````\n\n\n" -- "A line ending also counts as whitespace:\n\n" +- "A line ending also counts as whitespace:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4796,7 +4947,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    *(*foo)

    \n" - "````````````````" - "````````````````\n\n\n" -- "The point of this restriction is more easily appreciated\nwith this example:\n\n" +- "The point of this restriction is more easily appreciated\nwith this example:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4805,7 +4957,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ")

    \n" - "````````````````" - "````````````````\n\n\n" -- "Intraword emphasis with `*` is allowed:\n\n" +- "Intraword emphasis with `*` is allowed:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4814,8 +4967,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n\n" -- "Rule 4:\n\n" -- "This is not emphasis, because the closing `_` is preceded by\n" +- "Rule 4:\n" +- "\nThis is not emphasis, because the closing `_` is preceded by\n" - "whitespace:\n\n" - "````````````````" - "```````````````` " @@ -4833,7 +4986,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    _(_foo)

    \n" - "````````````````" - "````````````````\n\n\n" -- "This is emphasis within emphasis:\n\n" +- "This is emphasis within emphasis:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4842,7 +4996,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ")

    \n" - "````````````````" - "````````````````\n\n\n" -- "Intraword emphasis is disallowed for `_`:\n\n" +- "Intraword emphasis is disallowed for `_`:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4879,7 +5034,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "p>\n" - "````````````````" - "````````````````\n\n\n" -- "Rule 5:\n\n" +- "Rule 5:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4908,7 +5064,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "quot;**

    \n" - "````````````````" - "````````````````\n\n\n" -- "Intraword strong emphasis with `**` is permitted:\n\n" +- "Intraword strong emphasis with `**` is permitted:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4917,7 +5074,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "Rule 6:\n\n" +- "Rule 6:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4953,7 +5111,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "quot;__

    \n" - "````````````````" - "````````````````\n\n\n" -- "Intraword strong emphasis is forbidden with `__`:\n\n" +- "Intraword strong emphasis is forbidden with `__`:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -4997,8 +5156,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n\n" -- "Rule 7:\n\n" -- "This is not strong emphasis, because the closing delimiter is preceded\n" +- "Rule 7:\n" +- "\nThis is not strong emphasis, because the closing delimiter is preceded\n" - "by whitespace:\n\n" - "````````````````" - "```````````````` " @@ -5018,7 +5177,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    **(**foo)

    \n" - "````````````````" - "````````````````\n\n\n" -- "The point of this restriction is more easily appreciated\nwith these examples:\n\n" +- "The point of this restriction is more easily appreciated\nwith these examples:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5049,7 +5209,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Intraword emphasis:\n\n" +- "Intraword emphasis:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5058,8 +5219,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "Rule 8:\n\n" -- "This is not strong emphasis, because the closing delimiter is\n" +- "Rule 8:\n" +- "\nThis is not strong emphasis, because the closing delimiter is\n" - "preceded by whitespace:\n\n" - "````````````````" - "```````````````` " @@ -5077,7 +5238,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    __(__foo)

    \n" - "````````````````" - "````````````````\n\n\n" -- "The point of this restriction is more easily appreciated\nwith this example:\n\n" +- "The point of this restriction is more easily appreciated\nwith this example:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5086,7 +5248,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ")

    \n" - "````````````````" - "````````````````\n\n\n" -- "Intraword strong emphasis is forbidden with `__`:\n\n" +- "Intraword strong emphasis is forbidden with `__`:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5123,8 +5286,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "p>\n" - "````````````````" - "````````````````\n\n\n" -- "Rule 9:\n\n" -- "Any nonempty sequence of inline elements can be the contents of an\n" +- "Rule 9:\n" +- "\nAny nonempty sequence of inline elements can be the contents of an\n" - "emphasized span.\n\n" - "````````````````" - "```````````````` " @@ -5142,7 +5305,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "In particular, emphasis and strong emphasis can be nested\ninside emphasis:\n\n" +- "In particular, emphasis and strong emphasis can be nested\ninside emphasis:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5191,8 +5355,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz

    \n" - "````````````````" - "````````````````\n\n" -- "Note that in the preceding case, the interpretation\n\n" -- "``` markdown\n" +- "Note that in the preceding case, the interpretation\n" +- "\n``` markdown\n" - "

    foobar" - "baz\n```\n\n\n" @@ -5259,7 +5423,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Indefinite levels of nesting are possible:\n\n" +- "Indefinite levels of nesting are possible:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5279,7 +5444,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "There can be no empty emphasis or strong emphasis:\n\n" +- "There can be no empty emphasis or strong emphasis:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5295,8 +5461,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n\n" -- "Rule 10:\n\n" -- "Any nonempty sequence of inline elements can be the contents of an\n" +- "Rule 10:\n" +- "\nAny nonempty sequence of inline elements can be the contents of an\n" - "strongly emphasized span.\n\n" - "````````````````" - "```````````````` " @@ -5314,7 +5480,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "In particular, emphasis and strong emphasis can be nested\ninside strong emphasis:\n\n" +- "In particular, emphasis and strong emphasis can be nested\ninside strong emphasis:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5379,7 +5546,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Indefinite levels of nesting are possible:\n\n" +- "Indefinite levels of nesting are possible:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5400,7 +5568,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "There can be no empty emphasis or strong emphasis:\n\n" +- "There can be no empty emphasis or strong emphasis:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5416,7 +5585,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n\n" -- "Rule 11:\n\n" +- "Rule 11:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5514,7 +5684,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/p>\n" - "````````````````" - "````````````````\n\n\n\n" -- "Rule 12:\n\n" +- "Rule 12:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5644,7 +5815,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/em>

    \n" - "````````````````" - "````````````````\n\n\n" -- "However, strong emphasis within strong emphasis is possible without\nswitching delimiters:\n\n" +- "However, strong emphasis within strong emphasis is possible without\nswitching delimiters:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5671,7 +5843,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "strong>

    \n" - "````````````````" - "````````````````\n\n\n" -- "Rule 14:\n\n" +- "Rule 14:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5688,7 +5861,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "strong>

    \n" - "````````````````" - "````````````````\n\n\n" -- "Rule 15:\n\n" +- "Rule 15:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5706,7 +5880,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "bim bam

    \n" - "````````````````" - "````````````````\n\n\n" -- "Rule 16:\n\n" +- "Rule 16:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5723,7 +5898,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Rule 17:\n\n" +- "Rule 17:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5872,7 +6048,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "effect as described\nabove. The link'" - "s title consists of the link title, excluding its\n" - "enclosing delimiters, with backslash-escapes in effect " -- "as described\nabove.\n\nHere is a simple inline link:\n\n" +- "as described\nabove.\n\nHere is a simple inline link:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5881,7 +6058,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\"title\">link

    \n" - "````````````````" - "````````````````\n\n\n" -- "The title, the link text and even \nthe destination may be omitted:\n\n" +- "The title, the link text and even \nthe destination may be omitted:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5922,7 +6100,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n" -- "The destination can only contain spaces if it is\nenclosed in pointy brackets:\n\n" +- "The destination can only contain spaces if it is\nenclosed in pointy brackets:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5938,7 +6117,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">link

    \n" - "````````````````" - "````````````````\n\n" -- "The destination cannot contain line endings,\neven if enclosed in pointy brackets:\n\n" +- "The destination cannot contain line endings,\neven if enclosed in pointy brackets:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5954,7 +6134,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "bar>)

    \n" - "````````````````" - "````````````````\n\n" -- "The destination can contain `)` if it is enclosed\nin pointy brackets:\n\n" +- "The destination can contain `)` if it is enclosed\nin pointy brackets:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5963,7 +6144,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n" -- "Pointy brackets that enclose links must be unescaped:\n\n" +- "Pointy brackets that enclose links must be unescaped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5972,7 +6154,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ";)

    \n" - "````````````````" - "````````````````\n\n" -- "These are not links, because the opening pointy bracket\nis not matched properly:\n\n" +- "These are not links, because the opening pointy bracket\nis not matched properly:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -5984,7 +6167,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "[a](c)

    \n" - "````````````````" - "````````````````\n\n" -- "Parentheses inside the link destination may be escaped:\n\n" +- "Parentheses inside the link destination may be escaped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6039,7 +6223,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "link

    \n" - "````````````````" - "````````````````\n\n\n" -- "A link can contain fragment identifiers and queries:\n\n" +- "A link can contain fragment identifiers and queries:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6094,7 +6279,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\">link

    \n" - "````````````````" - "````````````````\n\n\n" -- "Titles may be in single quotes, double quotes, or parentheses:\n\n" +- "Titles may be in single quotes, double quotes, or parentheses:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6133,7 +6319,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Nested balanced quotes are not allowed without escaping:\n\n" +- "Nested balanced quotes are not allowed without escaping:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6143,7 +6330,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ";)

    \n" - "````````````````" - "````````````````\n\n\n" -- "But it is easy to work around this by using a different quote type:\n\n" +- "But it is easy to work around this by using a different quote type:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6180,7 +6368,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\"title\">link

    \n" - "````````````````" - "````````````````\n\n\n" -- "But it is not allowed between the link text and the\nfollowing parenthesis:\n\n" +- "But it is not allowed between the link text and the\nfollowing parenthesis:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6222,7 +6411,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "[bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "The link text may contain inline content:\n\n" +- "The link text may contain inline content:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6244,7 +6434,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "moon\" />

    \n" - "````````````````" - "````````````````\n\n\n" -- "However, links may not contain other links, at any level of nesting.\n\n" +- "However, links may not contain other links, at any level of nesting.\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6277,7 +6468,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "p>\n" - "````````````````" - "````````````````\n\n\n" -- "These cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n" +- "These cases illustrate the precedence of link text grouping over\nemphasis grouping:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6361,7 +6553,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "document is used. " - "(It is desirable in such cases to emit a warning.)\n\n" - "The link's URI and title are provided by the matching [link\n" -- "reference definition].\n\nHere is a simple example:\n\n" +- "reference definition].\n\nHere is a simple example:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6393,7 +6586,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "[bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "The link text may contain inline content:\n\n" +- "The link text may contain inline content:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6416,7 +6610,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "moon\" />

    \n" - "````````````````" - "````````````````\n\n\n" -- "However, links may not contain other links, at any level of nesting.\n\n" +- "However, links may not contain other links, at any level of nesting.\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6440,7 +6635,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "````````````````\n\n\n" - "(In the examples above, we have two [shortcut reference links]\n" - "instead of one [full reference link].)\n\n" -- "The following cases illustrate the precedence of link text grouping over\nemphasis grouping:\n\n" +- "The following cases illustrate the precedence of link text grouping over\nemphasis grouping:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6492,7 +6688,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "search=][ref]

    \n" - "````````````````" - "````````````````\n\n\n" -- "Matching is case-insensitive:\n\n" +- "Matching is case-insensitive:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6502,7 +6699,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\"title\">foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Unicode case fold is used:\n\n" +- "Unicode case fold is used:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6563,7 +6761,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "link label; but once shortcut references are introduced, it is\n" - "too dangerous to allow this, as it frequently leads to\n" - "unintended results.)\n\n" -- "When there are multiple matching [link reference definitions],\nthe first is used:\n\n" +- "When there are multiple matching [link reference definitions],\nthe first is used:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6585,7 +6784,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    [bar][foo!]

    \n" - "````````````````" - "````````````````\n\n\n" -- "[Link labels] cannot contain brackets, unless they are\nbackslash-escaped:\n\n" +- "[Link labels] cannot contain brackets, unless they are\nbackslash-escaped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6625,7 +6825,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "Note that in this example `]` is not backslash-escaped:\n\n" +- "Note that in this example `]` is not backslash-escaped:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6679,7 +6880,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "a>

    \n" - "````````````````" - "````````````````\n\n\n" -- "The link labels are case-insensitive:\n\n" +- "The link labels are case-insensitive:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6745,7 +6947,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\">foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "The link labels are case-insensitive:\n\n" +- "The link labels are case-insensitive:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6754,7 +6957,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\"title\">Foo

    \n" - "````````````````" - "````````````````\n\n\n" -- "A space after the link text should be preserved:\n\n" +- "A space after the link text should be preserved:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6782,7 +6986,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "foo*

    \n" - "````````````````" - "````````````````\n\n\n" -- "Full and collapsed references take precedence over shortcut\nreferences:\n\n" +- "Full and collapsed references take precedence over shortcut\nreferences:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6800,7 +7005,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "foo

    \n" - "````````````````" - "````````````````\n\n" -- "Inline links also take precedence:\n\n" +- "Inline links also take precedence:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6969,7 +7175,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "=\"\" />

    \n" - "````````````````" - "````````````````\n\n\n" -- "Reference-style:\n\n" +- "Reference-style:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -6987,7 +7194,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "=\"foo\" />

    \n" - "````````````````" - "````````````````\n\n\n" -- "Collapsed:\n\n" +- "Collapsed:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7007,7 +7215,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "The labels are case-insensitive:\n\n" +- "The labels are case-insensitive:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7029,7 +7238,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "[]

    \n" - "````````````````" - "````````````````\n\n\n" -- "Shortcut:\n\n" +- "Shortcut:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7049,7 +7259,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "Note that link labels cannot contain unescaped brackets:\n\n" +- "Note that link labels cannot contain unescaped brackets:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7060,7 +7271,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "quot;title"

    \n" - "````````````````" - "````````````````\n\n\n" -- "The link labels are case-insensitive:\n\n" +- "The link labels are case-insensitive:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7115,7 +7327,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "by any combination of ASCII letters, digits, or the symbols plus\n(" - "\"+\"), period (\".\"), or " - "hyphen (\"-\").\n\n" -- "Here are some valid autolinks:\n\n" +- "Here are some valid autolinks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7150,7 +7363,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/p>\n" - "````````````````" - "````````````````\n\n\n" -- "Uppercase is also fine:\n\n" +- "Uppercase is also fine:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7200,7 +7414,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "a>

    \n" - "````````````````" - "````````````````\n\n\n" -- "Spaces are not allowed in autolinks:\n\n" +- "Spaces are not allowed in autolinks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7209,7 +7424,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz bim>

    \n" - "````````````````" - "````````````````\n\n\n" -- "Backslash-escapes do not work inside autolinks:\n\n" +- "Backslash-escapes do not work inside autolinks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7241,7 +7457,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "(?:\\.[a-zA-Z0-9]" - "(?:[a-zA-Z0-9-]{" - "0,61}[a-zA-Z0-9])" -- "?)*$/\n\nExamples of email autolinks:\n\n" +- "?)*$/\n\nExamples of email autolinks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7262,7 +7479,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/p>\n" - "````````````````" - "````````````````\n\n\n" -- "Backslash-escapes do not work inside email autolinks:\n\n" +- "Backslash-escapes do not work inside email autolinks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7271,7 +7489,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">

    \n" - "````````````````" - "````````````````\n\n\n" -- "These are not autolinks:\n\n" +- "These are not autolinks:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7323,8 +7542,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "raw HTML tag and will be rendered in HTML without escaping.\n" - "Tag and attribute names are not limited to current HTML tags,\n" - "so custom tags (and even, say, DocBook tags) may be " -- "used.\n\nHere is the grammar for tags:\n\n" -- "A [tag name](@) consists of an ASCII letter\n" +- "used.\n\nHere is the grammar for tags:\n" +- "\nA [tag name](@) consists of an ASCII letter\n" - "followed by zero or more ASCII letters, digits, or\n" - "hyphens (`-`).\n\n" - "An [attribute](@) consists of spaces, tabs, and up " @@ -7384,7 +7603,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "An [HTML tag](@) consists of an [open tag" - "], a [closing tag],\nan [HTML comment]" - ", a [processing instruction], a [declaration],\nor a [" -- "CDATA section].\n\nHere are some simple open tags:\n\n" +- "CDATA section].\n\nHere are some simple open tags:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7393,7 +7613,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/p>\n" - "````````````````" - "````````````````\n\n\n" -- "Empty elements:\n\n" +- "Empty elements:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7401,7 +7622,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Whitespace is allowed:\n\n" +- "Whitespace is allowed:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7410,7 +7632,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "data=\"foo\" >

    \n" - "````````````````" - "````````````````\n\n\n" -- "With attributes:\n\n" +- "With attributes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7423,7 +7646,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/p>\n" - "````````````````" - "````````````````\n\n\n" -- "Custom tag names can be used:\n\n" +- "Custom tag names can be used:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7433,7 +7657,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "foo.jpg\" />

    \n" - "````````````````" - "````````````````\n\n\n" -- "Illegal tag names, not parsed as HTML:\n\n" +- "Illegal tag names, not parsed as HTML:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7442,7 +7667,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "__>

    \n" - "````````````````" - "````````````````\n\n\n" -- "Illegal attribute names:\n\n" +- "Illegal attribute names:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7452,7 +7678,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "p>\n" - "````````````````" - "````````````````\n\n\n" -- "Illegal attribute values:\n\n" +- "Illegal attribute values:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7463,7 +7690,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "hi'>

    \n" - "````````````````" - "````````````````\n\n\n" -- "Illegal whitespace:\n\n" +- "Illegal whitespace:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7475,7 +7703,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "bop />

    \n" - "````````````````" - "````````````````\n\n\n" -- "Missing whitespace:\n\n" +- "Missing whitespace:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7484,7 +7713,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "=title>

    \n" - "````````````````" - "````````````````\n\n\n" -- "Closing tags:\n\n" +- "Closing tags:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7492,7 +7722,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    \n" - "````````````````" - "````````````````\n\n\n" -- "Illegal attributes in closing tag:\n\n" +- "Illegal attributes in closing tag:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7502,7 +7733,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "/p>\n" - "````````````````" - "````````````````\n\n\n" -- "Comments:\n\n" +- "Comments:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7523,7 +7755,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "gt;

    \n" - "````````````````" - "````````````````\n\n\n" -- "Processing instructions:\n\n" +- "Processing instructions:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7532,7 +7765,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">

    \n" - "````````````````" - "````````````````\n\n\n" -- "Declarations:\n\n" +- "Declarations:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7541,7 +7775,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "ELEMENT br EMPTY>

    \n" - "````````````````" - "````````````````\n\n\n" -- "CDATA sections:\n\n" +- "CDATA sections:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7561,7 +7796,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ";\">

    \n" - "````````````````" - "````````````````\n\n\n" -- "Backslash escapes do not work in HTML attributes:\n\n" +- "Backslash escapes do not work in HTML attributes:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7602,7 +7838,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz

    \n" - "````````````````" - "````````````````\n\n\n" -- "More than two spaces can be used:\n\n" +- "More than two spaces can be used:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7610,7 +7847,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "baz

    \n" - "````````````````" - "````````````````\n\n\n" -- "Leading spaces at the beginning of the next line are ignored:\n\n" +- "Leading spaces at the beginning of the next line are ignored:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7643,7 +7881,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "bar

    \n" - "````````````````" - "````````````````\n\n\n" -- "Hard line breaks do not occur inside code spans\n\n" +- "Hard line breaks do not occur inside code spans\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7659,7 +7898,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ">\n" - "````````````````" - "````````````````\n\n\n" -- "or HTML tags:\n\n" +- "or HTML tags:\n" +- "\n" - "````````````````" - "```````````````` " - "example\n" @@ -7747,7 +7987,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    Foo χρῆν

    \n" - "````````````````" - "````````````````\n\n\n" -- "Internal spaces are preserved verbatim:\n\n" +- "Internal spaces are preserved verbatim:\n" +- "\n" - "````````````````" - "```````````````` " - "example\nMultiple spaces\n.\n

    Multiple spaces

    \n" @@ -7832,24 +8073,25 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "sit amet.\n" - "> - Qui *quodsi iracundia*\n" - "> - aliquando id\n```\n\n" -- "At the outset, our document model is just\n\n" -- "``` tree\n-> document\n```\n\n" -- "The first line of our text,\n\n" -- "``` markdown\n> Lorem ipsum dolor\n```\n\n" -- "causes a `block_quote` block to be created as a child of our\n" +- "At the outset, our document model is just\n" +- "\n``` tree\n-> document\n```" +- "\n\nThe first line of our text,\n" +- "\n``` markdown\n> Lorem ipsum dolor\n```" +- "\n\ncauses a `block_quote` block to be created as a child of our\n" - "open `document` block, and a `paragraph`" - " block as a child of\nthe `block_quote`" - ". Then the text is added to the last open\nblock, the `paragraph`" - ":\n\n" - "``` tree\n-> document\n -> block_quote\n -> paragraph\n" -- " \"Lorem ipsum dolor\"\n```\n\nThe next line,\n\n" -- "``` markdown\nsit amet.\n```\n\n" +- " \"Lorem ipsum dolor\"\n```\n\nThe next line,\n" +- "\n``` markdown\nsit amet.\n```" +- "\n\n" - "is a \"lazy continuation\" of the open `paragraph`, so it gets " - "added\nto the paragraph's text:\n\n" - "``` tree\n-> document\n -> block_quote\n -> paragraph\n" - " \"Lorem ipsum dolor\\nsit amet.\"\n" -- "```\n\nThe third line,\n\n" -- "``` markdown\n" +- "```\n\nThe third line,\n" +- "\n``` markdown\n" - "> - Qui *quodsi iracundia*\n" - "```\n\n" - "causes the `paragraph` block to be closed, and a new `list` " @@ -7862,8 +8104,9 @@ input_file: tests/inputs/markdown/commonmark_spec.md - " -> list (type=bullet tight=true bullet_char=-" - ")\n -> list_item\n -> paragraph\n" - " \"Qui *quodsi iracundia*\"\n" -- "```\n\nThe fourth line,\n\n" -- "``` markdown\n> - aliquando id\n```\n\n" +- "```\n\nThe fourth line,\n" +- "\n``` markdown\n> - aliquando id\n```" +- "\n\n" - "causes the `list_item` (and its child the `paragraph`) " - "to be closed,\nand a new `list_item`" - " opened up as child of the `list`. A `paragraph`" @@ -7877,8 +8120,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - " -> list_item\n -> paragraph\n \"aliquando id\"\n" - "```\n\n" - "## Phase 2: inline structure\n\n" -- "Once all of the input has been parsed, all open blocks are closed.\n\n" -- "We then \"walk the tree,\" visiting every node, and parse raw\n" +- "Once all of the input has been parsed, all open blocks are closed.\n" +- "\nWe then \"walk the tree,\" visiting every node, and parse raw\n" - "string contents of paragraphs and headings as inlines. At this\n" - "point we have seen all the link reference definitions, so we can\n" - "resolve reference links as we go.\n\n" @@ -7933,13 +8176,12 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "+ If we don't, then we remove the opening delimiter from " - "the\n delimiter stack and return a literal text node `]`.\n\n " - "+ If we do, then\n\n" -- " " -- "* We return a link or image node whose children are the inlines\n" +- " * We return a link or image node whose children are the inlines\n" - " after the text node pointed to by the opening delimiter.\n\n " - "* We run *process emphasis* on these inlines, with the `[" - "` opener\n as `stack_bottom`.\n\n " -- "* We remove the opening delimiter.\n\n " -- "* If we have a link (and not an image), we also set " +- "* We remove the opening delimiter.\n\n" +- " * If we have a link (and not an image), we also set " - "all\n `[` delimiters before the opening delimiter to " - "*inactive*. (This\n will prevent us from getting links within links.)\n\n" - "#### *process emphasis*\n\n" diff --git a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md-2.snap b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md-2.snap index b752cf1d..6e20ee4d 100644 --- a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md-2.snap +++ b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md-2.snap @@ -18,20 +18,20 @@ input_file: tests/inputs/markdown/github_flavored.md - "\n[arbitrary case-insensitive reference text]: https://www.mozilla.org\n[1]: http://slashdot.org\n[link text itself]: http://www.reddit.com\n\n------\n\n" - "# Images\n\n" - "```\nHere's our logo (hover to see the title text):\n\nInline-style:\n![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \"Logo Title Text 1\")\n\nReference-style:\n![alt text][logo]\n\n[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \"Logo Title Text 2\"\n\n![Minion](https://octodex.github.com/images/minion.png)\n![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg \"The Stormtroopocat\")\n\nLike links, Images also have a footnote style syntax\n\n![Alt text][id]\n\nWith a reference later in the document defining the URL location:\n\n" -- "[id]: https://octodex.github.com/images/dojocat.jpg \"The Dojocat\"\n```\n\nHere's our logo (hover to see the title text):\n\nInline-style:\n![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \"Logo Title Text 1\")\n\nReference-style:\n![alt text][logo]\n\n[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \"Logo Title Text 2\"\n\n![Minion](https://octodex.github.com/images/minion.png)\n![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg \"The Stormtroopocat\")\n\nLike links, Images also have a footnote style syntax\n\n" -- "![Alt text][id]\n\nWith a reference later in the document defining the URL location:\n\n[id]: https://octodex.github.com/images/dojocat.jpg \"The Dojocat\"\n\n------\n\n# [Footnotes](https://github.com/markdown-it/markdown-it-footnote)\n\n```\nFootnote 1 link[^first].\n\nFootnote 2 link[^second].\n\nInline footnote^[Text of inline footnote] definition.\n\nDuplicated footnote reference[^second].\n\n[^first]: Footnote **can have markup**\n\n and multiple paragraphs.\n\n[^second]: Footnote text.\n```\n\nFootnote 1 link[^first].\n\nFootnote 2 link[^second].\n\nInline footnote^[Text of inline footnote] definition.\n\nDuplicated footnote reference[^second].\n\n[^first]: Footnote **can have markup**\n\n and multiple paragraphs.\n\n[^second]: Footnote text.\n\n------\n\n" -- "# Code and Syntax Highlighting\n\n```\nInline `code` has `back-ticks around` it.\n```\n\nInline `code` has `back-ticks around` it.\n\n```c#\nusing System.IO.Compression;\n\n#pragma warning disable 414, 3021\n\nnamespace MyApplication\n{\n [Obsolete(\"...\")]\n class Program : IInterface\n {\n public static List JustDoIt(int count)\n {\n Console.WriteLine($\"Hello {Name}!\");\n return new List(new int[] { 1, 2, 3 })\n }\n }\n}\n```\n\n" -- "```css\n@font-face {\n font-family: Chunkfive; src: url('Chunkfive.otf');\n}\n\nbody, .usertext {\n color: #F0F0F0; background: #600;\n font-family: Chunkfive, sans;\n}\n\n@import url(print.css);\n@media print {\n a[href^=http]::after {\n content: attr(href)\n }\n}\n```\n\n" -- "```javascript\nfunction $initHighlight(block, cls) {\n try {\n if (cls.search(/\\bno\\-highlight\\b/) != -1)\n return process(block, true, 0x0F) +\n ` class=\"${cls}\"`;\n } catch (e) {\n /* handle exception */\n }\n for (var i = 0 / 2; i < classes.length; i++) {\n if (checkCondition(classes[i]) === undefined)\n console.log('undefined');\n }\n}\n\nexport $initHighlight;\n```\n\n" -- "```php\nrequire_once 'Zend/Uri/Http.php';\n\nnamespace Location\\Web;\n\ninterface Factory\n{\n static function _factory();\n}\n\nabstract class URI extends BaseURI implements Factory\n{\n abstract function test();\n\n public static $st1 = 1;\n const ME = \"Yo\";\n var $list = NULL;\n private $var;\n\n /**\n * Returns a URI\n *\n * @return URI\n */\n static public function _factory($stats = array(), $uri = 'http')\n {\n echo __METHOD__;\n $uri = explode(':', $uri, 0b10);\n $schemeSpecific = isset($uri[1]) ? $uri[1] : '';\n $desc = 'Multi\nline description';\n\n // Security check\n if (!ctype_alnum($scheme)) {\n throw new Zend_Uri_Exception('Illegal scheme');\n }\n\n $this->var = 0 - self::$st;\n" +- "[id]: https://octodex.github.com/images/dojocat.jpg \"The Dojocat\"\n```\n\nHere's our logo (hover to see the title text):\n\nInline-style:\n![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \"Logo Title Text 1\")\n\nReference-style:\n![alt text][logo]\n\n[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png \"Logo Title Text 2\"\n\n![Minion](https://octodex.github.com/images/minion.png)\n![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg \"The Stormtroopocat\")\n\nLike links, Images also have a footnote style syntax\n" +- "\n![Alt text][id]\n\nWith a reference later in the document defining the URL location:\n\n[id]: https://octodex.github.com/images/dojocat.jpg \"The Dojocat\"\n\n------\n\n# [Footnotes](https://github.com/markdown-it/markdown-it-footnote)\n\n```\nFootnote 1 link[^first].\n\nFootnote 2 link[^second].\n\nInline footnote^[Text of inline footnote] definition.\n\nDuplicated footnote reference[^second].\n\n[^first]: Footnote **can have markup**\n\n and multiple paragraphs.\n\n[^second]: Footnote text.\n```\n\nFootnote 1 link[^first].\n\nFootnote 2 link[^second].\n\nInline footnote^[Text of inline footnote] definition.\n\nDuplicated footnote reference[^second].\n\n[^first]: Footnote **can have markup**\n\n and multiple paragraphs.\n\n[^second]: Footnote text.\n\n------\n\n" +- "# Code and Syntax Highlighting\n\n```\nInline `code` has `back-ticks around` it.\n```\n\nInline `code` has `back-ticks around` it.\n\n```c#\nusing System.IO.Compression;\n\n#pragma warning disable 414, 3021\n\nnamespace MyApplication\n{\n [Obsolete(\"...\")]\n class Program : IInterface\n {\n public static List JustDoIt(int count)\n {\n Console.WriteLine($\"Hello {Name}!\");\n return new List(new int[] { 1, 2, 3 })\n }\n }\n}\n```" +- "\n\n```css\n@font-face {\n font-family: Chunkfive; src: url('Chunkfive.otf');\n}\n\nbody, .usertext {\n color: #F0F0F0; background: #600;\n font-family: Chunkfive, sans;\n}\n\n@import url(print.css);\n@media print {\n a[href^=http]::after {\n content: attr(href)\n }\n}\n```" +- "\n\n```javascript\nfunction $initHighlight(block, cls) {\n try {\n if (cls.search(/\\bno\\-highlight\\b/) != -1)\n return process(block, true, 0x0F) +\n ` class=\"${cls}\"`;\n } catch (e) {\n /* handle exception */\n }\n for (var i = 0 / 2; i < classes.length; i++) {\n if (checkCondition(classes[i]) === undefined)\n console.log('undefined');\n }\n}\n\nexport $initHighlight;\n```" +- "\n\n```php\nrequire_once 'Zend/Uri/Http.php';\n\nnamespace Location\\Web;\n\ninterface Factory\n{\n static function _factory();\n}\n\nabstract class URI extends BaseURI implements Factory\n{\n abstract function test();\n\n public static $st1 = 1;\n const ME = \"Yo\";\n var $list = NULL;\n private $var;\n\n /**\n * Returns a URI\n *\n * @return URI\n */\n static public function _factory($stats = array(), $uri = 'http')\n {\n echo __METHOD__;\n $uri = explode(':', $uri, 0b10);\n $schemeSpecific = isset($uri[1]) ? $uri[1] : '';\n $desc = 'Multi\nline description';\n\n // Security check\n if (!ctype_alnum($scheme)) {\n throw new Zend_Uri_Exception('Illegal scheme');\n }\n\n $this->var = 0 - self::$st;\n" - " $this->list = list(Array(\"1\"=> 2, 2=>self::ME, 3 => \\Location\\Web\\URI::class));\n\n return [\n 'uri' => $uri,\n 'value' => null,\n ];\n }\n}\n\necho URI::ME . URI::$st1;\n\n__halt_compiler () ; datahere\ndatahere\ndatahere */\ndatahere\n```\n\n------\n\n" - "# Tables\n\n" - "```\nColons can be used to align columns.\n\n| Tables | Are | Cool |\n| ------------- |:-------------:| -----:|\n| col 3 is | right-aligned | $1600 |\n| col 2 is | centered | $12 |\n| zebra stripes | are neat | $1 |\n\nThere must be at least 3 dashes separating each header cell.\nThe outer pipes (|) are optional, and you don't need to make the\nraw Markdown line up prettily. You can also use inline Markdown.\n\nMarkdown | Less | Pretty\n--- | --- | ---\n*Still* | `renders` | **nicely**\n1 | 2 | 3\n\n| First Header | Second Header |\n| ------------- | ------------- |\n| Content Cell | Content Cell |\n| Content Cell | Content Cell |\n\n| Command | Description |\n| --- | --- |\n" - "| git status | List all new or modified files |\n| git diff | Show file differences that haven't been staged |\n\n| Command | Description |\n| --- | --- |\n| `git status` | List all *new or modified* files |\n| `git diff` | Show file differences that **haven't been** staged |\n\n| Left-aligned | Center-aligned | Right-aligned |\n| :--- | :---: | ---: |\n| git status | git status | git status |\n| git diff | git diff | git diff |\n\n| Name | Character |\n| --- | --- |\n| Backtick | ` |\n| Pipe | \\| |\n```\n\nColons can be used to align columns.\n\n" -- "| Tables | Are | Cool |\n| ------------- |:-------------:| -----:|\n| col 3 is | right-aligned | $1600 |\n| col 2 is | centered | $12 |\n| zebra stripes | are neat | $1 |\n\nThere must be at least 3 dashes separating each header cell.\nThe outer pipes (|) are optional, and you don't need to make the\nraw Markdown line up prettily. You can also use inline Markdown.\n\nMarkdown | Less | Pretty\n--- | --- | ---\n*Still* | `renders` | **nicely**\n1 | 2 | 3\n\n| First Header | Second Header |\n| ------------- | ------------- |\n| Content Cell | Content Cell |\n| Content Cell | Content Cell |\n\n" -- "| Command | Description |\n| --- | --- |\n| git status | List all new or modified files |\n| git diff | Show file differences that haven't been staged |\n\n| Command | Description |\n| --- | --- |\n| `git status` | List all *new or modified* files |\n| `git diff` | Show file differences that **haven't been** staged |\n\n| Left-aligned | Center-aligned | Right-aligned |\n| :--- | :---: | ---: |\n| git status | git status | git status |\n| git diff | git diff | git diff |\n\n| Name | Character |\n| --- | --- |\n| Backtick | ` |\n| Pipe | \\| |\n\n------\n\n" -- "# Blockquotes\n\n```\n> Blockquotes are very handy in email to emulate reply text.\n> This line is part of the same quote.\n\nQuote break.\n\n> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.\n\n> Blockquotes can also be nested...\n>> ...by using additional greater-than signs right next to each other...\n> > > ...or with spaces between arrows.\n```\n\n> Blockquotes are very handy in email to emulate reply text.\n> This line is part of the same quote.\n\nQuote break.\n\n> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.\n\n" -- "> Blockquotes can also be nested...\n>> ...by using additional greater-than signs right next to each other...\n> > > ...or with spaces between arrows.\n\n------\n\n# Inline HTML\n\n```\n
    \n
    Definition list
    \n
    Is something people use sometimes.
    \n\n
    Markdown in HTML
    \n
    Does *not* work **very** well. Use HTML tags.
    \n
    \n```\n\n
    \n
    Definition list
    \n
    Is something people use sometimes.
    \n\n
    Markdown in HTML
    \n
    Does *not* work **very** well. Use HTML tags.
    \n
    \n\n------\n\n" +- "| Tables | Are | Cool |\n| ------------- |:-------------:| -----:|\n| col 3 is | right-aligned | $1600 |\n| col 2 is | centered | $12 |\n| zebra stripes | are neat | $1 |\n\nThere must be at least 3 dashes separating each header cell.\nThe outer pipes (|) are optional, and you don't need to make the\nraw Markdown line up prettily. You can also use inline Markdown.\n\nMarkdown | Less | Pretty\n--- | --- | ---\n*Still* | `renders` | **nicely**\n1 | 2 | 3\n\n| First Header | Second Header |\n| ------------- | ------------- |\n| Content Cell | Content Cell |\n| Content Cell | Content Cell |\n" +- "\n| Command | Description |\n| --- | --- |\n| git status | List all new or modified files |\n| git diff | Show file differences that haven't been staged |\n\n| Command | Description |\n| --- | --- |\n| `git status` | List all *new or modified* files |\n| `git diff` | Show file differences that **haven't been** staged |\n\n| Left-aligned | Center-aligned | Right-aligned |\n| :--- | :---: | ---: |\n| git status | git status | git status |\n| git diff | git diff | git diff |\n\n| Name | Character |\n| --- | --- |\n| Backtick | ` |\n| Pipe | \\| |\n\n------\n\n" +- "# Blockquotes\n\n```\n> Blockquotes are very handy in email to emulate reply text.\n> This line is part of the same quote.\n\nQuote break.\n\n> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.\n\n> Blockquotes can also be nested...\n>> ...by using additional greater-than signs right next to each other...\n> > > ...or with spaces between arrows.\n```\n\n> Blockquotes are very handy in email to emulate reply text.\n> This line is part of the same quote.\n\nQuote break.\n\n> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.\n" +- "\n> Blockquotes can also be nested...\n>> ...by using additional greater-than signs right next to each other...\n> > > ...or with spaces between arrows.\n\n------\n\n# Inline HTML\n\n```\n
    \n
    Definition list
    \n
    Is something people use sometimes.
    \n\n
    Markdown in HTML
    \n
    Does *not* work **very** well. Use HTML tags.
    \n
    \n```\n\n
    \n
    Definition list
    \n
    Is something people use sometimes.
    \n\n
    Markdown in HTML
    \n
    Does *not* work **very** well. Use HTML tags.
    \n
    \n\n------\n\n" - "# Horizontal Rules\n\n```\nThree or more...\n\n---\n\nHyphens\n\n***\n\nAsterisks\n\n___\n\nUnderscores\n```\n\nThree or more...\n\n---\n\nHyphens\n\n***\n\nAsterisks\n\n___\n\nUnderscores\n\n------\n\n" - "# YouTube Videos\n\n```\n\n\"IMAGE\n\n```\n\n" - "\n\"IMAGE\n\n" diff --git a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md.snap b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md.snap index e71c4c4f..8f156141 100644 --- a/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md.snap +++ b/tests/snapshots/text_splitter_snapshots__huggingface_markdown@github_flavored.md.snap @@ -41,9 +41,9 @@ input_file: tests/inputs/markdown/github_flavored.md - Combined emphasis with **asterisks and _underscores_* - "*.\n\n" - Strikethrough uses two tildes. ~~Scratch this. -- "~~\n\n**This is bold text**\n\n" -- "__This is bold text__\n\n*This is italic text*\n\n" -- "_This is italic text_\n\n~~Strikethrough~~\n\n" +- "~~\n\n**This is bold text**\n" +- "\n__This is bold text__\n\n*This is italic text*\n" +- "\n_This is italic text_\n\n~~Strikethrough~~\n\n" - "------\n\n" - "# Lists\n\n" - "```\n1. First ordered list item\n2. Another item\n" @@ -101,8 +101,7 @@ input_file: tests/inputs/markdown/github_flavored.md - "+ Create a list by starting a line with `+`, `-" - "`, or `*`\n" - "+ Sub-lists are made by indenting 2 spaces:\n" -- " " -- "- Marker character change forces new list start:\n" +- " - Marker character change forces new list start:\n" - " * Ac tristique libero volutpat at\n " - "+ Facilisis in pretium nisl aliquet\n " - "- Nulla volutpat aliquam velit\n" @@ -167,8 +166,9 @@ input_file: tests/inputs/markdown/github_flavored.md - "-insensitive reference text]\n\n" - "[I'm a relative reference to a repository file](.." - "/blob/master/LICENSE)\n\n" -- "[You can use numbers for reference-style link definitions][1]\n\n" -- "Or leave it empty and use the [link text itself].\n\n" +- "[You can use numbers for reference-style link definitions][1]\n" +- "\nOr leave it empty and use the [link text itself].\n" +- "\n" - URLs and URLs in angle brackets will automatically get turned into links - ".\nhttp://www.example.com or " - "" @@ -205,8 +205,8 @@ input_file: tests/inputs/markdown/github_flavored.md - "[id]: https://" - octodex.github.com/images/ - "dojocat.jpg \"The Dojocat\"\n```\n\n" -- "Here's our logo (hover to see the title text):\n\n" -- "Inline-style:\n![" +- "Here's our logo (hover to see the title text):\n" +- "\nInline-style:\n![" - "alt text](https://github.com/" - adam-p/markdown-here/raw/master/src - "/common/images/icon48.png \"Logo Title Text 1" @@ -223,9 +223,9 @@ input_file: tests/inputs/markdown/github_flavored.md - "Stormtroopocat](https://" - octodex.github.com/images/ - "stormtroopocat.jpg \"The Stormtroopocat" -- "\")\n\nLike links, Images also have a footnote style syntax\n\n" -- "![Alt text][id]\n\n" -- "With a reference later in the document defining the URL location:\n" +- "\")\n\nLike links, Images also have a footnote style syntax\n" +- "\n![Alt text][id]\n" +- "\nWith a reference later in the document defining the URL location:\n" - "\n" - "[id]: https://" - octodex.github.com/images/ @@ -239,19 +239,19 @@ input_file: tests/inputs/markdown/github_flavored.md - "Duplicated footnote reference[^second].\n\n" - "[^first]: Footnote **can have markup**\n\n" - " and multiple paragraphs.\n\n[^second]: Footnote text.\n" -- "```\n\nFootnote 1 link[^first].\n\n" -- "Footnote 2 link[^second].\n\n" -- "Inline footnote^[Text of inline footnote] definition.\n\n" -- "Duplicated footnote reference[^second].\n\n" -- "[^first]: Footnote **can have markup**\n\n " -- "and multiple paragraphs.\n\n[^second]: Footnote text.\n\n" +- "```\n\nFootnote 1 link[^first].\n" +- "\nFootnote 2 link[^second].\n" +- "\nInline footnote^[Text of inline footnote] definition.\n" +- "\nDuplicated footnote reference[^second].\n" +- "\n[^first]: Footnote **can have markup**\n\n" +- " and multiple paragraphs.\n\n[^second]: Footnote text.\n\n" - "------\n\n" - "# Code and Syntax Highlighting\n\n" - "```\n" - "Inline `code` has `back-ticks around` it.\n" - "```\n\n" -- "Inline `code` has `back-ticks around` it.\n\n" -- "```c#\nusing System.IO.Compression;\n\n" +- "Inline `code` has `back-ticks around` it.\n" +- "\n```c#\nusing System.IO.Compression;\n\n" - "#pragma warning disable 414, 3021\n\n" - "namespace MyApplication\n{\n" - " [Obsolete(\"...\")]\n" @@ -352,8 +352,7 @@ input_file: tests/inputs/markdown/github_flavored.md - "| col 3 is | right-aligned | $1600 |\n" - "| col 2 is | centered | $12 |\n" - "| zebra stripes | are neat | $1 |\n" -- "\n" -- "There must be at least 3 dashes separating each header cell.\n" +- "\nThere must be at least 3 dashes separating each header cell.\n" - "The outer pipes (|) are optional, and you don't need to " - "make the\n" - "raw Markdown line up prettily. " @@ -448,8 +447,8 @@ input_file: tests/inputs/markdown/github_flavored.md - YOUTUBE_VIDEO_ID_HERE/0. - "jpg\" alt=\"IMAGE ALT TEXT " - "HERE\" width=\"240\" height=\"180\" border=" -- "\"10\">\n\n\n" -- "```\n[![" +- "\"10\">\n\n" +- "\n```\n[![" - "IMAGE ALT TEXT HERE](http:/" - /img.youtube.com/vi/ - YOUTUBE_VIDEO_ID_HERE/0. diff --git a/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md-2.snap b/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md-2.snap index aa839594..f33309a7 100644 --- a/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md-2.snap +++ b/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md-2.snap @@ -11,7 +11,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "```\n1. List item one.\n\n List item one continued with a second paragraph followed by an\n Indented block.\n\n $ ls *.sh\n $ mv *.sh ~/tmp\n\n List item continued with a third paragraph.\n\n2. List item two continued with an open block.\n\n This paragraph is part of the preceding list item.\n\n 1. This list is nested and does not require explicit item continuation.\n\n This paragraph is part of the preceding list item.\n\n 2. List item b.\n\n This paragraph belongs to item two of the outer list.\n```\n\nThe AsciiDoc version is, arguably, easier to write. You don't need\nto worry about indentation. But the Markdown version is much easier\nto read. The nesting of list items is apparent to the eye in the\nsource, not just in the processed document." - "## Why is a spec needed?\n\nJohn Gruber's [canonical description of Markdown's\nsyntax](https://daringfireball.net/projects/markdown/syntax)\ndoes not specify the syntax unambiguously. Here are some examples of\nquestions it does not answer:" - "1. How much indentation is needed for a sublist? The spec says that\n continuation paragraphs need to be indented four spaces, but is\n not fully explicit about sublists. It is natural to think that\n they, too, must be indented four spaces, but `Markdown.pl` does\n not require that. This is hardly a \"corner case,\" and divergences\n between implementations on this issue often lead to surprises for\n users in real documents. (See [this comment by John\n Gruber](https://web.archive.org/web/20170611172104/http://article.gmane.org/gmane.text.markdown.general/1997).)\n\n2. Is a blank line needed before a block quote or heading?\n Most implementations do not require the blank line. However,\n this can lead to unexpected results in hard-wrapped text, and\n also to ambiguities in parsing (note that some implementations\n put the heading inside the blockquote, while others do not).\n (John Gruber has also spoken [in favor of requiring the blank" -- "lines](https://web.archive.org/web/20170611172104/http://article.gmane.org/gmane.text.markdown.general/2146).)\n\n3. Is a blank line needed before an indented code block?\n (`Markdown.pl` requires it, but this is not mentioned in the\n documentation, and some implementations do not require it.)\n\n ``` markdown\n paragraph\n code?\n ```\n\n4. What is the exact rule for determining when list items get\n wrapped in `

    ` tags? Can a list be partially \"loose\" and partially\n \"tight\"? What should we do with a list like this?\n\n ``` markdown\n 1. one\n\n 2. two\n 3. three\n ```\n\n Or this?\n\n ``` markdown\n 1. one\n - a\n\n - b\n 2. two\n ```\n\n (There are some relevant comments by John Gruber\n [here](https://web.archive.org/web/20170611172104/http://article.gmane.org/gmane.text.markdown.general/2554).)" +- " lines](https://web.archive.org/web/20170611172104/http://article.gmane.org/gmane.text.markdown.general/2146).)\n\n3. Is a blank line needed before an indented code block?\n (`Markdown.pl` requires it, but this is not mentioned in the\n documentation, and some implementations do not require it.)\n\n ``` markdown\n paragraph\n code?\n ```\n\n4. What is the exact rule for determining when list items get\n wrapped in `

    ` tags? Can a list be partially \"loose\" and partially\n \"tight\"? What should we do with a list like this?\n\n ``` markdown\n 1. one\n\n 2. two\n 3. three\n ```\n\n Or this?\n\n ``` markdown\n 1. one\n - a\n\n - b\n 2. two\n ```\n\n (There are some relevant comments by John Gruber\n [here](https://web.archive.org/web/20170611172104/http://article.gmane.org/gmane.text.markdown.general/2554).)" - "5. Can list markers be indented? Can ordered list markers be right-aligned?\n\n ``` markdown\n 8. item 1\n 9. item 2\n 10. item 2a\n ```\n\n6. Is this one list with a thematic break in its second item,\n or two lists separated by a thematic break?\n\n ``` markdown\n * a\n * * * * *\n * b\n ```\n\n7. When list markers change from numbers to bullets, do we have\n two lists or one? (The Markdown syntax description suggests two,\n but the perl scripts and many other implementations produce one.)\n\n ``` markdown\n 1. fee\n 2. fie\n - foe\n - fum\n ```\n\n8. What are the precedence rules for the markers of inline structure?\n For example, is the following a valid link, or does the code span\n take precedence ?\n\n ``` markdown\n [a backtick (`)](/url) and [another backtick (`)](/url).\n ```" - "9. What are the precedence rules for markers of emphasis and strong\n emphasis? For example, how should the following be parsed?\n\n ``` markdown\n *foo *bar* baz*\n ```\n\n10. What are the precedence rules between block-level and inline-level\n structure? For example, how should the following be parsed?\n\n ``` markdown\n - `a long code span can contain a hyphen like this\n - and it can screw things up`\n ```\n\n11. Can list items include section headings? (`Markdown.pl` does not\n allow this, but does allow blockquotes to include headings.)\n\n ``` markdown\n - # Heading\n ```\n\n12. Can list items be empty?\n\n ``` markdown\n * a\n *\n * b\n ```\n\n13. Can link references be defined inside block quotes or list items?\n\n ``` markdown\n > Blockquote [foo].\n >\n > [foo]: /url\n ```" - "14. If there are multiple definitions for the same reference, which takes\n precedence?\n\n ``` markdown\n [foo]: /url1\n [foo]: /url2\n\n [foo][]\n ```\n\nIn the absence of a spec, early implementers consulted `Markdown.pl`\nto resolve these ambiguities. But `Markdown.pl` was quite buggy, and\ngave manifestly bad results in many cases, so it was not a\nsatisfactory replacement for a spec.\n\nBecause there is no unambiguous spec, implementations have diverged\nconsiderably. As a result, users are often surprised to find that\na document that renders one way on one system (say, a GitHub wiki)\nrenders differently on another (say, converting to docbook using\npandoc). To make matters worse, because nothing in Markdown counts\nas a \"syntax error,\" the divergence often isn't discovered right away." @@ -281,14 +281,14 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "This is enough for most users, but these rules leave much undecided,\nespecially when it comes to nested emphasis. The original\n`Markdown.pl` test suite makes it clear that triple `***` and\n`___` delimiters can be used for strong emphasis, and most\nimplementations have also allowed the following patterns:\n\n``` markdown\n***strong emph***\n***strong** in emph*\n***emph* in strong**\n**in strong *emph***\n*in emph **strong***\n```\n\nThe following patterns are less widely supported, but the intent\nis clear and they are useful (especially in contexts like bibliography\nentries):\n\n``` markdown\n*emph *with emph* in it*\n**strong **with strong** in it**\n```\n\nMany implementations have also restricted intraword emphasis to\nthe `*` forms, to avoid unwanted emphasis in words containing\ninternal underscores. (It is best practice to put these in code\nspans, but users often do not.)" - "``` markdown\ninternal emphasis: foo*bar*baz\nno emphasis: foo_bar_baz\n```\n\nThe rules given below capture all of these patterns, while allowing\nfor efficient parsing strategies that do not backtrack.\n\nFirst, some definitions. A [delimiter run](@) is either\na sequence of one or more `*` characters that is not preceded or\nfollowed by a non-backslash-escaped `*` character, or a sequence\nof one or more `_` characters that is not preceded or followed by\na non-backslash-escaped `_` character.\n\nA [left-flanking delimiter run](@) is\na [delimiter run] that is (1) not followed by [Unicode whitespace],\nand either (2a) not followed by a [Unicode punctuation character], or\n(2b) followed by a [Unicode punctuation character] and\npreceded by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace." - "A [right-flanking delimiter run](@) is\na [delimiter run] that is (1) not preceded by [Unicode whitespace],\nand either (2a) not preceded by a [Unicode punctuation character], or\n(2b) preceded by a [Unicode punctuation character] and\nfollowed by [Unicode whitespace] or a [Unicode punctuation character].\nFor purposes of this definition, the beginning and the end of\nthe line count as Unicode whitespace.\n\nHere are some examples of delimiter runs." -- "- left-flanking but not right-flanking:\n\n ```\n ***abc\n _abc\n **\"abc\"\n _\"abc\"\n ```\n\n - right-flanking but not left-flanking:\n\n ```\n abc***\n abc_\n \"abc\"**\n \"abc\"_\n ```\n\n - Both left and right-flanking:\n\n ```\n abc***def\n \"abc\"_\"def\"\n ```\n\n - Neither left nor right-flanking:\n\n ```\n abc *** def\n a _ b\n ```" +- " - left-flanking but not right-flanking:\n\n ```\n ***abc\n _abc\n **\"abc\"\n _\"abc\"\n ```\n\n - right-flanking but not left-flanking:\n\n ```\n abc***\n abc_\n \"abc\"**\n \"abc\"_\n ```\n\n - Both left and right-flanking:\n\n ```\n abc***def\n \"abc\"_\"def\"\n ```\n\n - Neither left nor right-flanking:\n\n ```\n abc *** def\n a _ b\n ```" - "(The idea of distinguishing left-flanking and right-flanking\ndelimiter runs based on the character before and the character\nafter comes from Roopesh Chander's\n[vfmd](https://web.archive.org/web/20220608143320/http://www.vfmd.org/vfmd-spec/specification/#procedure-for-identifying-emphasis-tags).\nvfmd uses the terminology \"emphasis indicator string\" instead of \"delimiter\nrun,\" and its rules for distinguishing left- and right-flanking runs\nare a bit more complex than the ones given here.)\n\nThe following rules define emphasis and strong emphasis:" - "1. A single `*` character [can open emphasis](@)\n iff (if and only if) it is part of a [left-flanking delimiter run].\n\n2. A single `_` character [can open emphasis] iff\n it is part of a [left-flanking delimiter run]\n and either (a) not part of a [right-flanking delimiter run]\n or (b) part of a [right-flanking delimiter run]\n preceded by a [Unicode punctuation character].\n\n3. A single `*` character [can close emphasis](@)\n iff it is part of a [right-flanking delimiter run].\n\n4. A single `_` character [can close emphasis] iff\n it is part of a [right-flanking delimiter run]\n and either (a) not part of a [left-flanking delimiter run]\n or (b) part of a [left-flanking delimiter run]\n followed by a [Unicode punctuation character].\n\n5. A double `**` [can open strong emphasis](@)" -- "iff it is part of a [left-flanking delimiter run].\n\n6. A double `__` [can open strong emphasis] iff\n it is part of a [left-flanking delimiter run]\n and either (a) not part of a [right-flanking delimiter run]\n or (b) part of a [right-flanking delimiter run]\n preceded by a [Unicode punctuation character].\n\n7. A double `**` [can close strong emphasis](@)\n iff it is part of a [right-flanking delimiter run].\n\n8. A double `__` [can close strong emphasis] iff\n it is part of a [right-flanking delimiter run]\n and either (a) not part of a [left-flanking delimiter run]\n or (b) part of a [left-flanking delimiter run]\n followed by a [Unicode punctuation character]." +- " iff it is part of a [left-flanking delimiter run].\n\n6. A double `__` [can open strong emphasis] iff\n it is part of a [left-flanking delimiter run]\n and either (a) not part of a [right-flanking delimiter run]\n or (b) part of a [right-flanking delimiter run]\n preceded by a [Unicode punctuation character].\n\n7. A double `**` [can close strong emphasis](@)\n iff it is part of a [right-flanking delimiter run].\n\n8. A double `__` [can close strong emphasis] iff\n it is part of a [right-flanking delimiter run]\n and either (a) not part of a [left-flanking delimiter run]\n or (b) part of a [left-flanking delimiter run]\n followed by a [Unicode punctuation character]." - "9. Emphasis begins with a delimiter that [can open emphasis] and ends\n with a delimiter that [can close emphasis], and that uses the same\n character (`_` or `*`) as the opening delimiter. The\n opening and closing delimiters must belong to separate\n [delimiter runs]. If one of the delimiters can both\n open and close emphasis, then the sum of the lengths of the\n delimiter runs containing the opening and closing delimiters\n must not be a multiple of 3 unless both lengths are\n multiples of 3.\n\n10. Strong emphasis begins with a delimiter that\n [can open strong emphasis] and ends with a delimiter that\n [can close strong emphasis], and that uses the same character\n (`_` or `*`) as the opening delimiter. The\n opening and closing delimiters must belong to separate\n [delimiter runs]. If one of the delimiters can both open\n and close strong emphasis, then the sum of the lengths of\n the delimiter runs containing the opening and closing\n delimiters must not be a multiple of 3 unless both lengths\n are multiples of 3." - "11. A literal `*` character cannot occur at the beginning or end of\n `*`-delimited emphasis or `**`-delimited strong emphasis, unless it\n is backslash-escaped.\n\n12. A literal `_` character cannot occur at the beginning or end of\n `_`-delimited emphasis or `__`-delimited strong emphasis, unless it\n is backslash-escaped.\n\nWhere rules 1--12 above are compatible with multiple parsings,\nthe following principles resolve ambiguity:" - "13. The number of nestings should be minimized. Thus, for example,\n an interpretation `...` is always preferred to\n `...`.\n\n14. An interpretation `...` is always\n preferred to `...`.\n\n15. When two potential emphasis or strong emphasis spans overlap,\n so that the second begins before the first ends and ends after\n the first ends, the first takes precedence. Thus, for example,\n `*foo _bar* baz_` is parsed as `foo _bar baz_` rather\n than `*foo bar* baz`.\n\n16. When there are two potential emphasis or strong emphasis spans\n with the same closing delimiter, the shorter one (the one that\n opens later) takes precedence. Thus, for example," -- "`**foo **bar baz**` is parsed as `**foo bar baz`\n rather than `foo **bar baz`.\n\n17. Inline code spans, links, images, and HTML tags group more tightly\n than emphasis. So, when there is a choice between an interpretation\n that contains one of these elements and one that does not, the\n former always wins. Thus, for example, `*[foo*](bar)` is\n parsed as `*foo*` rather than as\n `[foo](bar)`." +- " `**foo **bar baz**` is parsed as `**foo bar baz`\n rather than `foo **bar baz`.\n\n17. Inline code spans, links, images, and HTML tags group more tightly\n than emphasis. So, when there is a choice between an interpretation\n that contains one of these elements and one that does not, the\n former always wins. Thus, for example, `*[foo*](bar)` is\n parsed as `*foo*` rather than as\n `[foo](bar)`." - "These rules can be illustrated through a series of examples.\n\nRule 1:\n\n```````````````````````````````` example\n*foo bar*\n.\n

    foo bar

    \n````````````````````````````````\n\n\nThis is not emphasis, because the opening `*` is followed by\nwhitespace, and hence not part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na * foo bar*\n.\n

    a * foo bar*

    \n````````````````````````````````" - "This is not emphasis, because the opening `*` is preceded\nby an alphanumeric and followed by punctuation, and hence\nnot part of a [left-flanking delimiter run]:\n\n```````````````````````````````` example\na*\"foo\"*\n.\n

    a*"foo"*

    \n````````````````````````````````\n\n\nUnicode nonbreaking spaces count as whitespace, too:\n\n```````````````````````````````` example\n* a *\n.\n

    * a *

    \n````````````````````````````````\n\n\nUnicode symbols count as punctuation, too:" - "```````````````````````````````` example\n*$*alpha.\n\n*£*bravo.\n\n*€*charlie.\n.\n

    *$*alpha.

    \n

    *£*bravo.

    \n

    *€*charlie.

    \n````````````````````````````````\n\n\nIntraword emphasis with `*` is permitted:\n\n```````````````````````````````` example\nfoo*bar*\n.\n

    foobar

    \n````````````````````````````````" @@ -445,7 +445,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "```````````````````````````````` example\n\n.\n

    https://../

    \n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

    localhost:5001/foo

    \n````````````````````````````````\n\n\nSpaces are not allowed in autolinks:" - "```````````````````````````````` example\n\n.\n

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

    \n````````````````````````````````\n\n\nBackslash-escapes do not work inside autolinks:\n\n```````````````````````````````` example\n\n.\n

    https://example.com/\\[\\

    \n````````````````````````````````" - "An [email autolink](@)\nconsists of `<`, followed by an [email address],\nfollowed by `>`. The link's label is the email address,\nand the URL is `mailto:` followed by the email address.\n\nAn [email address](@),\nfor these purposes, is anything that matches\nthe [non-normative regex from the HTML5\nspec](https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-(type=email)):" -- "/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\n (?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/\n\nExamples of email autolinks:\n\n```````````````````````````````` example\n\n.\n

    foo@bar.example.com

    \n````````````````````````````````" +- " /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\n (?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/\n\nExamples of email autolinks:\n\n```````````````````````````````` example\n\n.\n

    foo@bar.example.com

    \n````````````````````````````````" - "```````````````````````````````` example\n\n.\n

    foo+special@Bar.baz-bar0.com

    \n````````````````````````````````\n\n\nBackslash-escapes do not work inside email autolinks:\n\n```````````````````````````````` example\n\n.\n

    <foo+@bar.example.com>

    \n````````````````````````````````\n\n\nThese are not autolinks:" - "```````````````````````````````` example\n<>\n.\n

    <>

    \n````````````````````````````````\n\n\n```````````````````````````````` example\n< https://foo.bar >\n.\n

    < https://foo.bar >

    \n````````````````````````````````" - "```````````````````````````````` example\n\n.\n

    <m:abc>

    \n````````````````````````````````\n\n\n```````````````````````````````` example\n\n.\n

    <foo.bar.baz>

    \n````````````````````````````````" @@ -491,4 +491,4 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "- If we don't find one, we return a literal text node `]`.\n\n- If we do find one, but it's not *active*, we remove the inactive\n delimiter from the stack, and return a literal text node `]`.\n\n- If we find one and it's active, then we parse ahead to see if\n we have an inline link/image, reference link/image, collapsed reference\n link/image, or shortcut reference link/image.\n\n + If we don't, then we remove the opening delimiter from the\n delimiter stack and return a literal text node `]`.\n\n + If we do, then\n\n * We return a link or image node whose children are the inlines\n after the text node pointed to by the opening delimiter.\n\n * We run *process emphasis* on these inlines, with the `[` opener\n as `stack_bottom`.\n\n * We remove the opening delimiter.\n\n * If we have a link (and not an image), we also set all\n `[` delimiters before the opening delimiter to *inactive*. (This\n will prevent us from getting links within links.)" - "#### *process emphasis*\n\nParameter `stack_bottom` sets a lower bound to how far we\ndescend in the [delimiter stack]. If it is NULL, we can\ngo all the way to the bottom. Otherwise, we stop before\nvisiting `stack_bottom`.\n\nLet `current_position` point to the element on the [delimiter stack]\njust above `stack_bottom` (or the first element if `stack_bottom`\nis NULL).\n\nWe keep track of the `openers_bottom` for each delimiter\ntype (`*`, `_`), indexed to the length of the closing delimiter run\n(modulo 3) and to whether the closing delimiter can also be an\nopener. Initialize this to `stack_bottom`.\n\nThen we repeat the following until we run out of potential\nclosers:" - "- Move `current_position` forward in the delimiter stack (if needed)\n until we find the first potential closer with delimiter `*` or `_`.\n (This will be the potential closer closest\n to the beginning of the input -- the first one in parse order.)\n\n- Now, look back in the stack (staying above `stack_bottom` and\n the `openers_bottom` for this delimiter type) for the\n first matching potential opener (\"matching\" means same delimiter).\n\n- If one is found:\n\n + Figure out whether we have emphasis or strong emphasis:\n if both closer and opener spans have length >= 2, we have\n strong, otherwise regular.\n\n + Insert an emph or strong emph node accordingly, after\n the text node corresponding to the opener.\n\n + Remove any delimiters between the opener and closer from\n the delimiter stack.\n\n + Remove 1 (for regular emph) or 2 (for strong emph) delimiters\n from the opening and closing text nodes. If they become empty\n as a result, remove them and remove the corresponding element\n of the delimiter stack. If the closing node is removed, reset" -- "`current_position` to the next element in the stack.\n\n- If none is found:\n\n + Set `openers_bottom` to the element before `current_position`.\n (We know that there are no openers for this kind of closer up to and\n including this point, so this puts a lower bound on future searches.)\n\n + If the closer at `current_position` is not a potential opener,\n remove it from the delimiter stack (since we know it can't\n be a closer either).\n\n + Advance `current_position` to the next element in the stack.\n\nAfter we're done, we remove all delimiters above `stack_bottom` from the\ndelimiter stack." +- " `current_position` to the next element in the stack.\n\n- If none is found:\n\n + Set `openers_bottom` to the element before `current_position`.\n (We know that there are no openers for this kind of closer up to and\n including this point, so this puts a lower bound on future searches.)\n\n + If the closer at `current_position` is not a potential opener,\n remove it from the delimiter stack (since we know it can't\n be a closer either).\n\n + Advance `current_position` to the next element in the stack.\n\nAfter we're done, we remove all delimiters above `stack_bottom` from the\ndelimiter stack." diff --git a/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md.snap b/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md.snap index b581b203..c6e1c0ce 100644 --- a/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md.snap +++ b/tests/snapshots/text_splitter_snapshots__huggingface_markdown_trim@commonmark_spec.md.snap @@ -58,15 +58,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "This paragraph belongs to item two of the outer list.\n--\n```" - "And here is the equivalent in Markdown:" - "```\n1. List item one." -- "List item one continued with a second paragraph followed by an\n Indented block." +- " List item one continued with a second paragraph followed by an\n Indented block." - $ ls *.sh - $ mv *.sh ~/tmp -- "List item continued with a third paragraph.\n\n2." +- " List item continued with a third paragraph.\n\n2." - List item two continued with an open block. -- "This paragraph is part of the preceding list item.\n\n 1." +- " This paragraph is part of the preceding list item.\n\n 1." - This list is nested and does not require explicit item continuation. -- "This paragraph is part of the preceding list item.\n\n 2. List item b." -- "This paragraph belongs to item two of the outer list.\n```" +- " This paragraph is part of the preceding list item.\n\n 2. List item b." +- " This paragraph belongs to item two of the outer list.\n```" - "The AsciiDoc version is, arguably, easier to write." - "You don't need" - to worry about indentation. But the Markdown version is much easier @@ -109,11 +109,11 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "``` markdown\n paragraph\n code?\n ```" - 4. What is the exact rule for determining when list items get - "wrapped in `

    `" -- "tags? Can a list be partially \"loose\" and partially\n \"tight\"" +- " tags? Can a list be partially \"loose\" and partially\n \"tight\"" - "? What should we do with a list like this?" - "``` markdown\n 1. one\n\n 2. two\n 3. three" -- "```\n\n Or this?" -- "``` markdown\n 1. one\n - a\n\n - b\n 2. two" +- " ```\n\n Or this?" +- " ``` markdown\n 1. one\n - a\n\n - b\n 2. two" - "```" - (There are some relevant comments by John Gruber - "[here](https://web.archive.org/web/" @@ -123,7 +123,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - 5. Can list markers be indented? - Can ordered list markers be right-aligned? - "``` markdown\n 8. item 1\n 9. item 2" -- "10. item 2a\n ```" +- " 10. item 2a\n ```" - "6. Is this one list with a thematic break in its second item," - or two lists separated by a thematic break? - "``` markdown\n * a\n * * * * *\n * b" @@ -132,7 +132,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "two lists or one? (The Markdown syntax description suggests two," - but the perl scripts and many other implementations produce one.) - "``` markdown\n 1. fee\n 2. fie\n - foe" -- "- fum\n ```" +- " - fum\n ```" - 8. What are the precedence rules for the markers of inline structure? - "For example, is the following a valid link, or does the code span" - take precedence ? @@ -147,20 +147,20 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "structure? For example, how should the following be parsed?" - "``` markdown" - "- `a long code span can contain a hyphen like this" -- "- and it can screw things up`\n ```" +- " - and it can screw things up`\n ```" - 11. Can list items include section headings? - "(`Markdown.pl`" - does not - "allow this, but does allow blockquotes to include headings.)" - "``` markdown\n - # Heading\n ```" - "12. Can list items be empty?\n\n ``` markdown\n * a\n *" -- "* b\n ```" +- " * b\n ```" - 13. Can link references be defined inside block quotes or list items? -- "``` markdown\n > Blockquote [foo].\n >" -- "> [foo]: /url\n ```" +- " ``` markdown\n > Blockquote [foo].\n >" +- " > [foo]: /url\n ```" - "14. If there are multiple definitions for the same reference, which takes\n precedence?" -- "``` markdown\n [foo]: /url1" -- "[foo]: /url2\n\n [foo][]" +- " ``` markdown\n [foo]: /url1" +- " [foo]: /url2\n\n [foo][]" - "```" - "In the absence of a spec, early implementers consulted `" - "Markdown.pl`\nto resolve these ambiguities. But" @@ -249,10 +249,10 @@ input_file: tests/inputs/markdown/commonmark_spec.md - ", `%`, `&`, `'`, `(`" - ", `)`,\n`*`, `+`, `,`" - ", `-`, `.`, `/`" -- "(U+0021–2F), \n`:`," +- " (U+0021–2F), \n`:`," - "`;`, `<`, `=`, `>`," - "`?`, `@`" -- "(U+003A–0040),\n`[`," +- " (U+003A–0040),\n`[`," - "`\\`, `]`, `^`, `_`," - "`` ` `` (U+005B–0060)," - "`{`, `|`, `}`, or `~`" @@ -279,7 +279,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "````````````````" - "````````````````" - example -- "→foo→baz→→bim\n." +- " →foo→baz→→bim\n." - "

    foo→baz→→bim"
     - "
    " - "````````````````" @@ -287,7 +287,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "````````````````" - "````````````````" - example -- "a→a\n ὐ→a\n.\n
    a→a"
    +- "    a→a\n    ὐ→a\n.\n
    a→a"
     - "ὐ→a\n
    " - "````````````````" - "````````````````" @@ -297,7 +297,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "````````````````" - "````````````````" - example -- "- foo\n\n→bar\n.\n\n" - "````````````````````````````````\n" -- "\n\n" -- 3. **Item starting with a blank line. +- "\n\n3. **Item starting with a blank line." - "** If a sequence of lines *Ls*" - "\n starting with a single [blank line] constitute a (possibly empty)" - "\n sequence of blocks *Bs*, and *M*" @@ -2692,7 +2723,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n " - "marker. If the list item is ordered, then it is also assigned a" - "\n start number, based on the ordered list marker.\n\n" -- "Here are some list items that start with a blank line but are not empty:\n\n" +- "Here are some list items that start with a blank line but are not empty:\n" +- "\n" - "````````````````````````````````" - " example\n" - "-\n foo\n-\n ```\n bar\n ```\n-\n baz\n" @@ -2701,16 +2733,14 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    baz\n
    \n\n" - "\n" - "````````````````````````````````\n" -- "\n" -- "When the list item starts with a blank line, the number of spaces\n" +- "\nWhen the list item starts with a blank line, the number of spaces\n" - "following the list marker doesn't change the required indentation:\n\n" - "````````````````````````````````" - " example\n" - "- \n foo\n.\n
      \n
    • foo
    • \n" - "
    \n" - "````````````````````````````````\n" -- "\n\n" -- "A list item can begin with at most one blank line.\n" +- "\n\nA list item can begin with at most one blank line.\n" - "In the following example, `foo`" - " is not part of the list\nitem:\n\n" - "````````````````````````````````" @@ -2718,39 +2748,43 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "-\n\n foo\n.\n
      \n
    • \n
    \n" - "

    foo

    \n" - "````````````````````````````````\n" -- "\n\nHere is an empty bullet list item:\n\n" +- "\n\nHere is an empty bullet list item:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- foo\n-\n- bar\n.\n
      \n
    • foo
    • \n" - "
    • \n
    • bar
    • \n
    \n" - "````````````````````````````````\n" - "\n\n" -- "It does not matter whether there are spaces or tabs following the [list marker]:\n\n" +- "It does not matter whether there are spaces or tabs following the [list marker]:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- foo\n- \n- bar\n.\n
      \n" - "
    • foo
    • \n
    • \n
    • bar
    • \n" - "
    \n" - "````````````````````````````````\n" -- "\n\nHere is an empty ordered list item:\n\n" +- "\n\nHere is an empty ordered list item:\n" +- "\n" - "````````````````````````````````" - " example\n" - "1. foo\n2.\n3. bar\n.\n
      \n" - "
    1. foo
    2. \n
    3. \n
    4. bar
    5. \n" - "
    \n" - "````````````````````````````````\n" -- "\n\nA list may start or end with an empty list item:\n\n" +- "\n\nA list may start or end with an empty list item:\n" +- "\n" - "````````````````````````````````" - " example\n*\n.\n
      \n
    • \n
    \n" - "````````````````````````````````\n" -- "\nHowever, an empty list item cannot interrupt a paragraph:\n\n" +- "\nHowever, an empty list item cannot interrupt a paragraph:\n" +- "\n" - "````````````````````````````````" - " example\n" - "foo\n*\n\nfoo\n1.\n.\n

    foo\n*

    \n" - "

    foo\n1.

    \n" - "````````````````````````````````\n" -- "\n\n" -- 4. **Indentation. +- "\n\n4. **Indentation." - "** If a sequence of lines *Ls*" - " constitutes a list item\n " - "according to rule #1, #2, or #3, then the result" @@ -2759,7 +2793,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n " - "constitutes a list item with the same contents and attributes. " - "If a line is\n empty, then it need not be indented.\n\n" -- "Indented one space:\n\n" +- "Indented one space:\n" +- "\n" - "````````````````````````````````" - " example\n" - " 1. A paragraph\n with two lines.\n\n" @@ -2768,7 +2803,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    indented code\n
    \n
    \n" - "

    A block quote.

    \n
    \n\n\n" - "````````````````````````````````\n" -- "\n\nIndented two spaces:\n\n" +- "\n\nIndented two spaces:\n" +- "\n" - "````````````````````````````````" - " example\n" - " 1. A paragraph\n with two lines.\n\n" @@ -2777,7 +2813,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    indented code\n
    \n
    \n" - "

    A block quote.

    \n
    \n\n\n" - "````````````````````````````````\n" -- "\n\nIndented three spaces:\n\n" +- "\n\nIndented three spaces:\n" +- "\n" - "````````````````````````````````" - " example\n" - " 1. A paragraph\n with two lines.\n\n" @@ -2786,7 +2823,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    indented code\n
    \n
    \n" - "

    A block quote.

    \n
    \n\n\n" - "````````````````````````````````\n" -- "\n\nFour spaces indent gives a code block:\n\n" +- "\n\nFour spaces indent gives a code block:\n" +- "\n" - "````````````````````````````````" - " example\n" - " 1. A paragraph\n with two lines.\n\n" @@ -2795,8 +2833,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - " indented code\n\n > A block quote.\n" - "
    \n" - "````````````````````````````````\n" -- "\n\n\n" -- 5. **Laziness. +- "\n\n\n5. **Laziness." - "** If a string of lines *Ls* constitute a " - "[list\n item](#list-items) with contents *Bs*" - ", then the result of deleting\n " @@ -2805,7 +2842,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "paragraph continuation text] is a\n " - "list item with the same contents and attributes. The unindented\n " - "lines are called\n [lazy continuation line](@)s.\n\n" -- "Here is an example with [lazy continuation lines]:\n\n" +- "Here is an example with [lazy continuation lines]:\n" +- "\n" - "````````````````````````````````" - " example\n" - " 1. A paragraph\nwith two lines.\n\n" @@ -2814,13 +2852,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
    indented code\n
    \n
    \n" - "

    A block quote.

    \n
    \n\n\n" - "````````````````````````````````\n" -- "\n\nIndentation can be partially deleted:\n\n" +- "\n\nIndentation can be partially deleted:\n" +- "\n" - "````````````````````````````````" - " example\n" - " 1. A paragraph\n with two lines.\n.\n" - "
      \n
    1. A paragraph\nwith two lines.
    2. \n
    \n" - "````````````````````````````````\n" -- "\n\nThese examples show how laziness can work in nested structures:\n\n" +- "\n\nThese examples show how laziness can work in nested structures:\n" +- "\n" - "````````````````````````````````" - " example\n" - "> 1. > Blockquote\ncontinued here.\n.\n
    \n" @@ -2836,15 +2876,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "continued here.

    \n
    \n\n\n" - "\n" - "````````````````````````````````\n" -- "\n\n\n" -- "6. **That's all." +- "\n\n\n6. **That's all." - "** Nothing that is not counted as a list item by rules\n #1" - "--5 counts as a [list item](#list-items).\n\n" - "The rules for sublists follow from the general rules\n" - "[above][List items]. A sublist must be indented the same number" - "\nof spaces of indentation a paragraph would need to be in order to be included" - "\nin the list item.\n\n" -- "So, in this case we need two spaces indent:\n\n" +- "So, in this case we need two spaces indent:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- foo\n - bar\n - baz\n - boo\n.\n" @@ -2853,28 +2893,32 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "\n\n\n\n\n" - "\n" - "````````````````````````````````\n" -- "\n\nOne is not enough:\n\n" +- "\n\nOne is not enough:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- foo\n - bar\n - baz\n - boo\n.\n" - "
      \n
    • foo
    • \n
    • bar
    • \n" - "
    • baz
    • \n
    • boo
    • \n
    \n" - "````````````````````````````````\n" -- "\n\nHere we need four, because the list marker is wider:\n\n" +- "\n\nHere we need four, because the list marker is wider:\n" +- "\n" - "````````````````````````````````" - " example\n" - "10) foo\n - bar\n.\n
      \n" - "
    1. foo\n
        \n
      • bar
      • \n
      \n" - "
    2. \n
    \n" - "````````````````````````````````\n" -- "\n\nThree is not enough:\n\n" +- "\n\nThree is not enough:\n" +- "\n" - "````````````````````````````````" - " example\n" - "10) foo\n - bar\n.\n
      \n" - "
    1. foo
    2. \n
    \n
      \n" - "
    • bar
    • \n
    \n" - "````````````````````````````````\n" -- "\n\nA list may be the first block in a list item:\n\n" +- "\n\nA list may be the first block in a list item:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- - foo\n.\n
      \n
    • \n
        \n" @@ -2887,7 +2931,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
      • \n
          \n
        1. foo
        2. \n" - "
        \n
      • \n
      \n
    • \n\n" - "````````````````````````````````\n" -- "\n\nA list item can contain a heading:\n\n" +- "\n\nA list item can contain a heading:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- # Foo\n- Bar\n ---\n baz\n.\n
        \n" @@ -2963,13 +3008,13 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "This rule is superior, we claim, to any rule requiring a fixed level of" - "\nindentation from the margin. The four-space rule is clear but\n" - "unnatural. It is quite unintuitive that\n\n" -- "``` markdown\n- foo\n\n bar\n\n - baz\n```\n\n" -- "should be parsed as two lists with an intervening paragraph,\n\n" -- "``` html\n
          \n
        • foo
        • \n
        \n" +- "``` markdown\n- foo\n\n bar\n\n - baz\n```" +- "\n\nshould be parsed as two lists with an intervening paragraph,\n" +- "\n``` html\n
          \n
        • foo
        • \n
        \n" - "

        bar

        \n
          \n
        • baz
        • \n" - "
        \n```\n\n" -- "as the four-space rule demands, rather than a single list,\n\n" -- "``` html\n
          \n
        • \n

          foo

          \n" +- "as the four-space rule demands, rather than a single list,\n" +- "\n``` html\n
            \n
          • \n

            foo

            \n" - "

            bar

            \n
              \n
            • baz
            • \n" - "
            \n
          • \n
          \n```\n\n" - "The choice of four spaces is arbitrary. " @@ -2981,32 +3026,33 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "the initial list marker, allows text that is indented *less than* the" - "\noriginal list marker to be included in the list item. For example,\n" - "`Markdown.pl` parses\n\n" -- "``` markdown\n - one\n\n two\n```\n\n" -- "as a single list item, with `two` a continuation paragraph:\n\n" -- "``` html\n
            \n
          • \n

            one

            \n" +- "``` markdown\n - one\n\n two\n```" +- "\n\nas a single list item, with `two` a continuation paragraph:\n" +- "\n``` html\n
              \n
            • \n

              one

              \n" - "

              two

              \n
            • \n
            \n```\n\n" -- "and similarly\n\n" -- "``` markdown\n> - one\n>\n> two\n```\n\n" -- "as\n\n" -- "``` html\n
            \n
              \n
            • \n

              one

              \n" -- "

              two

              \n
            • \n
            \n
            \n" -- "```\n\nThis is extremely unintuitive.\n\n" -- "Rather than requiring a fixed indent from the margin, we could require\n" +- "and similarly\n" +- "\n``` markdown\n> - one\n>\n> two\n```" +- "\n\nas\n" +- "\n``` html\n
            \n
              \n
            • \n" +- "

              one

              \n

              two

              \n
            • \n" +- "
            \n
            \n```\n\nThis is extremely unintuitive.\n" +- "\nRather than requiring a fixed indent from the margin, we could require\n" - "a fixed indent (say, two spaces, or even one space) from the" - " list marker (which\n" - "may itself be indented). This proposal would remove the last anomaly\n" - "discussed. Unlike the spec presented above, it would count the following\n" - "as a list item with a subparagraph, even though the paragraph `bar`" - "\nis not indented as far as the first paragraph `foo`:\n\n" -- "``` markdown\n 10. foo\n\n bar \n```\n\n" +- "``` markdown\n 10. foo\n\n bar \n```" +- "\n\n" - "Arguably this text does read like a list item with `bar` as a" - " subparagraph,\n" - "which may count in favor of the proposal. " - "However, on this proposal indented\n" - "code would have to be indented six spaces after the list marker. " - "And this\nwould break a lot of existing Markdown, which has the pattern:\n\n" -- "``` markdown\n1. foo\n\n indented code\n```\n\n" -- "where the code is indented eight spaces. " +- "``` markdown\n1. foo\n\n indented code\n```" +- "\n\nwhere the code is indented eight spaces. " - "The spec above, by contrast, will\n" - "parse this text as expected, since the code block's indentation is measured\n" - "from the beginning of `foo`.\n\n" @@ -3043,7 +3089,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "between them. Otherwise a list is [tight](@)" - ".\n(The difference in HTML output is that paragraphs in a loose list are\n" - "wrapped in `

            ` tags, while paragraphs in a tight list are not.)\n\n" -- "Changing the bullet or ordered list delimiter starts a new list:\n\n" +- "Changing the bullet or ordered list delimiter starts a new list:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- foo\n- bar\n+ baz\n.\n

              \n" @@ -3057,8 +3104,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
            • foo
            • \n
            • bar
            • \n\n" - "
                \n
              1. baz
              2. \n
              \n" - "````````````````````````````````\n" -- "\n\n" -- "In CommonMark, a list can interrupt a paragraph. That is,\n" +- "\n\nIn CommonMark, a list can interrupt a paragraph. That is,\n" - "no blank line is needed to separate a paragraph from a following\nlist:\n\n" - "````````````````````````````````" - " example\n" @@ -3092,8 +3138,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - " tags, since the list is \"tight\"),\nthen\n\n" - "``` markdown\nI need to buy\n- new shoes\n- a coat\n" - "- a plane ticket\n```\n\n" -- "by itself should be a paragraph followed by a nested sublist.\n\n" -- "Since it is well established Markdown practice to allow lists to\n" +- "by itself should be a paragraph followed by a nested sublist.\n" +- "\nSince it is well established Markdown practice to allow lists to\n" - "interrupt paragraphs inside list items, the [principle of\nuniformity]" - " requires us to allow this outside list items as\nwell. (" - "[reStructuredText](https://docutils.sourceforge.net/rst.html)" @@ -3109,7 +3155,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

              The number of windows in my house is\n14. " - "The number of doors is 6.

              \n" - "````````````````````````````````\n" -- "\nWe may still get an unintended result in cases like\n\n" +- "\nWe may still get an unintended result in cases like\n" +- "\n" - "````````````````````````````````" - " example\n" - "The number of windows in my house is\n1. " @@ -3117,8 +3164,9 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

              The number of windows in my house is

              \n
                \n" - "
              1. The number of doors is 6.
              2. \n
              \n" - "````````````````````````````````\n" -- "\nbut this rule should prevent most spurious list captures.\n\n" -- "There can be any number of blank lines between items:\n\n" +- "\nbut this rule should prevent most spurious list captures.\n" +- "\nThere can be any number of blank lines between items:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- foo\n\n- bar\n\n\n- baz\n.\n
                \n
              • \n" @@ -3134,8 +3182,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

                baz

                \n

                bim

                \n
              • \n" - "
              \n\n
            \n
          • \n
          \n" - "````````````````````````````````\n" -- "\n\n" -- "To separate consecutive lists of the same type, or to separate a\n" +- "\n\nTo separate consecutive lists of the same type, or to separate a\n" - "list from an indented code block that would otherwise be parsed\n" - "as a subparagraph of the final list item, you can insert a blank HTML\n" - "comment:\n\n" @@ -3155,9 +3202,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

          foo

          \n
        • \n
        \n\n" - "
        code\n
        \n" - "````````````````````````````````\n" -- "\n\n" -- "List items need not be indented to the same level. The following\n" -- "list items will be treated as items at the same list level,\n" +- "\n\nList items need not be indented to the same level. " +- "The following\nlist items will be treated as items at the same list level,\n" - "since none is indented enough to belong to the previous list\nitem:\n\n" - "````````````````````````````````" - " example\n" @@ -3175,8 +3221,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

        b

        \n\n
      • \n

        c

        \n" - "
      • \n\n" - "````````````````````````````````\n" -- "\n" -- "Note, however, that list items may not be preceded by more than\n" +- "\nNote, however, that list items may not be preceded by more than\n" - "three spaces of indentation. Here `- e`" - " is treated as a paragraph continuation\n" - "line, because it is indented more than three spaces:\n\n" @@ -3197,8 +3242,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

        b

        \n\n\n" - "
        3. c\n
        \n" - "````````````````````````````````\n" -- "\n\n" -- "This is a loose list, because there is a blank line between\n" +- "\n\nThis is a loose list, because there is a blank line between\n" - "two of the list items:\n\n" - "````````````````````````````````" - " example\n" @@ -3206,7 +3250,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

        a

        \n\n
      • \n

        b

        \n" - "
      • \n
      • \n

        c

        \n
      • \n
      \n" - "````````````````````````````````\n" -- "\n\nSo is this, with a empty second item:\n\n" +- "\n\nSo is this, with a empty second item:\n" +- "\n" - "````````````````````````````````" - " example\n" - "* a\n*\n\n* c\n.\n
        \n
      • \n" @@ -3233,15 +3278,15 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
      • \n
      \n" - "````````````````````````````````\n" - "\n\n" -- "This is a tight list, because the blank lines are in a code block:\n\n" +- "This is a tight list, because the blank lines are in a code block:\n" +- "\n" - "````````````````````````````````" - " example\n" - "- a\n- ```\n b\n\n\n ```\n- c\n.\n
        \n" - "
      • a
      • \n
      • \n
        b\n\n\n"
         - "
        \n
      • \n
      • c
      • \n
      \n" - "````````````````````````````````\n" -- "\n\n" -- "This is a tight list, because the blank line is between two\n" +- "\n\nThis is a tight list, because the blank line is between two\n" - "paragraphs of a sublist. So the sublist is loose while\n" - "the outer list is tight:\n\n" - "````````````````````````````````" @@ -3251,8 +3296,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

      c

      \n\n
    \n\n" - "
  • d
  • \n\n" - "````````````````````````````````\n" -- "\n\n" -- "This is a tight list, because the blank line is inside the\n" +- "\n\nThis is a tight list, because the blank line is inside the\n" - "block quote:\n\n" - "````````````````````````````````" - " example\n" @@ -3260,8 +3304,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • a\n
    \n

    b

    \n
    \n" - "
  • \n
  • c
  • \n\n" - "````````````````````````````````\n" -- "\n\n" -- "This list is tight, because the consecutive block elements\n" +- "\n\nThis list is tight, because the consecutive block elements\n" - "are not separated by blank lines:\n\n" - "````````````````````````````````" - " example\n" @@ -3270,7 +3313,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "

    b

    \n\n
    c\n"
     - "
    \n\n
  • d
  • \n\n" - "````````````````````````````````\n" -- "\n\nA single-paragraph list is tight:\n\n" +- "\n\nA single-paragraph list is tight:\n" +- "\n" - "````````````````````````````````" - " example\n- a\n.\n
      \n
    • a
    • \n
    \n" - "````````````````````````````````\n" @@ -3280,8 +3324,7 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "- a\n - b\n.\n
      \n
    • a\n
        \n" - "
      • b
      • \n
      \n
    • \n
    \n" - "````````````````````````````````\n" -- "\n\n" -- "This list is loose, because of the blank line between the\n" +- "\n\nThis list is loose, because of the blank line between the\n" - "two block elements in the list item:\n\n" - "````````````````````````````````" - " example\n" @@ -3289,7 +3332,8 @@ input_file: tests/inputs/markdown/commonmark_spec.md - "
  • \n
    foo\n
    \n" - "

    bar

    \n
  • \n\n" - "````````````````````````````````\n" -- "\n\nHere the outer list is loose, the inner list tight:\n\n" +- "\n\nHere the outer list is loose, the inner list tight:\n" +- "\n" - "````````````````````````````````" - " example\n" - "* foo\n * bar\n\n baz\n.\n