diff --git a/package.json b/package.json index 86648af..71b1d46 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,10 @@ "type": "git", "url": "https://github.com/coreyti/showdown.git" }, + "devDependencies": { + "mocha": "*", + "should": "*" + }, "licenses": [{ "type": "BSD" }], "main": "./src/showdown" } diff --git a/test/cases/anchors-by-reference.html b/test/cases/anchors-by-reference.html new file mode 100644 index 0000000..9265274 --- /dev/null +++ b/test/cases/anchors-by-reference.html @@ -0,0 +1,5 @@ + +

This is an example reference-style link. +This is another reference-style link. +This is a third reference-style link. +This is a fourth reference-style link.

\ No newline at end of file diff --git a/test/cases/anchors-by-reference.md b/test/cases/anchors-by-reference.md new file mode 100644 index 0000000..522f961 --- /dev/null +++ b/test/cases/anchors-by-reference.md @@ -0,0 +1,11 @@ + +This is [an example][id] reference-style link. +This is [another] [foo] reference-style link. +This is [a third][bar] reference-style link. +This is [a fourth][4] reference-style link. + + [id]: http://example.com/ "Optional Title Here" + [foo]: http://example.com/ (Optional Title Here) + [bar]: http://example.com/ (Optional Title Here) + [4]: + "Optional Title Here" \ No newline at end of file diff --git a/test/cases/automatic-anchors.html b/test/cases/automatic-anchors.html new file mode 100644 index 0000000..8d32215 --- /dev/null +++ b/test/cases/automatic-anchors.html @@ -0,0 +1,2 @@ + +

http://example.com/

\ No newline at end of file diff --git a/test/cases/automatic-anchors.md b/test/cases/automatic-anchors.md new file mode 100644 index 0000000..a430e77 --- /dev/null +++ b/test/cases/automatic-anchors.md @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/test/cases/blockquote-nested-markdown.html b/test/cases/blockquote-nested-markdown.html new file mode 100644 index 0000000..25800d7 --- /dev/null +++ b/test/cases/blockquote-nested-markdown.html @@ -0,0 +1,13 @@ +
+

This is a header.

+ +
    +
  1. This is the first list item.
  2. +
  3. This is the second list item.
  4. +
+ +

Here's some example code:

+ +
return shell_exec("echo $input | $markdown_script");
+    
+
diff --git a/test/cases/blockquote-nested-markdown.md b/test/cases/blockquote-nested-markdown.md new file mode 100644 index 0000000..b0d102e --- /dev/null +++ b/test/cases/blockquote-nested-markdown.md @@ -0,0 +1,8 @@ +> ## 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"); \ No newline at end of file diff --git a/test/cases/blockquote.html b/test/cases/blockquote.html new file mode 100644 index 0000000..c31f284 --- /dev/null +++ b/test/cases/blockquote.html @@ -0,0 +1,5 @@ +
+

This is a multi line blockquote test

+ +

With more than one line.

+
\ No newline at end of file diff --git a/test/cases/blockquote.md b/test/cases/blockquote.md new file mode 100644 index 0000000..4d40995 --- /dev/null +++ b/test/cases/blockquote.md @@ -0,0 +1,4 @@ + + > This is a multi line blockquote test + > + > With more than one line. \ No newline at end of file diff --git a/test/cases/code-block-html-escape.html b/test/cases/code-block-html-escape.html new file mode 100644 index 0000000..123e4f3 --- /dev/null +++ b/test/cases/code-block-html-escape.html @@ -0,0 +1,5 @@ + +

This is some HTML:

+ +
<h1>Heading</h1>
+
\ No newline at end of file diff --git a/test/cases/code-block-html-escape.md b/test/cases/code-block-html-escape.md new file mode 100644 index 0000000..3f6bc3e --- /dev/null +++ b/test/cases/code-block-html-escape.md @@ -0,0 +1,4 @@ + +This is some HTML: + +

Heading

\ No newline at end of file diff --git a/test/cases/code-block.html b/test/cases/code-block.html new file mode 100644 index 0000000..bdb50b4 --- /dev/null +++ b/test/cases/code-block.html @@ -0,0 +1,5 @@ + +

This is a normal paragraph:

