Browse Source

Rewritten string fetch for inline tokenizer + list fixes

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
9728b685ec
  1. 32
      lib/helpers.js
  2. 2
      lib/lexer_block/blockquote.js
  3. 3
      lib/lexer_block/code.js
  4. 6
      lib/lexer_block/fences.js
  5. 2
      lib/lexer_block/heading.js
  6. 2
      lib/lexer_block/lheading.js
  7. 52
      lib/lexer_block/list.js
  8. 4
      lib/lexer_block/paragraph.js
  9. 4
      lib/lexer_block/table.js
  10. 11
      lib/lexer_inline.js
  11. 27
      lib/renderer.js
  12. 7
      lib/state.js
  13. 582
      test/fixtures/stmd/bad.txt
  14. 324
      test/fixtures/stmd/good.txt

32
lib/helpers.js

@ -49,16 +49,36 @@ function skipCharsBack(state, pos, code, min) {
} }
// cut lines range from source. // cut lines range from source.
function getLines(state, begin, end, keepLastLF) { function getLines(state, begin, end, indent, keepLastLF) {
var last; var i, first, last, queue,
line = begin;
if (keepLastLF) { if (begin >= end) {
last = end < state.lineMax ? state.bMarks[end] : state.src.length; return '';
}
// Opt: don't use push queue for single line;
if (line + 1 === end) {
first = state.bMarks[line] + Math.min(state.tShift[line], indent);
last = keepLastLF ? state.bMarks[end] : state.eMarks[end - 1];
return state.src.slice(first, last);
}
queue = new Array(end - begin);
for (i = 0; line < end; line++, i++) {
first = state.bMarks[line] + Math.min(state.tShift[line], indent);
if (line + 1 < end || keepLastLF) {
last = state.bMarks[line + 1];
} else { } else {
last = end < state.lineMax ? state.eMarks[end - 1] : state.src.length; last = state.eMarks[line];
}
queue[i] = state.src.slice(first, last);
} }
return state.src.slice(state.bMarks[begin], last); return queue.join('');
} }
exports.isWhiteSpace = isWhiteSpace; exports.isWhiteSpace = isWhiteSpace;

2
lib/lexer_block/blockquote.js

@ -47,7 +47,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
if (isEmpty(state, nextLine)) { break; } if (isEmpty(state, nextLine)) { break; }
nextLine++; nextLine++;
} }
subState = state.clone(getLines(state, startLine, nextLine, true) subState = state.clone(getLines(state, startLine, nextLine, 0, true)
.replace(/^ {0,3}> ?/mg, '')); .replace(/^ {0,3}> ?/mg, ''));
state.lexerBlock.tokenize(subState, 0, insideLines); state.lexerBlock.tokenize(subState, 0, insideLines);
nextLine = startLine = subState.line + startLine; nextLine = startLine = subState.line + startLine;

3
lib/lexer_block/code.js

