FEATURE: update CommonMark to version 0.28

This commit is contained in:
Sam 2018-03-08 12:19:32 +11:00
parent fb77a6eb49
commit b57d4c87a4
3 changed files with 151 additions and 96 deletions

View File

@ -1,8 +1,8 @@
--- ---
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/)'
... ...
@ -11,10 +11,12 @@ license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
## 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
@ -312,7 +314,7 @@ form feed (`U+000C`), or carriage return (`U+000D`).
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`).
@ -331,7 +333,7 @@ is `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`,
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
@ -402,8 +404,8 @@ as indentation with four spaces would:
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.
@ -481,7 +483,7 @@ We can think of a document as a sequence of
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
@ -525,7 +527,7 @@ Markdown document.
A line consisting of 0-3 spaces of indentation, followed by a sequence A line consisting of 0-3 spaces of indentation, followed by a sequence
of three or more matching `-`, `_`, or `*` characters, each followed of three or more matching `-`, `_`, or `*` characters, each followed
optionally by any number of spaces, forms a optionally by any number of spaces or tabs, forms a
[thematic break](@). [thematic break](@).
```````````````````````````````` example ```````````````````````````````` example
@ -1582,7 +1584,7 @@ begins with a code fence, indented no more than three spaces.
The line with the opening code fence may optionally contain some text The line with the opening code fence may optionally contain some text
following the code fence; this is trimmed of leading and trailing following the code fence; this is trimmed of leading and trailing
spaces and called the [info string](@). whitespace and called the [info string](@).
The [info string] may not contain any backtick The [info string] may not contain any backtick
characters. (The reason for this restriction is that otherwise characters. (The reason for this restriction is that otherwise
some inline code would be incorrectly interpreted as the some inline code would be incorrectly interpreted as the
@ -1643,6 +1645,15 @@ With tildes:
</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:
@ -2031,6 +2042,37 @@ or [closing tag] (with any [tag name] other than `script`,
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
@ -3637,11 +3679,15 @@ The following rules define [list items]:
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
@ -5796,6 +5842,15 @@ we just have literal backticks:
<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
@ -5845,19 +5900,20 @@ 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.
@ -5936,7 +5992,7 @@ The following rules define emphasis and strong emphasis:
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]
@ -5976,8 +6032,8 @@ the following principles resolve ambiguity:
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
@ -7000,14 +7056,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>
```````````````````````````````` ````````````````````````````````
@ -7148,8 +7204,9 @@ A [link destination](@) consists of either
- 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
@ -7255,35 +7312,29 @@ Parentheses inside the link destination may be escaped:
<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
[link](foo\(and\(bar\))
.
<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>
````````````````````````````````
```````````````````````````````` example
[link](<foo(and(bar))>)
.
<p><a href="foo(and(bar))">link</a></p>
```````````````````````````````` ````````````````````````````````
@ -7567,13 +7618,16 @@ 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.)
@ -8326,11 +8380,11 @@ The link labels are case-insensitive:
```````````````````````````````` ````````````````````````````````
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"
. .
@ -8570,7 +8624,7 @@ a [single-quoted attribute value], or a [double-quoted attribute value].
An [unquoted attribute value](@) An [unquoted attribute value](@)
is a nonempty string of characters not is a nonempty string of characters not
including spaces, `"`, `'`, `=`, `<`, `>`, or `` ` ``. including [whitespace], `"`, `'`, `=`, `<`, `>`, or `` ` ``.
A [single-quoted attribute value](@) A [single-quoted attribute value](@)
consists of `'`, zero or more consists of `'`, zero or more
@ -8691,9 +8745,13 @@ Illegal [whitespace]:
```````````````````````````````` example ```````````````````````````````` example
< a>< < a><
foo><bar/ > foo><bar/ >
<foo bar=baz
bim!bop />
. .
<p>&lt; a&gt;&lt; <p>&lt; a&gt;&lt;
foo&gt;&lt;bar/ &gt;</p> foo&gt;&lt;bar/ &gt;
&lt;foo bar=baz
bim!bop /&gt;</p>
```````````````````````````````` ````````````````````````````````