+ +
This is a code block.
+
\ No newline at end of file diff --git a/test/cases/code-block.md b/test/cases/code-block.md new file mode 100644 index 0000000..adfac54 --- /dev/null +++ b/test/cases/code-block.md @@ -0,0 +1,4 @@ + +This is a normal paragraph: + + This is a code block. \ No newline at end of file diff --git a/test/cases/doubline-list.html b/test/cases/doubline-list.html new file mode 100644 index 0000000..da41237 --- /dev/null +++ b/test/cases/doubline-list.html @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/test/cases/doubline-list.md b/test/cases/doubline-list.md new file mode 100644 index 0000000..764998c --- /dev/null +++ b/test/cases/doubline-list.md @@ -0,0 +1,4 @@ + + * Bird + + * Magic \ No newline at end of file diff --git a/test/cases/emphasis.html b/test/cases/emphasis.html new file mode 100644 index 0000000..056fdea --- /dev/null +++ b/test/cases/emphasis.html @@ -0,0 +1,8 @@ + +

important

+ +

important

+ +

this midimportantsentence

+ +

*not important*

\ No newline at end of file diff --git a/test/cases/emphasis.md b/test/cases/emphasis.md new file mode 100644 index 0000000..0e70802 --- /dev/null +++ b/test/cases/emphasis.md @@ -0,0 +1,8 @@ + +*important* + +_important_ + +this mid*important*sentence + +\*not important\* \ No newline at end of file diff --git a/test/cases/escaped-number-period.html b/test/cases/escaped-number-period.html new file mode 100644 index 0000000..f773d21 --- /dev/null +++ b/test/cases/escaped-number-period.html @@ -0,0 +1 @@ +

It happened in 1986. What a great season.

\ No newline at end of file diff --git a/test/cases/escaped-number-period.md b/test/cases/escaped-number-period.md new file mode 100644 index 0000000..d321a38 --- /dev/null +++ b/test/cases/escaped-number-period.md @@ -0,0 +1 @@ +It happened in 1986\. What a great season. \ No newline at end of file diff --git a/test/cases/escaping.html b/test/cases/escaping.html new file mode 100644 index 0000000..671a2a6 --- /dev/null +++ b/test/cases/escaping.html @@ -0,0 +1,32 @@ + +

These should all be escaped:

+ +

\

+ +

