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';
|
txt = node.outerHTML + '\n\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// common normalization
|
||||||
|
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +503,7 @@ showdown.Converter = function (converterOptions) {
|
||||||
// multiple spaces are collapsed
|
// multiple spaces are collapsed
|
||||||
txt = txt.replace(/ +/g, ' ');
|
txt = txt.replace(/ +/g, ' ');
|
||||||
|
|
||||||
|
// replace the custom ¨NBSP; with a space
|
||||||
txt = txt.replace(/¨NBSP;/g, ' ');
|
txt = txt.replace(/¨NBSP;/g, ' ');
|
||||||
|
|
||||||
// ", <, > and & should replace escaped html entities
|
// ", <, > and & should replace escaped html entities
|
||||||
|
@ -723,6 +727,10 @@ showdown.Converter = function (converterOptions) {
|
||||||
txt += parseNode(children[i]);
|
txt += parseNode(children[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// some text normalization
|
||||||
|
txt = txt.trim();
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,5 +13,5 @@
|
||||||
<p>but. this should not</p>
|
<p>but. this should not</p>
|
||||||
<p>. nor this</p>
|
<p>. nor this</p>
|
||||||
<p>or 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>
|
<p>multiple spaces are colapsed to 1</p>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
\[a false reference]: must be escaped
|
\[a false reference]: must be escaped
|
||||||
|
|
||||||
\- a list item
|
\- a list item
|
||||||
|
|
||||||
\*
|
\*
|
||||||
|
|
||||||
|
@ -28,6 +28,6 @@ but. this should not
|
||||||
|
|
||||||
or this.
|
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
|
multiple spaces are colapsed to 1
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<pre><code>function MyFunc(a) {
|
<pre><code>
|
||||||
|
function MyFunc(a) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<p>That is some code!</p>
|
<p>That is some code!</p>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<p>Define a function in javascript:</p>
|
<p>Define a function in javascript:</p>
|
||||||
<pre><code>function MyFunc(a) {
|
<pre><code>function MyFunc(a) {
|
||||||
var s = '`';
|
var s = '`';
|
||||||
}
|
}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<p>And some HTML</p>
|
<p>And some HTML</p>
|
||||||
<pre><code class="html language-html"><div>HTML!</div>
|
<pre><code class="html language-html"><div>HTML!</div>
|
||||||
|
|
|
@ -15,6 +15,6 @@ And some HTML
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function foo() {
|
function foo() {
|
||||||
return 'bar';
|
return 'bar';
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<pre><code>code can go here
|
<pre><code>code can go here
|
||||||
this is rendered on a second line
|
this is rendered on a second line
|
||||||
</code></pre>
|
</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
|
|
@ -1,3 +1,3 @@
|
||||||
1. Red
|
1. Red
|
||||||
2. Green
|
2. Green
|
||||||
3. Blue
|
3. Blue
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
- foo
|
- foo
|
||||||
|
|
||||||
- bazinga
|
- bazinga
|
||||||
|
|
||||||
- yeah
|
- yeah
|
||||||
|
|
||||||
- bar
|
- bar
|
||||||
|
|
||||||
1. damn
|
1. damn
|
||||||
|
|
||||||
2. so many paragraphs
|
2. so many paragraphs
|
||||||
|
|
||||||
- baz
|
- baz
|
||||||
|
|
|
@ -56,21 +56,9 @@
|
||||||
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
|
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
|
||||||
testCase.actual = testCase.actual.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
|
// Remove extra lines
|
||||||
testCase.expected = testCase.expected.trim();
|
testCase.expected = testCase.expected.replace(/^\n+/, '').replace(/\n+$/, '');
|
||||||
testCase.actual = testCase.actual.trim();
|
testCase.actual = testCase.actual.replace(/^\n+/, '').replace(/\n+$/, '');
|
||||||
|
|
||||||
// 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');
|
|
||||||
|
|
||||||
return testCase;
|
return testCase;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user