`, ``, ``, etc. — must be separated from
+> surrounding content by blank lines, and the start and end tags of the
+> block should not be indented with spaces or tabs.
-This is not a link reference definition, because it is indented
-four spaces:
+In some ways Gruber's rule is more restrictive than the one given
+here:
-```````````````````````````````` example
- [foo]: /url "title"
+- It requires that an HTML block be preceded by a blank line.
+- It does not allow the start tag to be indented.
+- It requires a matching end tag, which it also does not allow to
+ be indented.
-[foo]
-.
-
[foo]: /url "title"
-
-[foo]
-````````````````````````````````
+Most Markdown implementations (including some of Gruber's own) do not
+respect all of these restrictions.
+There is one respect, however, in which Gruber's rule is more liberal
+than the one given here, since it allows blank lines to occur inside
+an HTML block. There are two reasons for disallowing them here.
+First, it removes the need to parse balanced tags, which is
+expensive and can require backtracking from the end of the document
+if no matching end tag is found. Second, it provides a very simple
+and flexible way of including Markdown content inside HTML tags:
+simply separate the Markdown from the HTML using blank lines:
-This is not a link reference definition, because it occurs inside
-a code block:
+Compare:
```````````````````````````````` example
-```
-[foo]: /url
-```
+
-[foo]
+*Emphasized* text.
+
+
.
-[foo]: /url
-
-[foo]
+
````````````````````````````````
-A [link reference definition] cannot interrupt a paragraph.
-
```````````````````````````````` example
-Foo
-[bar]: /baz
-
-[bar]
+
+*Emphasized* text.
+
.
-Foo
-[bar]: /baz
-[bar]
+
+*Emphasized* text.
+
````````````````````````````````
-However, it can directly follow other block elements, such as headings
-and thematic breaks, and it need not be followed by a blank line.
+Some Markdown implementations have adopted a convention of
+interpreting content inside tags as text if the open tag has
+the attribute `markdown=1`. The rule given above seems a simpler and
+more elegant way of achieving the same expressive power, which is also
+much simpler to parse.
+
+The main potential drawback is that one can no longer paste HTML
+blocks into Markdown documents with 100% reliability. However,
+*in most cases* this will work fine, because the blank lines in
+HTML are usually followed by HTML block tags. For example:
```````````````````````````````` example
-# [Foo]
-[foo]: /url
-> bar
-.
-
-
-bar
-
-````````````````````````````````
+
+
-Several [link reference definitions]
-can occur one after another, without intervening blank lines.
+|
+Hi
+ |
-```````````````````````````````` example
-[foo]: /foo-url "foo"
-[bar]: /bar-url
- "bar"
-[baz]: /baz-url
+
-[foo],
-[bar],
-[baz]
+
.
-foo,
-bar,
-baz
+
````````````````````````````````
-[Link reference definitions] can occur
-inside block containers, like lists and block quotations. They
-affect the entire document, not just the container in which they
-are defined:
+There are problems, however, if the inner tags are indented
+*and* separated by spaces, as then they will be interpreted as
+an indented code block:
```````````````````````````````` example
-[foo]
+
-> [foo]: /url
+
+
+ |
+ Hi
+ |
+
+
+
+
.
-foo
-
-
+
+
+<td>
+ Hi
+</td>
+
+
+
````````````````````````````````
+Fortunately, blank lines are usually not necessary and can be
+deleted. The exception is inside `` tags, but as described
+[above][HTML blocks], raw HTML blocks starting with ``
+*can* contain blank lines.
-## Paragraphs
+## Link reference definitions
-A sequence of non-blank lines that cannot be interpreted as other
-kinds of blocks forms a [paragraph](@).
-The contents of the paragraph are the result of parsing the
-paragraph's raw content as inlines. The paragraph's raw content
-is formed by concatenating the lines and removing initial and final
-[whitespace].
+A [link reference definition](@)
+consists of a [link label], optionally preceded by up to three spaces of
+indentation, followed
+by a colon (`:`), optional spaces or tabs (including up to one
+[line ending]), a [link destination],
+optional spaces or tabs (including up to one
+[line ending]), and an optional [link
+title], which if it is present must be separated
+from the [link destination] by spaces or tabs.
+No further character may occur.
-A simple example with two paragraphs:
+A [link reference definition]
+does not correspond to a structural element of a document. Instead, it
+defines a label which can be used in [reference links]
+and reference-style [images] elsewhere in the document. [Link
+reference definitions] can come either before or after the links that use
+them.
```````````````````````````````` example
-aaa
+[foo]: /url "title"
-bbb
+[foo]
.
-aaa
-bbb
+foo
````````````````````````````````
-Paragraphs can contain multiple lines, but no blank lines:
-
```````````````````````````````` example
-aaa
-bbb
+ [foo]:
+ /url
+ 'the title'
-ccc
-ddd
+[foo]
.
-aaa
-bbb
-ccc
-ddd
+foo
````````````````````````````````
-Multiple blank lines between paragraph have no effect:
-
```````````````````````````````` example
-aaa
-
+[Foo*bar\]]:my_(url) 'title (with parens)'
-bbb
+[Foo*bar\]]
.
-aaa
-bbb
+Foo*bar]
````````````````````````````````
-Leading spaces are skipped:
-
```````````````````````````````` example
- aaa
- bbb
+[Foo bar]:
+
+'title'
+
+[Foo bar]
.
-aaa
-bbb
+Foo bar
````````````````````````````````
-Lines after the first may be indented any amount, since indented
-code blocks cannot interrupt paragraphs.
+The title may extend over multiple lines:
```````````````````````````````` example
-aaa
- bbb
- ccc
+[foo]: /url '
+title
+line1
+line2
+'
+
+[foo]
.
-aaa
-bbb
-ccc
+foo
````````````````````````````````
-However, the first line may be indented at most three spaces,
-or an indented code block will be triggered:
+However, it may not contain a [blank line]:
```````````````````````````````` example
- aaa
-bbb
+[foo]: /url 'title
+
+with blank line'
+
+[foo]
.
-aaa
-bbb
+[foo]: /url 'title
+with blank line'
+[foo]
````````````````````````````````
+The title may be omitted:
+
```````````````````````````````` example
- aaa
-bbb
+[foo]:
+/url
+
+[foo]
.
-aaa
-
-bbb
+foo
````````````````````````````````
-Final spaces are stripped before inline parsing, so a paragraph
-that ends with two or more spaces will not end with a [hard line
-break]:
+The link destination may not be omitted:
```````````````````````````````` example
-aaa
-bbb
+[foo]:
+
+[foo]
.
-aaa
-bbb
+[foo]:
+[foo]
````````````````````````````````
+ However, an empty link destination may be specified using
+ angle brackets:
-## Blank lines
+```````````````````````````````` example
+[foo]: <>
-[Blank lines] between block-level elements are ignored,
-except for the role they play in determining whether a [list]
-is [tight] or [loose].
+[foo]
+.
+foo
+````````````````````````````````
-Blank lines at the beginning and end of the document are also ignored.
+The title must be separated from the link destination by
+spaces or tabs:
```````````````````````````````` example
-
+[foo]: (baz)
-aaa
-
-
-# aaa
-
-
+[foo]
.
-aaa
-aaa
+[foo]: (baz)
+[foo]
````````````````````````````````
+Both title and destination can contain backslash escapes
+and literal backslashes:
-# Container blocks
-
-A [container block] is a block that has other
-blocks as its contents. There are two basic kinds of container blocks:
-[block quotes] and [list items].
-[Lists] are meta-containers for [list items].
+```````````````````````````````` example
+[foo]: /url\bar\*baz "foo\"bar\baz"
-We define the syntax for container blocks recursively. The general
-form of the definition is:
+[foo]
+.
+foo
+````````````````````````````````
-> If X is a sequence of blocks, then the result of
-> transforming X in such-and-such a way is a container of type Y
-> with these blocks as its content.
-So, we explain what counts as a block quote or list item by explaining
-how these can be *generated* from their contents. This should suffice
-to define the syntax, although it does not give a recipe for *parsing*
-these constructions. (A recipe is provided below in the section entitled
-[A parsing strategy](#appendix-a-parsing-strategy).)
+A link can come before its corresponding definition:
-## Block quotes
+```````````````````````````````` example
+[foo]
-A [block quote marker](@)
-consists of 0-3 spaces of initial indent, plus (a) the character `>` together
-with a following space, or (b) a single character `>` not followed by a space.
+[foo]: url
+.
+foo
+````````````````````````````````
-The following rules define [block quotes]:
-1. **Basic case.** If a string of lines *Ls* constitute a sequence
- of blocks *Bs*, then the result of prepending a [block quote
- marker] to the beginning of each line in *Ls*
- is a [block quote](#block-quotes) containing *Bs*.
+If there are several matching definitions, the first one takes
+precedence:
-2. **Laziness.** If a string of lines *Ls* constitute a [block
- quote](#block-quotes) with contents *Bs*, then the result of deleting
- the initial [block quote marker] from one or
- more lines in which the next [non-whitespace character] after the [block
- quote marker] is [paragraph continuation
- text] is a block quote with *Bs* as its content.
- [Paragraph continuation text](@) is text
- that will be parsed as part of the content of a paragraph, but does
- not occur at the beginning of the paragraph.
+```````````````````````````````` example
+[foo]
-3. **Consecutiveness.** A document cannot contain two [block
- quotes] in a row unless there is a [blank line] between them.
+[foo]: first
+[foo]: second
+.
+foo
+````````````````````````````````
-Nothing else counts as a [block quote](#block-quotes).
-Here is a simple example:
+As noted in the section on [Links], matching of labels is
+case-insensitive (see [matches]).
```````````````````````````````` example
-> # Foo
-> bar
-> baz
+[FOO]: /url
+
+[Foo]
.
-
-Foo
-bar
-baz
-
+Foo
````````````````````````````````
-The spaces after the `>` characters can be omitted:
-
```````````````````````````````` example
-># Foo
->bar
-> baz
+[ΑΓΩ]: /φου
+
+[αγω]
.
-
-Foo
-bar
-baz
-
+αγω
````````````````````````````````
-The `>` characters can be indented 1-3 spaces:
+Whether something is a [link reference definition] is
+independent of whether the link reference it defines is
+used in the document. Thus, for example, the following
+document contains just a link reference definition, and
+no visible content:
```````````````````````````````` example
- > # Foo
- > bar
- > baz
+[foo]: /url
.
-
-Foo
-bar
-baz
-
````````````````````````````````
-Four spaces gives us a code block:
+Here is another one:
```````````````````````````````` example
- > # Foo
- > bar
- > baz
+[
+foo
+]: /url
+bar
.
-> # Foo
-> bar
-> baz
-
+bar
````````````````````````````````
-The Laziness clause allows us to omit the `>` before a
-paragraph continuation line:
+This is not a link reference definition, because there are
+characters other than spaces or tabs after the title:
```````````````````````````````` example
-> # Foo
-> bar
-baz
+[foo]: /url "title" ok
.
-
-Foo
-bar
-baz
-
+[foo]: /url "title" ok
````````````````````````````````
-A block quote can contain some lazy and some non-lazy
-continuation lines:
+This is a link reference definition, but it has no title:
```````````````````````````````` example
-> bar
-baz
-> foo
+[foo]: /url
+"title" ok
.
-
-bar
-baz
-foo
-
+"title" ok
````````````````````````````````
-Laziness only applies to lines that would have been continuations of
-paragraphs had they been prepended with [block quote markers].
-For example, the `> ` cannot be omitted in the second line of
-
-``` markdown
-> foo
-> ---
-```
-
-without changing the meaning:
+This is not a link reference definition, because it is indented
+four spaces:
```````````````````````````````` example
-> foo
----
+ [foo]: /url "title"
+
+[foo]
.
-
-foo
-
-
+[foo]: /url "title"
+
+[foo]
````````````````````````````````
-Similarly, if we omit the `> ` in the second line of
+This is not a link reference definition, because it occurs inside
+a code block:
-``` markdown
-> - foo
-> - bar
+```````````````````````````````` example
+```
+[foo]: /url
```
-then the block quote ends after the first line:
-
-```````````````````````````````` example
-> - foo
-- bar
+[foo]
.
-
-
-
-
+[foo]: /url
+
+[foo]
````````````````````````````````
-For the same reason, we can't omit the `> ` in front of
-subsequent lines of an indented or fenced code block:
+A [link reference definition] cannot interrupt a paragraph.
```````````````````````````````` example
-> foo
- bar
+Foo
+[bar]: /baz
+
+[bar]
.
-
-foo
-
-
-bar
-
+Foo
+[bar]: /baz
+[bar]
````````````````````````````````
+However, it can directly follow other block elements, such as headings
+and thematic breaks, and it need not be followed by a blank line.
+
```````````````````````````````` example
-> ```
-foo
-```
+# [Foo]
+[foo]: /url
+> bar
.
+
-
+bar
-foo
-
````````````````````````````````
-
-Note that in the following case, we have a paragraph
-continuation line:
-
```````````````````````````````` example
-> foo
- - bar
+[foo]: /url
+bar
+===
+[foo]
.
-
-foo
-- bar
-
+bar
+foo
````````````````````````````````
-
-To see why, note that in
-
-```markdown
-> foo
-> - bar
-```
-
-the `- bar` is indented too far to start a list, and can't
-be an indented code block because indented code blocks cannot
-interrupt paragraphs, so it is a [paragraph continuation line].
-
-A block quote can be empty:
-
```````````````````````````````` example
->
+[foo]: /url
+===
+[foo]
.
-
-
+===
+foo
````````````````````````````````
+Several [link reference definitions]
+can occur one after another, without intervening blank lines.
+
```````````````````````````````` example
->
->
->
-.
-
-
-````````````````````````````````
-
-
-A block quote can have initial or final blank lines:
+[foo]: /foo-url "foo"
+[bar]: /bar-url
+ "bar"
+[baz]: /baz-url
-```````````````````````````````` example
->
-> foo
->
+[foo],
+[bar],
+[baz]
.
-
-foo
-
+foo,
+bar,
+baz
````````````````````````````````
-A blank line always separates block quotes:
+[Link reference definitions] can occur
+inside block containers, like lists and block quotations. They
+affect the entire document, not just the container in which they
+are defined:
```````````````````````````````` example
-> foo
+[foo]
-> bar
+> [foo]: /url
.
+foo
-foo
-
-
-bar
````````````````````````````````
-(Most current Markdown implementations, including John Gruber's
-original `Markdown.pl`, will parse this example as a single block quote
-with two paragraphs. But it seems better to allow the author to decide
-whether two block quotes or one are wanted.)
+## Paragraphs
-Consecutiveness means that if we put these block quotes together,
-we get a single block quote:
+A sequence of non-blank lines that cannot be interpreted as other
+kinds of blocks forms a [paragraph](@).
+The contents of the paragraph are the result of parsing the
+paragraph's raw content as inlines. The paragraph's raw content
+is formed by concatenating the lines and removing initial and final
+spaces or tabs.
+
+A simple example with two paragraphs:
```````````````````````````````` example
-> foo
-> bar
+aaa
+
+bbb
.
-
-foo
-bar
-
+aaa
+bbb
````````````````````````````````
-To get a block quote with two paragraphs, use:
+Paragraphs can contain multiple lines, but no blank lines:
```````````````````````````````` example
-> foo
->
-> bar
+aaa
+bbb
+
+ccc
+ddd
.
-
-foo
-bar
-
+aaa
+bbb
+ccc
+ddd
````````````````````````````````
-Block quotes can interrupt paragraphs:
+Multiple blank lines between paragraphs have no effect:
```````````````````````````````` example
-foo
-> bar
-.
-foo
-
-bar
-
-````````````````````````````````
-
+aaa
-In general, blank lines are not needed before or after block
-quotes:
-```````````````````````````````` example
-> aaa
-***
-> bbb
+bbb
.
-
aaa
-
-
-
bbb
-
````````````````````````````````
-However, because of laziness, a blank line is needed between
-a block quote and a following paragraph:
+Leading spaces or tabs are skipped:
```````````````````````````````` example
-> bar
-baz
+ aaa
+ bbb
.
-
-bar
-baz
-
+aaa
+bbb
````````````````````````````````
-```````````````````````````````` example
-> bar
+Lines after the first may be indented any amount, since indented
+code blocks cannot interrupt paragraphs.
-baz
+```````````````````````````````` example
+aaa
+ bbb
+ ccc
.
-
-bar
-
-baz
+aaa
+bbb
+ccc
````````````````````````````````
+However, the first line may be preceded by up to three spaces of indentation.
+Four spaces of indentation is too many:
+
```````````````````````````````` example
-> bar
->
-baz
+ aaa
+bbb
.
-
-bar
-
-baz
+aaa
+bbb
````````````````````````````````
-It is a consequence of the Laziness rule that any number
-of initial `>`s may be omitted on a continuation line of a
-nested block quote:
-
```````````````````````````````` example
-> > > foo
-bar
+ aaa
+bbb
.
-
-
-
-foo
-bar
-
-
-
+aaa
+
+bbb
````````````````````````````````
+Final spaces or tabs are stripped before inline parsing, so a paragraph
+that ends with two or more spaces will not end with a [hard line
+break]:
+
```````````````````````````````` example
->>> foo
-> bar
->>baz
+aaa
+bbb
.
-
-
-
-foo
-bar
-baz
-
-
-
+aaa
+bbb
````````````````````````````````
-When including an indented code block in a block quote,
-remember that the [block quote marker] includes
-both the `>` and a following space. So *five spaces* are needed after
-the `>`:
+## Blank lines
+
+[Blank lines] between block-level elements are ignored,
+except for the role they play in determining whether a [list]
+is [tight] or [loose].
+
+Blank lines at the beginning and end of the document are also ignored.
```````````````````````````````` example
-> code
+
-> not code
+aaa
+
+
+# aaa
+
+
.
-
-code
-
-
-
-not code
-
+aaa
+aaa
````````````````````````````````
-## List items
+# Container blocks
-A [list marker](@) is a
-[bullet list marker] or an [ordered list marker].
+A [container block](#container-blocks) is a block that has other
+blocks as its contents. There are two basic kinds of container blocks:
+[block quotes] and [list items].
+[Lists] are meta-containers for [list items].
-A [bullet list marker](@)
-is a `-`, `+`, or `*` character.
+We define the syntax for container blocks recursively. The general
+form of the definition is:
-An [ordered list marker](@)
-is a sequence of 1--9 arabic digits (`0-9`), followed by either a
-`.` character or a `)` character. (The reason for the length
-limit is that with 10 digits we start seeing integer overflows
-in some browsers.)
+> If X is a sequence of blocks, then the result of
+> transforming X in such-and-such a way is a container of type Y
+> with these blocks as its content.
-The following rules define [list items]:
+So, we explain what counts as a block quote or list item by explaining
+how these can be *generated* from their contents. This should suffice
+to define the syntax, although it does not give a recipe for *parsing*
+these constructions. (A recipe is provided below in the section entitled
+[A parsing strategy](#appendix-a-parsing-strategy).)
-1. **Basic case.** If a sequence of lines *Ls* constitute a sequence of
- blocks *Bs* starting with a [non-whitespace character] and not separated
- from each other by more than one blank line, and *M* is a list
- marker of width *W* followed by 0 < *N* < 5 spaces, then the result
- of prepending *M* and the following spaces to the first line of
- *Ls*, and indenting subsequent lines of *Ls* by *W + N* spaces, is a
- list item with *Bs* as its contents. The type of the list item
- (bullet or ordered) is determined by the type of its list marker.
- If the list item is ordered, then it is also assigned a start
- number, based on the ordered list marker.
+## Block quotes
-For example, let *Ls* be the lines
+A [block quote marker](@),
+optionally preceded by up to three spaces of indentation,
+consists of (a) the character `>` together with a following space of
+indentation, or (b) a single character `>` not followed by a space of
+indentation.
-```````````````````````````````` example
-A paragraph
-with two lines.
+The following rules define [block quotes]:
- indented code
+1. **Basic case.** If a string of lines *Ls* constitute a sequence
+ of blocks *Bs*, then the result of prepending a [block quote
+ marker] to the beginning of each line in *Ls*
+ is a [block quote](#block-quotes) containing *Bs*.
-> A block quote.
-.
-A paragraph
-with two lines.
-indented code
-
+2. **Laziness.** If a string of lines *Ls* constitute a [block
+ quote](#block-quotes) with contents *Bs*, then the result of deleting
+ the initial [block quote marker] from one or
+ more lines in which the next character other than a space or tab after the
+ [block quote marker] is [paragraph continuation
+ text] is a block quote with *Bs* as its content.
+ [Paragraph continuation text](@) is text
+ that will be parsed as part of the content of a paragraph, but does
+ not occur at the beginning of the paragraph.
+
+3. **Consecutiveness.** A document cannot contain two [block
+ quotes] in a row unless there is a [blank line] between them.
+
+Nothing else counts as a [block quote](#block-quotes).
+
+Here is a simple example:
+
+```````````````````````````````` example
+> # Foo
+> bar
+> baz
+.
-A block quote.
+Foo
+bar
+baz
````````````````````````````````
-And let *M* be the marker `1.`, and *N* = 2. Then rule #1 says
-that the following is an ordered list item with start number 1,
-and the same contents as *Ls*:
+The space or tab after the `>` characters can be omitted:
```````````````````````````````` example
-1. A paragraph
- with two lines.
-
- indented code
-
- > A block quote.
+># Foo
+>bar
+> baz
.
-
--
-
A paragraph
-with two lines.
-indented code
-
-A block quote.
+Foo
+bar
+baz
-
-
````````````````````````````````
-The most important thing to notice is that the position of
-the text after the list marker determines how much indentation
-is needed in subsequent blocks in the list item. If the list
-marker takes up two spaces, and there are three spaces between
-the list marker and the next [non-whitespace character], then blocks
-must be indented five spaces in order to fall under the list
-item.
-
-Here are some examples showing how far content must be indented to be
-put under the list item:
+The `>` characters can be preceded by up to three spaces of indentation:
```````````````````````````````` example
-- one
-
- two
+ > # Foo
+ > bar
+ > baz
.
-
-two
+
+Foo
+bar
+baz
+
````````````````````````````````
-```````````````````````````````` example
-- one
+Four spaces of indentation is too many:
- two
+```````````````````````````````` example
+ > # Foo
+ > bar
+ > baz
.
-
+> # Foo
+> bar
+> baz
+
````````````````````````````````
-```````````````````````````````` example
- - one
+The Laziness clause allows us to omit the `>` before
+[paragraph continuation text]:
- two
+```````````````````````````````` example
+> # Foo
+> bar
+baz
.
-
- two
-
+
+Foo
+bar
+baz
+
````````````````````````````````
-```````````````````````````````` example
- - one
+A block quote can contain some lazy and some non-lazy
+continuation lines:
- two
+```````````````````````````````` example
+> bar
+baz
+> foo
.
-
+
+bar
+baz
+foo
+
````````````````````````````````
-It is tempting to think of this in terms of columns: the continuation
-blocks must be indented at least to the column of the first
-[non-whitespace character] after the list marker. However, that is not quite right.
-The spaces after the list marker determine how much relative indentation
-is needed. Which column this indentation reaches will depend on
-how the list item is embedded in other constructions, as shown by
-this example:
+Laziness only applies to lines that would have been continuations of
+paragraphs had they been prepended with [block quote markers].
+For example, the `> ` cannot be omitted in the second line of
+
+``` markdown
+> foo
+> ---
+```
+
+without changing the meaning:
```````````````````````````````` example
- > > 1. one
->>
->> two
+> foo
+---
.
-
-
--
-
one
-two
-
-
-
+foo
+
````````````````````````````````
-Here `two` occurs in the same column as the list marker `1.`,
-but is actually contained in the list item, because there is
-sufficient indentation after the last containing blockquote marker.
+Similarly, if we omit the `> ` in the second line of
-The converse is also possible. In the following example, the word `two`
-occurs far to the right of the initial text of the list item, `one`, but
-it is not considered part of the list item, because it is not indented
-far enough past the blockquote marker:
+``` markdown
+> - foo
+> - bar
+```
+
+then the block quote ends after the first line:
```````````````````````````````` example
->>- one
->>
- > > two
+> - foo
+- bar
.
-
-two
-
+
````````````````````````````````
-Note that at least one space is needed between the list marker and
-any following content, so these are not list items:
+For the same reason, we can't omit the `> ` in front of
+subsequent lines of an indented or fenced code block:
```````````````````````````````` example
--one
+> foo
+ bar
+.
+
+foo
+
+
+bar
+
+````````````````````````````````
-2.two
+
+```````````````````````````````` example
+> ```
+foo
+```
.
--one
-2.two
+
+
+
+foo
+
````````````````````````````````
-A list item may not contain blocks that are separated by more than
-one blank line. Thus, two blank lines will end a list, unless the
-two blanks are contained in a [fenced code block].
+Note that in the following case, we have a [lazy
+continuation line]:
```````````````````````````````` example
-- foo
+> foo
+ - bar
+.
+
+foo
+- bar
+
+````````````````````````````````
- bar
-- foo
+To see why, note that in
+```markdown
+> foo
+> - bar
+```
- bar
+the `- bar` is indented too far to start a list, and can't
+be an indented code block because indented code blocks cannot
+interrupt paragraphs, so it is [paragraph continuation text].
-- ```
- foo
+A block quote can be empty:
+```````````````````````````````` example
+>
+.
+
+
+````````````````````````````````
- bar
- ```
-- baz
+```````````````````````````````` example
+>
+>
+>
+.
+
+
+````````````````````````````````
- + ```
- foo
+A block quote can have initial or final blank lines:
- bar
- ```
-.
-
--
-
foo
-bar
-
--
+```````````````````````````````` example
+>
+> foo
+>
+.
+
foo
-
-
-bar
-
--
-
foo
-
-
-bar
-
-
--
-
baz
-
-
-
+
````````````````````````````````
-A list item may contain any kind of block:
+A blank line always separates block quotes:
```````````````````````````````` example
-1. foo
-
- ```
- bar
- ```
-
- baz
+> foo
- > bam
+> bar
.
-
--
+
foo
-bar
-
-baz
+
-bam
+bar
-
-
````````````````````````````````
-A list item that contains an indented code block will preserve
-empty lines within the code block verbatim, unless there are two
-or more empty lines in a row (since as described above, two
-blank lines end the list):
-
-```````````````````````````````` example
-- Foo
+(Most current Markdown implementations, including John Gruber's
+original `Markdown.pl`, will parse this example as a single block quote
+with two paragraphs. But it seems better to allow the author to decide
+whether two block quotes or one are wanted.)
- bar
+Consecutiveness means that if we put these block quotes together,
+we get a single block quote:
- baz
+```````````````````````````````` example
+> foo
+> bar
.
-
+
+foo
+bar
+
````````````````````````````````
-```````````````````````````````` example
-- Foo
-
- bar
-
+To get a block quote with two paragraphs, use:
- baz
+```````````````````````````````` example
+> foo
+>
+> bar
.
-
- baz
-
+
+foo
+bar
+
````````````````````````````````
-Note that ordered list start numbers must be nine digits or less:
+Block quotes can interrupt paragraphs:
```````````````````````````````` example
-123456789. ok
+foo
+> bar
.
-
-- ok
-
+foo
+
+bar
+
````````````````````````````````
+In general, blank lines are not needed before or after block
+quotes:
+
```````````````````````````````` example
-1234567890. not ok
+> aaa
+***
+> bbb
.
-1234567890. not ok
+
+aaa
+
+
+
+bbb
+
````````````````````````````````
-A start number may begin with 0s:
+However, because of laziness, a blank line is needed between
+a block quote and a following paragraph:
```````````````````````````````` example
-0. ok
+> bar
+baz
.
-
-- ok
-
+
+bar
+baz
+
````````````````````````````````
```````````````````````````````` example
-003. ok
+> bar
+
+baz
.
-
-- ok
-
+
+bar
+
+baz
````````````````````````````````
-A start number may not be negative:
-
```````````````````````````````` example
--1. not ok
+> bar
+>
+baz
.
--1. not ok
+
+bar
+
+baz
````````````````````````````````
-
-2. **Item starting with indented code.** If a sequence of lines *Ls*
- constitute a sequence of blocks *Bs* starting with an indented code
- block and not separated from each other by more than one blank line,
- and *M* is a list marker of width *W* followed by
- one space, then the result of prepending *M* and the following
- space to the first line of *Ls*, and indenting subsequent lines of
- *Ls* by *W + 1* spaces, is a list item with *Bs* as its contents.
- If a line is empty, then it need not be indented. The type of the
- list item (bullet or ordered) is determined by the type of its list
- marker. If the list item is ordered, then it is also assigned a
- start number, based on the ordered list marker.
-
-An indented code block will have to be indented four spaces beyond
-the edge of the region where text will be included in the list item.
-In the following case that is 6 spaces:
+It is a consequence of the Laziness rule that any number
+of initial `>`s may be omitted on a continuation line of a
+nested block quote:
```````````````````````````````` example
-- foo
-
- bar
+> > > foo
+bar
.
-
+
+
+
+foo
+bar
+
+
+
````````````````````````````````
-And in this case it is 11 spaces:
-
```````````````````````````````` example
- 10. foo
-
- bar
+>>> foo
+> bar
+>>baz
.
-
--
-
foo
-bar
-
-
-
+
+
+
+foo
+bar
+baz
+
+
+
````````````````````````````````
-If the *first* block in the list item is an indented code block,
-then by rule #2, the contents must be indented *one* space after the
-list marker:
+When including an indented code block in a block quote,
+remember that the [block quote marker] includes
+both the `>` and a following space of indentation. So *five spaces* are needed
+after the `>`:
```````````````````````````````` example
- indented code
-
-paragraph
+> code
- more code
+> not code
.
-indented code
-
-paragraph
-more code
+
+code
+
+
+not code
+
````````````````````````````````
-```````````````````````````````` example
-1. indented code
- paragraph
+## List items
- more code
-.
-
--
-
indented code
-
-paragraph
-more code
+A [list marker](@) is a
+[bullet list marker] or an [ordered list marker].
+
+A [bullet list marker](@)
+is a `-`, `+`, or `*` character.
+
+An [ordered list marker](@)
+is a sequence of 1--9 arabic digits (`0-9`), followed by either a
+`.` character or a `)` character. (The reason for the length
+limit is that with 10 digits we start seeing integer overflows
+in some browsers.)
+
+The following rules define [list items]:
+
+1. **Basic case.** If a sequence of lines *Ls* constitute a sequence of
+ blocks *Bs* starting with a character other than a space or tab, and *M* is
+ a list marker of width *W* followed by 1 ≤ *N* ≤ 4 spaces of indentation,
+ then the result of prepending *M* and the following spaces to the first line
+ of *Ls*, and indenting subsequent lines of *Ls* by *W + N* spaces, is a
+ list item with *Bs* as its contents. The type of the list item
+ (bullet or ordered) is determined by the type of its list marker.
+ If the list item is ordered, then it is also assigned a start
+ number, based on the ordered list marker.
+
+ Exceptions:
+
+ 1. When the first list item in a [list] interrupts
+ a paragraph---that is, when it starts on a line that would
+ otherwise count as [paragraph continuation text]---then (a)
+ the lines *Ls* must not begin with a blank line, and (b) if
+ the list item is ordered, the start number must be 1.
+ 2. If any line is a [thematic break][thematic breaks] then
+ that line is not a list item.
+
+For example, let *Ls* be the lines
+
+```````````````````````````````` example
+A paragraph
+with two lines.
+
+ indented code
+
+> A block quote.
+.
+A paragraph
+with two lines.
+indented code
-
-
+
+A block quote.
+
````````````````````````````````
-Note that an additional space indent is interpreted as space
-inside the code block:
+And let *M* be the marker `1.`, and *N* = 2. Then rule #1 says
+that the following is an ordered list item with start number 1,
+and the same contents as *Ls*:
```````````````````````````````` example
-1. indented code
+1. A paragraph
+ with two lines.
- paragraph
+ indented code
- more code
+ > A block quote.
.
-
-
indented code
-
-paragraph
-more code
+A paragraph
+with two lines.
+indented code
+
+A block quote.
+
````````````````````````````````
-Note that rules #1 and #2 only apply to two cases: (a) cases
-in which the lines to be included in a list item begin with a
-[non-whitespace character], and (b) cases in which
-they begin with an indented code
-block. In a case like the following, where the first block begins with
-a three-space indent, the rules do not allow us to form a list item by
-indenting the whole thing and prepending a list marker:
-
-```````````````````````````````` example
- foo
-
-bar
-.
-foo
-bar
-````````````````````````````````
+The most important thing to notice is that the position of
+the text after the list marker determines how much indentation
+is needed in subsequent blocks in the list item. If the list
+marker takes up two spaces of indentation, and there are three spaces between
+the list marker and the next character other than a space or tab, then blocks
+must be indented five spaces in order to fall under the list
+item.
+Here are some examples showing how far content must be indented to be
+put under the list item:
```````````````````````````````` example
-- foo
+- one
- bar
+ two
.
-bar
+two
````````````````````````````````
-This is not a significant restriction, because when a block begins
-with 1-3 spaces indent, the indentation can always be removed without
-a change in interpretation, allowing rule #1 to be applied. So, in
-the above case:
-
```````````````````````````````` example
-- foo
+- one
- bar
+ two
.
````````````````````````````````
-3. **Item starting with a blank line.** If a sequence of lines *Ls*
- starting with a single [blank line] constitute a (possibly empty)
- sequence of blocks *Bs*, not separated from each other by more than
- one blank line, and *M* is a list marker of width *W*,
- then the result of prepending *M* to the first line of *Ls*, and
- indenting subsequent lines of *Ls* by *W + 1* spaces, is a list
- item with *Bs* as its contents.
- If a line is empty, then it need not be indented. The type of the
- list item (bullet or ordered) is determined by the type of its list
- marker. If the list item is ordered, then it is also assigned a
- start number, based on the ordered list marker.
-
-Here are some list items that start with a blank line but are not empty:
-
```````````````````````````````` example
--
- foo
--
- ```
- bar
- ```
--
- baz
+ - one
+
+ two
.
-- foo
--
-
bar
-
-
--
-
baz
-
-
+- one
+ two
+
````````````````````````````````
-A list item can begin with at most one blank line.
-In the following example, `foo` is not part of the list
-item:
-
```````````````````````````````` example
--
+ - one
- foo
+ two
.
-foo
````````````````````````````````
-Here is an empty bullet list item:
+It is tempting to think of this in terms of columns: the continuation
+blocks must be indented at least to the column of the first character other than
+a space or tab after the list marker. However, that is not quite right.
+The spaces of indentation after the list marker determine how much relative
+indentation is needed. Which column this indentation reaches will depend on
+how the list item is embedded in other constructions, as shown by
+this example:
```````````````````````````````` example
-- foo
--
-- bar
+ > > 1. one
+>>
+>> two
.
-
+
+
+
+-
+
one
+two
+
+
+
+
````````````````````````````````
-It does not matter whether there are spaces following the [list marker]:
+Here `two` occurs in the same column as the list marker `1.`,
+but is actually contained in the list item, because there is
+sufficient indentation after the last containing blockquote marker.
+
+The converse is also possible. In the following example, the word `two`
+occurs far to the right of the initial text of the list item, `one`, but
+it is not considered part of the list item, because it is not indented
+far enough past the blockquote marker:
```````````````````````````````` example
-- foo
--
-- bar
+>>- one
+>>
+ > > two
.
+
+
+two
+
+
````````````````````````````````
-Here is an empty ordered list item:
+Note that at least one space or tab is needed between the list marker and
+any following content, so these are not list items:
```````````````````````````````` example
-1. foo
-2.
-3. bar
+-one
+
+2.two
.
-
-- foo
-
-- bar
-
+-one
+2.two
````````````````````````````````
-A list may start or end with an empty list item:
+A list item may contain blocks that are separated by more than
+one blank line.
```````````````````````````````` example
-*
+- foo
+
+
+ bar
.
````````````````````````````````
-
-4. **Indentation.** If a sequence of lines *Ls* constitutes a list item
- according to rule #1, #2, or #3, then the result of indenting each line
- of *Ls* by 1-3 spaces (the same for each line) also constitutes a
- list item with the same contents and attributes. If a line is
- empty, then it need not be indented.
-
-Indented one space:
+A list item may contain any kind of block:
```````````````````````````````` example
- 1. A paragraph
- with two lines.
+1. foo
- indented code
+ ```
+ bar
+ ```
- > A block quote.
+ baz
+
+ > bam
.
-
-
A paragraph
-with two lines.
-indented code
+foo
+bar
+baz
-A block quote.
+bam
````````````````````````````````
-Indented two spaces:
+A list item that contains an indented code block will preserve
+empty lines within the code block verbatim.
```````````````````````````````` example
- 1. A paragraph
- with two lines.
+- Foo
- indented code
+ bar
- > A block quote.
+
+ baz
.
-
+
+
````````````````````````````````
-
-Indented three spaces:
+Note that ordered list start numbers must be nine digits or less:
```````````````````````````````` example
- 1. A paragraph
- with two lines.
+123456789. ok
+.
+
+- ok
+
+````````````````````````````````
- indented code
- > A block quote.
+```````````````````````````````` example
+1234567890. not ok
.
-
--
-
A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
+1234567890. not ok
````````````````````````````````
-Four spaces indent gives a code block:
+A start number may begin with 0s:
```````````````````````````````` example
- 1. A paragraph
- with two lines.
+0. ok
+.
+
+- ok
+
+````````````````````````````````
- indented code
- > A block quote.
+```````````````````````````````` example
+003. ok
.
-1. A paragraph
- with two lines.
+
+- ok
+
+````````````````````````````````
- indented code
- > A block quote.
-
+A start number may not be negative:
+
+```````````````````````````````` example
+-1. not ok
+.
+-1. not ok
````````````````````````````````
-5. **Laziness.** If a string of lines *Ls* constitute a [list
- item](#list-items) with contents *Bs*, then the result of deleting
- some or all of the indentation from one or more lines in which the
- next [non-whitespace character] after the indentation is
- [paragraph continuation text] is a
- list item with the same contents and attributes. The unindented
- lines are called
- [lazy continuation line](@)s.
+2. **Item starting with indented code.** If a sequence of lines *Ls*
+ constitute a sequence of blocks *Bs* starting with an indented code
+ block, and *M* is a list marker of width *W* followed by
+ one space of indentation, then the result of prepending *M* and the
+ following space to the first line of *Ls*, and indenting subsequent lines
+ of *Ls* by *W + 1* spaces, is a list item with *Bs* as its contents.
+ If a line is empty, then it need not be indented. The type of the
+ list item (bullet or ordered) is determined by the type of its list
+ marker. If the list item is ordered, then it is also assigned a
+ start number, based on the ordered list marker.
-Here is an example with [lazy continuation lines]:
+An indented code block will have to be preceded by four spaces of indentation
+beyond the edge of the region where text will be included in the list item.
+In the following case that is 6 spaces:
```````````````````````````````` example
- 1. A paragraph
-with two lines.
-
- indented code
+- foo
- > A block quote.
+ bar
.
-
+
+
````````````````````````````````
-Indentation can be partially deleted:
+And in this case it is 11 spaces:
```````````````````````````````` example
- 1. A paragraph
- with two lines.
+ 10. foo
+
+ bar
.
-
-- A paragraph
-with two lines.
+
+-
+
foo
+bar
+
+
````````````````````````````````
-These examples show how laziness can work in nested structures:
+If the *first* block in the list item is an indented code block,
+then by rule #2, the contents must be preceded by *one* space of indentation
+after the list marker:
```````````````````````````````` example
-> 1. > Blockquote
-continued here.
+ indented code
+
+paragraph
+
+ more code
.
-
-
--
-
-Blockquote
-continued here.
-
-
-
-
+indented code
+
+paragraph
+more code
+
````````````````````````````````
```````````````````````````````` example
-> 1. > Blockquote
-> continued here.
+1. indented code
+
+ paragraph
+
+ more code
.
-
-
-
-Blockquote
-continued here.
-
+indented code
+
+paragraph
+more code
+
-
````````````````````````````````
+Note that an additional space of indentation is interpreted as space
+inside the code block:
-6. **That's all.** Nothing that is not counted as a list item by rules
- #1--5 counts as a [list item](#list-items).
-
-The rules for sublists follow from the general rules above. A sublist
-must be indented the same number of spaces a paragraph would need to be
-in order to be included in the list item.
+```````````````````````````````` example
+1. indented code
-So, in this case we need two spaces indent:
+ paragraph
-```````````````````````````````` example
-- foo
- - bar
- - baz
+ more code
.
-
-- foo
-
+
+-
+
indented code
+
+paragraph
+more code
+
-
+
````````````````````````````````
-One is not enough:
+Note that rules #1 and #2 only apply to two cases: (a) cases
+in which the lines to be included in a list item begin with a
+character other than a space or tab, and (b) cases in which
+they begin with an indented code
+block. In a case like the following, where the first block begins with
+three spaces of indentation, the rules do not allow us to form a list item by
+indenting the whole thing and prepending a list marker:
```````````````````````````````` example
-- foo
- - bar
- - baz
-.
-
-````````````````````````````````
-
-
-Here we need four, because the list marker is wider:
+ foo
-```````````````````````````````` example
-10) foo
- - bar
+bar
.
-
-- foo
-
-
-
+foo
+bar
````````````````````````````````
-Three is not enough:
-
```````````````````````````````` example
-10) foo
- - bar
+- foo
+
+ bar
.
-
-- foo
-
+bar
````````````````````````````````
-A list may be the first block in a list item:
+This is not a significant restriction, because when a block is preceded by up to
+three spaces of indentation, the indentation can always be removed without
+a change in interpretation, allowing rule #1 to be applied. So, in
+the above case:
```````````````````````````````` example
-- - foo
+- foo
+
+ bar
.
````````````````````````````````
-```````````````````````````````` example
-1. - 2. foo
+3. **Item starting with a blank line.** If a sequence of lines *Ls*
+ starting with a single [blank line] constitute a (possibly empty)
+ sequence of blocks *Bs*, and *M* is a list marker of width *W*,
+ then the result of prepending *M* to the first line of *Ls*, and
+ preceding subsequent lines of *Ls* by *W + 1* spaces of indentation, is a
+ list item with *Bs* as its contents.
+ If a line is empty, then it need not be indented. The type of the
+ list item (bullet or ordered) is determined by the type of its list
+ marker. If the list item is ordered, then it is also assigned a
+ start number, based on the ordered list marker.
+
+Here are some list items that start with a blank line but are not empty:
+
+```````````````````````````````` example
+-
+ foo
+-
+ ```
+ bar
+ ```
+-
+ baz
.
-
--
+
-
+
baz
+
-
+
````````````````````````````````
+When the list item starts with a blank line, the number of spaces
+following the list marker doesn't change the required indentation:
-A list item can contain a heading:
+```````````````````````````````` example
+-
+ foo
+.
+
+````````````````````````````````
+
+
+A list item can begin with at most one blank line.
+In the following example, `foo` is not part of the list
+item:
```````````````````````````````` example
-- # Foo
-- Bar
- ---
- baz
+-
+
+ foo
.
+foo
````````````````````````````````
-### Motivation
+Here is an empty bullet list item:
-John Gruber's Markdown spec says the following about list items:
+```````````````````````````````` example
+- foo
+-
+- bar
+.
+
+````````````````````````````````
-1. "List markers typically start at the left margin, but may be indented
- by up to three spaces. List markers must be followed by one or more
- spaces or a tab."
-2. "To make lists look nice, you can wrap items with hanging indents....
- But if you don't want to, you don't have to."
+It does not matter whether there are spaces or tabs following the [list marker]:
-3. "List items may consist of multiple paragraphs. Each subsequent
- paragraph in a list item must be indented by either 4 spaces or one
- tab."
+```````````````````````````````` example
+- foo
+-
+- bar
+.
+
+````````````````````````````````
-4. "It looks nice if you indent every line of the subsequent paragraphs,
- but here again, Markdown will allow you to be lazy."
-5. "To put a blockquote within a list item, the blockquote's `>`
- delimiters need to be indented."
+Here is an empty ordered list item:
-6. "To put a code block within a list item, the code block needs to be
- indented twice — 8 spaces or two tabs."
+```````````````````````````````` example
+1. foo
+2.
+3. bar
+.
+
+- foo
+
+- bar
+
+````````````````````````````````
-These rules specify that a paragraph under a list item must be indented
-four spaces (presumably, from the left margin, rather than the start of
-the list marker, but this is not said), and that code under a list item
-must be indented eight spaces instead of the usual four. They also say
-that a block quote must be indented, but not by how much; however, the
-example given has four spaces indentation. Although nothing is said
-about other kinds of block-level content, it is certainly reasonable to
-infer that *all* block elements under a list item, including other
-lists, must be indented four spaces. This principle has been called the
-*four-space rule*.
-The four-space rule is clear and principled, and if the reference
-implementation `Markdown.pl` had followed it, it probably would have
-become the standard. However, `Markdown.pl` allowed paragraphs and
-sublists to start with only two spaces indentation, at least on the
-outer level. Worse, its behavior was inconsistent: a sublist of an
-outer-level list needed two spaces indentation, but a sublist of this
-sublist needed three spaces. It is not surprising, then, that different
-implementations of Markdown have developed very different rules for
-determining what comes under a list item. (Pandoc and python-Markdown,
-for example, stuck with Gruber's syntax description and the four-space
-rule, while discount, redcarpet, marked, PHP Markdown, and others
-followed `Markdown.pl`'s behavior more closely.)
+A list may start or end with an empty list item:
-Unfortunately, given the divergences between implementations, there
-is no way to give a spec for list items that will be guaranteed not
-to break any existing documents. However, the spec given here should
-correctly handle lists formatted with either the four-space rule or
-the more forgiving `Markdown.pl` behavior, provided they are laid out
-in a way that is natural for a human to read.
+```````````````````````````````` example
+*
+.
+
+````````````````````````````````
-The strategy here is to let the width and indentation of the list marker
-determine the indentation necessary for blocks to fall under the list
-item, rather than having a fixed and arbitrary number. The writer can
-think of the body of the list item as a unit which gets indented to the
-right enough to fit the list marker (and any indentation on the list
-marker). (The laziness rule, #5, then allows continuation lines to be
-unindented if needed.)
+However, an empty list item cannot interrupt a paragraph:
-This rule is superior, we claim, to any rule requiring a fixed level of
-indentation from the margin. The four-space rule is clear but
-unnatural. It is quite unintuitive that
+```````````````````````````````` example
+foo
+*
-``` markdown
-- foo
+foo
+1.
+.
+foo
+*
+foo
+1.
+````````````````````````````````
- bar
- - baz
-```
+4. **Indentation.** If a sequence of lines *Ls* constitutes a list item
+ according to rule #1, #2, or #3, then the result of preceding each line
+ of *Ls* by up to three spaces of indentation (the same for each line) also
+ constitutes a list item with the same contents and attributes. If a line is
+ empty, then it need not be indented.
-should be parsed as two lists with an intervening paragraph,
+Indented one space:
-``` html
-
-bar
-
-```
+```````````````````````````````` example
+ 1. A paragraph
+ with two lines.
-as the four-space rule demands, rather than a single list,
+ indented code
-``` html
-
+ > A block quote.
+.
+
-
-
foo
-bar
-
+A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
-
-```
-
-The choice of four spaces is arbitrary. It can be learned, but it is
-not likely to be guessed, and it trips up beginners regularly.
+
+````````````````````````````````
-Would it help to adopt a two-space rule? The problem is that such
-a rule, together with the rule allowing 1--3 spaces indentation of the
-initial list marker, allows text that is indented *less than* the
-original list marker to be included in the list item. For example,
-`Markdown.pl` parses
-``` markdown
- - one
+Indented two spaces:
- two
-```
+```````````````````````````````` example
+ 1. A paragraph
+ with two lines.
-as a single list item, with `two` a continuation paragraph:
+ indented code
-``` html
-
+ > A block quote.
+.
+
-
-
one
-two
+A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
-
-```
+
+````````````````````````````````
-and similarly
-``` markdown
-> - one
->
-> two
-```
+Indented three spaces:
-as
+```````````````````````````````` example
+ 1. A paragraph
+ with two lines.
-``` html
-
-
+ indented code
+
+ > A block quote.
+.
+
-
-
one
-two
-
-
+A paragraph
+with two lines.
+indented code
+
+
+A block quote.
-```
-
-This is extremely unintuitive.
+
+
+````````````````````````````````
-Rather than requiring a fixed indent from the margin, we could require
-a fixed indent (say, two spaces, or even one space) from the list marker (which
-may itself be indented). This proposal would remove the last anomaly
-discussed. Unlike the spec presented above, it would count the following
-as a list item with a subparagraph, even though the paragraph `bar`
-is not indented as far as the first paragraph `foo`:
-``` markdown
- 10. foo
+Four spaces indent gives a code block:
- bar
-```
+```````````````````````````````` example
+ 1. A paragraph
+ with two lines.
-Arguably this text does read like a list item with `bar` as a subparagraph,
-which may count in favor of the proposal. However, on this proposal indented
-code would have to be indented six spaces after the list marker. And this
-would break a lot of existing Markdown, which has the pattern:
+ indented code
-``` markdown
-1. foo
+ > A block quote.
+.
+1. A paragraph
+ with two lines.
indented code
-```
-where the code is indented eight spaces. The spec above, by contrast, will
-parse this text as expected, since the code block's indentation is measured
-from the beginning of `foo`.
+ > A block quote.
+
+````````````````````````````````
-The one case that needs special treatment is a list item that *starts*
-with indented code. How much indentation is required in that case, since
-we don't have a "first paragraph" to measure from? Rule #2 simply stipulates
-that in such cases, we require one space indentation from the list marker
-(and then the normal four spaces for the indented code). This will match the
-four-space rule in cases where the list marker plus its initial indentation
-takes four spaces (a common case), but diverge in other cases.
-## Lists
-A [list](@) is a sequence of one or more
-list items [of the same type]. The list items
-may be separated by single [blank lines], but two
-blank lines end all containing lists.
+5. **Laziness.** If a string of lines *Ls* constitute a [list
+ item](#list-items) with contents *Bs*, then the result of deleting
+ some or all of the indentation from one or more lines in which the
+ next character other than a space or tab after the indentation is
+ [paragraph continuation text] is a
+ list item with the same contents and attributes. The unindented
+ lines are called
+ [lazy continuation line](@)s.
-Two list items are [of the same type](@)
-if they begin with a [list marker] of the same type.
-Two list markers are of the
-same type if (a) they are bullet list markers using the same character
-(`-`, `+`, or `*`) or (b) they are ordered list numbers with the same
-delimiter (either `.` or `)`).
+Here is an example with [lazy continuation lines]:
-A list is an [ordered list](@)
-if its constituent list items begin with
-[ordered list markers], and a
-[bullet list](@) if its constituent list
-items begin with [bullet list markers].
+```````````````````````````````` example
+ 1. A paragraph
+with two lines.
-The [start number](@)
-of an [ordered list] is determined by the list number of
-its initial list item. The numbers of subsequent list items are
-disregarded.
+ indented code
+
+ > A block quote.
+.
+
+-
+
A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
+
+
+````````````````````````````````
+
+
+Indentation can be partially deleted:
+
+```````````````````````````````` example
+ 1. A paragraph
+ with two lines.
+.
+
+- A paragraph
+with two lines.
+
+````````````````````````````````
+
+
+These examples show how laziness can work in nested structures:
+
+```````````````````````````````` example
+> 1. > Blockquote
+continued here.
+.
+
+
+-
+
+Blockquote
+continued here.
+
+
+
+
+````````````````````````````````
+
+
+```````````````````````````````` example
+> 1. > Blockquote
+> continued here.
+.
+
+
+-
+
+Blockquote
+continued here.
+
+
+
+
+````````````````````````````````
-A list is [loose](@) if any of its constituent
-list items are separated by blank lines, or if any of its constituent
-list items directly contain two block-level elements with a blank line
-between them. Otherwise a list is [tight](@).
-(The difference in HTML output is that paragraphs in a loose list are
-wrapped in `` tags, while paragraphs in a tight list are not.)
-Changing the bullet or ordered list delimiter starts a new list:
+
+6. **That's all.** Nothing that is not counted as a list item by rules
+ #1--5 counts as a [list item](#list-items).
+
+The rules for sublists follow from the general rules
+[above][List items]. A sublist must be indented the same number
+of spaces of indentation a paragraph would need to be in order to be included
+in the list item.
+
+So, in this case we need two spaces indent:
```````````````````````````````` example
- foo
-- bar
-+ baz
+ - bar
+ - baz
+ - boo
.
+foo
+
````````````````````````````````
+One is not enough:
+
```````````````````````````````` example
-1. foo
-2. bar
-3) baz
+- foo
+ - bar
+ - baz
+ - boo
.
-
+
-
- baz
-
+boo
+
````````````````````````````````
-In CommonMark, a list can interrupt a paragraph. That is,
-no blank line is needed to separate a paragraph from a following
-list:
+Here we need four, because the list marker is wider:
```````````````````````````````` example
-Foo
-- bar
-- baz
+10) foo
+ - bar
.
-Foo
+
+- foo
+
+
````````````````````````````````
-`Markdown.pl` does not allow this, through fear of triggering a list
-via a numeral in a hard-wrapped line:
+Three is not enough:
```````````````````````````````` example
-The number of windows in my house is
-14. The number of doors is 6.
+10) foo
+ - bar
.
-The number of windows in my house is
-
-- The number of doors is 6.
+
+- foo
+
````````````````````````````````
-Oddly, `Markdown.pl` *does* allow a blockquote to interrupt a paragraph,
-even though the same considerations might apply. We think that the two
-cases should be treated the same. Here are two reasons for allowing
-lists to interrupt paragraphs:
-
-First, it is natural and not uncommon for people to start lists without
-blank lines:
-
- I need to buy
- - new shoes
- - a coat
- - a plane ticket
-
-Second, we are attracted to a
-
-> [principle of uniformity](@):
-> if a chunk of text has a certain
-> meaning, it will continue to have the same meaning when put into a
-> container block (such as a list item or blockquote).
-
-(Indeed, the spec for [list items] and [block quotes] presupposes
-this principle.) This principle implies that if
-
- * I need to buy
- - new shoes
- - a coat
- - a plane ticket
-
-is a list item containing a paragraph followed by a nested sublist,
-as all Markdown implementations agree it is (though the paragraph
-may be rendered without `` tags, since the list is "tight"),
-then
-
- I need to buy
- - new shoes
- - a coat
- - a plane ticket
-
-by itself should be a paragraph followed by a nested sublist.
-
-Our adherence to the [principle of uniformity]
-thus inclines us to think that there are two coherent packages:
-
-1. Require blank lines before *all* lists and blockquotes,
- including lists that occur as sublists inside other list items.
-
-2. Require blank lines in none of these places.
-
-[reStructuredText](http://docutils.sourceforge.net/rst.html) takes
-the first approach, for which there is much to be said. But the second
-seems more consistent with established practice with Markdown.
-
-There can be blank lines between items, but two blank lines end
-a list:
+A list may be the first block in a list item:
```````````````````````````````` example
-- foo
-
-- bar
-
-
-- baz
+- - foo
.
+
````````````````````````````````
-As illustrated above in the section on [list items],
-two blank lines between blocks *within* a list item will also end a
-list:
-
```````````````````````````````` example
-- foo
-
-
- bar
-- baz
+1. - 2. foo
.
+
+-
-
bar
-
+
+
````````````````````````````````
-Indeed, two blank lines will end *all* containing lists:
+A list item can contain a heading:
```````````````````````````````` example
-- foo
- - bar
- - baz
-
-
- bim
+- # Foo
+- Bar
+ ---
+ baz
.
-- foo
-
+
-
+
Foo
+-
+
Bar
+baz
- bim
-
````````````````````````````````
-Thus, two blank lines can be used to separate consecutive lists of
-the same type, or to separate a list from an indented code block
-that would otherwise be parsed as a subparagraph of the final list
-item:
+### Motivation
-```````````````````````````````` example
-- foo
-- bar
+John Gruber's Markdown spec says the following about list items:
+1. "List markers typically start at the left margin, but may be indented
+ by up to three spaces. List markers must be followed by one or more
+ spaces or a tab."
-- baz
-- bim
-.
-
-
-````````````````````````````````
+2. "To make lists look nice, you can wrap items with hanging indents....
+ But if you don't want to, you don't have to."
+3. "List items may consist of multiple paragraphs. Each subsequent
+ paragraph in a list item must be indented by either 4 spaces or one
+ tab."
-```````````````````````````````` example
-- foo
+4. "It looks nice if you indent every line of the subsequent paragraphs,
+ but here again, Markdown will allow you to be lazy."
- notcode
+5. "To put a blockquote within a list item, the blockquote's `>`
+ delimiters need to be indented."
-- foo
+6. "To put a code block within a list item, the code block needs to be
+ indented twice — 8 spaces or two tabs."
+
+These rules specify that a paragraph under a list item must be indented
+four spaces (presumably, from the left margin, rather than the start of
+the list marker, but this is not said), and that code under a list item
+must be indented eight spaces instead of the usual four. They also say
+that a block quote must be indented, but not by how much; however, the
+example given has four spaces indentation. Although nothing is said
+about other kinds of block-level content, it is certainly reasonable to
+infer that *all* block elements under a list item, including other
+lists, must be indented four spaces. This principle has been called the
+*four-space rule*.
+
+The four-space rule is clear and principled, and if the reference
+implementation `Markdown.pl` had followed it, it probably would have
+become the standard. However, `Markdown.pl` allowed paragraphs and
+sublists to start with only two spaces indentation, at least on the
+outer level. Worse, its behavior was inconsistent: a sublist of an
+outer-level list needed two spaces indentation, but a sublist of this
+sublist needed three spaces. It is not surprising, then, that different
+implementations of Markdown have developed very different rules for
+determining what comes under a list item. (Pandoc and python-Markdown,
+for example, stuck with Gruber's syntax description and the four-space
+rule, while discount, redcarpet, marked, PHP Markdown, and others
+followed `Markdown.pl`'s behavior more closely.)
+
+Unfortunately, given the divergences between implementations, there
+is no way to give a spec for list items that will be guaranteed not
+to break any existing documents. However, the spec given here should
+correctly handle lists formatted with either the four-space rule or
+the more forgiving `Markdown.pl` behavior, provided they are laid out
+in a way that is natural for a human to read.
+
+The strategy here is to let the width and indentation of the list marker
+determine the indentation necessary for blocks to fall under the list
+item, rather than having a fixed and arbitrary number. The writer can
+think of the body of the list item as a unit which gets indented to the
+right enough to fit the list marker (and any indentation on the list
+marker). (The laziness rule, #5, then allows continuation lines to be
+unindented if needed.)
+
+This rule is superior, we claim, to any rule requiring a fixed level of
+indentation from the margin. The four-space rule is clear but
+unnatural. It is quite unintuitive that
+
+``` markdown
+- foo
+
+ bar
+
+ - baz
+```
+should be parsed as two lists with an intervening paragraph,
- code
-.
+``` html
--
-
foo
-notcode
-
--
-
foo
-
+- foo
-code
-
-````````````````````````````````
-
-
-List items need not be indented to the same level. The following
-list items will be treated as items at the same list level,
-since none is indented enough to belong to the previous list
-item:
-
-```````````````````````````````` example
-- a
- - b
- - c
- - d
- - e
- - f
- - g
- - h
-- i
-.
+bar
-- a
-- b
-- c
-- d
-- e
-- f
-- g
-- h
-- i
+- baz
-````````````````````````````````
-
-
-```````````````````````````````` example
-1. a
+```
- 2. b
+as the four-space rule demands, rather than a single list,
- 3. c
-.
-
--
-
a
-
--
-
b
-
+``` html
+
-````````````````````````````````
+
+```
+The choice of four spaces is arbitrary. It can be learned, but it is
+not likely to be guessed, and it trips up beginners regularly.
-This is a loose list, because there is a blank line between
-two of the list items:
+Would it help to adopt a two-space rule? The problem is that such
+a rule, together with the rule allowing up to three spaces of indentation for
+the initial list marker, allows text that is indented *less than* the
+original list marker to be included in the list item. For example,
+`Markdown.pl` parses
-```````````````````````````````` example
-- a
-- b
+``` markdown
+ - one
-- c
-.
+ two
+```
+
+as a single list item, with `two` a continuation paragraph:
+
+``` html
-
-
a
-
--
-
b
-
--
-
c
+one
+two
-````````````````````````````````
+```
+and similarly
-So is this, with a empty second item:
+``` markdown
+> - one
+>
+> two
+```
-```````````````````````````````` example
-* a
-*
+as
-* c
-.
+``` html
+
-````````````````````````````````
+
+```
+This is extremely unintuitive.
-These are loose lists, even though there is no space between the items,
-because one of the items directly contains two block-level elements
-with a blank line between them:
+Rather than requiring a fixed indent from the margin, we could require
+a fixed indent (say, two spaces, or even one space) from the list marker (which
+may itself be indented). This proposal would remove the last anomaly
+discussed. Unlike the spec presented above, it would count the following
+as a list item with a subparagraph, even though the paragraph `bar`
+is not indented as far as the first paragraph `foo`:
-```````````````````````````````` example
-- a
-- b
+``` markdown
+ 10. foo
- c
-- d
-.
-
--
-
a
-
--
-
b
-c
-
--
-
d
-
-
-````````````````````````````````
+ bar
+```
+Arguably this text does read like a list item with `bar` as a subparagraph,
+which may count in favor of the proposal. However, on this proposal indented
+code would have to be indented six spaces after the list marker. And this
+would break a lot of existing Markdown, which has the pattern:
-```````````````````````````````` example
-- a
-- b
+``` markdown
+1. foo
- [ref]: /url
-- d
-.
-
-````````````````````````````````
+ indented code
+```
+where the code is indented eight spaces. The spec above, by contrast, will
+parse this text as expected, since the code block's indentation is measured
+from the beginning of `foo`.
-This is a tight list, because the blank lines are in a code block:
+The one case that needs special treatment is a list item that *starts*
+with indented code. How much indentation is required in that case, since
+we don't have a "first paragraph" to measure from? Rule #2 simply stipulates
+that in such cases, we require one space indentation from the list marker
+(and then the normal four spaces for the indented code). This will match the
+four-space rule in cases where the list marker plus its initial indentation
+takes four spaces (a common case), but diverge in other cases.
-```````````````````````````````` example
-- a
-- ```
- b
+## Lists
+A [list](@) is a sequence of one or more
+list items [of the same type]. The list items
+may be separated by any number of blank lines.
- ```
-- c
-.
-
-- a
--
-
b
+Two list items are [of the same type](@)
+if they begin with a [list marker] of the same type.
+Two list markers are of the
+same type if (a) they are bullet list markers using the same character
+(`-`, `+`, or `*`) or (b) they are ordered list numbers with the same
+delimiter (either `.` or `)`).
+A list is an [ordered list](@)
+if its constituent list items begin with
+[ordered list markers], and a
+[bullet list](@) if its constituent list
+items begin with [bullet list markers].
-
-
-- c
-
-````````````````````````````````
+The [start number](@)
+of an [ordered list] is determined by the list number of
+its initial list item. The numbers of subsequent list items are
+disregarded.
+A list is [loose](@) if any of its constituent
+list items are separated by blank lines, or if any of its constituent
+list items directly contain two block-level elements with a blank line
+between them. Otherwise a list is [tight](@).
+(The difference in HTML output is that paragraphs in a loose list are
+wrapped in `` tags, while paragraphs in a tight list are not.)
-This is a tight list, because the blank line is between two
-paragraphs of a sublist. So the sublist is loose while
-the outer list is tight:
+Changing the bullet or ordered list delimiter starts a new list:
```````````````````````````````` example
-- a
- - b
-
- c
-- d
+- foo
+- bar
++ baz
.
)
.
-[link](</my uri>)
+link
````````````````````````````````
+The destination cannot contain line endings,
+even if enclosed in pointy brackets:
```````````````````````````````` example
[link](foo
@@ -7111,7 +7605,6 @@ bar)
bar)
````````````````````````````````
-
```````````````````````````````` example
[link]()
@@ -7120,6 +7613,36 @@ bar>)
bar>)
````````````````````````````````
+The destination can contain `)` if it is enclosed
+in pointy brackets:
+
+```````````````````````````````` example
+[a]()
+.
+a
+````````````````````````````````
+
+Pointy brackets that enclose links must be unescaped:
+
+```````````````````````````````` example
+[link]()
+.
+[link](<foo>)
+````````````````````````````````
+
+These are not links, because the opening pointy bracket
+is not matched properly:
+
+```````````````````````````````` example
+[a](
+[a](c)
+.
+[a](<b)c
+[a](<b)c>
+[a](c)
+````````````````````````````````
+
Parentheses inside the link destination may be escaped:
```````````````````````````````` example
@@ -7128,35 +7651,36 @@ Parentheses inside the link destination may be escaped:
link
````````````````````````````````
-One level of balanced parentheses is allowed without escaping:
+Any number of parentheses are allowed without escaping, as long as they are
+balanced:
```````````````````````````````` example
-[link]((foo)and(bar))
+[link](foo(and(bar)))
.
-link
+link
````````````````````````````````
-However, if you have parentheses within parentheses, you need to escape
-or use the `<...>` form:
+However, if you have unbalanced parentheses, you need to escape or use the
+`<...>` form:
```````````````````````````````` example
-[link](foo(and(bar)))
+[link](foo(and(bar))
.
-[link](foo(and(bar)))
+[link](foo(and(bar))
````````````````````````````````
```````````````````````````````` example
-[link](foo(and\(bar\)))
+[link](foo\(and\(bar\))
.
-link
+link
````````````````````````````````
```````````````````````````````` example
-[link]()
+[link]()
.
-link
+link
````````````````````````````````
@@ -7175,13 +7699,13 @@ A link can contain fragment identifiers and queries:
```````````````````````````````` example
[link](#fragment)
-[link](http://example.com#fragment)
+[link](https://example.com#fragment)
-[link](http://example.com?foo=3#frag)
+[link](https://example.com?foo=3#frag)
.
link
-link
-link
+link
+link
````````````````````````````````
@@ -7245,6 +7769,17 @@ may be used in titles:
````````````````````````````````
+Titles must be separated from the link using spaces, tabs, and up to one line
+ending.
+Other [Unicode whitespace] like non-breaking space doesn't work.
+
+```````````````````````````````` example
+[link](/url "title")
+.
+link
+````````````````````````````````
+
+
Nested balanced quotes are not allowed without escaping:
```````````````````````````````` example
@@ -7278,7 +7813,8 @@ titles with no closing quotation mark, though 1.0.2b8 does not.
It seems preferable to adopt a simple, rational rule that works
the same way in inline links and link reference definitions.)
-[Whitespace] is allowed around the destination and title:
+Spaces, tabs, and up to one line ending is allowed around the destination and
+title:
```````````````````````````````` example
[link]( /uri
@@ -7413,9 +7949,9 @@ and autolinks over link grouping:
```````````````````````````````` example
-[foo
+[foo
.
-[foohttp://example.com/?search=](uri)
+[foohttps://example.com/?search=](uri)
````````````````````````````````
@@ -7429,21 +7965,24 @@ that [matches] a [link reference definition] elsewhere in the document.
A [link label](@) begins with a left bracket (`[`) and ends
with the first right bracket (`]`) that is not backslash-escaped.
-Between these brackets there must be at least one [non-whitespace character].
-Unescaped square bracket characters are not allowed in
-[link labels]. A link label can have at most 999
-characters inside the square brackets.
+Between these brackets there must be at least one character that is not a space,
+tab, or line ending.
+Unescaped square bracket characters are not allowed inside the
+opening and closing square brackets of [link labels]. A link
+label can have at most 999 characters inside the square
+brackets.
One label [matches](@)
another just in case their normalized forms are equal. To normalize a
-label, perform the *Unicode case fold* and collapse consecutive internal
-[whitespace] to a single space. If there are multiple
+label, strip off the opening and closing brackets,
+perform the *Unicode case fold*, strip leading and trailing
+spaces, tabs, and line endings, and collapse consecutive internal
+spaces, tabs, and line endings to a single space. If there are multiple
matching reference link definitions, the one that comes first in the
document is used. (It is desirable in such cases to emit a warning.)
-The contents of the first link label are parsed as inlines, which are
-used as the link's text. The link's URI and title are provided by the
-matching [link reference definition].
+The link's URI and title are provided by the matching [link
+reference definition].
Here is a simple example:
@@ -7536,11 +8075,11 @@ emphasis grouping:
```````````````````````````````` example
-[foo *bar][ref]
+[foo *bar][ref]*
[ref]: /uri
.
-foo *bar
+foo *bar*
````````````````````````````````
@@ -7566,11 +8105,11 @@ and autolinks over link grouping:
```````````````````````````````` example
-[foo
+[foo
[ref]: /uri
.
-[foohttp://example.com/?search=][ref]
+[foohttps://example.com/?search=][ref]
````````````````````````````````
@@ -7588,15 +8127,15 @@ Matching is case-insensitive:
Unicode case fold is used:
```````````````````````````````` example
-[Толпой][Толпой] is a Russian word.
+[ẞ]
-[ТОЛПОЙ]: /url
+[SS]: /url
.
-Толпой is a Russian word.
+ẞ
````````````````````````````````
-Consecutive internal [whitespace] is treated as one space for
+Consecutive internal spaces, tabs, and line endings are treated as one space for
purposes of determining matching:
```````````````````````````````` example
@@ -7609,7 +8148,7 @@ purposes of determining matching:
````````````````````````````````
-No [whitespace] is allowed between the [link text] and the
+No spaces, tabs, or line endings are allowed between the [link text] and the
[link label]:
```````````````````````````````` example
@@ -7739,7 +8278,8 @@ Note that in this example `]` is not backslash-escaped:
````````````````````````````````
-A [link label] must contain at least one [non-whitespace character]:
+A [link label] must contain at least one character that is not a space, tab, or
+line ending:
```````````````````````````````` example
[]
@@ -7769,7 +8309,7 @@ A [collapsed reference link](@)
consists of a [link label] that [matches] a
[link reference definition] elsewhere in the
document, followed by the string `[]`.
-The contents of the first link label are parsed as inlines,
+The contents of the link label are parsed as inlines,
which are used as the link's text. The link's URI and title are
provided by the matching reference link definition. Thus,
`[foo][]` is equivalent to `[foo][foo]`.
@@ -7804,7 +8344,7 @@ The link labels are case-insensitive:
-As with full reference links, [whitespace] is not
+As with full reference links, spaces, tabs, or line endings are not
allowed between the two sets of brackets:
```````````````````````````````` example
@@ -7822,8 +8362,8 @@ A [shortcut reference link](@)
consists of a [link label] that [matches] a
[link reference definition] elsewhere in the
document and is not followed by `[]` or a link label.
-The contents of the first link label are parsed as inlines,
-which are used as the link's text. the link's URI and title
+The contents of the link label are parsed as inlines,
+which are used as the link's text. The link's URI and title
are provided by the matching link reference definition.
Thus, `[foo]` is equivalent to `[foo][]`.
@@ -7909,7 +8449,8 @@ following closing bracket:
````````````````````````````````
-Full references take precedence over shortcut references:
+Full and collapsed references take precedence over shortcut
+references:
```````````````````````````````` example
[foo][bar]
@@ -7920,6 +8461,31 @@ Full references take precedence over shortcut references:
foo
````````````````````````````````
+```````````````````````````````` example
+[foo][]
+
+[foo]: /url1
+.
+foo
+````````````````````````````````
+
+Inline links also take precedence:
+
+```````````````````````````````` example
+[foo]()
+
+[foo]: /url1
+.
+foo
+````````````````````````````````
+
+```````````````````````````````` example
+[foo](not a link)
+
+[foo]: /url1
+.
+foo(not a link)
+````````````````````````````````
In the following case `[bar][baz]` is parsed as a reference,
`[foo]` as normal text:
@@ -8106,7 +8672,7 @@ The labels are case-insensitive:
````````````````````````````````
-As with reference links, [whitespace] is not allowed
+As with reference links, spaces, tabs, and line endings, are not allowed
between the two sets of brackets:
```````````````````````````````` example
@@ -8163,11 +8729,11 @@ The link labels are case-insensitive:
````````````````````````````````
-If you just want bracketed text, you can backslash-escape the
-opening `!` and `[`:
+If you just want a literal `!` followed by bracketed text, you can
+backslash-escape the opening `[`:
```````````````````````````````` example
-\!\[foo]
+!\[foo]
[foo]: /url "title"
.
@@ -8194,14 +8760,14 @@ If you want a link after a literal `!`, backslash-escape the
as the link label.
A [URI autolink](@) consists of `<`, followed by an
-[absolute URI] not containing `<`, followed by `>`. It is parsed as
+[absolute URI] followed by `>`. It is parsed as
a link to the URI, with the URI as the link's label.
An [absolute URI](@),
for these purposes, consists of a [scheme] followed by a colon (`:`)
-followed by zero or more characters other than ASCII
-[whitespace] and control characters, `<`, and `>`. If
-the URI includes these characters, they must be percent-encoded
+followed by zero or more characters other than [ASCII control
+characters][ASCII control character], [space], `<`, and `>`.
+If the URI includes these characters, they must be percent-encoded
(e.g. `%20` for a space).
For purposes of this spec, a [scheme](@) is any sequence
@@ -8219,9 +8785,9 @@ Here are some valid autolinks:
```````````````````````````````` example
-
+
.
-http://foo.bar.baz/test?q=hello&id=22&boolean
+https://foo.bar.baz/test?q=hello&id=22&boolean
````````````````````````````````
@@ -8261,9 +8827,9 @@ with their syntax:
```````````````````````````````` example
-
+
.
-http://../
+https://../
````````````````````````````````
@@ -8277,18 +8843,18 @@ with their syntax:
Spaces are not allowed in autolinks:
```````````````````````````````` example
-
+
.
-<http://foo.bar/baz bim>
+<https://foo.bar/baz bim>
````````````````````````````````
Backslash-escapes do not work inside autolinks:
```````````````````````````````` example
-
+
.
-http://example.com/\[\
+https://example.com/\[\
````````````````````````````````
@@ -8340,9 +8906,9 @@ These are not autolinks:
```````````````````````````````` example
-< http://foo.bar >
+< https://foo.bar >
.
-< http://foo.bar >
+< https://foo.bar >
````````````````````````````````
@@ -8361,9 +8927,9 @@ These are not autolinks:
```````````````````````````````` example
-http://example.com
+https://example.com
.
-http://example.com
+https://example.com
````````````````````````````````
@@ -8387,7 +8953,7 @@ A [tag name](@) consists of an ASCII letter
followed by zero or more ASCII letters, digits, or
hyphens (`-`).
-An [attribute](@) consists of [whitespace],
+An [attribute](@) consists of spaces, tabs, and up to one line ending,
an [attribute name], and an optional
[attribute value specification].
@@ -8397,9 +8963,9 @@ letters, digits, `_`, `.`, `:`, or `-`. (Note: This is the XML
specification restricted to ASCII. HTML5 is laxer.)
An [attribute value specification](@)
-consists of optional [whitespace],
-a `=` character, optional [whitespace], and an [attribute
-value].
+consists of optional spaces, tabs, and up to one line ending,
+a `=` character, optional spaces, tabs, and up to one line ending,
+and an [attribute value].
An [attribute value](@)
consists of an [unquoted attribute value],
@@ -8407,7 +8973,7 @@ a [single-quoted attribute value], or a [double-quoted attribute value].
An [unquoted attribute value](@)
is a nonempty string of characters not
-including spaces, `"`, `'`, `=`, `<`, `>`, or `` ` ``.
+including spaces, tabs, line endings, `"`, `'`, `=`, `<`, `>`, or `` ` ``.
A [single-quoted attribute value](@)
consists of `'`, zero or more
@@ -8418,26 +8984,24 @@ consists of `"`, zero or more
characters not including `"`, and a final `"`.
An [open tag](@) consists of a `<` character, a [tag name],
-zero or more [attributes], optional [whitespace], an optional `/`
-character, and a `>` character.
+zero or more [attributes], optional spaces, tabs, and up to one line ending,
+an optional `/` character, and a `>` character.
A [closing tag](@) consists of the string ``, a
-[tag name], optional [whitespace], and the character `>`.
+[tag name], optional spaces, tabs, and up to one line ending, and the character
+`>`.
-An [HTML comment](@) consists of ``,
-where *text* does not start with `>` or `->`, does not end with `-`,
-and does not contain `--`. (See the
-[HTML5 spec](http://www.w3.org/TR/html5/syntax.html#comments).)
+An [HTML comment](@) consists of ``, ``, or ``, and `-->` (see the
+[HTML spec](https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state)).
A [processing instruction](@)
consists of the string ``, a string
of characters not including the string `?>`, and the string
`?>`.
-A [declaration](@) consists of the
-string ``, and the character `>`.
+A [declaration](@) consists of the string ``, and the character `>`.
A [CDATA section](@) consists of
the string `<
foo>
+
.
< a><
-foo><bar/ >
+foo><bar/ >
+<foo bar=baz
+bim!bop />
````````````````````````````````
-Missing [whitespace]:
+Missing whitespace:
```````````````````````````````` example
@@ -8564,30 +9132,20 @@ Illegal attributes in closing tag:
Comments:
```````````````````````````````` example
-foo
+foo
.
-foo
+foo
````````````````````````````````
-
-```````````````````````````````` example
-foo
-.
-foo <!-- not a comment -- two hyphens -->
-````````````````````````````````
-
-
-Not comments:
-
```````````````````````````````` example
foo foo -->
-foo
+foo foo -->
.
-foo <!--> foo -->
-foo <!-- foo--->
+foo foo -->
+foo foo -->
````````````````````````````````
@@ -8646,7 +9204,7 @@ foo
## Hard line breaks
-A line break (not in a code span or HTML tag) that is preceded
+A line ending (not in a code span or HTML tag) that is preceded
by two or more spaces and does not occur at the end of a block
is parsed as a [hard line break](@) (rendered
in HTML as a `
` tag):
@@ -8661,7 +9219,7 @@ baz
For a more visible alternative, a backslash before the
-[line ending] may be used instead of two spaces:
+[line ending] may be used instead of two or more spaces:
```````````````````````````````` example
foo\
@@ -8703,7 +9261,7 @@ bar
````````````````````````````````
-Line breaks can occur inside emphasis, links, and other constructs
+Hard line breaks can occur inside emphasis, links, and other constructs
that allow inline content:
```````````````````````````````` example
@@ -8724,13 +9282,13 @@ bar
````````````````````````````````
-Line breaks do not occur inside code spans
+Hard line breaks do not occur inside code spans
```````````````````````````````` example
`code
span`
.
-code span
+code span
````````````````````````````````
@@ -8796,9 +9354,9 @@ foo
## Soft line breaks
-A regular line break (not in a code span or HTML tag) that is not
+A regular line ending (not in a code span or HTML tag) that is not
preceded by two or more spaces or a backslash is parsed as a
-softbreak. (A softbreak may be rendered in HTML either as a
+[softbreak](@). (A soft line break may be rendered in HTML either as a
[line ending] or as a space. The result will be the same in
browsers. In the examples here, a [line ending] will be used.)
@@ -8824,7 +9382,7 @@ baz
A conforming parser may render a soft line break in HTML either as a
-line break or as a space.
+line ending or as a space.
A renderer may also provide an option to render soft line breaks
as hard line breaks.
@@ -8929,10 +9487,10 @@ blocks. But we cannot close unmatched blocks yet, because we may have a
[lazy continuation line].
2. Next, after consuming the continuation markers for existing
-blocks, we look for new block starts (e.g. `>` for a block quote.
+blocks, we look for new block starts (e.g. `>` for a block quote).
If we encounter a new block start, we close any blocks unmatched
in step 1 before creating the new block as a child of the last
-matched block.
+matched container block.
3. Finally, we look at the remainder of the line (after block
markers like `>`, list markers, and indentation have been consumed).
@@ -8940,7 +9498,7 @@ This is text that can be incorporated into the last open
block (a paragraph, code block, heading, or raw HTML).
Setext headings are formed when we see a line of a paragraph
-that is a setext heading line.
+that is a [setext heading underline].
Reference link definitions are detected when a paragraph is closed;
the accumulated text lines are parsed to see if they begin with
@@ -9116,7 +9674,7 @@ through the stack for an opening `[` or `![` delimiter.
delimiter from the stack, and return a literal text node `]`.
- If we find one and it's active, then we parse ahead to see if
- we have an inline link/image, reference link/image, compact reference
+ we have an inline link/image, reference link/image, collapsed reference
link/image, or shortcut reference link/image.
+ If we don't, then we remove the opening delimiter from the
@@ -9148,7 +9706,9 @@ just above `stack_bottom` (or the first element if `stack_bottom`
is NULL).
We keep track of the `openers_bottom` for each delimiter
-type (`*`, `_`). Initialize this to `stack_bottom`.
+type (`*`, `_`), indexed to the length of the closing delimiter run
+(modulo 3) and to whether the closing delimiter can also be an
+opener. Initialize this to `stack_bottom`.
Then we repeat the following until we run out of potential
closers:
@@ -9180,7 +9740,7 @@ closers:
of the delimiter stack. If the closing node is removed, reset
`current_position` to the next element in the stack.
-- If none in found:
+- If none is found:
+ Set `openers_bottom` to the element before `current_position`.
(We know that there are no openers for this kind of closer up to and
@@ -9194,4 +9754,3 @@ closers:
After we're done, we remove all delimiters above `stack_bottom` from the
delimiter stack.
-
diff --git a/commonmark/.settings/org.eclipse.core.runtime.prefs b/commonmark/.settings/org.eclipse.core.runtime.prefs
deleted file mode 100644
index 5a0ad22d2..000000000
--- a/commonmark/.settings/org.eclipse.core.runtime.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-eclipse.preferences.version=1
-line.separator=\n
diff --git a/commonmark/.settings/org.eclipse.jdt.core.prefs b/commonmark/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 3c0d27c8f..000000000
--- a/commonmark/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,290 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.compliance=1.7
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.7
-org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_assignment=0
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
-org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
-org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
-org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
-org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
-org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
-org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
-org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_after_package=1
-org.eclipse.jdt.core.formatter.blank_lines_before_field=0
-org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
-org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
-org.eclipse.jdt.core.formatter.blank_lines_before_method=1
-org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
-org.eclipse.jdt.core.formatter.blank_lines_before_package=0
-org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
-org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
-org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
-org.eclipse.jdt.core.formatter.comment.format_block_comments=true
-org.eclipse.jdt.core.formatter.comment.format_header=false
-org.eclipse.jdt.core.formatter.comment.format_html=true
-org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
-org.eclipse.jdt.core.formatter.comment.format_line_comments=true
-org.eclipse.jdt.core.formatter.comment.format_source_code=true
-org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
-org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
-org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
-org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
-org.eclipse.jdt.core.formatter.comment.line_length=120
-org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
-org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
-org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
-org.eclipse.jdt.core.formatter.compact_else_if=true
-org.eclipse.jdt.core.formatter.continuation_indentation=2
-org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
-org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
-org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
-org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
-org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_empty_lines=false
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
-org.eclipse.jdt.core.formatter.indentation.size=4
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
-org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
-org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
-org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.join_lines_in_comments=true
-org.eclipse.jdt.core.formatter.join_wrapped_lines=false
-org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
-org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
-org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.lineSplit=120
-org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
-org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
-org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
-org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
-org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
-org.eclipse.jdt.core.formatter.tabulation.char=space
-org.eclipse.jdt.core.formatter.tabulation.size=4
-org.eclipse.jdt.core.formatter.use_on_off_tags=false
-org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
-org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
-org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
-org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
diff --git a/commonmark/pom.xml b/commonmark/pom.xml
index 326208c92..4e060edaa 100644
--- a/commonmark/pom.xml
+++ b/commonmark/pom.xml
@@ -2,18 +2,18 @@
4.0.0
- com.atlassian.commonmark
+ org.commonmark
commonmark-parent
- 0.4.2-SNAPSHOT
+ 0.28.1-SNAPSHOT
commonmark
commonmark-java core
- Core of commonmark-java (implementation of CommonMark for parsing markdown and rendering to HTML)
+ Core of commonmark-java (a library for parsing Markdown to an AST, modifying the AST and rendering it to HTML or Markdown)
- com.atlassian.commonmark
+ org.commonmark
commonmark-test-util
test
@@ -38,7 +38,7 @@
org.codehaus.mojo
exec-maven-plugin
- 1.4.0
+ 3.2.0
java
test
@@ -54,4 +54,12 @@
+
+
+ BSD-2-Clause
+ https://opensource.org/licenses/BSD-2-Clause
+ repo
+
+
+
diff --git a/commonmark/src/main/java/module-info.java b/commonmark/src/main/java/module-info.java
new file mode 100644
index 000000000..009fc7d18
--- /dev/null
+++ b/commonmark/src/main/java/module-info.java
@@ -0,0 +1,13 @@
+module org.commonmark {
+ exports org.commonmark;
+ exports org.commonmark.node;
+ exports org.commonmark.parser;
+ exports org.commonmark.parser.beta;
+ exports org.commonmark.parser.block;
+ exports org.commonmark.parser.delimiter;
+ exports org.commonmark.renderer;
+ exports org.commonmark.renderer.html;
+ exports org.commonmark.renderer.markdown;
+ exports org.commonmark.renderer.text;
+ exports org.commonmark.text;
+}
diff --git a/commonmark/src/main/java/org/commonmark/html/AttributeProvider.java b/commonmark/src/main/java/org/commonmark/html/AttributeProvider.java
deleted file mode 100644
index e5f62365d..000000000
--- a/commonmark/src/main/java/org/commonmark/html/AttributeProvider.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.commonmark.html;
-
-import org.commonmark.node.Node;
-
-import java.util.Map;
-
-/**
- * Extension point for adding/changing attributes on the primary HTML tag for a node.
- */
-public interface AttributeProvider {
-
- /**
- * Set the attributes for the node by modifying the provided map.
- *
- * This allows to change or even remove default attributes. With great power comes great responsibility.
- *
- * The attribute key and values will be escaped (preserving character entities), so don't escape them here,
- * otherwise they will be double-escaped.
- *
- * @param node the node to set attributes for
- * @param attributes the attributes, with any default attributes already set in the map
- */
- void setAttributes(Node node, Map attributes);
-
-}
diff --git a/commonmark/src/main/java/org/commonmark/html/CustomHtmlRenderer.java b/commonmark/src/main/java/org/commonmark/html/CustomHtmlRenderer.java
deleted file mode 100644
index cf414a35e..000000000
--- a/commonmark/src/main/java/org/commonmark/html/CustomHtmlRenderer.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.commonmark.html;
-
-import org.commonmark.node.Node;
-import org.commonmark.node.Visitor;
-
-public interface CustomHtmlRenderer {
- // TODO: maybe pass renderer instead of visitor?
- boolean render(Node node, HtmlWriter htmlWriter, Visitor visitor);
-}
-
diff --git a/commonmark/src/main/java/org/commonmark/html/HtmlRenderer.java b/commonmark/src/main/java/org/commonmark/html/HtmlRenderer.java
deleted file mode 100644
index 25e18a2ce..000000000
--- a/commonmark/src/main/java/org/commonmark/html/HtmlRenderer.java
+++ /dev/null
@@ -1,437 +0,0 @@
-package org.commonmark.html;
-
-import org.commonmark.Extension;
-import org.commonmark.internal.util.Escaping;
-import org.commonmark.node.*;
-
-import java.util.*;
-
-/**
- * Renders a tree of nodes to HTML.
- *
- * Start with the {@link #builder} method to configure the renderer. Example:
- *
- * HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
- * renderer.render(node);
- *
- */
-public class HtmlRenderer {
-
- private static final Map NO_ATTRIBUTES = Collections.emptyMap();
-
- private final String softbreak;
- private final boolean escapeHtml;
- private final boolean percentEncodeUrls;
- private final List customHtmlRenderers;
- private final List attributeProviders;
-
- private HtmlRenderer(Builder builder) {
- this.softbreak = builder.softbreak;
- this.escapeHtml = builder.escapeHtml;
- this.percentEncodeUrls = builder.percentEncodeUrls;
- this.customHtmlRenderers = builder.customHtmlRenderers;
- this.attributeProviders = builder.attributeProviders;
- }
-
- /**
- * Create a new builder for configuring an {@link HtmlRenderer}.
- *
- * @return a builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- public void render(Node node, Appendable output) {
- RendererVisitor rendererVisitor = new RendererVisitor(new HtmlWriter(output), customHtmlRenderers);
- node.accept(rendererVisitor);
- }
-
- /**
- * Render the tree of nodes to HTML.
- * @param node the root node
- * @return the rendered HTML
- */
- public String render(Node node) {
- StringBuilder sb = new StringBuilder();
- render(node, sb);
- return sb.toString();
- }
-
- private String escape(String input, boolean preserveEntities) {
- return Escaping.escapeHtml(input, preserveEntities);
- }
-
- private String optionallyPercentEncodeUrl(String url) {
- if (percentEncodeUrls) {
- return Escaping.percentEncodeUrl(url);
- } else {
- return url;
- }
- }
-
- /**
- * Builder for configuring an {@link HtmlRenderer}. See methods for default configuration.
- */
- public static class Builder {
-
- private String softbreak = "\n";
- private boolean escapeHtml = false;
- private boolean percentEncodeUrls = false;
- private List customHtmlRenderers = new ArrayList<>();
- private List attributeProviders = new ArrayList<>();
-
- /**
- * @return the configured {@link HtmlRenderer}
- */
- public HtmlRenderer build() {
- return new HtmlRenderer(this);
- }
-
- /**
- * The HTML to use for rendering a softbreak, defaults to {@code "\n"} (meaning the rendered result doesn't have
- * a line break).
- *
- * Set it to {@code "
"} (or {@code "
"} to make them hard breaks.
- *
- * Set it to {@code " "} to ignore line wrapping in the source.
- *
- * @param softbreak HTML for softbreak
- * @return {@code this}
- */
- public Builder softbreak(String softbreak) {
- this.softbreak = softbreak;
- return this;
- }
-
- /**
- * Whether {@link HtmlInline} and {@link HtmlBlock} should be escaped, defaults to {@code false}.
- *
- * Note that {@link HtmlInline} is only a tag itself, not the text between an opening tag and a closing tag. So
- * markup in the text will be parsed as normal and is not affected by this option.
- *
- * @param escapeHtml true for escaping, false for preserving raw HTML
- * @return {@code this}
- */
- public Builder escapeHtml(boolean escapeHtml) {
- this.escapeHtml = escapeHtml;
- return this;
- }
-
- /**
- * Whether URLs of link or images should be percent-encoded, defaults to {@code false}.
- *
- * If enabled, the following is done:
- *
- * - Existing percent-encoded parts are preserved (e.g. "%20" is kept as "%20")
- * - Reserved characters such as "/" are preserved, except for "[" and "]" (see encodeURI in JS)
- * - Unreserved characters such as "a" are preserved
- * - Other characters such umlauts are percent-encoded
- *
- *
- * @param percentEncodeUrls true to percent-encode, false for leaving as-is
- * @return {@code this}
- */
- public Builder percentEncodeUrls(boolean percentEncodeUrls) {
- this.percentEncodeUrls = percentEncodeUrls;
- return this;
- }
-
- /**
- * Add an attribute provider for adding/changing HTML attributes to the rendered tags.
- *
- * @param attributeProvider the attribute provider to add
- * @return {@code this}
- */
- public Builder attributeProvider(AttributeProvider attributeProvider) {
- this.attributeProviders.add(attributeProvider);
- return this;
- }
-
- public Builder customHtmlRenderer(CustomHtmlRenderer customHtmlRenderer) {
- this.customHtmlRenderers.add(customHtmlRenderer);
- return this;
- }
-
- /**
- * @param extensions extensions to use on this HTML renderer
- * @return {@code this}
- */
- public Builder extensions(Iterable extends Extension> extensions) {
- for (Extension extension : extensions) {
- if (extension instanceof HtmlRendererExtension) {
- HtmlRendererExtension htmlRendererExtension = (HtmlRendererExtension) extension;
- htmlRendererExtension.extend(this);
- }
- }
- return this;
- }
- }
-
- /**
- * Extension for {@link HtmlRenderer}.
- */
- public interface HtmlRendererExtension extends Extension {
- void extend(Builder rendererBuilder);
- }
-
- private class RendererVisitor extends AbstractVisitor {
-
- private final HtmlWriter html;
- private final List customHtmlRenderers;
-
- public RendererVisitor(HtmlWriter html, List customHtmlRenderers) {
- this.html = html;
- this.customHtmlRenderers = customHtmlRenderers;
- }
-
- @Override
- public void visit(Document document) {
- visitChildren(document);
- }
-
- @Override
- public void visit(Heading heading) {
- String htag = "h" + heading.getLevel();
- html.line();
- html.tag(htag, getAttrs(heading));
- visitChildren(heading);
- html.tag('/' + htag);
- html.line();
- }
-
- @Override
- public void visit(Paragraph paragraph) {
- boolean inTightList = isInTightList(paragraph);
- if (!inTightList) {
- html.line();
- html.tag("p", getAttrs(paragraph));
- }
- visitChildren(paragraph);
- if (!inTightList) {
- html.tag("/p");
- html.line();
- }
- }
-
- @Override
- public void visit(BlockQuote blockQuote) {
- html.line();
- html.tag("blockquote", getAttrs(blockQuote));
- html.line();
- visitChildren(blockQuote);
- html.line();
- html.tag("/blockquote");
- html.line();
- }
-
- @Override
- public void visit(BulletList bulletList) {
- renderListBlock(bulletList, "ul", getAttrs(bulletList));
- }
-
- @Override
- public void visit(FencedCodeBlock fencedCodeBlock) {
- String literal = fencedCodeBlock.getLiteral();
- Map attributes = new LinkedHashMap<>();
- String info = fencedCodeBlock.getInfo();
- if (info != null && !info.isEmpty()) {
- int space = info.indexOf(" ");
- String language;
- if (space == -1) {
- language = info;
- } else {
- language = info.substring(0, space);
- }
- attributes.put("class", "language-" + language);
- }
- renderCodeBlock(literal, getAttrs(fencedCodeBlock, attributes));
- }
-
- @Override
- public void visit(HtmlBlock htmlBlock) {
- html.line();
- if (escapeHtml) {
- html.raw(escape(htmlBlock.getLiteral(), false));
- } else {
- html.raw(htmlBlock.getLiteral());
- }
- html.line();
- }
-
- @Override
- public void visit(ThematicBreak thematicBreak) {
- html.line();
- html.tag("hr", getAttrs(thematicBreak), true);
- html.line();
- }
-
- @Override
- public void visit(IndentedCodeBlock indentedCodeBlock) {
- renderCodeBlock(indentedCodeBlock.getLiteral(), getAttrs(indentedCodeBlock));
- }
-
- @Override
- public void visit(Link link) {
- Map attrs = new LinkedHashMap<>();
- String url = optionallyPercentEncodeUrl(link.getDestination());
- attrs.put("href", url);
- if (link.getTitle() != null) {
- attrs.put("title", link.getTitle());
- }
- html.tag("a", getAttrs(link, attrs));
- visitChildren(link);
- html.tag("/a");
- }
-
- @Override
- public void visit(ListItem listItem) {
- html.tag("li", getAttrs(listItem));
- visitChildren(listItem);
- html.tag("/li");
- html.line();
- }
-
- @Override
- public void visit(OrderedList orderedList) {
- int start = orderedList.getStartNumber();
- Map attrs = new LinkedHashMap<>();
- if (start != 1) {
- attrs.put("start", String.valueOf(start));
- }
- renderListBlock(orderedList, "ol", getAttrs(orderedList, attrs));
- }
-
- @Override
- public void visit(Image image) {
- if (html.isTagAllowed()) {
- String url = optionallyPercentEncodeUrl(image.getDestination());
- html.raw("
");
- }
- }
-
- @Override
- public void visit(Emphasis emphasis) {
- html.tag("em");
- visitChildren(emphasis);
- html.tag("/em");
- }
-
- @Override
- public void visit(StrongEmphasis strongEmphasis) {
- html.tag("strong");
- visitChildren(strongEmphasis);
- html.tag("/strong");
- }
-
- @Override
- public void visit(Text text) {
- html.raw(escape(text.getLiteral(), false));
- }
-
- @Override
- public void visit(Code code) {
- html.tag("code");
- html.raw(escape(code.getLiteral(), false));
- html.tag("/code");
- }
-
- @Override
- public void visit(HtmlInline htmlInline) {
- if (escapeHtml) {
- html.raw(escape(htmlInline.getLiteral(), false));
- } else {
- html.raw(htmlInline.getLiteral());
- }
- }
-
- @Override
- public void visit(SoftLineBreak softLineBreak) {
- html.raw(softbreak);
- }
-
- @Override
- public void visit(HardLineBreak hardLineBreak) {
- html.tag("br", NO_ATTRIBUTES, true);
- html.line();
- }
-
- @Override
- public void visit(CustomBlock customBlock) {
- renderCustom(customBlock);
- }
-
- @Override
- public void visit(CustomNode customNode) {
- renderCustom(customNode);
- }
-
- private void renderCustom(Node node) {
- for (CustomHtmlRenderer customHtmlRenderer : customHtmlRenderers) {
- // TODO: Should we pass attributes here?
- boolean handled = customHtmlRenderer.render(node, html, this);
- if (handled) {
- break;
- }
- }
- }
-
- private void renderCodeBlock(String literal, Map attributes) {
- html.line();
- html.tag("pre");
- html.tag("code", attributes);
- html.raw(escape(literal, false));
- html.tag("/code");
- html.tag("/pre");
- html.line();
- }
-
- private void renderListBlock(ListBlock listBlock, String tagName, Map attributes) {
- html.line();
- html.tag(tagName, attributes);
- html.line();
- visitChildren(listBlock);
- html.line();
- html.tag('/' + tagName);
- html.line();
- }
-
- private boolean isInTightList(Paragraph paragraph) {
- Node parent = paragraph.getParent();
- if (parent != null) {
- Node gramps = parent.getParent();
- if (gramps != null && gramps instanceof ListBlock) {
- ListBlock list = (ListBlock) gramps;
- return list.isTight();
- }
- }
- return false;
- }
-
- private Map getAttrs(Node node) {
- return getAttrs(node, Collections.emptyMap());
- }
-
- private Map getAttrs(Node node, Map defaultAttributes) {
- Map