forked from showdownjs/showdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also refactor tests to improve maintainability
- Loading branch information
Showing
216 changed files
with
680 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* Created by Estevao on 08-06-2015. | ||
*/ | ||
|
||
//jscs:disable requireCamelCaseOrUpperCaseIdentifiers | ||
require('source-map-support').install(); | ||
require('chai').should(); | ||
var fs = require('fs'), | ||
os = require('os'), | ||
beautify = require('js-beautify').html_beautify, | ||
beauOptions = { | ||
eol: os.EOL, | ||
indent_size: 2, | ||
preserve_newlines: false | ||
}; | ||
|
||
function getTestSuite(dir) { | ||
return fs.readdirSync(dir) | ||
.filter(filter()) | ||
.map(map(dir)); | ||
} | ||
|
||
function filter() { | ||
return function (file) { | ||
var ext = file.slice(-3); | ||
return (ext === '.md'); | ||
}; | ||
} | ||
|
||
function map(dir) { | ||
return function (file) { | ||
var name = file.replace('.md', ''), | ||
htmlPath = dir + name + '.html', | ||
html = fs.readFileSync(htmlPath, 'utf8'), | ||
mdPath = dir + name + '.md', | ||
md = fs.readFileSync(mdPath, 'utf8'); | ||
|
||
return { | ||
name: name, | ||
input: md, | ||
expected: html | ||
}; | ||
}; | ||
} | ||
|
||
function assertion(testCase, converter) { | ||
return function () { | ||
testCase.actual = converter.makeHtml(testCase.input); | ||
testCase = normalize(testCase); | ||
|
||
// Compare | ||
testCase.actual.should.equal(testCase.expected); | ||
}; | ||
} | ||
|
||
//Normalize input/output | ||
function normalize(testCase) { | ||
|
||
// 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'); | ||
|
||
// 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(); | ||
|
||
//Beautify | ||
testCase.expected = beautify(testCase.expected, beauOptions); | ||
testCase.actual = beautify(testCase.actual, beauOptions); | ||
|
||
// Normalize line returns | ||
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, os.EOL); | ||
testCase.actual = testCase.actual.replace(/(\r\n)|\n|\r/g, os.EOL); | ||
|
||
return testCase; | ||
} | ||
|
||
module.exports = { | ||
getTestSuite: getTestSuite, | ||
assertion: assertion | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p>This is a first paragraph, | ||
on multiple lines.</p> | ||
|
||
<p>This is a second paragraph. | ||
There are spaces in between the two.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This is a first paragraph, | ||
on multiple lines. | ||
|
||
This is a second paragraph. | ||
There are spaces in between the two. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p>This is a first paragraph, | ||
on multiple lines.</p> | ||
|
||
<p>This is a second paragraph | ||
which has multiple lines too.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This is a first paragraph, | ||
on multiple lines. | ||
|
||
This is a second paragraph | ||
which has multiple lines too. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>A first paragraph.</p> | ||
|
||
<p>A second paragraph after 3 CR (carriage return).</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
A first paragraph. | ||
|
||
|
||
|
||
A second paragraph after 3 CR (carriage return). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph on 1 line.</p> | ||
|
||
<p>A few spaces and a new long long long long long long long long long long long long long long long long paragraph on 1 line.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph on 1 line. | ||
|
||
A few spaces and a new long long long long long long long long long long long long long long long long paragraph on 1 line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph on 1 line.</p> | ||
|
||
<p>1 tab to separate them and a new long long long long long long long long long long long long long long long long paragraph on 1 line.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph on 1 line. | ||
|
||
1 tab to separate them and a new long long long long long long long long long long long long long long long long paragraph on 1 line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph on 1 line.</p> | ||
|
||
<p>A new long long long long long long long long long long long long long long long long paragraph on 1 line.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph on 1 line. | ||
|
||
A new long long long long long long long long long long long long long long long long paragraph on 1 line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p>These lines all end with end of line (EOL) sequences.</p> | ||
|
||
<p>Seriously, they really do.</p> | ||
|
||
<p>If you don't believe me: HEX EDIT!</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
These lines all end with end of line (EOL) sequences. | ||
|
||
Seriously, they really do. | ||
|
||
If you don't believe me: HEX EDIT! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
These lines all end with end of line (EOL) sequences.Seriously, they really do.If you don't believe me: HEX EDIT! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p>These lines all end with end of line (EOL) sequences.</p> | ||
|
||
<p>Seriously, they really do.</p> | ||
|
||
<p>If you don't believe me: HEX EDIT!</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
These lines all end with end of line (EOL) sequences. | ||
|
||
Seriously, they really do. | ||
|
||
If you don't believe me: HEX EDIT! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>An ampersand & in the text flow is escaped as an html entity.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
An ampersand & in the text flow is escaped as an html entity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>There is an <a href="http://validator.w3.org/check?uri=http://www.w3.org/&verbose=1">ampersand</a> in the URI.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
There is an [ampersand](http://validator.w3.org/check?uri=http://www.w3.org/&verbose=1) in the URI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>This is *an asterisk which should stay as is.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is \*an asterisk which should stay as is. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>This is * an asterisk which should stay as is.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is * an asterisk which should stay as is. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<p>\ backslash | ||
` backtick | ||
* asterisk | ||
_ underscore | ||
{} curly braces | ||
[] square brackets | ||
() parentheses | ||
# hash mark | ||
+ plus sign | ||
- minus sign (hyphen) | ||
. dot | ||
! exclamation mark</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
\\ backslash | ||
\` backtick | ||
\* asterisk | ||
\_ underscore | ||
\{\} curly braces | ||
\[\] square brackets | ||
\(\) parentheses | ||
\# hash mark | ||
\+ plus sign | ||
\- minus sign (hyphen) | ||
\. dot | ||
\! exclamation mark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<blockquote> | ||
<h1>heading level 1</h1> | ||
|
||
<p>paragraph</p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
> # heading level 1 | ||
> | ||
> paragraph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<blockquote> | ||
<p>A blockquote with a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long line.</p> | ||
|
||
<p>and a second very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long line.</p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
>A blockquote with a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long line. | ||
>and a second very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<blockquote> | ||
<p>This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph in a blockquote.</p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
>This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph in a blockquote. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<blockquote> | ||
<p>A blockquote | ||
on multiple lines | ||
like this.</p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
> A blockquote | ||
> on multiple lines | ||
> like this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<blockquote> | ||
<p>A blockquote | ||
on multiple lines | ||
like this. </p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
>A blockquote | ||
>on multiple lines | ||
>like this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<blockquote> | ||
<p>A blockquote | ||
on multiple lines | ||
like this.</p> | ||
|
||
<p>But it has | ||
two paragraphs.</p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
>A blockquote | ||
>on multiple lines | ||
>like this. | ||
> | ||
>But it has | ||
>two paragraphs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<blockquote> | ||
<p>A blockquote | ||
on multiple lines | ||
like this</p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
>A blockquote | ||
>on multiple lines | ||
>like this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<blockquote> | ||
<p>This is the first level of quoting.</p> | ||
|
||
<blockquote> | ||
<p>This is nested blockquote.</p> | ||
</blockquote> | ||
|
||
<p>Back to the first level.</p> | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
> This is the first level of quoting. | ||
> | ||
> > This is nested blockquote. | ||
> | ||
> Back to the first level. |
Oops, something went wrong.