View File

@ -67,7 +67,7 @@ QUnit.test("basic cooking", assert => {
assert.cooked("__bold__", "<p><strong>bold</strong></p>", "it bolds text."); assert.cooked("__bold__", "<p><strong>bold</strong></p>", "it bolds text.");
assert.cooked("*trout*", "<p><em>trout</em></p>", "it italicizes text."); assert.cooked("*trout*", "<p><em>trout</em></p>", "it italicizes text.");
assert.cooked("_trout_", "<p><em>trout</em></p>", "it italicizes text."); assert.cooked("_trout_", "<p><em>trout</em></p>", "it italicizes text.");
assert.cooked("***hello***", "<p><strong><em>hello</em></strong></p>", "it can do bold and italics at once."); assert.cooked("***hello***", "<p><em><strong>hello</strong></em></p>", "it can do bold and italics at once.");
assert.cooked("word_with_underscores", "<p>word_with_underscores</p>", "it doesn't do intraword italics"); assert.cooked("word_with_underscores", "<p>word_with_underscores</p>", "it doesn't do intraword italics");
assert.cooked("common/_special_font_face.html.erb", "<p>common/_special_font_face.html.erb</p>", "it doesn't intraword with a slash"); assert.cooked("common/_special_font_face.html.erb", "<p>common/_special_font_face.html.erb</p>", "it doesn't intraword with a slash");
assert.cooked("hello \\*evil\\*", "<p>hello *evil*</p>", "it supports escaping of asterisks"); assert.cooked("hello \\*evil\\*", "<p>hello *evil*</p>", "it supports escaping of asterisks");

View File

@ -1,4 +1,4 @@
/*! markdown-it 8.3.1 https://github.com//markdown-it/markdown-it @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownit = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ /*! markdown-it 8.4.1 https://github.com//markdown-it/markdown-it @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownit = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// HTML5 entities map: { name -> utf16string } // HTML5 entities map: { name -> utf16string }
// //
'use strict'; 'use strict';
@ -64,10 +64,8 @@ module.exports = [
'option', 'option',
'p', 'p',
'param', 'param',
'pre',
'section', 'section',
'source', 'source',
'title',
'summary', 'summary',
'table', 'table',
'tbody', 'tbody',
@ -459,18 +457,18 @@ module.exports = function parseLinkDestination(str, pos, max) {
if (code === 0x28 /* ( */) { if (code === 0x28 /* ( */) {
level++; level++;
if (level > 1) { break; }
} }
if (code === 0x29 /* ) */) { if (code === 0x29 /* ) */) {
if (level === 0) { break; }
level--; level--;
if (level < 0) { break; }
} }
pos++; pos++;
} }
if (start === pos) { return result; } if (start === pos) { return result; }
if (level !== 0) { return result; }
result.str = unescapeAll(str.slice(start, pos)); result.str = unescapeAll(str.slice(start, pos));
result.lines = lines; result.lines = lines;
@ -1185,7 +1183,7 @@ var _rules = [
[ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ], [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
[ 'code', require('./rules_block/code') ], [ 'code', require('./rules_block/code') ],
[ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
[ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ], [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
[ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
[ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ], [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ],
[ 'reference', require('./rules_block/reference') ], [ 'reference', require('./rules_block/reference') ],
@ -1250,7 +1248,7 @@ ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
if (ok) { break; } if (ok) { break; }
} }
// set state.tight iff we had an empty line before current tag // set state.tight if we had an empty line before current tag
// i.e. latest empty line should not count // i.e. latest empty line should not count
state.tight = !hasEmptyLines; state.tight = !hasEmptyLines;
@ -1778,7 +1776,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) {
return highlighted + '\n'; return highlighted + '\n';
} }
// If language exists, inject class gently, without mudofying original token. // If language exists, inject class gently, without modifying original token.
// May be, one day we will add .clone() for token and simplify this part, but // May be, one day we will add .clone() for token and simplify this part, but
// now we prefer to keep things local. // now we prefer to keep things local.
if (info) { if (info) {
@ -1867,7 +1865,7 @@ function Renderer() {
* var result = md.renderInline(...); * var result = md.renderInline(...);
* ``` * ```
* *
* Each rule is called as independed static function with fixed signature: * Each rule is called as independent static function with fixed signature:
* *
* ```javascript * ```javascript
* function my_token_render(tokens, idx, options, env, renderer) { * function my_token_render(tokens, idx, options, env, renderer) {
@ -2423,7 +2421,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
ch, ch,
i, i,
initial, initial,
isOutdented,
l, l,
lastLineEmpty, lastLineEmpty,
lines, lines,
@ -2439,6 +2436,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
terminate, terminate,
terminatorRules, terminatorRules,
token, token,
wasOutdented,
oldLineMax = state.lineMax, oldLineMax = state.lineMax,
pos = state.bMarks[startLine] + state.tShift[startLine], pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine]; max = state.eMarks[startLine];
@ -2519,6 +2517,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
oldParentType = state.parentType; oldParentType = state.parentType;
state.parentType = 'blockquote'; state.parentType = 'blockquote';
wasOutdented = false;
// Search the end of the block // Search the end of the block
// //
@ -2547,7 +2546,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
// > current blockquote // > current blockquote
// 2. checking this line // 2. checking this line
// ``` // ```
isOutdented = state.sCount[nextLine] < state.blkIndent; if (state.sCount[nextLine] < state.blkIndent) wasOutdented = true;
pos = state.bMarks[nextLine] + state.tShift[nextLine]; pos = state.bMarks[nextLine] + state.tShift[nextLine];
max = state.eMarks[nextLine]; max = state.eMarks[nextLine];
@ -2557,7 +2556,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
break; break;
} }
if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) { if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !wasOutdented) {
// This line is inside the blockquote. // This line is inside the blockquote.
// skip spaces after ">" and re-calculate offset // skip spaces after ">" and re-calculate offset
@ -2657,8 +2656,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
break; break;
} }
if (isOutdented) break;
oldBMarks.push(state.bMarks[nextLine]); oldBMarks.push(state.bMarks[nextLine]);
oldBSCount.push(state.bsCount[nextLine]); oldBSCount.push(state.bsCount[nextLine]);
oldTShift.push(state.tShift[nextLine]); oldTShift.push(state.tShift[nextLine]);
@ -3103,7 +3100,7 @@ module.exports = function lheading(state, startLine, endLine/*, silent*/) {
var isSpace = require('../common/utils').isSpace; var isSpace = require('../common/utils').isSpace;
// Search `[-+*][\n ]`, returns next pos arter marker on success // Search `[-+*][\n ]`, returns next pos after marker on success
// or -1 on fail. // or -1 on fail.
function skipBulletListMarker(state, startLine) { function skipBulletListMarker(state, startLine) {
var marker, pos, max, ch; var marker, pos, max, ch;
@ -3131,7 +3128,7 @@ function skipBulletListMarker(state, startLine) {
return pos; return pos;
} }
// Search `\d+[.)][\n ]`, returns next pos arter marker on success // Search `\d+[.)][\n ]`, returns next pos after marker on success
// or -1 on fail. // or -1 on fail.
function skipOrderedListMarker(state, startLine) { function skipOrderedListMarker(state, startLine) {
var ch, var ch,
@ -3308,12 +3305,10 @@ module.exports = function list(state, startLine, endLine, silent) {
while (pos < max) { while (pos < max) {
ch = state.src.charCodeAt(pos); ch = state.src.charCodeAt(pos);
if (isSpace(ch)) { if (ch === 0x09) {
if (ch === 0x09) { offset += 4 - (offset + state.bsCount[nextLine]) % 4;
offset += 4 - (offset + state.bsCount[nextLine]) % 4; } else if (ch === 0x20) {
} else { offset++;
offset++;
}
} else { } else {
break; break;
} }
@ -3414,7 +3409,7 @@ module.exports = function list(state, startLine, endLine, silent) {
if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; } if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
} }
// Finilize list // Finalize list
if (isOrdered) { if (isOrdered) {
token = state.push('ordered_list_close', 'ol', -1); token = state.push('ordered_list_close', 'ol', -1);
} else { } else {
@ -4480,7 +4475,8 @@ function process_inlines(tokens, state) {
lastChar = text.charCodeAt(t.index - 1); lastChar = text.charCodeAt(t.index - 1);
} else { } else {
for (j = i - 1; j >= 0; j--) { for (j = i - 1; j >= 0; j--) {
if (tokens[j].type !== 'text') { continue; } if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20
if (tokens[j].type !== 'text') continue;
lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1); lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
break; break;
@ -4496,7 +4492,8 @@ function process_inlines(tokens, state) {
nextChar = text.charCodeAt(pos); nextChar = text.charCodeAt(pos);
} else { } else {
for (j = i + 1; j < tokens.length; j++) { for (j = i + 1; j < tokens.length; j++) {
if (tokens[j].type !== 'text') { continue; } if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20
if (tokens[j].type !== 'text') continue;
nextChar = tokens[j].content.charCodeAt(0); nextChar = tokens[j].content.charCodeAt(0);
break; break;
@ -4880,7 +4877,7 @@ module.exports.postProcess = function emphasis(state) {
delimiters = state.delimiters, delimiters = state.delimiters,
max = state.delimiters.length; max = state.delimiters.length;
for (i = 0; i < max; i++) { for (i = max - 1; i >= 0; i--) {
startDelim = delimiters[i]; startDelim = delimiters[i];
if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) { if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {
@ -4894,16 +4891,16 @@ module.exports.postProcess = function emphasis(state) {
endDelim = delimiters[startDelim.end]; endDelim = delimiters[startDelim.end];
// If the next delimiter has the same marker and is adjacent to this one, // If the previous delimiter has the same marker and is adjacent to this one,
// merge those into one strong delimiter. // merge those into one strong delimiter.
// //
// `<em><em>whatever</em></em>` -> `<strong>whatever</strong>` // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
// //
isStrong = i + 1 < max && isStrong = i > 0 &&
delimiters[i + 1].end === startDelim.end - 1 && delimiters[i - 1].end === startDelim.end + 1 &&
delimiters[i + 1].token === startDelim.token + 1 && delimiters[i - 1].token === startDelim.token - 1 &&
delimiters[startDelim.end - 1].token === endDelim.token - 1 && delimiters[startDelim.end + 1].token === endDelim.token + 1 &&
delimiters[i + 1].marker === startDelim.marker; delimiters[i - 1].marker === startDelim.marker;
ch = String.fromCharCode(startDelim.marker); ch = String.fromCharCode(startDelim.marker);
@ -4922,9 +4919,9 @@ module.exports.postProcess = function emphasis(state) {
token.content = ''; token.content = '';
if (isStrong) { if (isStrong) {
state.tokens[delimiters[i + 1].token].content = ''; state.tokens[delimiters[i - 1].token].content = '';
state.tokens[delimiters[startDelim.end - 1].token].content = ''; state.tokens[delimiters[startDelim.end + 1].token].content = '';
i++; i--;
} }
} }
}; };
@ -4980,7 +4977,7 @@ module.exports = function entity(state, silent) {
}; };
},{"../common/entities":1,"../common/utils":4}],42:[function(require,module,exports){ },{"../common/entities":1,"../common/utils":4}],42:[function(require,module,exports){
// Proceess escaped chars and hardbreaks // Process escaped chars and hardbreaks
'use strict'; 'use strict';
@ -7944,7 +7941,7 @@ module.exports=/[\0-\x1F\x7F-\x9F]/
},{}],62:[function(require,module,exports){ },{}],62:[function(require,module,exports){
module.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804\uDCBD|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/ module.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804\uDCBD|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/
},{}],63:[function(require,module,exports){ },{}],63:[function(require,module,exports){
module.exports=/[!-#%-\*,-/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E44\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD807[\uDC41-\uDC45\uDC70\uDC71]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/ module.exports=/[!-#%-\*,-/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E49\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/
},{}],64:[function(require,module,exports){ },{}],64:[function(require,module,exports){
module.exports=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/ module.exports=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/
},{}],65:[function(require,module,exports){ },{}],65:[function(require,module,exports){