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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
> ## This is a header.
|
||||
>
|
||||
>
|
||||
> 1. This is the first list item.
|
||||
> 2. This is the second list item.
|
||||
>
|
||||
>
|
||||
> Here's some example code:
|
||||
>
|
||||
>
|
||||
> ```
|
||||
> return shell_exec("echo $input | $markdown_script");
|
||||
> ```
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
> This is a multi line blockquote test
|
||||
>
|
||||
>
|
||||
> With more than one line.
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
\[a false reference]: must be escaped
|
||||
|
||||
\- a list item
|
||||
\- a list item
|
||||
|
||||
\*
|
||||
|
||||
|
@ -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,5 +1,6 @@
|
|||
<pre><code>function MyFunc(a) {
|
||||
<pre><code>
|
||||
function MyFunc(a) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<p>That is some code!</p>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
function MyFunc(a) {
|
||||
// ...
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
> Define a function in javascript:
|
||||
>
|
||||
>
|
||||
> ```
|
||||
> function MyFunc(a) {
|
||||
> var s = '`';
|
||||
> }
|
||||
> ```
|
||||
>
|
||||
>
|
||||
> > And some nested quote
|
||||
> >
|
||||
> >
|
||||
> > ```html
|
||||
> > <div>HTML!</div>
|
||||
> > ```
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<p>Define a function in javascript:</p>
|
||||
<pre><code>function MyFunc(a) {
|
||||
var s = '`';
|
||||
}
|
||||
var s = '`';
|
||||
}
|
||||
</code></pre>
|
||||
<p>And some HTML</p>
|
||||
<pre><code class="html language-html"><div>HTML!</div>
|
||||
|
|
|
@ -15,6 +15,6 @@ And some HTML
|
|||
|
||||
```javascript
|
||||
function foo() {
|
||||
return 'bar';
|
||||
return 'bar';
|
||||
}
|
||||
```
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<pre><code>code can go here
|
||||
this is rendered on a second line
|
||||
this is rendered on a second line
|
||||
</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
|
||||
2. Green
|
||||
3. Blue
|
||||
1. Red
|
||||
2. Green
|
||||
3. Blue
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
- foo
|
||||
|
||||
- foo
|
||||
|
||||
- bazinga
|
||||
|
||||
|
||||
- yeah
|
||||
|
||||
- bar
|
||||
|
||||
|
||||
- bar
|
||||
|
||||
1. damn
|
||||
|
||||
|
||||
2. so many paragraphs
|
||||
|
||||
- baz
|
||||
|
||||
- baz
|
||||
|
|
|
@ -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