`

+ +

*

+ +

_

+ +

{

+ +

}

+ +

[

+ +

]

+ +

(

+ +

)

+ +

#

+ +

+

+ +

-

+ +

.

+ +

!

\ No newline at end of file diff --git a/test/cases/escaping.md b/test/cases/escaping.md new file mode 100644 index 0000000..ea017af --- /dev/null +++ b/test/cases/escaping.md @@ -0,0 +1,32 @@ + +These should all be escaped: + +\\ + +\` + +\* + +\_ + +\{ + +\} + +\[ + +\] + +\( + +\) + +\# + +\+ + +\- + +\. + +\! \ No newline at end of file diff --git a/test/cases/github-style-codeblock.html b/test/cases/github-style-codeblock.html new file mode 100644 index 0000000..8a5db9b --- /dev/null +++ b/test/cases/github-style-codeblock.html @@ -0,0 +1,13 @@ + + +

Define a function in javascript:

+ +
function MyFunc(a) {
+    // ...
+}
+
+ +And some HTML + +
<div>HTML!</div>
+
\ No newline at end of file diff --git a/test/cases/github-style-codeblock.md b/test/cases/github-style-codeblock.md new file mode 100644 index 0000000..5c59c1d --- /dev/null +++ b/test/cases/github-style-codeblock.md @@ -0,0 +1,14 @@ + +Define a function in javascript: + +``` +function MyFunc(a) { + // ... +} +``` + +And some HTML + +```html +
HTML!
+``` \ No newline at end of file diff --git a/test/cases/h1-with-double-hash.html b/test/cases/h1-with-double-hash.html new file mode 100644 index 0000000..2cecc38 --- /dev/null +++ b/test/cases/h1-with-double-hash.html @@ -0,0 +1 @@ +

This is an H1

\ No newline at end of file diff --git a/test/cases/h1-with-double-hash.md b/test/cases/h1-with-double-hash.md new file mode 100644 index 0000000..147d59b --- /dev/null +++ b/test/cases/h1-with-double-hash.md @@ -0,0 +1 @@ +# This is an H1 # \ No newline at end of file diff --git a/test/cases/h1-with-equals.html b/test/cases/h1-with-equals.html new file mode 100644 index 0000000..2cecc38 --- /dev/null +++ b/test/cases/h1-with-equals.html @@ -0,0 +1 @@ +

This is an H1

\ No newline at end of file diff --git a/test/cases/h1-with-equals.md b/test/cases/h1-with-equals.md new file mode 100644 index 0000000..f18b949 --- /dev/null +++ b/test/cases/h1-with-equals.md @@ -0,0 +1,2 @@ +This is an H1 +============= \ No newline at end of file diff --git a/test/cases/h1-with-single-hash.html b/test/cases/h1-with-single-hash.html new file mode 100644 index 0000000..2cecc38 --- /dev/null +++ b/test/cases/h1-with-single-hash.html @@ -0,0 +1 @@ +

This is an H1

\ No newline at end of file diff --git a/test/cases/h1-with-single-hash.md b/test/cases/h1-with-single-hash.md new file mode 100644 index 0000000..f6a39e1 --- /dev/null +++ b/test/cases/h1-with-single-hash.md @@ -0,0 +1 @@ +# This is an H1 \ No newline at end of file diff --git a/test/cases/h2-with-dashes.html b/test/cases/h2-with-dashes.html new file mode 100644 index 0000000..d040d75 --- /dev/null +++ b/test/cases/h2-with-dashes.html @@ -0,0 +1 @@ +

This is an H2

\ No newline at end of file diff --git a/test/cases/h2-with-dashes.md b/test/cases/h2-with-dashes.md new file mode 100644 index 0000000..4564336 --- /dev/null +++ b/test/cases/h2-with-dashes.md @@ -0,0 +1,2 @@ +This is an H2 +------------- \ No newline at end of file diff --git a/test/cases/h2-with-double-hash.html b/test/cases/h2-with-double-hash.html new file mode 100644 index 0000000..d040d75 --- /dev/null +++ b/test/cases/h2-with-double-hash.html @@ -0,0 +1 @@ +

This is an H2

\ No newline at end of file diff --git a/test/cases/h2-with-double-hash.md b/test/cases/h2-with-double-hash.md new file mode 100644 index 0000000..b84a1de --- /dev/null +++ b/test/cases/h2-with-double-hash.md @@ -0,0 +1 @@ +## This is an H2 ## \ No newline at end of file diff --git a/test/cases/h2-with-single-hash.html b/test/cases/h2-with-single-hash.html new file mode 100644 index 0000000..d040d75 --- /dev/null +++ b/test/cases/h2-with-single-hash.html @@ -0,0 +1 @@ +

This is an H2

\ No newline at end of file diff --git a/test/cases/h2-with-single-hash.md b/test/cases/h2-with-single-hash.md new file mode 100644 index 0000000..6a93c6b --- /dev/null +++ b/test/cases/h2-with-single-hash.md @@ -0,0 +1 @@ +## This is an H2 \ No newline at end of file diff --git a/test/cases/h3-with-double-hash.html b/test/cases/h3-with-double-hash.html new file mode 100644 index 0000000..082318e --- /dev/null +++ b/test/cases/h3-with-double-hash.html @@ -0,0 +1 @@ +

This is an H3

\ No newline at end of file diff --git a/test/cases/h3-with-double-hash.md b/test/cases/h3-with-double-hash.md new file mode 100644 index 0000000..7d790cf --- /dev/null +++ b/test/cases/h3-with-double-hash.md @@ -0,0 +1 @@ +### This is an H3 ### \ No newline at end of file diff --git a/test/cases/h3-with-single-hash.html b/test/cases/h3-with-single-hash.html new file mode 100644 index 0000000..082318e --- /dev/null +++ b/test/cases/h3-with-single-hash.html @@ -0,0 +1 @@ +

This is an H3

\ No newline at end of file diff --git a/test/cases/h3-with-single-hash.md b/test/cases/h3-with-single-hash.md new file mode 100644 index 0000000..70c6d10 --- /dev/null +++ b/test/cases/h3-with-single-hash.md @@ -0,0 +1 @@ +### This is an H3 \ No newline at end of file diff --git a/test/cases/h4-with-single-hash.html b/test/cases/h4-with-single-hash.html new file mode 100644 index 0000000..cc32aa1 --- /dev/null +++ b/test/cases/h4-with-single-hash.html @@ -0,0 +1 @@ +

This is an H4

\ No newline at end of file diff --git a/test/cases/h4-with-single-hash.md b/test/cases/h4-with-single-hash.md new file mode 100644 index 0000000..8283f11 --- /dev/null +++ b/test/cases/h4-with-single-hash.md @@ -0,0 +1 @@ +#### This is an H4 \ No newline at end of file diff --git a/test/cases/h5-with-single-hash.html b/test/cases/h5-with-single-hash.html new file mode 100644 index 0000000..96dca78 --- /dev/null +++ b/test/cases/h5-with-single-hash.html @@ -0,0 +1 @@ +
This is an H5
\ No newline at end of file diff --git a/test/cases/h5-with-single-hash.md b/test/cases/h5-with-single-hash.md new file mode 100644 index 0000000..abcdd91 --- /dev/null +++ b/test/cases/h5-with-single-hash.md @@ -0,0 +1 @@ +##### This is an H5 \ No newline at end of file diff --git a/test/cases/h6-with-single-hash.html b/test/cases/h6-with-single-hash.html new file mode 100644 index 0000000..10de690 --- /dev/null +++ b/test/cases/h6-with-single-hash.html @@ -0,0 +1 @@ +
This is an H6
\ No newline at end of file diff --git a/test/cases/h6-with-single-hash.md b/test/cases/h6-with-single-hash.md new file mode 100644 index 0000000..df2ff4c --- /dev/null +++ b/test/cases/h6-with-single-hash.md @@ -0,0 +1 @@ +###### This is an H6 \ No newline at end of file diff --git a/test/cases/horizontal-rules.html b/test/cases/horizontal-rules.html new file mode 100644 index 0000000..88eb5de --- /dev/null +++ b/test/cases/horizontal-rules.html @@ -0,0 +1,10 @@ + +
+ +
+ +
+ +
+ +
\ No newline at end of file diff --git a/test/cases/horizontal-rules.md b/test/cases/horizontal-rules.md new file mode 100644 index 0000000..6a45ca1 --- /dev/null +++ b/test/cases/horizontal-rules.md @@ -0,0 +1,10 @@ + +* * * + +*** + +***** + +- - - + +--------------------------------------- diff --git a/test/cases/images.html b/test/cases/images.html new file mode 100644 index 0000000..f214ba1 --- /dev/null +++ b/test/cases/images.html @@ -0,0 +1,6 @@ + +

Alt text

+ +

Alt text

+ +

Alt text

\ No newline at end of file diff --git a/test/cases/images.md b/test/cases/images.md new file mode 100644 index 0000000..81ecfbf --- /dev/null +++ b/test/cases/images.md @@ -0,0 +1,8 @@ + +![Alt text](/path/to/img.jpg) + +![Alt text](/path/to/img.jpg "Optional title") + +![Alt text][id] + + [id]: url/to/image "Optional title attribute" \ No newline at end of file diff --git a/test/cases/implicit-anchors.html b/test/cases/implicit-anchors.html new file mode 100644 index 0000000..8bb39ff --- /dev/null +++ b/test/cases/implicit-anchors.html @@ -0,0 +1,2 @@ + +

Search the web at Google or Daring Fireball.

\ No newline at end of file diff --git a/test/cases/implicit-anchors.md b/test/cases/implicit-anchors.md new file mode 100644 index 0000000..d474773 --- /dev/null +++ b/test/cases/implicit-anchors.md @@ -0,0 +1,5 @@ + +Search the web at [Google][] or [Daring Fireball][]. + + [Google]: http://google.com/ + [Daring Fireball]: http://daringfireball.net/ \ No newline at end of file diff --git a/test/cases/inline-anchors.html b/test/cases/inline-anchors.html new file mode 100644 index 0000000..7be05ef --- /dev/null +++ b/test/cases/inline-anchors.html @@ -0,0 +1,4 @@ + +

This is an example inline link.

+ +

This link has no title attribute.

\ No newline at end of file diff --git a/test/cases/inline-anchors.md b/test/cases/inline-anchors.md new file mode 100644 index 0000000..a0bbd6e --- /dev/null +++ b/test/cases/inline-anchors.md @@ -0,0 +1,4 @@ + +This is [an example](http://example.com/ "Title") inline link. + +[This link](http://example.net/) has no title attribute. \ No newline at end of file diff --git a/test/cases/inline-code.html b/test/cases/inline-code.html new file mode 100644 index 0000000..e1809e6 --- /dev/null +++ b/test/cases/inline-code.html @@ -0,0 +1,12 @@ + +

Create a new function.

+ +

Use the backtick in MySQL syntax SELECT `column` FROM whatever.

+ +

A single backtick in a code span: `

+ +

A backtick-delimited string in a code span: `foo`

+ +

Please don't use any <blink> tags.

+ +

&#8212; is the decimal-encoded equivalent of &mdash;.

\ No newline at end of file diff --git a/test/cases/inline-code.md b/test/cases/inline-code.md new file mode 100644 index 0000000..6cc0b2a --- /dev/null +++ b/test/cases/inline-code.md @@ -0,0 +1,12 @@ + +Create a new `function`. + +Use the backtick in MySQL syntax ``SELECT `column` FROM whatever``. + +A single backtick in a code span: `` ` `` + +A backtick-delimited string in a code span: `` `foo` `` + +Please don't use any `` tags. + +`—` is the decimal-encoded equivalent of `—`. \ No newline at end of file diff --git a/test/cases/lazy-blockquote.html b/test/cases/lazy-blockquote.html new file mode 100644 index 0000000..c31f284 --- /dev/null +++ b/test/cases/lazy-blockquote.html @@ -0,0 +1,5 @@ +
+

This is a multi line blockquote test

+ +

With more than one line.

+
\ No newline at end of file diff --git a/test/cases/lazy-blockquote.md b/test/cases/lazy-blockquote.md new file mode 100644 index 0000000..c00b7e2 --- /dev/null +++ b/test/cases/lazy-blockquote.md @@ -0,0 +1,4 @@ + + > This is a multi line blockquote test + + > With more than one line. \ No newline at end of file diff --git a/test/cases/list-with-blockquote.html b/test/cases/list-with-blockquote.html new file mode 100644 index 0000000..e33c04f --- /dev/null +++ b/test/cases/list-with-blockquote.html @@ -0,0 +1,8 @@ +
    +
  • A list item with a blockquote:

    + +
    +

    This is a blockquote + inside a list item.

    +
  • +
\ No newline at end of file diff --git a/test/cases/list-with-blockquote.md b/test/cases/list-with-blockquote.md new file mode 100644 index 0000000..50c1c9d --- /dev/null +++ b/test/cases/list-with-blockquote.md @@ -0,0 +1,4 @@ +* A list item with a blockquote: + + > This is a blockquote + > inside a list item. \ No newline at end of file diff --git a/test/cases/list-with-code.html b/test/cases/list-with-code.html new file mode 100644 index 0000000..753a269 --- /dev/null +++ b/test/cases/list-with-code.html @@ -0,0 +1,6 @@ +
    +
  • A list item with code:

    + +
    alert('Hello world!');
    +    
  • +
\ No newline at end of file diff --git a/test/cases/list-with-code.md b/test/cases/list-with-code.md new file mode 100644 index 0000000..47f7a1c --- /dev/null +++ b/test/cases/list-with-code.md @@ -0,0 +1,3 @@ +* A list item with code: + + alert('Hello world!'); \ No newline at end of file diff --git a/test/cases/multi-paragraph-list.html b/test/cases/multi-paragraph-list.html new file mode 100644 index 0000000..1afca57 --- /dev/null +++ b/test/cases/multi-paragraph-list.html @@ -0,0 +1,6 @@ +
    +
  1. This is a major bullet point.

    + +

    That contains multiple paragraphs.

  2. +
  3. And another line

  4. +
\ No newline at end of file diff --git a/test/cases/multi-paragraph-list.md b/test/cases/multi-paragraph-list.md new file mode 100644 index 0000000..377e708 --- /dev/null +++ b/test/cases/multi-paragraph-list.md @@ -0,0 +1,6 @@ + + 1. This is a major bullet point. + + That contains multiple paragraphs. + + 2. And another line \ No newline at end of file diff --git a/test/cases/multiline-unordered-list.html b/test/cases/multiline-unordered-list.html new file mode 100644 index 0000000..bb6c06a --- /dev/null +++ b/test/cases/multiline-unordered-list.html @@ -0,0 +1,5 @@ +
    +
  • This line spans + more than one line and is lazy
  • +
  • Similar to this line
  • +
\ No newline at end of file diff --git a/test/cases/multiline-unordered-list.md b/test/cases/multiline-unordered-list.md new file mode 100644 index 0000000..3548a05 --- /dev/null +++ b/test/cases/multiline-unordered-list.md @@ -0,0 +1,4 @@ + + - This line spans + more than one line and is lazy + - Similar to this line \ No newline at end of file diff --git a/test/cases/nested-blockquote.html b/test/cases/nested-blockquote.html new file mode 100644 index 0000000..c142b2e --- /dev/null +++ b/test/cases/nested-blockquote.html @@ -0,0 +1,9 @@ +
+

This is a multi line blockquote test

+ +
+

And nesting! +

+ +

With more than one line.

+
\ No newline at end of file diff --git a/test/cases/nested-blockquote.md b/test/cases/nested-blockquote.md new file mode 100644 index 0000000..010893c --- /dev/null +++ b/test/cases/nested-blockquote.md @@ -0,0 +1,4 @@ + + > This is a multi line blockquote test + > > And nesting! + > With more than one line. \ No newline at end of file diff --git a/test/cases/ordered-list-same-number.html b/test/cases/ordered-list-same-number.html new file mode 100644 index 0000000..726f66c --- /dev/null +++ b/test/cases/ordered-list-same-number.html @@ -0,0 +1,5 @@ +
    +
  1. Red
  2. +
  3. Green
  4. +
  5. Blue
  6. +
\ No newline at end of file diff --git a/test/cases/ordered-list-same-number.md b/test/cases/ordered-list-same-number.md new file mode 100644 index 0000000..6df2316 --- /dev/null +++ b/test/cases/ordered-list-same-number.md @@ -0,0 +1,4 @@ + + 1. Red + 1. Green + 1. Blue \ No newline at end of file diff --git a/test/cases/ordered-list-wrong-numbers.html b/test/cases/ordered-list-wrong-numbers.html new file mode 100644 index 0000000..726f66c --- /dev/null +++ b/test/cases/ordered-list-wrong-numbers.html @@ -0,0 +1,5 @@ +
    +
  1. Red
  2. +
  3. Green
  4. +
  5. Blue
  6. +
\ No newline at end of file diff --git a/test/cases/ordered-list-wrong-numbers.md b/test/cases/ordered-list-wrong-numbers.md new file mode 100644 index 0000000..9b19b9b --- /dev/null +++ b/test/cases/ordered-list-wrong-numbers.md @@ -0,0 +1,4 @@ + + 8. Red + 1. Green + 3. Blue \ No newline at end of file diff --git a/test/cases/ordered-list.html b/test/cases/ordered-list.html new file mode 100644 index 0000000..726f66c --- /dev/null +++ b/test/cases/ordered-list.html @@ -0,0 +1,5 @@ +
    +
  1. Red
  2. +
  3. Green
  4. +
  5. Blue
  6. +
\ No newline at end of file diff --git a/test/cases/ordered-list.md b/test/cases/ordered-list.md new file mode 100644 index 0000000..aab422f --- /dev/null +++ b/test/cases/ordered-list.md @@ -0,0 +1,4 @@ + + 1. Red + 2. Green + 3. Blue \ No newline at end of file diff --git a/test/cases/relative-anchors.html b/test/cases/relative-anchors.html new file mode 100644 index 0000000..a412083 --- /dev/null +++ b/test/cases/relative-anchors.html @@ -0,0 +1,2 @@ + +

See my About page for details.

\ No newline at end of file diff --git a/test/cases/relative-anchors.md b/test/cases/relative-anchors.md new file mode 100644 index 0000000..5d66708 --- /dev/null +++ b/test/cases/relative-anchors.md @@ -0,0 +1,2 @@ + +See my [About](/about/) page for details. \ No newline at end of file diff --git a/test/cases/simple-paragraph.html b/test/cases/simple-paragraph.html new file mode 100644 index 0000000..1f19a39 --- /dev/null +++ b/test/cases/simple-paragraph.html @@ -0,0 +1 @@ +

Hello, world!

\ No newline at end of file diff --git a/test/cases/simple-paragraph.md b/test/cases/simple-paragraph.md new file mode 100644 index 0000000..8045a95 --- /dev/null +++ b/test/cases/simple-paragraph.md @@ -0,0 +1,2 @@ + +Hello, world! \ No newline at end of file diff --git a/test/cases/strong.html b/test/cases/strong.html new file mode 100644 index 0000000..4938794 --- /dev/null +++ b/test/cases/strong.html @@ -0,0 +1,6 @@ + +

important

+ +

important

+ +

really freakingstrong

\ No newline at end of file diff --git a/test/cases/strong.md b/test/cases/strong.md new file mode 100644 index 0000000..78d3c3e --- /dev/null +++ b/test/cases/strong.md @@ -0,0 +1,6 @@ + +**important** + +__important__ + +really **freaking**strong \ No newline at end of file diff --git a/test/cases/unordered-list-asterisk.html b/test/cases/unordered-list-asterisk.html new file mode 100644 index 0000000..ddc422c --- /dev/null +++ b/test/cases/unordered-list-asterisk.html @@ -0,0 +1,5 @@ +
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
\ No newline at end of file diff --git a/test/cases/unordered-list-asterisk.md b/test/cases/unordered-list-asterisk.md new file mode 100644 index 0000000..95553a4 --- /dev/null +++ b/test/cases/unordered-list-asterisk.md @@ -0,0 +1,4 @@ + + * Red + * Green + * Blue \ No newline at end of file diff --git a/test/cases/unordered-list-minus.html b/test/cases/unordered-list-minus.html new file mode 100644 index 0000000..ddc422c --- /dev/null +++ b/test/cases/unordered-list-minus.html @@ -0,0 +1,5 @@ +
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
\ No newline at end of file diff --git a/test/cases/unordered-list-minus.md b/test/cases/unordered-list-minus.md new file mode 100644 index 0000000..feecfe9 --- /dev/null +++ b/test/cases/unordered-list-minus.md @@ -0,0 +1,4 @@ + + - Red + - Green + - Blue \ No newline at end of file diff --git a/test/cases/unordered-list-plus.html b/test/cases/unordered-list-plus.html new file mode 100644 index 0000000..ddc422c --- /dev/null +++ b/test/cases/unordered-list-plus.html @@ -0,0 +1,5 @@ +
    +
  • Red
  • +
  • Green
  • +
  • Blue
  • +
\ No newline at end of file diff --git a/test/cases/unordered-list-plus.md b/test/cases/unordered-list-plus.md new file mode 100644 index 0000000..e4cffff --- /dev/null +++ b/test/cases/unordered-list-plus.md @@ -0,0 +1,4 @@ + + + Red + + Green + + Blue \ No newline at end of file diff --git a/test/run.js b/test/run.js new file mode 100644 index 0000000..c742a53 --- /dev/null +++ b/test/run.js @@ -0,0 +1,49 @@ + +var showdown = new require('../src/showdown').Showdown, + convertor = new showdown.converter(), + fs = require('fs'), + path = require('path'), + should = require('should'); + +// Load test cases from disk +var cases = fs.readdirSync('test/cases').filter(function(file){ + return ~file.indexOf('.md'); +}).map(function(file){ + return file.replace('.md', ''); +}); + +// Run each test case +cases.forEach(function(test){ + var name = test.replace(/[-.]/g, ' '); + it (name, function(){ + var mdpath = path.join('test/cases', test + '.md'), + htmlpath = path.join('test/cases', test + '.html'), + md = fs.readFileSync(mdpath, 'utf8'), + expected = fs.readFileSync(htmlpath, 'utf8').trim(), + actual = convertor.makeHtml(md).trim(); + + // Normalize line returns + expected = expected.replace(/\r/g, ''); + + // Ignore all leading/trailing whitespace + expected = expected.split('\n').map(function(x){ + return x.trim(); + }).join('\n'); + actual = actual.split('\n').map(function(x){ + return x.trim(); + }).join('\n'); + + // Convert whitespace to a visible character so that it shows up on error reports + expected = expected.replace(/ /g, '·'); + expected = expected.replace(/\n/g, '•\n'); + actual = actual.replace(/ /g, '·'); + actual = actual.replace(/\n/g, '•\n'); + + if (test == 'github-style-codeblock') { + console.log(actual); + } + + // Compare + actual.should.equal(expected); + }); +});