From 2a9218cf60dc2e6d5566ddd5791235ca97e680d8 Mon Sep 17 00:00:00 2001
From: Vitaly Puzrin
Date: Thu, 25 Dec 2014 01:12:28 +0300
Subject: [PATCH] Updated line breaks rendering logic
---
lib/renderer.js | 95 +-
support/specsplit.js | 3 +-
test/fixtures/commonmark/bad.txt | 1210 --------------------------
test/fixtures/commonmark/good.txt | 1053 +++++++++++++++++++---
test/fixtures/markdown-it/tables.txt | 3 +-
test/misc.js | 4 +-
6 files changed, 973 insertions(+), 1395 deletions(-)
diff --git a/lib/renderer.js b/lib/renderer.js
index b711581..33d689f 100644
--- a/lib/renderer.js
+++ b/lib/renderer.js
@@ -8,31 +8,6 @@ var replaceEntities = require('./common/utils').replaceEntities;
var escapeHtml = require('./common/utils').escapeHtml;
-////////////////////////////////////////////////////////////////////////////////
-// Helpers
-
-function nextToken(tokens, idx) {
- if (++idx >= tokens.length - 2) { return idx; }
- if ((tokens[idx].type === 'paragraph_open' && tokens[idx].tight) &&
- (tokens[idx + 1].type === 'inline' && tokens[idx + 1].content.length === 0) &&
- (tokens[idx + 2].type === 'paragraph_close' && tokens[idx + 2].tight)) {
- return nextToken(tokens, idx + 2);
- }
- return idx;
-}
-
-
-// check if we need to hide '\n' before next token
-function getBreak(tokens, idx) {
- idx = nextToken(tokens, idx);
- if (idx < tokens.length &&
- tokens[idx].type === 'list_item_close') {
- return '';
- }
-
- return '\n';
-}
-
////////////////////////////////////////////////////////////////////////////////
var rules = {};
@@ -42,14 +17,14 @@ var rules = {};
rules.blockquote_open = function (/* tokens, idx, options, env */) {
return '\n';
};
-rules.blockquote_close = function (tokens, idx /*, options, env */) {
- return '
' + getBreak(tokens, idx);
+rules.blockquote_close = function (/* tokens, idx, options, env */) {
+ return '\n';
};
rules.code = function (tokens, idx /*, options, env */) {
if (tokens[idx].block) {
- return '' + escapeHtml(tokens[idx].content) + '
' + getBreak(tokens, idx);
+ return '' + escapeHtml(tokens[idx].content) + '
\n';
}
return '' + escapeHtml(tokens[idx].content) + '
';
@@ -91,7 +66,7 @@ rules.fence = function (tokens, idx, options, env, self) {
return ''
+ highlighted
- + '
' + getBreak(tokens, idx);
+ + '\n';
};
rules.fence_custom = {};
@@ -105,30 +80,35 @@ rules.heading_close = function (tokens, idx /*, options, env */) {
rules.hr = function (tokens, idx, options /*, env */) {
- return (options.xhtmlOut ? '
' : '
') + getBreak(tokens, idx);
+ return (options.xhtmlOut ? '
\n' : '
\n');
};
rules.bullet_list_open = function (/* tokens, idx, options, env */) {
return '\n';
};
-rules.bullet_list_close = function (tokens, idx /*, options, env */) {
- return '
' + getBreak(tokens, idx);
+rules.bullet_list_close = function (/* tokens, idx, options, env */) {
+ return '\n';
};
-rules.list_item_open = function (/* tokens, idx, options, env */) {
- return '';
+rules.list_item_open = function (tokens, idx /*, options, env */) {
+ var next = tokens[idx + 1];
+ if ((next.type === 'list_item_close') ||
+ (next.type === 'paragraph_open' && next.tight)) {
+ return '';
+ }
+ return '\n';
};
rules.list_item_close = function (/* tokens, idx, options, env */) {
return '\n';
};
rules.ordered_list_open = function (tokens, idx /*, options, env */) {
- var token = tokens[idx];
- return ' 1 ? ' start="' + token.order + '"' : '')
- + '>\n';
+ if (tokens[idx].order > 1) {
+ return '\n';
+ }
+ return '\n';
};
-rules.ordered_list_close = function (tokens, idx /*, options, env */) {
- return '
' + getBreak(tokens, idx);
+rules.ordered_list_close = function (/* tokens, idx, options, env */) {
+ return '
\n';
};
@@ -136,8 +116,21 @@ rules.paragraph_open = function (tokens, idx /*, options, env */) {
return tokens[idx].tight ? '' : '';
};
rules.paragraph_close = function (tokens, idx /*, options, env */) {
- var addBreak = !(tokens[idx].tight && idx && tokens[idx - 1].type === 'inline' && !tokens[idx - 1].content);
- return (tokens[idx].tight ? '' : '
') + (addBreak ? getBreak(tokens, idx) : '');
+ // We have 2 cases of "hidden" paragraphs
+ //
+ // 1. In tight lists
+ // 2. When content was stripped (reference definition, for example)
+ //
+ if (tokens[idx].tight === true) {
+ if (!tokens[idx - 1].content) {
+ return '';
+ }
+ if (tokens[idx + 1].type === 'list_item_close') {
+ return '';
+ }
+ return '\n';
+ }
+ return '
\n';
};
@@ -184,19 +177,19 @@ rules.tr_close = function (/* tokens, idx, options, env */) {
return '\n';
};
rules.th_open = function (tokens, idx /*, options, env */) {
- var token = tokens[idx];
- return '';
+ if (tokens[idx].align) {
+ return ' | ';
+ }
+ return ' | ';
};
rules.th_close = function (/* tokens, idx, options, env */) {
return ' | ';
};
rules.td_open = function (tokens, idx /*, options, env */) {
- var token = tokens[idx];
- return '';
+ if (tokens[idx].align) {
+ return ' | ';
+ }
+ return ' | ';
};
rules.td_close = function (/* tokens, idx, options, env */) {
return ' | ';
@@ -335,8 +328,6 @@ rules.dd_close = function() {
function Renderer() {
// Clone rules object to allow local modifications
this.rules = assign({}, rules);
- // exported helper, for custom rules only
- this.getBreak = getBreak;
}
diff --git a/support/specsplit.js b/support/specsplit.js
index 079eab3..782f1db 100755
--- a/support/specsplit.js
+++ b/support/specsplit.js
@@ -86,7 +86,8 @@ readFile(options.spec, 'utf8', function (error, input) {
bad.push(result);
}
} catch (___) {
- bad.push(result);
+ // bad.push(result);
+ throw ___;
}
});
diff --git a/test/fixtures/commonmark/bad.txt b/test/fixtures/commonmark/bad.txt
index beb8d30..339f872 100644
--- a/test/fixtures/commonmark/bad.txt
+++ b/test/fixtures/commonmark/bad.txt
@@ -1,1213 +1,3 @@
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 468
-
-.
-- Foo
-- * * *
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2530
-
-.
-1. A paragraph
- with two lines.
-
- indented code
-
- > A block quote.
-.
-
--
-
A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-.
-
-error:
-
-
-A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2573
-
-.
-- one
-
- two
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2598
-
-.
- - one
-
- two
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2619
-
-.
- > > 1. one
->>
->> two
-.
-
-
-
--
-
one
-two
-
-
-
-
-.
-
-error:
-
-
-
-
-one
-two
-
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2664
-
-.
-- foo
-
- bar
-
-- foo
-
-
- bar
-
-- ```
- foo
-
-
- bar
- ```
-.
-
-bar
-
-.
-
-error:
-
-
-bar
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2704
-
-.
-1. foo
-
- ```
- bar
- ```
-
- baz
-
- > bam
-.
-
--
-
foo
-bar
-
-baz
-
-bam
-
-
-
-.
-
-error:
-
-
-foo
-bar
-
-baz
-
-bam
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2744
-
-.
-- foo
-
- bar
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2760
-
-.
- 10. foo
-
- bar
-.
-
--
-
foo
-bar
-
-
-
-.
-
-error:
-
-
-foo
-bar
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2792
-
-.
-1. indented code
-
- paragraph
-
- more code
-.
-
--
-
indented code
-
-paragraph
-more code
-
-
-
-.
-
-error:
-
-
-indented code
-
-paragraph
-more code
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2813
-
-.
-1. indented code
-
- paragraph
-
- more code
-.
-
--
-
indented code
-
-paragraph
-more code
-
-
-
-.
-
-error:
-
-
- indented code
-
-paragraph
-more code
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2863
-
-.
-- foo
-
- bar
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2885
-
-.
- 1. A paragraph
- with two lines.
-
- indented code
-
- > A block quote.
-.
-
--
-
A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-.
-
-error:
-
-
-A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2908
-
-.
- 1. A paragraph
- with two lines.
-
- indented code
-
- > A block quote.
-.
-
--
-
A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-.
-
-error:
-
-
-A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2931
-
-.
- 1. A paragraph
- with two lines.
-
- indented code
-
- > A block quote.
-.
-
--
-
A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-.
-
-error:
-
-
-A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2984
-
-.
- 1. A paragraph
-with two lines.
-
- indented code
-
- > A block quote.
-.
-
--
-
A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-.
-
-error:
-
-
-A paragraph
-with two lines.
-indented code
-
-
-A block quote.
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3019
-
-.
-> 1. > Blockquote
-continued here.
-.
-
-
--
-
-Blockquote
-continued here.
-
-
-
-
-.
-
-error:
-
-
-
-
-Blockquote
-continued here.
-
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3035
-
-.
-> 1. > Blockquote
-> continued here.
-.
-
-
--
-
-Blockquote
-continued here.
-
-
-
-
-.
-
-error:
-
-
-
-
-Blockquote
-continued here.
-
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3061
-
-.
-- foo
- - bar
- - baz
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3095
-
-.
-10) foo
- - bar
-.
-
-- foo
-
-
-
-.
-
-error:
-
-
-- foo
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3124
-
-.
-- - foo
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3136
-
-.
-1. - 2. foo
-.
-
--
-
-
-
-.
-
-error:
-
-
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3176
-
-.
-- # Foo
-- Bar
- ---
- baz
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3524
-
-.
-- foo
-
-- bar
-
-
-- baz
-.
-
-
-.
-
-error:
-
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3567
-
-.
-- foo
- - bar
- - baz
-
-
- bim
-.
-
- bim
-
-.
-
-error:
-
-
- bim
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3613
-
-.
-- foo
-
- notcode
-
-- foo
-
-
- code
-.
-
--
-
foo
-notcode
-
--
-
foo
-
-
-code
-
-.
-
-error:
-
-
-code
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3664
-
-.
-- a
-- b
-
-- c
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3685
-
-.
-* a
-*
-
-* c
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3706
-
-.
-- a
-- b
-
- c
-- d
-.
-
--
-
a
-
--
-
b
-c
-
--
-
d
-
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3727
-
-.
-- a
-- b
-
- [ref]: /url
-- d
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3749
-
-.
-- a
-- ```
- b
-
-
- ```
-- c
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3774
-
-.
-- a
- - b
-
- c
-- d
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3797
-
-.
-* a
- > b
- >
-* c
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3816
-
-.
-- a
- > b
- ```
- c
- ```
-- d
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3846
-
-.
-- a
- - b
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3861
-
-.
-* foo
- * bar
-
- baz
-.
-
-.
-
-error:
-
-
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3878
-
-.
-- a
- - b
- - c
-
-- d
- - e
- - f
-.
-
-.
-
-error:
-
-
-
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 4463
diff --git a/test/fixtures/commonmark/good.txt b/test/fixtures/commonmark/good.txt
index 2424e11..c603924 100644
--- a/test/fixtures/commonmark/good.txt
+++ b/test/fixtures/commonmark/good.txt
@@ -239,6 +239,21 @@ src line: 452
.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 468
+
+.
+- Foo
+- * * *
+.
+
+.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 495
@@ -2145,6 +2160,30 @@ with two lines.
.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2530
+
+.
+1. A paragraph
+ with two lines.
+
+ indented code
+
+ > A block quote.
+.
+
+-
+
A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
+
+
+.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2562
@@ -2159,6 +2198,22 @@ src line: 2562
two
.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2573
+
+.
+- one
+
+ two
+.
+
+.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2586
@@ -2174,6 +2229,42 @@ src line: 2586
.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2598
+
+.
+ - one
+
+ two
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2619
+
+.
+ > > 1. one
+>>
+>> two
+.
+
+
+
+-
+
one
+two
+
+
+
+
+.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2645
@@ -2193,225 +2284,659 @@ src line: 2645
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2778
+src line: 2664
.
- indented code
-
-paragraph
+- foo
- more code
-.
-indented code
-
-paragraph
-more code
-
-.
+ bar
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2838
+- foo
-.
- foo
-bar
-.
-foo
-bar
-.
+ bar
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 2847
+- ```
+ foo
-.
-- foo
bar
+ ```
.
-- foo
+-
+
foo
+bar
+
+-
+
foo
+
bar
-.
+
.
- 1. A paragraph
- with two lines.
- indented code
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2704
- > A block quote.
.
-1. A paragraph
- with two lines.
-
- indented code
+1. foo
- > A block quote.
-
-.
+ ```
+ bar
+ ```
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3007
+ baz
-.
- 1. A paragraph
- with two lines.
+ > bam
.
-- A paragraph
-with two lines.
+-
+
foo
+bar
+
+baz
+
+bam
+
+
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3081
+src line: 2744
.
- foo
- - bar
- - baz
+
+ bar
.
-- foo
-- bar
-- baz
+-
+
foo
+bar
+
+
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3110
+src line: 2760
.
-10) foo
- - bar
+ 10. foo
+
+ bar
.
-- foo
+-
+
foo
+bar
+
+
-
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3154
+src line: 2778
.
-- foo
--
-- bar
-.
-
-.
+ indented code
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3166
+paragraph
+ more code
.
--
-.
-
+indented code
+
+paragraph
+more code
+
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3412
+src line: 2792
.
-- foo
-- bar
-+ baz
-.
-
-
-.
+1. indented code
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3426
+ paragraph
-.
-1. foo
-2. bar
-3) baz
+ more code
.
-- foo
-- bar
-
-
-- baz
+-
+
indented code
+
+paragraph
+more code
+
+
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3444
+src line: 2813
.
-Foo
-- bar
-- baz
+1. indented code
+
+ paragraph
+
+ more code
.
-Foo
-
+
+-
+
indented code
+
+paragraph
+more code
+
+
+
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3459
+src line: 2838
.
-The number of windows in my house is
-14. The number of doors is 6.
+ foo
+
+bar
.
-The number of windows in my house is
-
-- The number of doors is 6.
-
+foo
+bar
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3549
+src line: 2847
.
-- foo
-
+- foo
bar
-- baz
.
bar
-
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-src line: 3595
+src line: 2863
.
-- foo
-- bar
-
+- foo
+
+ bar
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2885
+
+.
+ 1. A paragraph
+ with two lines.
+
+ indented code
+
+ > A block quote.
+.
+
+-
+
A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2908
+
+.
+ 1. A paragraph
+ with two lines.
+
+ indented code
+
+ > A block quote.
+.
+
+-
+
A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2931
+
+.
+ 1. A paragraph
+ with two lines.
+
+ indented code
+
+ > A block quote.
+.
+
+-
+
A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2954
+
+.
+ 1. A paragraph
+ with two lines.
+
+ indented code
+
+ > A block quote.
+.
+1. A paragraph
+ with two lines.
+
+ indented code
+
+ > A block quote.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 2984
+
+.
+ 1. A paragraph
+with two lines.
+
+ indented code
+
+ > A block quote.
+.
+
+-
+
A paragraph
+with two lines.
+indented code
+
+
+A block quote.
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3007
+
+.
+ 1. A paragraph
+ with two lines.
+.
+
+- A paragraph
+with two lines.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3019
+
+.
+> 1. > Blockquote
+continued here.
+.
+
+
+-
+
+Blockquote
+continued here.
+
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3035
+
+.
+> 1. > Blockquote
+> continued here.
+.
+
+
+-
+
+Blockquote
+continued here.
+
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3061
+
+.
+- foo
+ - bar
+ - baz
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3081
+
+.
+- foo
+ - bar
+ - baz
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3095
+
+.
+10) foo
+ - bar
+.
+
+- foo
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3110
+
+.
+10) foo
+ - bar
+.
+
+- foo
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3124
+
+.
+- - foo
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3136
+
+.
+1. - 2. foo
+.
+
+-
+
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3154
+
+.
+- foo
+-
+- bar
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3166
+
+.
+-
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3176
+
+.
+- # Foo
+- Bar
+ ---
+ baz
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3412
+
+.
+- foo
+- bar
++ baz
+.
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3426
+
+.
+1. foo
+2. bar
+3) baz
+.
+
+- foo
+- bar
+
+
+- baz
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3444
+
+.
+Foo
+- bar
+- baz
+.
+Foo
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3459
+
+.
+The number of windows in my house is
+14. The number of doors is 6.
+.
+The number of windows in my house is
+
+- The number of doors is 6.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3524
+
+.
+- foo
+
+- bar
+
+
+- baz
+.
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3549
+
+.
+- foo
+
+
+ bar
+- baz
+.
+
+bar
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3567
+
+.
+- foo
+ - bar
+ - baz
+
+
+ bim
+.
+
+ bim
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3595
+
+.
+- foo
+- bar
+
- baz
- bim
@@ -2426,6 +2951,32 @@ src line: 3595
.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3613
+
+.
+- foo
+
+ notcode
+
+- foo
+
+
+ code
+.
+
+-
+
foo
+notcode
+
+-
+
foo
+
+
+code
+
+.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3641
@@ -2449,6 +3000,184 @@ src line: 3641
.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3664
+
+.
+- a
+- b
+
+- c
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3685
+
+.
+* a
+*
+
+* c
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3706
+
+.
+- a
+- b
+
+ c
+- d
+.
+
+-
+
a
+
+-
+
b
+c
+
+-
+
d
+
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3727
+
+.
+- a
+- b
+
+ [ref]: /url
+- d
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3749
+
+.
+- a
+- ```
+ b
+
+
+ ```
+- c
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3774
+
+.
+- a
+ - b
+
+ c
+- d
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3797
+
+.
+* a
+ > b
+ >
+* c
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3816
+
+.
+- a
+ > b
+ ```
+ c
+ ```
+- d
+.
+
+.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3838
@@ -2460,6 +3189,72 @@ src line: 3838
.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3846
+
+.
+- a
+ - b
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3861
+
+.
+* foo
+ * bar
+
+ baz
+.
+
+.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+src line: 3878
+
+.
+- a
+ - b
+ - c
+
+- d
+ - e
+ - f
+.
+
+.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3911
diff --git a/test/fixtures/markdown-it/tables.txt b/test/fixtures/markdown-it/tables.txt
index 6e41515..26363f8 100644
--- a/test/fixtures/markdown-it/tables.txt
+++ b/test/fixtures/markdown-it/tables.txt
@@ -98,7 +98,8 @@ Nested tables inside lists:
baz|baz
.
-
+-
+
foo | foo |
diff --git a/test/misc.js b/test/misc.js
index 6d5a1a2..5ec5e85 100644
--- a/test/misc.js
+++ b/test/misc.js
@@ -219,10 +219,10 @@ describe('Custom fences', function () {
it('should render differently overriden rule', function () {
var md = markdownit();
- md.renderer.rules.fence_custom.foo = function (tokens, idx, options, env, self) {
+ md.renderer.rules.fence_custom.foo = function (tokens, idx /*, options, env */) {
return '' +
md.utils.escapeHtml(tokens[idx].content) +
- '
' + self.getBreak(tokens, idx);
+ '\n';
};
var text = '```foo bar\n' +