mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
test: fix tests
This commit is contained in:
parent
13ba2675fe
commit
173ad51b05
|
@ -491,6 +491,9 @@ showdown.Converter = function (converterOptions) {
|
|||
txt = node.outerHTML + '\n\n';
|
||||
}
|
||||
|
||||
// common normalization
|
||||
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
@ -500,6 +503,7 @@ showdown.Converter = function (converterOptions) {
|
|||
// multiple spaces are collapsed
|
||||
txt = txt.replace(/ +/g, ' ');
|
||||
|
||||
// replace the custom ¨NBSP; with a space
|
||||
txt = txt.replace(/¨NBSP;/g, ' ');
|
||||
|
||||
// ", <, > and & should replace escaped html entities
|
||||
|
@ -723,6 +727,10 @@ showdown.Converter = function (converterOptions) {
|
|||
txt += parseNode(children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// some text normalization
|
||||
txt = txt.trim();
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
<p>but. this should not</p>
|
||||
<p>. nor this</p>
|
||||
<p>or this.</p>
|
||||
<p> four ate the beginning of line are removed</p>
|
||||
<p> 4 spaces at the beginning of line are removed</p>
|
||||
<p>multiple spaces are colapsed to 1</p>
|
||||
|
|
|
@ -28,6 +28,6 @@ but. this should not
|
|||
|
||||
or this.
|
||||
|
||||
four ate the beginning of line are removed
|
||||
4 spaces at the beginning of line are removed
|
||||
|
||||
multiple spaces are colapsed to 1
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<pre><code>function MyFunc(a) {
|
||||
<pre><code>
|
||||
function MyFunc(a) {
|
||||
// ...
|
||||
}
|
||||
</code></pre>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<hr />
|
||||
<hr>
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
|
||||
---
|
|
@ -0,0 +1,4 @@
|
|||
<ul>
|
||||
<li><p>Bird</p></li>
|
||||
<li><p>Magic</p></li>
|
||||
</ul>
|
|
@ -0,0 +1,3 @@
|
|||
- Bird
|
||||
|
||||
- Magic
|
|
@ -0,0 +1,12 @@
|
|||
<h1 id="sometitle">some title</h1>
|
||||
<ol>
|
||||
<li>list item 1</li>
|
||||
<li>list item 2</li>
|
||||
</ol>
|
||||
<blockquote>
|
||||
<p>some text in a blockquote</p>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>another list item 1</li>
|
||||
<li>another list item 2</li>
|
||||
</ul>
|
|
@ -0,0 +1,9 @@
|
|||
# some title
|
||||
|
||||
1. list item 1
|
||||
2. list item 2
|
||||
|
||||
> some text in a blockquote
|
||||
|
||||
- another list item 1
|
||||
- another list item 2
|
|
@ -0,0 +1,13 @@
|
|||
<h1 id="sometitle">some title</h1>
|
||||
<ol>
|
||||
<li>list item 1</li>
|
||||
<li>list item 2</li>
|
||||
</ol>
|
||||
<pre><code>some code
|
||||
|
||||
and some other line of code
|
||||
</code></pre>
|
||||
<ul>
|
||||
<li>another list item 1</li>
|
||||
<li>another list item 2</li>
|
||||
</ul>
|
|
@ -0,0 +1,13 @@
|
|||
# some title
|
||||
|
||||
1. list item 1
|
||||
2. list item 2
|
||||
|
||||
```
|
||||
some code
|
||||
|
||||
and some other line of code
|
||||
```
|
||||
|
||||
- another list item 1
|
||||
- another list item 2
|
|
@ -0,0 +1,7 @@
|
|||
<ul>
|
||||
<li><p>A list item with a blockquote:</p>
|
||||
<blockquote>
|
||||
<p>This is a blockquote
|
||||
inside a list item.</p>
|
||||
</blockquote></li>
|
||||
</ul>
|
|
@ -0,0 +1,3 @@
|
|||
- A list item with a blockquote:
|
||||
|
||||
> This is a blockquote inside a list item.
|
|
@ -0,0 +1,5 @@
|
|||
<ul>
|
||||
<li><p>A list item with code:</p>
|
||||
<pre><code>alert('Hello world!');
|
||||
</code></pre></li>
|
||||
</ul>
|
|
@ -0,0 +1,5 @@
|
|||
- A list item with code:
|
||||
|
||||
```
|
||||
alert('Hello world!');
|
||||
```
|
|
@ -0,0 +1,5 @@
|
|||
<ol>
|
||||
<li><p>This is a major bullet point.</p>
|
||||
<p>That contains multiple paragraphs.</p></li>
|
||||
<li><p>And another line</p></li>
|
||||
</ol>
|
|
@ -0,0 +1,5 @@
|
|||
1. This is a major bullet point.
|
||||
|
||||
That contains multiple paragraphs.
|
||||
|
||||
2. And another line
|
|
@ -56,21 +56,9 @@
|
|||
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
|
||||
testCase.actual = testCase.actual.replace(/(\r\n)|\n|\r/g, '\n');
|
||||
|
||||
// Ignore all leading/trailing whitespace
|
||||
testCase.expected = testCase.expected.split('\n').map(function (x) {
|
||||
return x.trim();
|
||||
}).join('\n');
|
||||
testCase.actual = testCase.actual.split('\n').map(function (x) {
|
||||
return x.trim();
|
||||
}).join('\n');
|
||||
|
||||
// Remove extra lines
|
||||
testCase.expected = testCase.expected.trim();
|
||||
testCase.actual = testCase.actual.trim();
|
||||
|
||||
// Normalize line returns
|
||||
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
|
||||
testCase.actual = testCase.actual.replace(/(\r\n)|\n|\r/g, '\n');
|
||||
testCase.expected = testCase.expected.replace(/^\n+/, '').replace(/\n+$/, '');
|
||||
testCase.actual = testCase.actual.replace(/^\n+/, '').replace(/\n+$/, '');
|
||||
|
||||
return testCase;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user