@ -34,8 +34,7 @@ module.exports = function code(state, startLine, endLine, silent) {
state.tokens.push({ state.tokens.push({
type: 'code', type: 'code',
content: getLines(state, startLine, last, true).replace( content: getLines(state, startLine, last, 4 + state.blkIndent, true)
new RegExp('^ {1,' + (4 + state.blkIndent) + '}', 'gm'), '')
}); });
state.line = nextLine; state.line = nextLine;

6
lib/lexer_block/fences.js

@ -85,11 +85,7 @@ module.exports = function fences(state, startLine, endLine, silent) {
state.tokens.push({ state.tokens.push({
type: 'fence', type: 'fence',
params: params ? params.split(/\s+/g) : [], params: params ? params.split(/\s+/g) : [],
content: len === 0 ? content: getLines(state, startLine + 1, nextLine, len, true)
getLines(state, startLine + 1, nextLine, true)
:
getLines(state, startLine + 1, nextLine, true)
.replace(RegExp('^ {1,' + len + '}', 'mg'), '')
}); });
state.line = nextLine + (haveEndMarker ? 1 : 0); state.line = nextLine + (haveEndMarker ? 1 : 0);

2
lib/lexer_block/heading.js

@ -58,7 +58,7 @@ module.exports = function heading(state, startLine, endLine, silent) {
state.tokens.push({ type: 'heading_open', level: level }); state.tokens.push({ type: 'heading_open', level: level });
// only if header is not empty // only if header is not empty
if (pos < max) { if (pos < max) {
state.lexerInline.tokenize(state, pos, max); state.lexerInline.tokenize(state, state.src.slice(pos, max));
} }
state.tokens.push({ type: 'heading_close', level: level }); state.tokens.push({ type: 'heading_close', level: level });

2
lib/lexer_block/lheading.js

@ -37,7 +37,7 @@ module.exports = function lheading(state, startLine, endLine, silent) {
max = skipCharsBack(state, state.eMarks[startLine], 0x20/* space */, pos); max = skipCharsBack(state, state.eMarks[startLine], 0x20/* space */, pos);
state.tokens.push({ type: 'heading_open', level: marker === 0x3D/* = */ ? 1 : 2 }); state.tokens.push({ type: 'heading_open', level: marker === 0x3D/* = */ ? 1 : 2 });
state.lexerInline.tokenize(state, pos, max); state.lexerInline.tokenize(state, state.src.slice(pos, max));
state.tokens.push({ type: 'heading_close', level: marker === 0x3D/* = */ ? 1 : 2 }); state.tokens.push({ type: 'heading_close', level: marker === 0x3D/* = */ ? 1 : 2 });
state.line = next + 1; state.line = next + 1;

52
lib/lexer_block/list.js

@ -85,11 +85,12 @@ module.exports = function list(state, startLine, endLine, silent) {
max, max,
indentAfterMarker, indentAfterMarker,
markerValue, markerValue,
markerCharCode,
isOrdered, isOrdered,
contentStart, contentStart,
listTokIdx, listTokIdx,
endOfList; prevEmptyEnd,
//rules_named = state.lexerBlock.rules_named; rules_named = state.lexerBlock.rules_named;
// Detect list type and position after marker // Detect list type and position after marker
if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) { if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
@ -99,6 +100,8 @@ module.exports = function list(state, startLine, endLine, silent) {
} else { } else {
return false; return false;
} }
// We should terminate list on style change. Remember first one to compare.
markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
// For validation mode we can terminate immediately // For validation mode we can terminate immediately
if (silent) { return true; } if (silent) { return true; }
@ -128,18 +131,9 @@ module.exports = function list(state, startLine, endLine, silent) {
// //
nextLine = startLine; nextLine = startLine;
endOfList = false; prevEmptyEnd = false;
while (nextLine < endLine && !endOfList) {
if (state.tShift[startLine] < state.blkIndent) { return -1; }
if (isOrdered) {
posAfterMarker = skipOrderedListMarker(state, nextLine);
if (posAfterMarker < 0) { break; }
} else {
posAfterMarker = skipBulletListMarker(state, nextLine);
if (posAfterMarker < 0) { break; }
}
while (nextLine < endLine) {
contentStart = skipSpaces(state, posAfterMarker); contentStart = skipSpaces(state, posAfterMarker);
max = state.eMarks[nextLine]; max = state.eMarks[nextLine];
@ -165,18 +159,22 @@ module.exports = function list(state, startLine, endLine, silent) {
// Run sublexer & write tokens // Run sublexer & write tokens
state.tokens.push({ type: 'list_item_open' }); state.tokens.push({ type: 'list_item_open' });
nextLine++; //nextLine++;
oldIndent = state.blkIndent; oldIndent = state.blkIndent;
oldTight = state.tight; oldTight = state.tight;
state.blkIndent = state.tShift[startLine] = indent; state.blkIndent = state.tShift[startLine] = indent;
state.tight = true;
state.lexerBlock.tokenize(state, startLine, endLine, true); state.lexerBlock.tokenize(state, startLine, endLine, true);
// If any of list item is loose, mark list as loose // If any of list item is tight, mark list as tight
if (!state.tight || isEmpty(state, state.line - 1)) { if (!state.tight || prevEmptyEnd) {
state.tokens[listTokIdx].tight = false; state.tokens[listTokIdx].tight = false;
} }
// Item become loose if finish with empty line,
// but we should filter last element, because it means list finish
prevEmptyEnd = (state.line - startLine) > 1 && isEmpty(state, state.line - 1);
state.blkIndent = state.tShift[startLine] = oldIndent; state.blkIndent = state.tShift[startLine] = oldIndent;
state.tight = oldTight; state.tight = oldTight;
@ -195,6 +193,28 @@ module.exports = function list(state, startLine, endLine, silent) {
break; break;
} }
} }
//
// Try to ckeck if list is terminated or continued.
//
// fail if terminating block found
if (rules_named.fences(state, nextLine, endLine, true)) { break; }
if (rules_named.blockquote(state, nextLine, endLine, true)) { break; }
if (rules_named.hr(state, nextLine, endLine, true)) { break; }
// fail if list has another type
if (isOrdered) {
posAfterMarker = skipOrderedListMarker(state, nextLine);
if (posAfterMarker < 0) { break; }
} else {
posAfterMarker = skipBulletListMarker(state, nextLine);
if (posAfterMarker < 0) { break; }
}
if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
} }
// Finilize list // Finilize list

4
lib/lexer_block/paragraph.js

@ -4,6 +4,7 @@
var isEmpty = require('../helpers').isEmpty; var isEmpty = require('../helpers').isEmpty;
var getLines = require('../helpers').getLines;
module.exports = function paragraph(state, startLine/*, endLine*/) { module.exports = function paragraph(state, startLine/*, endLine*/) {
@ -32,8 +33,7 @@ module.exports = function paragraph(state, startLine/*, endLine*/) {
state.tokens.push({ type: 'paragraph_open' }); state.tokens.push({ type: 'paragraph_open' });
state.lexerInline.tokenize( state.lexerInline.tokenize(
state, state,
state.bMarks[startLine] + state.tShift[startLine], getLines(state, startLine, nextLine, state.blkIndent, false)
state.eMarks[nextLine - 1]
); );
state.tokens.push({ type: 'paragraph_close' }); state.tokens.push({ type: 'paragraph_close' });

4
lib/lexer_block/table.js

@ -53,7 +53,7 @@ module.exports = function table(state, startLine, endLine, silent) {
for (i = 0; i < rows.length; i++) { for (i = 0; i < rows.length; i++) {
state.tokens.push({ type: 'th_open', align: aligns[i] }); state.tokens.push({ type: 'th_open', align: aligns[i] });
subState = state.clone(rows[i].trim()); subState = state.clone(rows[i].trim());
state.lexerInline.tokenize(subState, 0, subState.eMarks[0]); state.lexerInline.tokenize(subState, subState.src);
state.tokens.push({ type: 'th_close' }); state.tokens.push({ type: 'th_close' });
} }
state.tokens.push({ type: 'tr_close' }); state.tokens.push({ type: 'tr_close' });
@ -67,7 +67,7 @@ module.exports = function table(state, startLine, endLine, silent) {
for (i = 0; i < rows.length; i++) { for (i = 0; i < rows.length; i++) {
state.tokens.push({ type: 'td_open', align: aligns[i] }); state.tokens.push({ type: 'td_open', align: aligns[i] });
subState = state.clone(rows[i].replace(/^\|? *| *\|?$/g, '')); subState = state.clone(rows[i].replace(/^\|? *| *\|?$/g, ''));
state.lexerInline.tokenize(subState, 0, subState.eMarks[0]); state.lexerInline.tokenize(subState, subState.src);
state.tokens.push({ type: 'td_close' }); state.tokens.push({ type: 'td_close' });
} }
state.tokens.push({ type: 'tr_close' }); state.tokens.push({ type: 'tr_close' });

11
lib/lexer_inline.js

@ -10,10 +10,10 @@ var rules = [];
// Pure text // Pure text
rules.push(function text(state, begin, end) { rules.push(function text(state, str, begin, end) {
state.tokens.push({ state.tokens.push({
type: 'text', type: 'text',
content: state.src.slice(begin, end).replace(/^ {1,}/mg, '') content: str.slice(begin, end).replace(/^ {1,}/mg, '')
}); });
state.pos = end; state.pos = end;
@ -107,11 +107,12 @@ LexerInline.prototype.after = function (name, fn) {
// Generate tokens for input range // Generate tokens for input range
// //
LexerInline.prototype.tokenize = function (state, begin, end) { LexerInline.prototype.tokenize = function (state, str) {
var ok, i, var ok, i,
rules = this.rules, rules = this.rules,
len = this.rules.length, len = this.rules.length,
pos = begin; pos = 0,
end = str.length;
while (pos < end) { while (pos < end) {
@ -123,7 +124,7 @@ LexerInline.prototype.tokenize = function (state, begin, end) {
// - return true // - return true
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
ok = rules[i](state, pos, end); ok = rules[i](state, str, pos, end);
if (ok) { break; } if (ok) { break; }
} }

27
lib/renderer.js

@ -40,12 +40,12 @@ rules.blockquote_close = function (state, token, idx) {
}; };
rules.code = function (state, token) { rules.code = function (state, token, idx) {
state.result += '<pre><code>' + escapeHtml(token.content) + '</code></pre>\n'; state.result += '<pre><code>' + escapeHtml(token.content) + '</code></pre>' + getBreak(state, idx);
}; };
rules.fence = function (state, token) { rules.fence = function (state, token, idx) {
var langMark = ''; var langMark = '';
var langPrefix = state.options.codeLangPrefix || ''; var langPrefix = state.options.codeLangPrefix || '';
@ -53,7 +53,9 @@ rules.fence = function (state, token) {
langMark = ' class="' + langPrefix + escapeHtml(token.params[0]) + '"'; langMark = ' class="' + langPrefix + escapeHtml(token.params[0]) + '"';
} }
state.result += '<pre><code' + langMark + '>' + escapeHtml(token.content) + '</code></pre>\n'; state.result += '<pre><code' + langMark + '>'
+ escapeHtml(token.content)
+ '</code></pre>' + getBreak(state, idx);
}; };
@ -130,7 +132,7 @@ rules.td_close = function (state /*, token, idx*/) {
}; };
rules.text = function (state, token) { rules.text = function (state, token /*, idx*/) {
state.result += escapeHtml(unescapeMd(token.content)); state.result += escapeHtml(unescapeMd(token.content));
}; };
@ -142,7 +144,7 @@ function Renderer() {
} }
Renderer.prototype.render = function (state) { Renderer.prototype.render = function (state) {
var i, len, rule, name, var i, len, rule, name, next,
tokens = state.tokens, tokens = state.tokens,
rules = this.rules, rules = this.rules,
tightStack = []; tightStack = [];
@ -170,7 +172,18 @@ Renderer.prototype.render = function (state) {
// in tight mode just ignore paragraphs for lists // in tight mode just ignore paragraphs for lists
// TODO - track right nesting to blockquotes // TODO - track right nesting to blockquotes
if ((name === 'paragraph_open' || name === 'paragraph_close') && state.tight) { if (name === 'paragraph_open' && state.tight) {
continue;
}
if (name === 'paragraph_close' && state.tight) {
// Quick hack - texts should have LF if followed by blocks
if (i + 1 < state.tokens.length) {
next = state.tokens[i + 1].type;
if (next === 'bullet_list_open' || next === 'ordered_list_open') {
state.result += '\n';
}
}
continue; continue;
} }
rule(state, tokens[i], i); rule(state, tokens[i], i);

7
lib/state.js

@ -71,6 +71,11 @@ function State(src, lexerBlock, lexerInline, renderer, tokens, options) {
this.tShift.push(indent); this.tShift.push(indent);
} }
// Push fake entry to simplify cache bounds checks
this.bMarks.push(s.length);
this.eMarks.push(s.length);
this.tShift.push(0);
// inline lexer variables // inline lexer variables
this.pos = 0; // char index in src this.pos = 0; // char index in src
@ -78,7 +83,7 @@ function State(src, lexerBlock, lexerInline, renderer, tokens, options) {
this.blkLevel = 0; this.blkLevel = 0;
this.blkIndent = 0; this.blkIndent = 0;
this.line = 0; // line index in src this.line = 0; // line index in src
this.lineMax = this.bMarks.length; this.lineMax = this.bMarks.length - 1; // don't count last fake line
this.tight = false; // loose/tight mode for lists this.tight = false; // loose/tight mode for lists
// renderer // renderer

582
test/fixtures/stmd/bad.txt

@ -699,75 +699,6 @@ error:
bbb </p> bbb </p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2147
.
> foo
bar
.
<blockquote>
<pre><code>foo
</code></pre>
</blockquote>
<pre><code>bar
</code></pre>
.
error:
<blockquote>
<pre><code>foo
bar
</code></pre>
</blockquote>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2159
.
> ```
foo
```
.
<blockquote>
<pre><code></code></pre>
</blockquote>
<p>foo</p>
<pre><code></code></pre>
.
error:
<blockquote>
<pre><code>foo
</code></pre>
</blockquote>
<pre><code></code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2236
.
> foo
>
> bar
.
<blockquote>
<p>foo</p>
<p>bar</p>
</blockquote>
.
error:
<blockquote>
<p>foo</p>
</blockquote>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2414 src line: 2414
@ -794,63 +725,13 @@ error:
<ol> <ol>
<li><p>A paragraph <li><p>A paragraph
with two lines.</p></li> with two lines.</p>
<pre><code>indented code
</code></pre>
<p>&gt; A block quote.</p></li>
</ol> </ol>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2540
.
- foo
bar
- foo
bar
- ```
foo
bar
```
.
<ul>
<li><p>foo</p>
<p>bar</p></li>
<li><p>foo</p></li>
</ul>
<p>bar</p>
<ul>
<li><pre><code>foo
bar
</code></pre></li>
</ul>
.
error:
<ul>
<li><p>foo</p>
<p>bar</p></li>
</ul>
<ul>
<li>foo</li>
</ul>
<p>bar</p>
<ul>
<li><pre><code>foo</code></pre>
</li>
</ul>
<p>bar</p>
<pre><code></code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2574 src line: 2574
@ -882,55 +763,8 @@ error:
<li><p>foo</p> <li><p>foo</p>
<pre><code>bar <pre><code>bar
</code></pre> </code></pre>
</li> <p>baz</p>
</ol> <p>&gt; bam</p></li>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2612
.
- foo
bar
.
<ul>
<li><p>foo</p>
<pre><code>bar
</code></pre></li>
</ul>
.
error:
<ul>
<li><p>foo</p>
<pre><code>bar</code></pre>
</li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2626
.
10. foo
bar
.
<ol start="10">
<li><p>foo</p>
<pre><code>bar
</code></pre></li>
</ol>
.
error:
<ol start="10">
<li><p>foo</p>
<pre><code>bar</code></pre>
</li>
</ol> </ol>
@ -956,7 +790,10 @@ src line: 2656
error: error:
<ol> <ol>
<li><p>indented code</p></li> <li><p>indented code</p>
<p>paragraph</p>
<pre><code>more code
</code></pre></li>
</ol> </ol>
@ -982,7 +819,10 @@ src line: 2675
error: error:
<ol> <ol>
<li><p>indented code</p></li> <li><p>indented code</p>
<p>paragraph</p>
<pre><code>more code
</code></pre></li>
</ol> </ol>
@ -1012,7 +852,10 @@ error:
<ol> <ol>
<li><p>A paragraph <li><p>A paragraph
with two lines.</p></li> with two lines.</p>
<pre><code>indented code
</code></pre>
<p>&gt; A block quote.</p></li>
</ol> </ol>
@ -1042,7 +885,10 @@ error:
<ol> <ol>
<li><p>A paragraph <li><p>A paragraph
with two lines.</p></li> with two lines.</p>
<pre><code>indented code
</code></pre>
<p>&gt; A block quote.</p></li>
</ol> </ol>
@ -1072,7 +918,10 @@ error:
<ol> <ol>
<li><p>A paragraph <li><p>A paragraph
with two lines.</p></li> with two lines.</p>
<pre><code>indented code
</code></pre>
<p>&gt; A block quote.</p></li>
</ol> </ol>
@ -1102,7 +951,10 @@ error:
<ol> <ol>
<li><p>A paragraph <li><p>A paragraph
with two lines.</p></li> with two lines.</p>
<pre><code>indented code
</code></pre>
<p>&gt; A block quote.</p></li>
</ol> </ol>
@ -1123,17 +975,6 @@ continued here.</p>
</blockquote> </blockquote>
. .
error:
<blockquote>
<ol>
<li><blockquote>
Blockquote
continued here.</blockquote></li>
</ol>
</blockquote>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2880 src line: 2880
@ -1151,156 +992,6 @@ continued here.</p>
</blockquote> </blockquote>
. .
error:
<blockquote>
<ol>
<li><blockquote>
Blockquote
continued here.</blockquote></li>
</ol>
</blockquote>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2904
.
- foo
- bar
- baz
.
<ul>
<li>foo
<ul>
<li>bar
<ul>
<li>baz</li>
</ul></li>
</ul></li>
</ul>
.
error:
<ul>
<li>foo<ul>
<li>bar<ul>
<li>baz</li>
</ul></li>
</ul></li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2936
.
10) foo
- bar
.
<ol start="10">
<li>foo
<ul>
<li>bar</li>
</ul></li>
</ol>
.
error:
<ol start="10">
<li>foo<ul>
<li>bar</li>
</ul></li>
</ol>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3222
.
- foo
- bar
+ baz
.
<ul>
<li>foo</li>
<li>bar</li>
</ul>
<ul>
<li>baz</li>
</ul>
.
error:
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3236
.
1. foo
2. bar
3) baz
.
<ol>
<li>foo</li>
<li>bar</li>
</ol>
<ol start="3">
<li>baz</li>
</ol>
.
error:
<ol>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ol>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3253
.
- foo
- bar
- baz
.
<ul>
<li><p>foo</p></li>
<li><p>bar</p></li>
</ul>
<ul>
<li>baz</li>
</ul>
.
error:
<ul>
<li>foo</li>
</ul>
<ul>
<li>bar</li>
</ul>
<ul>
<li>baz</li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3292 src line: 3292
@ -1328,102 +1019,14 @@ src line: 3292
error: error:
<ul> <ul>
<li>foo<ul> <li>foo
<li>bar<ul>
<li>baz</li>
</ul></li>
</ul></li>
</ul>
<pre><code> bim
</code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3336
.
- foo
notcode
- foo
code
.
<ul>
<li><p>foo</p>
<p>notcode</p></li>
<li><p>foo</p></li>
</ul>
<pre><code>code
</code></pre>
.
error:
<ul>
<li><p>foo</p>
<p>notcode</p></li>
</ul>
<ul>
<li>foo</li>
</ul>
<pre><code>code
</code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3383
.
- a
- b
- c
.
<ul>
<li><p>a</p></li>
<li><p>b</p></li>
<li><p>c</p></li>
</ul>
.
error:
<ul>
<li>a</li>
<li>b</li>
</ul>
<ul>
<li>c</li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3398
.
* a
*
* c
.
<ul> <ul>
<li><p>a</p></li> <li><p>bar</p>
<li></li>
<li><p>c</p></li>
</ul>
.
error:
<ul> <ul>
<li>a</li> <li>baz</li>
<li></li>
</ul> </ul>
<ul> <p>bim</p></li>
<li>c</li> </ul></li>
</ul> </ul>
@ -1454,39 +1057,6 @@ error:
</ul> </ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3446
.
- a
- ```
b
```
- c
.
<ul>
<li>a</li>
<li><pre><code>b
</code></pre></li>
<li>c</li>
</ul>
.
error:
<ul>
<li>a</li>
<li><pre><code>b</code></pre>
</li>
</ul>
<pre><code>- c
</code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3469 src line: 3469
@ -1510,11 +1080,12 @@ src line: 3469
error: error:
<ul> <ul>
<li>a<ul> <li>a
<ul>
<li><p>b</p> <li><p>b</p>
<p>c</p></li> <p>c</p></li>
<li><p>d</p></li>
</ul></li> </ul></li>
<li>d</li>
</ul> </ul>
@ -1573,36 +1144,11 @@ error:
<li>a<blockquote> <li>a<blockquote>
b</blockquote> b</blockquote>
<pre><code>c <pre><code>c
</code></pre> </code></pre></li>
</li>
<li>d</li> <li>d</li>
</ul> </ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3536
.
- a
- b
.
<ul>
<li>a
<ul>
<li>b</li>
</ul></li>
</ul>
.
error:
<ul>
<li>a<ul>
<li>b</li>
</ul></li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3550 src line: 3550
@ -1624,7 +1170,8 @@ src line: 3550
error: error:
<ul> <ul>
<li>foo<ul> <li>foo
<ul>
<li>bar</li> <li>bar</li>
</ul> </ul>
baz</li> baz</li>
@ -1660,16 +1207,16 @@ src line: 3565
error: error:
<ul> <ul>
<li>a<ul> <li>a
<li>b</li> <ul>
<li>c</li> <li><p>b</p></li>
</ul></li> <li><p>c</p></li>
</ul> <li><p>d</p>
<ul> <ul>
<li>d<ul>
<li>e</li> <li>e</li>
<li>f</li> <li>f</li>
</ul></li> </ul></li>
</ul></li>
</ul> </ul>
@ -4462,39 +4009,4 @@ error:
<p>foo <p>foo
baz</p> baz</p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 444
.
* Foo
* * *
* Bar
.
<ul>
<li>Foo</li>
</ul>
<hr />
<ul>
<li>Bar</li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3274
.
- foo
bar
- baz
.
<ul>
<li>foo</li>
</ul>
<p>bar</p>
<ul>
<li>baz</li>
</ul>
.

324
test/fixtures/stmd/good.txt

@ -210,6 +210,23 @@ bar
<p>bar</p> <p>bar</p>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 444
.
* Foo
* * *
* Bar
.
<ul>
<li>Foo</li>
</ul>
<hr />
<ul>
<li>Bar</li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 460 src line: 460
@ -1312,6 +1329,36 @@ src line: 2133
</ul> </ul>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2147
.
> foo
bar
.
<blockquote>
<pre><code>foo
</code></pre>
</blockquote>
<pre><code>bar
</code></pre>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2159
.
> ```
foo
```
.
<blockquote>
<pre><code></code></pre>
</blockquote>
<p>foo</p>
<pre><code></code></pre>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2173 src line: 2173
@ -1376,6 +1423,20 @@ bar</p>
</blockquote> </blockquote>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2236
.
> foo
>
> bar
.
<blockquote>
<p>foo</p>
<p>bar</p>
</blockquote>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2249 src line: 2249
@ -1613,6 +1674,71 @@ src line: 2521
</blockquote> </blockquote>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2540
.
- foo
bar
- foo
bar
- ```
foo
bar
```
.
<ul>
<li><p>foo</p>
<p>bar</p></li>
<li><p>foo</p></li>
</ul>
<p>bar</p>
<ul>
<li><pre><code>foo
bar
</code></pre></li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2612
.
- foo
bar
.
<ul>
<li><p>foo</p>
<pre><code>bar
</code></pre></li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2626
.
10. foo
bar
.
<ol start="10">
<li><p>foo</p>
<pre><code>bar
</code></pre></li>
</ol>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2642 src line: 2642
@ -1703,6 +1829,25 @@ with two lines.</li>
</ol> </ol>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2904
.
- foo
- bar
- baz
.
<ul>
<li>foo
<ul>
<li>bar
<ul>
<li>baz</li>
</ul></li>
</ul></li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2922 src line: 2922
@ -1718,6 +1863,21 @@ src line: 2922
</ul> </ul>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2936
.
10) foo
- bar
.
<ol start="10">
<li>foo
<ul>
<li>bar</li>
</ul></li>
</ol>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2950 src line: 2950
@ -1787,6 +1947,79 @@ src line: 3000
</ul> </ul>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3222
.
- foo
- bar
+ baz
.
<ul>
<li>foo</li>
<li>bar</li>
</ul>
<ul>
<li>baz</li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3236
.
1. foo
2. bar
3) baz
.
<ol>
<li>foo</li>
<li>bar</li>
</ol>
<ol start="3">
<li>baz</li>
</ol>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3253
.
- foo
- bar
- baz
.
<ul>
<li><p>foo</p></li>
<li><p>bar</p></li>
</ul>
<ul>
<li>baz</li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3274
.
- foo
bar
- baz
.
<ul>
<li>foo</li>
</ul>
<p>bar</p>
<ul>
<li>baz</li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3318 src line: 3318
@ -1808,6 +2041,28 @@ src line: 3318
</ul> </ul>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3336
.
- foo
notcode
- foo
code
.
<ul>
<li><p>foo</p>
<p>notcode</p></li>
<li><p>foo</p></li>
</ul>
<pre><code>code
</code></pre>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3360 src line: 3360
@ -1831,6 +2086,38 @@ src line: 3360
</ul> </ul>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3383
.
- a
- b
- c
.
<ul>
<li><p>a</p></li>
<li><p>b</p></li>
<li><p>c</p></li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3398
.
* a
*
* c
.
<ul>
<li><p>a</p></li>
<li></li>
<li><p>c</p></li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3415 src line: 3415
@ -1849,6 +2136,28 @@ src line: 3415
</ul> </ul>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3446
.
- a
- ```
b
```
- c
.
<ul>
<li>a</li>
<li><pre><code>b
</code></pre></li>
<li>c</li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3528 src line: 3528
@ -1860,6 +2169,21 @@ src line: 3528
</ul> </ul>
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3536
.
- a
- b
.
<ul>
<li>a
<ul>
<li>b</li>
</ul></li>
</ul>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3607 src line: 3607

Loading…
Cancel
Save