test: fix tests

This commit is contained in:
Estevao Soares dos Santos 2017-12-23 13:20:14 +00:00
parent 13ba2675fe
commit 173ad51b05
28 changed files with 129 additions and 43 deletions

View File

@ -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;
}

View File

@ -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");
> ```

View File

@ -1,3 +1,3 @@
> This is a multi line blockquote test
>
>
> With more than one line.

View File

@ -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>

View File

@ -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

View File

@ -1,5 +1,6 @@
<pre><code>function MyFunc(a) {
<pre><code>
function MyFunc(a) {
// ...
}
}
</code></pre>
<p>That is some code!</p>

View File

@ -1,6 +1,6 @@
```
function MyFunc(a) {
// ...
// ...
}
```

View File

@ -1,13 +1,13 @@
> Define a function in javascript:
>
>
> ```
> function MyFunc(a) {
> var s = '`';
> }
> ```
>
>
> > And some nested quote
> >
> >
> > ```html
> > <div>HTML!</div>
> > ```

View File

@ -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">&lt;div&gt;HTML!&lt;/div&gt;

View File

@ -15,6 +15,6 @@ And some HTML
```javascript
function foo() {
return 'bar';
return 'bar';
}
```

View File

@ -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>

View File

@ -0,0 +1,2 @@
<hr />
<hr>

View File

@ -0,0 +1,3 @@
---
---

View File

@ -0,0 +1,4 @@
<ul>
<li><p>Bird</p></li>
<li><p>Magic</p></li>
</ul>

View File

@ -0,0 +1,3 @@
- Bird
- Magic

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -0,0 +1,3 @@
- A list item with a blockquote:
> This is a blockquote inside a list item.

View File

@ -0,0 +1,5 @@
<ul>
<li><p>A list item with code:</p>
<pre><code>alert('Hello world!');
</code></pre></li>
</ul>

View File

@ -0,0 +1,5 @@
- A list item with code:
```
alert('Hello world!');
```

View File

@ -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>

View File

@ -0,0 +1,5 @@
1. This is a major bullet point.
That contains multiple paragraphs.
2. And another line

View File

@ -1,3 +1,3 @@
1. Red
2. Green
3. Blue
1. Red
2. Green
3. Blue

View File

@ -1,13 +1,13 @@
- foo
- foo
- bazinga
- yeah
- bar
- bar
1. damn
2. so many paragraphs
- baz
- baz

View File

@ -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;
}