Couldn't find wdiff. Falling back to builtin diff colouring...
spec.txt | spec.txt | |||
---|---|---|---|---|
--- | --- | |||
title: CommonMark Spec | title: CommonMark Spec | |||
author: John MacFarlane | author: John MacFarlane | |||
version: 0.27 | version: 0.28 | |||
date: '2016-11-18' | date: '2017-08-01' | |||
license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' | license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' | |||
... | ... | |||
# Introduction | # Introduction | |||
## What is Markdown? | ## What is Markdown? | |||
Markdown is a plain text format for writing structured documents, | Markdown is a plain text format for writing structured documents, | |||
based on conventions used for indicating formatting in email and | based on conventions for indicating formatting in email | |||
usenet posts. It was developed in 2004 by John Gruber, who wrote | and usenet posts. It was developed by John Gruber (with | |||
the first Markdown-to-HTML converter in Perl, and it soon became | help from Aaron Swartz) and released in 2004 in the form of a | |||
ubiquitous. In the next decade, dozens of implementations were | [syntax description](http://daringfireball.net/projects/markdown/syntax) | |||
and a Perl script (`Markdown.pl`) for converting Markdown to | ||||
HTML. In the next decade, dozens of implementations were | ||||
developed in many languages. Some extended the original | developed in many languages. Some extended the original | |||
Markdown syntax with conventions for footnotes, tables, and | Markdown syntax with conventions for footnotes, tables, and | |||
other document elements. Some allowed Markdown documents to be | other document elements. Some allowed Markdown documents to be | |||
rendered in formats other than HTML. Websites like Reddit, | rendered in formats other than HTML. Websites like Reddit, | |||
StackOverflow, and GitHub had millions of people using Markdown. | StackOverflow, and GitHub had millions of people using Markdown. | |||
And Markdown started to be used beyond the web, to author books, | And Markdown started to be used beyond the web, to author books, | |||
articles, slide shows, letters, and lecture notes. | articles, slide shows, letters, and lecture notes. | |||
What distinguishes Markdown from many other lightweight markup | What distinguishes Markdown from many other lightweight markup | |||
syntaxes, which are often easier to write, is its readability. | syntaxes, which are often easier to write, is its readability. | |||
skipping to change at line 315 ¶ | skipping to change at line 317 ¶ | |||
The following definitions of character classes will be used in this spec: | The following definitions of character classes will be used in this spec: | |||
A [whitespace character](@) is a space | A [whitespace character](@) is a space | |||
(`U+0020`), tab (`U+0009`), newline (`U+000A`), line tabulation (`U+000B`), | (`U+0020`), tab (`U+0009`), newline (`U+000A`), line tabulation (`U+000B`), | |||
form feed (`U+000C`), or carriage return (`U+000D`). | form feed (`U+000C`), or carriage return (`U+000D`). | |||
[Whitespace](@) is a sequence of one or more [whitespace | [Whitespace](@) is a sequence of one or more [whitespace | |||
characters]. | characters]. | |||
A [Unicode whitespace character](@) is | A [Unicode whitespace character](@) is | |||
any code point in the Unicode `Zs` class, or a tab (`U+0009`), | any code point in the Unicode `Zs` general category, or a tab (`U+0009`), | |||
carriage return (`U+000D`), newline (`U+000A`), or form feed | carriage return (`U+000D`), newline (`U+000A`), or form feed | |||
(`U+000C`). | (`U+000C`). | |||
[Unicode whitespace](@) is a sequence of one | [Unicode whitespace](@) is a sequence of one | |||
or more [Unicode whitespace characters]. | or more [Unicode whitespace characters]. | |||
A [space](@) is `U+0020`. | A [space](@) is `U+0020`. | |||
A [non-whitespace character](@) is any character | A [non-whitespace character](@) is any character | |||
that is not a [whitespace character]. | that is not a [whitespace character]. | |||
An [ASCII punctuation character](@) | An [ASCII punctuation character](@) | |||
is `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`, | is `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`, | |||
`*`, `+`, `,`, `-`, `.`, `/`, `:`, `;`, `<`, `=`, `>`, `?`, `@`, | `*`, `+`, `,`, `-`, `.`, `/`, `:`, `;`, `<`, `=`, `>`, `?`, `@`, | |||
`[`, `\`, `]`, `^`, `_`, `` ` ``, `{`, `|`, `}`, or `~`. | `[`, `\`, `]`, `^`, `_`, `` ` ``, `{`, `|`, `}`, or `~`. | |||
A [punctuation character](@) is an [ASCII | A [punctuation character](@) is an [ASCII | |||
punctuation character] or anything in | punctuation character] or anything in | |||
the Unicode classes `Pc`, `Pd`, `Pe`, `Pf`, `Pi`, `Po`, or `Ps`. | the general Unicode categories `Pc`, `Pd`, `Pe`, `Pf`, `Pi`, `Po`, or `Ps`. | |||
## Tabs | ## Tabs | |||
Tabs in lines are not expanded to [spaces]. However, | Tabs in lines are not expanded to [spaces]. However, | |||
in contexts where whitespace helps to define block structure, | in contexts where whitespace helps to define block structure, | |||
tabs behave as if they were replaced by spaces with a tab stop | tabs behave as if they were replaced by spaces with a tab stop | |||
of 4 characters. | of 4 characters. | |||
Thus, for example, a tab can be used instead of four spaces | Thus, for example, a tab can be used instead of four spaces | |||
in an indented code block. (Note, however, that internal | in an indented code block. (Note, however, that internal | |||
skipping to change at line 405 ¶ | skipping to change at line 407 ¶ | |||
<p>foo</p> | <p>foo</p> | |||
<pre><code> bar | <pre><code> bar | |||
</code></pre> | </code></pre> | |||
</li> | </li> | |||
</ul> | </ul> | |||
```````````````````````````````` | ```````````````````````````````` | |||
Normally the `>` that begins a block quote may be followed | Normally the `>` that begins a block quote may be followed | |||
optionally by a space, which is not considered part of the | optionally by a space, which is not considered part of the | |||
content. In the following case `>` is followed by a tab, | content. In the following case `>` is followed by a tab, | |||
which is treated as if it were expanded into spaces. | which is treated as if it were expanded into three spaces. | |||
Since one of theses spaces is considered part of the | Since one of these spaces is considered part of the | |||
delimiter, `foo` is considered to be indented six spaces | delimiter, `foo` is considered to be indented six spaces | |||
inside the block quote context, so we get an indented | inside the block quote context, so we get an indented | |||
code block starting with two spaces. | code block starting with two spaces. | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
>→→foo | >→→foo | |||
. | . | |||
<blockquote> | <blockquote> | |||
<pre><code> foo | <pre><code> foo | |||
</code></pre> | </code></pre> | |||
skipping to change at line 482 ¶ | skipping to change at line 484 ¶ | |||
For security reasons, the Unicode character `U+0000` must be replaced | For security reasons, the Unicode character `U+0000` must be replaced | |||
with the REPLACEMENT CHARACTER (`U+FFFD`). | with the REPLACEMENT CHARACTER (`U+FFFD`). | |||
# Blocks and inlines | # Blocks and inlines | |||
We can think of a document as a sequence of | We can think of a document as a sequence of | |||
[blocks](@)---structural elements like paragraphs, block | [blocks](@)---structural elements like paragraphs, block | |||
quotations, lists, headings, rules, and code blocks. Some blocks (like | quotations, lists, headings, rules, and code blocks. Some blocks (like | |||
block quotes and list items) contain other blocks; others (like | block quotes and list items) contain other blocks; others (like | |||
headings and paragraphs) contain [inline](@) content---text, | headings and paragraphs) contain [inline](@) content---text, | |||
links, emphasized text, images, code, and so on. | links, emphasized text, images, code spans, and so on. | |||
## Precedence | ## Precedence | |||
Indicators of block structure always take precedence over indicators | Indicators of block structure always take precedence over indicators | |||
of inline structure. So, for example, the following is a list with | of inline structure. So, for example, the following is a list with | |||
two items, not a list with one item containing a code span: | two items, not a list with one item containing a code span: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
- `one | - `one | |||
- two` | - two` | |||
skipping to change at line 1559 ¶ | skipping to change at line 1561 ¶ | |||
~~~ | ~~~ | |||
< | < | |||
> | > | |||
~~~ | ~~~ | |||
. | . | |||
<pre><code>< | <pre><code>< | |||
> | > | |||
</code></pre> | </code></pre> | |||
```````````````````````````````` | ```````````````````````````````` | |||
Fewer than three backticks is not enough: | ||||
```````````````````````````````` example | ||||
`` | ||||
foo | ||||
`` | ||||
. | ||||
<p><code>foo</code></p> | ||||
```````````````````````````````` | ||||
The closing code fence must use the same character as the opening | The closing code fence must use the same character as the opening | |||
fence: | fence: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
``` | ``` | |||
aaa | aaa | |||
~~~ | ~~~ | |||
``` | ``` | |||
. | . | |||
<pre><code>aaa | <pre><code>aaa | |||
skipping to change at line 1918 ¶ | skipping to change at line 1930 ¶ | |||
by [whitespace], the end of the line, the string `>`, or | by [whitespace], the end of the line, the string `>`, or | |||
the string `/>`.\ | the string `/>`.\ | |||
**End condition:** line is followed by a [blank line]. | **End condition:** line is followed by a [blank line]. | |||
7. **Start condition:** line begins with a complete [open tag] | 7. **Start condition:** line begins with a complete [open tag] | |||
or [closing tag] (with any [tag name] other than `script`, | or [closing tag] (with any [tag name] other than `script`, | |||
`style`, or `pre`) followed only by [whitespace] | `style`, or `pre`) followed only by [whitespace] | |||
or the end of the line.\ | or the end of the line.\ | |||
**End condition:** line is followed by a [blank line]. | **End condition:** line is followed by a [blank line]. | |||
HTML blocks continue until they are closed by their appropriate | ||||
[end condition], or the last line of the document or other [container block]. | ||||
This means any HTML **within an HTML block** that might otherwise be recognised | ||||
as a start condition will be ignored by the parser and passed through as-is, | ||||
without changing the parser's state. | ||||
For instance, `<pre>` within a HTML block started by `<table>` will not affect | ||||
the parser state; as the HTML block was started in by start condition 6, it | ||||
will end at any blank line. This can be surprising: | ||||
```````````````````````````````` example | ||||
<table><tr><td> | ||||
<pre> | ||||
**Hello**, | ||||
_world_. | ||||
</pre> | ||||
</td></tr></table> | ||||
. | ||||
<table><tr><td> | ||||
<pre> | ||||
**Hello**, | ||||
<p><em>world</em>. | ||||
</pre></p> | ||||
</td></tr></table> | ||||
```````````````````````````````` | ||||
In this case, the HTML block is terminated by the newline — the `**hello**` | ||||
text remains verbatim — and regular parsing resumes, with a paragraph, | ||||
emphasised `world` and inline and block HTML following. | ||||
All types of [HTML blocks] except type 7 may interrupt | All types of [HTML blocks] except type 7 may interrupt | |||
a paragraph. Blocks of type 7 may not interrupt a paragraph. | a paragraph. Blocks of type 7 may not interrupt a paragraph. | |||
(This restriction is intended to prevent unwanted interpretation | (This restriction is intended to prevent unwanted interpretation | |||
of long tags inside a wrapped paragraph as starting HTML blocks.) | of long tags inside a wrapped paragraph as starting HTML blocks.) | |||
Some simple examples follow. Here are some basic HTML blocks | Some simple examples follow. Here are some basic HTML blocks | |||
of type 6: | of type 6: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
<table> | <table> | |||
skipping to change at line 3416 ¶ | skipping to change at line 3459 ¶ | |||
blocks *Bs* starting with a [non-whitespace character] and not separated | 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 | from each other by more than one blank line, and *M* is a list | |||
marker of width *W* followed by 1 ≤ *N* ≤ 4 spaces, then the result | marker of width *W* followed by 1 ≤ *N* ≤ 4 spaces, then the result | |||
of prepending *M* and the following spaces to the first line of | 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 | *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 | 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. | (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 | If the list item is ordered, then it is also assigned a start | |||
number, based on the ordered list marker. | number, based on the ordered list marker. | |||
Exceptions: When the first list item in a [list] interrupts | Exceptions: | |||
a paragraph---that is, when it starts on a line that would | ||||
otherwise count as [paragraph continuation text]---then (a) | 1. When the first list item in a [list] interrupts | |||
the lines *Ls* must not begin with a blank line, and (b) if | a paragraph---that is, when it starts on a line that would | |||
the list item is ordered, the start number must be 1. | 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 | For example, let *Ls* be the lines | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
A paragraph | A paragraph | |||
with two lines. | with two lines. | |||
indented code | indented code | |||
> A block quote. | > A block quote. | |||
skipping to change at line 5458 ¶ | skipping to change at line 5505 ¶ | |||
. | . | |||
<p>```foo``</p> | <p>```foo``</p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
`foo | `foo | |||
. | . | |||
<p>`foo</p> | <p>`foo</p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
The following case also illustrates the need for opening and | ||||
closing backtick strings to be equal in length: | ||||
```````````````````````````````` example | ||||
`foo``bar`` | ||||
. | ||||
<p>`foo<code>bar</code></p> | ||||
```````````````````````````````` | ||||
## Emphasis and strong emphasis | ## Emphasis and strong emphasis | |||
John Gruber's original [Markdown syntax | John Gruber's original [Markdown syntax | |||
description](http://daringfireball.net/projects/markdown/syntax#em) says: | description](http://daringfireball.net/projects/markdown/syntax#em) says: | |||
> Markdown treats asterisks (`*`) and underscores (`_`) as indicators of | > Markdown treats asterisks (`*`) and underscores (`_`) as indicators of | |||
> emphasis. Text wrapped with one `*` or `_` will be wrapped with an HTML | > emphasis. Text wrapped with one `*` or `_` will be wrapped with an HTML | |||
> `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML `<strong>` | > `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML `<strong>` | |||
> tag. | > tag. | |||
skipping to change at line 5506 ¶ | skipping to change at line 5562 ¶ | |||
``` markdown | ``` markdown | |||
internal emphasis: foo*bar*baz | internal emphasis: foo*bar*baz | |||
no emphasis: foo_bar_baz | no emphasis: foo_bar_baz | |||
``` | ``` | |||
The rules given below capture all of these patterns, while allowing | The rules given below capture all of these patterns, while allowing | |||
for efficient parsing strategies that do not backtrack. | for efficient parsing strategies that do not backtrack. | |||
First, some definitions. A [delimiter run](@) is either | First, some definitions. A [delimiter run](@) is either | |||
a sequence of one or more `*` characters that is not preceded or | a sequence of one or more `*` characters that is not preceded or | |||
followed by a `*` character, or a sequence of one or more `_` | followed by a non-backslash-escaped `*` character, or a sequence | |||
characters that is not preceded or followed by a `_` character. | of one or more `_` characters that is not preceded or followed by | |||
a non-backslash-escaped `_` character. | ||||
A [left-flanking delimiter run](@) is | A [left-flanking delimiter run](@) is | |||
a [delimiter run] that is (a) not followed by [Unicode whitespace], | a [delimiter run] that is (a) not followed by [Unicode whitespace], | |||
and (b) either not followed by a [punctuation character], or | and (b) not followed by a [punctuation character], or | |||
preceded by [Unicode whitespace] or a [punctuation character]. | preceded by [Unicode whitespace] or a [punctuation character]. | |||
For purposes of this definition, the beginning and the end of | For purposes of this definition, the beginning and the end of | |||
the line count as Unicode whitespace. | the line count as Unicode whitespace. | |||
A [right-flanking delimiter run](@) is | A [right-flanking delimiter run](@) is | |||
a [delimiter run] that is (a) not preceded by [Unicode whitespace], | a [delimiter run] that is (a) not preceded by [Unicode whitespace], | |||
and (b) either not preceded by a [punctuation character], or | and (b) not preceded by a [punctuation character], or | |||
followed by [Unicode whitespace] or a [punctuation character]. | followed by [Unicode whitespace] or a [punctuation character]. | |||
For purposes of this definition, the beginning and the end of | For purposes of this definition, the beginning and the end of | |||
the line count as Unicode whitespace. | the line count as Unicode whitespace. | |||
Here are some examples of delimiter runs. | Here are some examples of delimiter runs. | |||
- left-flanking but not right-flanking: | - left-flanking but not right-flanking: | |||
``` | ``` | |||
***abc | ***abc | |||
skipping to change at line 5597 ¶ | skipping to change at line 5654 ¶ | |||
6. A double `__` [can open strong emphasis] iff | 6. A double `__` [can open strong emphasis] iff | |||
it is part of a [left-flanking delimiter run] | it is part of a [left-flanking delimiter run] | |||
and either (a) not part of a [right-flanking delimiter run] | and either (a) not part of a [right-flanking delimiter run] | |||
or (b) part of a [right-flanking delimiter run] | or (b) part of a [right-flanking delimiter run] | |||
preceded by punctuation. | preceded by punctuation. | |||
7. A double `**` [can close strong emphasis](@) | 7. A double `**` [can close strong emphasis](@) | |||
iff it is part of a [right-flanking delimiter run]. | iff it is part of a [right-flanking delimiter run]. | |||
8. A double `__` [can close strong emphasis] | 8. A double `__` [can close strong emphasis] iff | |||
it is part of a [right-flanking delimiter run] | it is part of a [right-flanking delimiter run] | |||
and either (a) not part of a [left-flanking delimiter run] | and either (a) not part of a [left-flanking delimiter run] | |||
or (b) part of a [left-flanking delimiter run] | or (b) part of a [left-flanking delimiter run] | |||
followed by punctuation. | followed by punctuation. | |||
9. Emphasis begins with a delimiter that [can open emphasis] and ends | 9. Emphasis begins with a delimiter that [can open emphasis] and ends | |||
with a delimiter that [can close emphasis], and that uses the same | with a delimiter that [can close emphasis], and that uses the same | |||
character (`_` or `*`) as the opening delimiter. The | character (`_` or `*`) as the opening delimiter. The | |||
opening and closing delimiters must belong to separate | opening and closing delimiters must belong to separate | |||
[delimiter runs]. If one of the delimiters can both | [delimiter runs]. If one of the delimiters can both | |||
skipping to change at line 5637 ¶ | skipping to change at line 5694 ¶ | |||
`_`-delimited emphasis or `__`-delimited strong emphasis, unless it | `_`-delimited emphasis or `__`-delimited strong emphasis, unless it | |||
is backslash-escaped. | is backslash-escaped. | |||
Where rules 1--12 above are compatible with multiple parsings, | Where rules 1--12 above are compatible with multiple parsings, | |||
the following principles resolve ambiguity: | the following principles resolve ambiguity: | |||
13. The number of nestings should be minimized. Thus, for example, | 13. The number of nestings should be minimized. Thus, for example, | |||
an interpretation `<strong>...</strong>` is always preferred to | an interpretation `<strong>...</strong>` is always preferred to | |||
`<em><em>...</em></em>`. | `<em><em>...</em></em>`. | |||
14. An interpretation `<strong><em>...</em></strong>` is always | 14. An interpretation `<em><strong>...</strong></em>` is always | |||
preferred to `<em><strong>..</strong></em>`. | preferred to `<strong><em>...</em></strong>`. | |||
15. When two potential emphasis or strong emphasis spans overlap, | 15. When two potential emphasis or strong emphasis spans overlap, | |||
so that the second begins before the first ends and ends after | so that the second begins before the first ends and ends after | |||
the first ends, the first takes precedence. Thus, for example, | the first ends, the first takes precedence. Thus, for example, | |||
`*foo _bar* baz_` is parsed as `<em>foo _bar</em> baz_` rather | `*foo _bar* baz_` is parsed as `<em>foo _bar</em> baz_` rather | |||
than `*foo <em>bar* baz</em>`. | than `*foo <em>bar* baz</em>`. | |||
16. When there are two potential emphasis or strong emphasis spans | 16. When there are two potential emphasis or strong emphasis spans | |||
with the same closing delimiter, the shorter one (the one that | with the same closing delimiter, the shorter one (the one that | |||
opens later) takes precedence. Thus, for example, | opens later) takes precedence. Thus, for example, | |||
skipping to change at line 6542 ¶ | skipping to change at line 6599 ¶ | |||
******foo****** | ******foo****** | |||
. | . | |||
<p><strong><strong><strong>foo</strong></strong></strong></p> | <p><strong><strong><strong>foo</strong></strong></strong></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
Rule 14: | Rule 14: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
***foo*** | ***foo*** | |||
. | . | |||
<p><strong><em>foo</em></strong></p> | <p><em><strong>foo</strong></em></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
_____foo_____ | _____foo_____ | |||
. | . | |||
<p><strong><strong><em>foo</em></strong></strong></p> | <p><em><strong><strong>foo</strong></strong></em></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
Rule 15: | Rule 15: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
*foo _bar* baz_ | *foo _bar* baz_ | |||
. | . | |||
<p><em>foo _bar</em> baz_</p> | <p><em>foo _bar</em> baz_</p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
skipping to change at line 6674 ¶ | skipping to change at line 6731 ¶ | |||
A [link destination](@) consists of either | A [link destination](@) consists of either | |||
- a sequence of zero or more characters between an opening `<` and a | - a sequence of zero or more characters between an opening `<` and a | |||
closing `>` that contains no spaces, line breaks, or unescaped | closing `>` that contains no spaces, line breaks, or unescaped | |||
`<` or `>` characters, or | `<` or `>` characters, or | |||
- a nonempty sequence of characters that does not include | - a nonempty sequence of characters that does not include | |||
ASCII space or control characters, and includes parentheses | ASCII space or control characters, and includes parentheses | |||
only if (a) they are backslash-escaped or (b) they are part of | only if (a) they are backslash-escaped or (b) they are part of | |||
a balanced pair of unescaped parentheses that is not itself | a balanced pair of unescaped parentheses. (Implementations | |||
inside a balanced pair of unescaped parentheses. | may impose limits on parentheses nesting to avoid performance | |||
issues, but at least three levels of nesting should be supported.) | ||||
A [link title](@) consists of either | A [link title](@) consists of either | |||
- a sequence of zero or more characters between straight double-quote | - a sequence of zero or more characters between straight double-quote | |||
characters (`"`), including a `"` character only if it is | characters (`"`), including a `"` character only if it is | |||
backslash-escaped, or | backslash-escaped, or | |||
- a sequence of zero or more characters between straight single-quote | - a sequence of zero or more characters between straight single-quote | |||
characters (`'`), including a `'` character only if it is | characters (`'`), including a `'` character only if it is | |||
backslash-escaped, or | backslash-escaped, or | |||
skipping to change at line 6774 ¶ | skipping to change at line 6832 ¶ | |||
```````````````````````````````` | ```````````````````````````````` | |||
Parentheses inside the link destination may be escaped: | Parentheses inside the link destination may be escaped: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
[link](\(foo\)) | [link](\(foo\)) | |||
. | . | |||
<p><a href="(foo)">link</a></p> | <p><a href="(foo)">link</a></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
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)) | ||||
. | ||||
<p><a href="(foo)and(bar)">link</a></p> | ||||
```````````````````````````````` | ||||
However, if you have parentheses within parentheses, you need to escape | ||||
or use the `<...>` form: | ||||
```````````````````````````````` example | ```````````````````````````````` example | |||
[link](foo(and(bar))) | [link](foo(and(bar))) | |||
. | . | |||
<p>[link](foo(and(bar)))</p> | <p><a href="foo(and(bar))">link</a></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
However, if you have unbalanced parentheses, you need to escape or use the | ||||
`<...>` form: | ||||
```````````````````````````````` example | ```````````````````````````````` example | |||
[link](foo(and\(bar\))) | [link](foo\(and\(bar\)) | |||
. | . | |||
<p><a href="foo(and(bar))">link</a></p> | <p><a href="foo(and(bar)">link</a></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
[link](<foo(and(bar))>) | [link](<foo(and(bar)>) | |||
. | . | |||
<p><a href="foo(and(bar))">link</a></p> | <p><a href="foo(and(bar)">link</a></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
Parentheses and other symbols can also be escaped, as usual | Parentheses and other symbols can also be escaped, as usual | |||
in Markdown: | in Markdown: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
[link](foo\)\:) | [link](foo\)\:) | |||
. | . | |||
<p><a href="foo):">link</a></p> | <p><a href="foo):">link</a></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
skipping to change at line 7056 ¶ | skipping to change at line 7109 ¶ | |||
[full](#full-reference-link), [collapsed](#collapsed-reference-link), | [full](#full-reference-link), [collapsed](#collapsed-reference-link), | |||
and [shortcut](#shortcut-reference-link). | and [shortcut](#shortcut-reference-link). | |||
A [full reference link](@) | A [full reference link](@) | |||
consists of a [link text] immediately followed by a [link label] | consists of a [link text] immediately followed by a [link label] | |||
that [matches] a [link reference definition] elsewhere in the document. | that [matches] a [link reference definition] elsewhere in the document. | |||
A [link label](@) begins with a left bracket (`[`) and ends | A [link label](@) begins with a left bracket (`[`) and ends | |||
with the first right bracket (`]`) that is not backslash-escaped. | with the first right bracket (`]`) that is not backslash-escaped. | |||
Between these brackets there must be at least one [non-whitespace character]. | Between these brackets there must be at least one [non-whitespace character]. | |||
Unescaped square bracket characters are not allowed in | Unescaped square bracket characters are not allowed inside the | |||
[link labels]. A link label can have at most 999 | opening and closing square brackets of [link labels]. A link | |||
characters inside the square brackets. | label can have at most 999 characters inside the square | |||
brackets. | ||||
One label [matches](@) | One label [matches](@) | |||
another just in case their normalized forms are equal. To normalize a | another just in case their normalized forms are equal. To normalize a | |||
label, perform the *Unicode case fold* and collapse consecutive internal | label, strip off the opening and closing brackets, | |||
perform the *Unicode case fold*, strip leading and trailing | ||||
[whitespace] and collapse consecutive internal | ||||
[whitespace] to a single space. If there are multiple | [whitespace] to a single space. If there are multiple | |||
matching reference link definitions, the one that comes first in the | matching reference link definitions, the one that comes first in the | |||
document is used. (It is desirable in such cases to emit a warning.) | 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 | 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 | used as the link's text. The link's URI and title are provided by the | |||
matching [link reference definition]. | matching [link reference definition]. | |||
Here is a simple example: | Here is a simple example: | |||
skipping to change at line 7752 ¶ | skipping to change at line 7808 ¶ | |||
The link labels are case-insensitive: | The link labels are case-insensitive: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
![Foo] | ![Foo] | |||
[foo]: /url "title" | [foo]: /url "title" | |||
. | . | |||
<p><img src="/url" alt="Foo" title="title" /></p> | <p><img src="/url" alt="Foo" title="title" /></p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
If you just want bracketed text, you can backslash-escape the | If you just want a literal `!` followed by bracketed text, you can | |||
opening `!` and `[`: | backslash-escape the opening `[`: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
\!\[foo] | !\[foo] | |||
[foo]: /url "title" | [foo]: /url "title" | |||
. | . | |||
<p>![foo]</p> | <p>![foo]</p> | |||
```````````````````````````````` | ```````````````````````````````` | |||
If you want a link after a literal `!`, backslash-escape the | If you want a link after a literal `!`, backslash-escape the | |||
`!`: | `!`: | |||
```````````````````````````````` example | ```````````````````````````````` example | |||
End of changes. 29 change blocks. | ||||
49 lines changed or deleted | 105 lines changed or added | |||
This html diff was produced by rfcdiff 1.45. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |