diff options
Diffstat (limited to 'spec.txt')
-rw-r--r-- | spec.txt | 150 |
1 files changed, 75 insertions, 75 deletions
@@ -191,7 +191,7 @@ In the examples, the `→` character is used to represent tabs. # Preprocessing -A [line](#line) <a id="line"/> +A [line](#line) <a id="line"></a> is a sequence of zero or more characters followed by a line ending (CR, LF, or CRLF) or by the end of file. @@ -217,15 +217,15 @@ foo→baz→→bim Line endings are replaced by newline characters (LF). A line containing only spaces (after tab expansion) followed by -a line ending is called a [blank line](#blank-line). <a -id="blank-line"/> +a line ending is called a [blank line](#blank-line). +<a id="blank-line"></a> # Blocks and inlines We can think of a document as a sequence of [blocks](#block)<a -id="block"/>---structural elements like paragraphs, block quotations, +id="block"></a>---structural elements like paragraphs, block quotations, lists, headers, rules, and code blocks. Blocks can contain other -blocks, or they can contain [inline](#inline)<a id="inline"/> content: +blocks, or they can contain [inline](#inline)<a id="inline"></a> content: words, spaces, links, emphasized text, images, and inline code. ## Precedence @@ -256,9 +256,9 @@ one block element does not affect the inline parsing of any other. ## Container blocks and leaf blocks We can divide blocks into two types: -[container blocks](#container-block), <a id="container-block"/> +[container blocks](#container-block), <a id="container-block"></a> which can contain other blocks, and [leaf blocks](#leaf-block), -<a id="leaf-block"/> which cannot. +<a id="leaf-block"></a> which cannot. # Leaf blocks @@ -269,8 +269,8 @@ Markdown document. A line consisting of 0-3 spaces of indentation, followed by a sequence of three or more matching `-`, `_`, or `*` characters, each followed -optionally any number of spaces, forms a [horizontal -rule](#horizontal-rule). <a id="horizontal-rule"/> +optionally by any number of spaces, forms a [horizontal +rule](#horizontal-rule). <a id="horizontal-rule"></a> . *** @@ -465,7 +465,7 @@ If you want a horizontal rule in a list item, use a different bullet: ## ATX headers -An [ATX header](#atx-header) <a id="atx-header"/> +An [ATX header](#atx-header) <a id="atx-header"></a> consists of a string of characters, parsed as inline content, between an opening sequence of 1--6 unescaped `#` characters and an optional closing sequence of any number of `#` characters. The opening sequence @@ -655,11 +655,11 @@ ATX headers can be empty: ## Setext headers -A [setext header](#setext-header) <a id="setext-header"/> +A [setext header](#setext-header) <a id="setext-header"></a> consists of a line of text, containing at least one nonspace character, with no more than 3 spaces indentation, followed by a [setext header underline](#setext-header-underline). A [setext header -underline](#setext-header-underline) <a id="setext-header-underline"/> +underline](#setext-header-underline) <a id="setext-header-underline"></a> is a sequence of `=` characters or a sequence of `-` characters, with no more than 3 spaces indentation and any number of trailing spaces. The header is a level 1 header if `=` characters are used, and @@ -863,9 +863,9 @@ Setext headers cannot be empty: ## Indented code blocks An [indented code block](#indented-code-block) -<a id="indented-code-block"/> is composed of one or more +<a id="indented-code-block"></a> is composed of one or more [indented chunks](#indented-chunk) separated by blank lines. -An [indented chunk](#indented-chunk) <a id="indented-chunk"/> +An [indented chunk](#indented-chunk) <a id="indented-chunk"></a> is a sequence of non-blank lines, each indented four or more spaces. An indented code block cannot interrupt a paragraph, so if it occurs before or after a paragraph, there must be an @@ -1015,16 +1015,16 @@ Trailing spaces are included in the code block's content: ## Fenced code blocks -A [code fence](#code-fence) <a id="code-fence"/> is a sequence +A [code fence](#code-fence) <a id="code-fence"></a> is a sequence of at least three consecutive backtick characters (`` ` ``) or tildes (`~`). (Tildes and backticks cannot be mixed.) -A [fenced code block](#fenced-code-block) <a id="fenced-code-block"/> +A [fenced code block](#fenced-code-block) <a id="fenced-code-block"></a> begins with a code fence, indented no more than three spaces. The line with the opening code fence may optionally contain some text following the code fence; this is trimmed of leading and trailing -spaces and called the [info string](#info-string). <a -id="info-string"/> The info string may not contain any backtick +spaces and called the [info string](#info-string). +<a id="info-string"></a> The info string may not contain any backtick characters. (The reason for this restriction is that otherwise some inline code would be incorrectly interpreted as the beginning of a fenced code block.) @@ -1343,7 +1343,7 @@ Closing code fences cannot have info strings: ## HTML blocks -An [HTML block tag](#html-block-tag) <a id="html-block-tag"/> is +An [HTML block tag](#html-block-tag) <a id="html-block-tag"></a> is an [open tag](#open-tag) or [closing tag](#closing-tag) whose tag name is one of the following (case-insensitive): `article`, `header`, `aside`, `hgroup`, `blockquote`, `hr`, `body`, @@ -1354,7 +1354,7 @@ name is one of the following (case-insensitive): `footer`, `tr`, `form`, `ul`, `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `video`, `script`, `style`. -An [HTML block](#html-block) <a id="html-block"/> begins with an +An [HTML block](#html-block) <a id="html-block"></a> begins with an [HTML block tag](#html-block-tag), [HTML comment](#html-comment), [processing instruction](#processing-instruction), [declaration](#declaration), or [CDATA section](#cdata-section). @@ -1629,7 +1629,7 @@ So there is no important loss of expressive power with the new rule. ## Link reference definitions A [link reference definition](#link-reference-definition) -<a id="link-reference-definition"/> consists of a [link +<a id="link-reference-definition"></a> consists of a [link label](#link-label), indented up to three spaces, followed by a colon (`:`), optional blank space (including up to one newline), a [link destination](#link-destination), optional @@ -1854,7 +1854,7 @@ are defined: ## Paragraphs A sequence of non-blank lines that cannot be interpreted as other -kinds of blocks forms a [paragraph](#paragraph) <a id="paragraph"/>. +kinds of blocks forms a [paragraph](#paragraph) <a id="paragraph"></a>. 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 @@ -1998,12 +1998,12 @@ provided below in the section entitled [A parsing strategy].) ## Block quotes -A [block quote marker](#block-quote-marker) <a id="block-quote-marker"/> +A [block quote marker](#block-quote-marker) <a id="block-quote-marker"></a> 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. The following rules define [block quotes](#block-quote): -<a id="block-quote"/> +<a id="block-quote"></a> 1. **Basic case.** If a string of lines *Ls* constitute a sequence of blocks *Bs*, then the result of appending a [block quote marker] @@ -2016,7 +2016,7 @@ The following rules define [block quotes](#block-quote): more lines in which the next non-space character after the [block quote marker](#block-quote-marker) is [paragraph continuation text](#paragraph-continuation-text) is a block quote with *Bs* as - its content. <a id="paragraph-continuation-text"/> + its content. <a id="paragraph-continuation-text"></a> [Paragraph continuation text](#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. @@ -2360,14 +2360,14 @@ the `>`: ## List items -A [list marker](#list-marker) <a id="list-marker"/> is a +A [list marker](#list-marker) <a id="list-marker"></a> is a [bullet list marker](#bullet-list-marker) or an [ordered list marker](#ordered-list-marker). -A [bullet list marker](#bullet-list-marker) <a id="bullet-list-marker"/> +A [bullet list marker](#bullet-list-marker) <a id="bullet-list-marker"></a> is a `-`, `+`, or `*` character. -An [ordered list marker](#ordered-list-marker) <a id="ordered-list-marker"/> +An [ordered list marker](#ordered-list-marker) <a id="ordered-list-marker"></a> is a sequence of one of more digits (`0-9`), followed by either a `.` character or a `)` character. @@ -2889,7 +2889,7 @@ continued here.</p> 5. **That's all.** Nothing that is not counted as a list item by rules - #1--4 counts as a [list item](#block-quote). + #1--4 counts as a [list item](#list-item). 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 @@ -3183,25 +3183,25 @@ takes four spaces (a common case), but diverge in other cases. ## Lists -A [list](#list) <a id="list"/> is a sequence of one or more +A [list](#list) <a id="list"></a> is a sequence of one or more list items [of the same type](#of-the-same-type). The list items may be separated by single [blank lines](#blank-line), but two blank lines end all containing lists. Two list items are [of the same type](#of-the-same-type) -<a id="of-the-same-type"/> if they begin with a [list +<a id="of-the-same-type"></a> if they begin with a [list marker](#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](#ordered-list) <a id="ordered-list"/> +A list is an [ordered list](#ordered-list) <a id="ordered-list"></a> if its constituent list items begin with [ordered list markers](#ordered-list-marker), and a [bullet -list](#bullet-list) <a id="bullet-list"/> if its constituent list +list](#bullet-list) <a id="bullet-list"></a> if its constituent list items begin with [bullet list markers](#bullet-list-marker). -The [start number](#start-number) <a id="start-number"/> +The [start number](#start-number) <a id="start-number"></a> of an [ordered list](#ordered-list) is determined by the list number of its initial list item. The numbers of subsequent list items are disregarded. @@ -3726,7 +3726,7 @@ foo Entities are parsed as entities, not as literal text, in all contexts except code spans and code blocks. Three kinds of entities are recognized. -[Named entities](#name-entities) <a id="named-entities"/> consist of `&` +[Named entities](#name-entities) <a id="named-entities"></a> consist of `&` + a string of 2-32 alphanumerics beginning with a letter + `;`. . @@ -3735,7 +3735,7 @@ except code spans and code blocks. Three kinds of entities are recognized. <p> & © Æ Ď ¾ ℋ ⅆ ∲</p> . -[Decimal entities](#decimal-entities) <a id="decimal-entities"/> +[Decimal entities](#decimal-entities) <a id="decimal-entities"></a> consist of `&#` + a string of 1--8 arabic digits + `;`. . @@ -3744,7 +3744,7 @@ consist of `&#` + a string of 1--8 arabic digits + `;`. <p> # Ӓ Ϡ �</p> . -[Hexadecimal entities](#hexadecimal-entities) <a id="hexadecimal-entities"/> +[Hexadecimal entities](#hexadecimal-entities) <a id="hexadecimal-entities"></a> consist of `&#` + either `X` or `x` + a string of 1-8 hexadecimal digits + `;`. @@ -3830,7 +3830,7 @@ Entities are treated as literal text in code spans and code blocks: ## Code span -A [backtick string](#backtick-string) <a id="backtick-string"/> +A [backtick string](#backtick-string) <a id="backtick-string"></a> is a string of one or more backtick characters (`` ` ``) that is neither preceded nor followed by a backtick. @@ -4015,7 +4015,7 @@ The following rules capture all of these patterns, while allowing for efficient parsing strategies that do not backtrack: 1. A single `*` character [can open emphasis](#can-open-emphasis) - <a id="can-open-emphasis"/> iff + <a id="can-open-emphasis"></a> iff (a) it is not part of a sequence of four or more unescaped `*`s, (b) it is not followed by whitespace, and @@ -4031,7 +4031,7 @@ for efficient parsing strategies that do not backtrack: followed immediately by strong emphasis. 3. A single `*` character [can close emphasis](#can-close-emphasis) - <a id="can-close-emphasis"/> iff + <a id="can-close-emphasis"></a> iff (a) it is not part of a sequence of four or more unescaped `*`s, and (b) it is not preceded by whitespace. @@ -4043,7 +4043,7 @@ for efficient parsing strategies that do not backtrack: (c) it is not followed by an ASCII alphanumeric character. 5. A double `**` [can open strong emphasis](#can-open-strong-emphasis) - <a id="can-open-strong-emphasis" /> iff + <a id="can-open-strong-emphasis" ></a> iff (a) it is not part of a sequence of four or more unescaped `*`s, (b) it is not followed by whitespace, and @@ -4060,7 +4060,7 @@ for efficient parsing strategies that do not backtrack: followed immediately by emphasis. 7. A double `**` [can close strong emphasis](#can-close-strong-emphasis) - <a id="can-close-strong-emphasis" /> iff + <a id="can-close-strong-emphasis" ></a> iff (a) it is not part of a sequence of four or more unescaped `*`s, and (b) it is not preceded by whitespace. @@ -4642,7 +4642,7 @@ and title are given immediately after the label. In [reference links](#reference-links) the destination and title are defined elsewhere in the document. -A [link label](#link-label) <a id="link-label"/> consists of +A [link label](#link-label) <a id="link-label"></a> consists of - an opening `[`, followed by - zero or more backtick code spans, autolinks, HTML tags, link labels, @@ -4657,7 +4657,7 @@ These rules are motivated by the following intuitive ideas: but less tightly than `<>` or `` ` ``. - Link labels may contain material in matching square brackets. -A [link destination](#link-destination) <a id="link-destination"/> +A [link destination](#link-destination) <a id="link-destination"></a> consists of either - a sequence of zero or more characters between an opening `<` and a @@ -4670,7 +4670,7 @@ consists of either a balanced pair of unescaped parentheses that is not itself inside a balanced pair of unescaped paretheses. -A [link title](#link-title) <a id="link-title"/> consists of either +A [link title](#link-title) <a id="link-title"></a> consists of either - a sequence of zero or more characters between straight double-quote characters (`"`), including a `"` character only if it is @@ -4683,7 +4683,7 @@ A [link title](#link-title) <a id="link-title"/> consists of either - a sequence of zero or more characters between matching parentheses (`(...)`), including a `)` character only if it is backslash-escaped. -An [inline link](#inline-link) <a id="inline-link"/> +An [inline link](#inline-link) <a id="inline-link"></a> consists of a [link label](#link-label) followed immediately by a left parenthesis `(`, optional whitespace, an optional [link destination](#link-destination), @@ -4887,15 +4887,15 @@ an HTML tag: There are three kinds of [reference links](#reference-link): -<a id="reference-link"/> +<a id="reference-link"></a> -A [full reference link](#full-reference-link) <a id="full-reference-link"/> +A [full reference link](#full-reference-link) <a id="full-reference-link"></a> consists of a [link label](#link-label), optional whitespace, and another [link label](#link-label) that [matches](#matches) a [link reference definition](#link-reference-definition) elsewhere in the document. -One label [matches](#matches) <a id="matches"/> +One label [matches](#matches) <a id="matches"></a> 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 matching reference @@ -5003,7 +5003,7 @@ labels define equivalent inline content: . A [collapsed reference link](#collapsed-reference-link) -<a id="collapsed-reference-link"/> consists of a [link +<a id="collapsed-reference-link"></a> consists of a [link label](#link-label) that [matches](#matches) a [link reference definition](#link-reference-definition) elsewhere in the document, optional whitespace, and the string `[]`. The contents of the @@ -5051,7 +5051,7 @@ between the two sets of brackets: . A [shortcut reference link](#shortcut-reference-link) -<a id="shortcut-reference-link"/> consists of a [link +<a id="shortcut-reference-link"></a> consists of a [link label](#link-label) that [matches](#matches) a [link reference definition](#link-reference-definition) elsewhere in the document and is not followed by `[]` or a link label. @@ -5116,7 +5116,7 @@ than emphasis: <p>*<a href="/url">foo*</a></p> . -However, this is not, because link labels bind tight less +However, this is not, because link labels bind less tightly than code backticks: . @@ -5386,18 +5386,18 @@ Autolinks are absolute URIs and email addresses inside `<` and `>`. They are parsed as links, with the URL or email address as the link label. -A [URI autolink](#uri-autolink) <a id="uri-autolink"/> +A [URI autolink](#uri-autolink) <a id="uri-autolink"></a> consists of `<`, followed by an [absolute URI](#absolute-uri) not containing `<`, followed by `>`. It is parsed as a link to the URI, with the URI as the link's label. -An [absolute URI](#absolute-uri), <a id="absolute-uri"/> +An [absolute URI](#absolute-uri), <a id="absolute-uri"></a> for these purposes, consists of a [scheme](#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, you must use percent-encoding (e.g. `%20` for a space). -The following [schemes](#scheme) <a id="scheme"/> +The following [schemes](#scheme) <a id="scheme"></a> are recognized (case-insensitive): `coap`, `doi`, `javascript`, `aaa`, `aaas`, `about`, `acap`, `cap`, `cid`, `crid`, `data`, `dav`, `dict`, `dns`, `file`, `ftp`, `geo`, `go`, @@ -5459,12 +5459,12 @@ Spaces are not allowed in autolinks: <p><http://foo.bar/baz bim></p> . -An [email autolink](#email-autolink) <a id="email-autolink"/> +An [email autolink](#email-autolink) <a id="email-autolink"></a> consists of `<`, followed by an [email address](#email-address), followed by `>`. The link's label is the email address, and the URL is `mailto:` followed by the email address. -An [email address](#email-address), <a id="email-address"/> +An [email address](#email-address), <a id="email-address"></a> for these purposes, is anything that matches the [non-normative regex from the HTML5 spec](http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#e-mail-state-%28type=email%29): @@ -5539,67 +5539,67 @@ so custom tags (and even, say, DocBook tags) may be used. Here is the grammar for tags: -A [tag name](#tag-name) <a id="tag-name"/> consists of an ASCII letter +A [tag name](#tag-name) <a id="tag-name"></a> consists of an ASCII letter followed by zero or more ASCII letters or digits. -An [attribute](#attribute) <a id="attribute"/> consists of whitespace, +An [attribute](#attribute) <a id="attribute"></a> consists of whitespace, an **attribute name**, and an optional **attribute value specification**. -An [attribute name](#attribute-name) <a id="attribute-name"/> +An [attribute name](#attribute-name) <a id="attribute-name"></a> consists of an ASCII letter, `_`, or `:`, followed by zero or more ASCII letters, digits, `_`, `.`, `:`, or `-`. (Note: This is the XML specification restricted to ASCII. HTML5 is laxer.) An [attribute value specification](#attribute-value-specification) -<a id="attribute-value-specification"/> consists of optional whitespace, +<a id="attribute-value-specification"></a> consists of optional whitespace, a `=` character, optional whitespace, and an [attribute value](#attribute-value). -An [attribute value](#attribute-value) <a id="attribute-value"/> +An [attribute value](#attribute-value) <a id="attribute-value"></a> consists of an [unquoted attribute value](#unquoted-attribute-value), a [single-quoted attribute value](#single-quoted-attribute-value), or a [double-quoted attribute value](#double-quoted-attribute-value). An [unquoted attribute value](#unquoted-attribute-value) -<a id="unquoted-attribute-value"/> is a nonempty string of characters not +<a id="unquoted-attribute-value"></a> is a nonempty string of characters not including spaces, `"`, `'`, `=`, `<`, `>`, or `` ` ``. A [single-quoted attribute value](#single-quoted-attribute-value) -<a id="single-quoted-attribute-value"/> consists of `'`, zero or more +<a id="single-quoted-attribute-value"></a> consists of `'`, zero or more characters not including `'`, and a final `'`. A [double-quoted attribute value](#double-quoted-attribute-value) -<a id="double-quoted-attribute-value"/> consists of `"`, zero or more +<a id="double-quoted-attribute-value"></a> consists of `"`, zero or more characters not including `"`, and a final `"`. -An [open tag](#open-tag) <a id="open-tag"/> consists of a `<` character, +An [open tag](#open-tag) <a id="open-tag"></a> consists of a `<` character, a [tag name](#tag-name), zero or more [attributes](#attribute), optional whitespace, an optional `/` character, and a `>` character. -A [closing tag](#closing-tag) <a id="closing-tag"/> consists of the +A [closing tag](#closing-tag) <a id="closing-tag"></a> consists of the string `</`, a [tag name](#tag-name), optional whitespace, and the character `>`. -An [HTML comment](#html-comment) <a id="html-comment"/> consists of the +An [HTML comment](#html-comment) <a id="html-comment"></a> consists of the string `<!--`, a string of characters not including the string `--`, and the string `-->`. A [processing instruction](#processing-instruction) -<a id="processing-instruction"/> consists of the string `<?`, a string +<a id="processing-instruction"></a> consists of the string `<?`, a string of characters not including the string `?>`, and the string `?>`. -A [declaration](#declaration) <a id="declaration"/> consists of the +A [declaration](#declaration) <a id="declaration"></a> consists of the string `<!`, a name consisting of one or more uppercase ASCII letters, whitespace, a string of characters not including the character `>`, and the character `>`. -A [CDATA section](#cdata-section) <a id="cdata-section"/> consists of +A [CDATA section](#cdata-section) <a id="cdata-section"></a> consists of the string `<![CDATA[`, a string of characters not including the string `]]>`, and the string `]]>`. -An [HTML tag](#html-tag) <a id="html-tag"/> consists of an [open +An [HTML tag](#html-tag) <a id="html-tag"></a> consists of an [open tag](#open-tag), a [closing tag](#closing-tag), an [HTML comment](#html-comment), a [processing instruction](#processing-instruction), an [element type @@ -5952,7 +5952,7 @@ references constructed in phase 1. At each point in processing, the document is represented as a tree of **blocks**. The root of the tree is a `document` block. The `document` may have any number of other blocks as **children**. These children -may, in turn, have other blocks a children. The last child of a block +may, in turn, have other blocks as children. The last child of a block is normally considered **open**, meaning that subsequent lines of input can alter its contents. (Blocks that are not open are **closed**.) Here, for example, is a possible document tree, with the open blocks @@ -6045,8 +6045,8 @@ The third line, causes the `paragraph` block to be closed, and a new `list` block opened as a child of the `block_quote`. A `list_item` is also -added as a child of the `list`, and a `paragraph` as a chid of -the `list_item`. The text is then added to the `paragraph`: +added as a child of the `list`, and a `paragraph` as a child of +the `list_item`. The text is then added to the new `paragraph`: ``` tree -> document |