diff --git a/Parsedown.php b/Parsedown.php index f877c4871..75ba01464 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -66,6 +66,24 @@ function setBreaksEnabled($breaksEnabled) return $this; } + private $escapingEnabled; + + function setHtmlEscaping($escapingEnabled) + { + $this->escapingEnabled = $escapingEnabled; + + return $this; + } + + private $safeLinksEnabled; + + function setSafeLinks($safeLinksEnabled) + { + $this->safeLinksEnabled = $safeLinksEnabled; + + return $this; + } + # # Lines # @@ -92,7 +110,7 @@ function setBreaksEnabled($breaksEnabled) '_' => array('Rule'), '`' => array('FencedCode'), '|' => array('Table'), - '~' => array('FencedCode'), + '~' => array('FencedCode') ); # ~ @@ -350,6 +368,11 @@ protected function completeCodeBlock($Block) protected function identifyComment($Line) { + if ($this->escapingEnabled) + { + return; + } + if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') { $Block = array( @@ -367,7 +390,7 @@ protected function identifyComment($Line) protected function addToComment($Line, array $Block) { - if (isset($Block['closed'])) + if (isset($Block['closed']) || $this->escapingEnabled) { return; } @@ -619,6 +642,11 @@ protected function identifySetext($Line, array $Block = null) protected function identifyMarkup($Line) { + if ($this->escapingEnabled) + { + return; + } + if (preg_match('/^<(\w[\w\d]*)(?:[ ][^>\/]*)?(\/?)[ ]*>/', $Line['text'], $matches)) { if (in_array($matches[1], $this->textLevelElements)) @@ -646,7 +674,7 @@ protected function identifyMarkup($Line) protected function addToMarkup($Line, array $Block) { - if (isset($Block['closed'])) + if (isset($Block['closed']) || $this->escapingEnabled) { return; } @@ -946,16 +974,17 @@ protected function elements(array $Elements) '*' => array('Emphasis'), '/' => array('Url'), '<' => array('UrlTag', 'EmailTag', 'Tag', 'LessThan'), + '>' => array('GreaterThan'), '[' => array('Link'), '_' => array('Emphasis'), '`' => array('InlineCode'), '~' => array('Strikethrough'), - '\\' => array('EscapeSequence'), + '\\' => array('EscapeSequence') ); # ~ - protected $spanMarkerList = '*_!&[/`~\\'; # # ~ @@ -1040,7 +1069,7 @@ protected function identifyUrl($Excerpt) if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) { - $url = str_replace(array('&', '<'), array('&', '<'), $matches[0][0]); + $url = str_replace(array('&', '<', '>'), array('&', '<', '>'), $matches[0][0]); return array( 'extent' => strlen($matches[0][0]), @@ -1091,10 +1120,20 @@ protected function identifyEscapeSequence($Excerpt) { if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) { - return array( - 'markup' => $Excerpt['text'][1], - 'extent' => 2, - ); + if ($this->escapingEnabled && $Excerpt['text'][1] == '>') + { + return array( + 'markup' => '>', + 'extent' => 2, + ); + } + else + { + return array( + 'markup' => $Excerpt['text'][1], + 'extent' => 2, + ); + } } } @@ -1106,11 +1145,19 @@ protected function identifyLessThan() ); } + protected function identifyGreaterThan() + { + return array( + 'markup' => '>', + 'extent' => 1, + ); + } + protected function identifyUrlTag($Excerpt) { if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(https?:[\/]{2}[^\s]+?)>/i', $Excerpt['text'], $matches)) { - $url = str_replace(array('&', '<'), array('&', '<'), $matches[1]); + $url = str_replace(array('&', '<', '>'), array('&', '<', '>'), $matches[1]); return array( 'extent' => strlen($matches[0]), @@ -1144,6 +1191,11 @@ protected function identifyEmailTag($Excerpt) protected function identifyTag($Excerpt) { + if ($this->escapingEnabled) + { + return; + } + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<\/?\w.*?>/', $Excerpt['text'], $matches)) { return array( @@ -1229,7 +1281,12 @@ protected function identifyLink($Excerpt) return; } - $url = str_replace(array('&', '<'), array('&', '<'), $Link['url']); + if ($this->safeLinksEnabled && stripos($Link['url'], 'javascript:') !== false) + { + return; + } + + $url = str_replace(array('&', '<', '>'), array('&', '<', '>'), $Link['url']); if ($Excerpt['text'][0] === '!') { diff --git a/test/Test.php b/test/Test.php index 5171d846f..ba4cd4365 100644 --- a/test/Test.php +++ b/test/Test.php @@ -23,7 +23,14 @@ function test_($filename) $expectedMarkup = str_replace("\r\n", "\n", $expectedMarkup); $expectedMarkup = str_replace("\r", "\n", $expectedMarkup); - $actualMarkup = Parsedown::instance()->text($markdown); + if (strpos($filename, '_escaped') !== false) + { + $actualMarkup = Parsedown::instance('escaped')->setHtmlEscaping(true)->text($markdown); + } + else + { + $actualMarkup = Parsedown::instance()->text($markdown); + } $this->assertEquals($expectedMarkup, $actualMarkup); } diff --git a/test/data/HTML_Comment_escaped.html b/test/data/HTML_Comment_escaped.html new file mode 100644 index 000000000..1e24c1712 --- /dev/null +++ b/test/data/HTML_Comment_escaped.html @@ -0,0 +1,5 @@ +

<!-- single line -->

+

paragraph

+

<!-- +multiline -->

+

paragraph

\ No newline at end of file diff --git a/test/data/HTML_Comment_escaped.md b/test/data/HTML_Comment_escaped.md new file mode 100644 index 000000000..6ddfdb441 --- /dev/null +++ b/test/data/HTML_Comment_escaped.md @@ -0,0 +1,8 @@ + + +paragraph + + + +paragraph \ No newline at end of file diff --git a/test/data/aesthetic_table_escaped.html b/test/data/aesthetic_table_escaped.html new file mode 100644 index 000000000..88e1c2bd4 --- /dev/null +++ b/test/data/aesthetic_table_escaped.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + +
header 1header 2
cell 1.1cell 1.2
cell 2.1cell 2.2
\ No newline at end of file diff --git a/test/data/aesthetic_table_escaped.md b/test/data/aesthetic_table_escaped.md new file mode 100644 index 000000000..5245e6c9d --- /dev/null +++ b/test/data/aesthetic_table_escaped.md @@ -0,0 +1,4 @@ +| header 1 | header 2 | +| -------- | -------- | +| cell 1.1 | cell 1.2 | +| cell 2.1 | cell 2.2 | \ No newline at end of file diff --git a/test/data/aligned_table_escaped.html b/test/data/aligned_table_escaped.html new file mode 100644 index 000000000..0657bd172 --- /dev/null +++ b/test/data/aligned_table_escaped.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + +
header 1header 2header 2
cell 1.1cell 1.2cell 1.3
cell 2.1cell 2.2cell 2.3
\ No newline at end of file diff --git a/test/data/aligned_table_escaped.md b/test/data/aligned_table_escaped.md new file mode 100644 index 000000000..69a45f90f --- /dev/null +++ b/test/data/aligned_table_escaped.md @@ -0,0 +1,4 @@ +| header 1 | header 2 | header 2 | +| :------- | :------: | -------: | +| cell 1.1 | cell 1.2 | cell 1.3 | +| cell 2.1 | cell 2.2 | cell 2.3 | \ No newline at end of file diff --git a/test/data/atx_heading_escaped.html b/test/data/atx_heading_escaped.html new file mode 100644 index 000000000..22d865de7 --- /dev/null +++ b/test/data/atx_heading_escaped.html @@ -0,0 +1,8 @@ +

h1

+

h2

+

h3

+

h4

+
h5
+
h6
+

closed h1

+

#

\ No newline at end of file diff --git a/test/data/atx_heading_escaped.md b/test/data/atx_heading_escaped.md new file mode 100644 index 000000000..039baaa90 --- /dev/null +++ b/test/data/atx_heading_escaped.md @@ -0,0 +1,15 @@ +# h1 + +## h2 + +### h3 + +#### h4 + +##### h5 + +###### h6 + +# closed h1 # + +# \ No newline at end of file diff --git a/test/data/automatic_link_escaped.html b/test/data/automatic_link_escaped.html new file mode 100644 index 000000000..50a94ba0f --- /dev/null +++ b/test/data/automatic_link_escaped.html @@ -0,0 +1 @@ +

http://example.com

\ No newline at end of file diff --git a/test/data/automatic_link_escaped.md b/test/data/automatic_link_escaped.md new file mode 100644 index 000000000..08d3bf46a --- /dev/null +++ b/test/data/automatic_link_escaped.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/data/block-level_html_escaped.html b/test/data/block-level_html_escaped.html new file mode 100644 index 000000000..c73df668b --- /dev/null +++ b/test/data/block-level_html_escaped.html @@ -0,0 +1,8 @@ +

<div>content</div>

+

sparse:

+

<div> +<div class="inner"> +content +</div> +</div>

+

paragraph

\ No newline at end of file diff --git a/test/data/block-level_html_escaped.md b/test/data/block-level_html_escaped.md new file mode 100644 index 000000000..943e183c3 --- /dev/null +++ b/test/data/block-level_html_escaped.md @@ -0,0 +1,11 @@ +
_content_
+ +sparse: + +
+
+_content_ +
+
+ +paragraph \ No newline at end of file diff --git a/test/data/code_block_escaped.html b/test/data/code_block_escaped.html new file mode 100644 index 000000000..889b02d99 --- /dev/null +++ b/test/data/code_block_escaped.html @@ -0,0 +1,8 @@ +
<?php
+
+$message = 'Hello World!';
+echo $message;
+
+
> not a quote
+- not a list item
+[not a reference]: http://foo.com
\ No newline at end of file diff --git a/test/data/code_block_escaped.md b/test/data/code_block_escaped.md new file mode 100644 index 000000000..2cfc953cc --- /dev/null +++ b/test/data/code_block_escaped.md @@ -0,0 +1,10 @@ + not a quote + - not a list item + [not a reference]: http://foo.com \ No newline at end of file diff --git a/test/data/code_span_escaped.html b/test/data/code_span_escaped.html new file mode 100644 index 000000000..5c4c231e3 --- /dev/null +++ b/test/data/code_span_escaped.html @@ -0,0 +1,6 @@ +

a code span

+

this is also a codespan trailing text

+

and look at this one!

+

single backtick in a code span: `

+

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

+

sth `` sth

\ No newline at end of file diff --git a/test/data/code_span_escaped.md b/test/data/code_span_escaped.md new file mode 100644 index 000000000..c2f1a7442 --- /dev/null +++ b/test/data/code_span_escaped.md @@ -0,0 +1,11 @@ +a `code span` + +`this is also a codespan` trailing text + +`and look at this one!` + +single backtick in a code span: `` ` `` + +backtick-delimited string in a code span: `` `foo` `` + +`sth `` sth` \ No newline at end of file diff --git a/test/data/compound_blockquote_escaped.html b/test/data/compound_blockquote_escaped.html new file mode 100644 index 000000000..37afb57a4 --- /dev/null +++ b/test/data/compound_blockquote_escaped.html @@ -0,0 +1,9 @@ +
+

header

+

paragraph

+ +
+

paragraph

+
\ No newline at end of file diff --git a/test/data/compound_blockquote_escaped.md b/test/data/compound_blockquote_escaped.md new file mode 100644 index 000000000..80c4aed16 --- /dev/null +++ b/test/data/compound_blockquote_escaped.md @@ -0,0 +1,10 @@ +> header +> ------ +> +> paragraph +> +> - li +> +> --- +> +> paragraph \ No newline at end of file diff --git a/test/data/compound_emphasis_escaped.html b/test/data/compound_emphasis_escaped.html new file mode 100644 index 000000000..178dd54ba --- /dev/null +++ b/test/data/compound_emphasis_escaped.html @@ -0,0 +1,2 @@ +

code code

+

codecodecode

\ No newline at end of file diff --git a/test/data/compound_emphasis_escaped.md b/test/data/compound_emphasis_escaped.md new file mode 100644 index 000000000..6fe07f260 --- /dev/null +++ b/test/data/compound_emphasis_escaped.md @@ -0,0 +1,4 @@ +_`code`_ __`code`__ + +*`code`**`code`**`code`* + diff --git a/test/data/compound_list_escaped.html b/test/data/compound_list_escaped.html new file mode 100644 index 000000000..f5593c142 --- /dev/null +++ b/test/data/compound_list_escaped.html @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/test/data/compound_list_escaped.md b/test/data/compound_list_escaped.md new file mode 100644 index 000000000..ed7f0c60f --- /dev/null +++ b/test/data/compound_list_escaped.md @@ -0,0 +1,7 @@ +- paragraph + + paragraph + +- paragraph + + > quote \ No newline at end of file diff --git a/test/data/deeply_nested_list_escaped.html b/test/data/deeply_nested_list_escaped.html new file mode 100644 index 000000000..d2c7e5acc --- /dev/null +++ b/test/data/deeply_nested_list_escaped.html @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/test/data/deeply_nested_list_escaped.md b/test/data/deeply_nested_list_escaped.md new file mode 100644 index 000000000..76b7552d8 --- /dev/null +++ b/test/data/deeply_nested_list_escaped.md @@ -0,0 +1,6 @@ +- li + - li + - li + - li + - li +- li \ No newline at end of file diff --git a/test/data/em_strong_escaped.html b/test/data/em_strong_escaped.html new file mode 100644 index 000000000..323d60aec --- /dev/null +++ b/test/data/em_strong_escaped.html @@ -0,0 +1,8 @@ +

em strong

+

em strong strong

+

strong em strong

+

strong em strong strong

+

em strong

+

em strong strong

+

strong em strong

+

strong em strong strong

\ No newline at end of file diff --git a/test/data/em_strong_escaped.md b/test/data/em_strong_escaped.md new file mode 100644 index 000000000..9abeb3fd4 --- /dev/null +++ b/test/data/em_strong_escaped.md @@ -0,0 +1,15 @@ +___em strong___ + +___em strong_ strong__ + +__strong _em strong___ + +__strong _em strong_ strong__ + +***em strong*** + +***em strong* strong** + +**strong *em strong*** + +**strong *em strong* strong** \ No newline at end of file diff --git a/test/data/email_escaped.html b/test/data/email_escaped.html new file mode 100644 index 000000000..c40759c96 --- /dev/null +++ b/test/data/email_escaped.html @@ -0,0 +1 @@ +

my email is me@example.com

\ No newline at end of file diff --git a/test/data/email_escaped.md b/test/data/email_escaped.md new file mode 100644 index 000000000..26b7b6cc5 --- /dev/null +++ b/test/data/email_escaped.md @@ -0,0 +1 @@ +my email is \ No newline at end of file diff --git a/test/data/emphasis_escaped.html b/test/data/emphasis_escaped.html new file mode 100644 index 000000000..60ff4bd8b --- /dev/null +++ b/test/data/emphasis_escaped.html @@ -0,0 +1,8 @@ +

underscore, asterisk, one two, three four, a, b

+

strong and em and strong and em

+

line +line +line

+

this_is_not_an_emphasis

+

an empty emphasis __ ** is not an emphasis

+

*mixed *double and single asterisk** spans

\ No newline at end of file diff --git a/test/data/emphasis_escaped.md b/test/data/emphasis_escaped.md new file mode 100644 index 000000000..85b9d2299 --- /dev/null +++ b/test/data/emphasis_escaped.md @@ -0,0 +1,13 @@ +_underscore_, *asterisk*, _one two_, *three four*, _a_, *b* + +**strong** and *em* and **strong** and *em* + +_line +line +line_ + +this_is_not_an_emphasis + +an empty emphasis __ ** is not an emphasis + +*mixed **double and* single asterisk** spans \ No newline at end of file diff --git a/test/data/escaping_escaped.html b/test/data/escaping_escaped.html new file mode 100644 index 000000000..c73b30970 --- /dev/null +++ b/test/data/escaping_escaped.html @@ -0,0 +1,4 @@ +

escaped *emphasis*.

+

escaped \*emphasis\* in a code span

+
escaped \*emphasis\* in a code block
+

\ ` * _ { } [ ] ( ) > # + - . !

\ No newline at end of file diff --git a/test/data/escaping_escaped.md b/test/data/escaping_escaped.md new file mode 100644 index 000000000..164039f80 --- /dev/null +++ b/test/data/escaping_escaped.md @@ -0,0 +1,7 @@ +escaped \*emphasis\*. + +`escaped \*emphasis\* in a code span` + + escaped \*emphasis\* in a code block + +\\ \` \* \_ \{ \} \[ \] \( \) \> \# \+ \- \. \! \ No newline at end of file diff --git a/test/data/fenced_code_block_escaped.html b/test/data/fenced_code_block_escaped.html new file mode 100644 index 000000000..8bdabba96 --- /dev/null +++ b/test/data/fenced_code_block_escaped.html @@ -0,0 +1,6 @@ +
<?php
+
+$message = 'fenced code block';
+echo $message;
+
tilde
+
echo 'language identifier';
\ No newline at end of file diff --git a/test/data/fenced_code_block_escaped.md b/test/data/fenced_code_block_escaped.md new file mode 100644 index 000000000..cbed8ebb5 --- /dev/null +++ b/test/data/fenced_code_block_escaped.md @@ -0,0 +1,14 @@ +``` + +
+
+
+
\ No newline at end of file diff --git a/test/data/horizontal_rule_escaped.md b/test/data/horizontal_rule_escaped.md new file mode 100644 index 000000000..bf461a925 --- /dev/null +++ b/test/data/horizontal_rule_escaped.md @@ -0,0 +1,9 @@ +--- + +- - - + + - - - + +*** + +___ \ No newline at end of file diff --git a/test/data/html_entity_escaped.html b/test/data/html_entity_escaped.html new file mode 100644 index 000000000..4d23e3cd4 --- /dev/null +++ b/test/data/html_entity_escaped.html @@ -0,0 +1 @@ +

& © {

\ No newline at end of file diff --git a/test/data/html_entity_escaped.md b/test/data/html_entity_escaped.md new file mode 100644 index 000000000..ff545ea5c --- /dev/null +++ b/test/data/html_entity_escaped.md @@ -0,0 +1 @@ +& © { \ No newline at end of file diff --git a/test/data/image_reference_escaped.html b/test/data/image_reference_escaped.html new file mode 100644 index 000000000..b3249cba2 --- /dev/null +++ b/test/data/image_reference_escaped.html @@ -0,0 +1 @@ +

Markdown Logo

\ No newline at end of file diff --git a/test/data/image_reference_escaped.md b/test/data/image_reference_escaped.md new file mode 100644 index 000000000..dcb1414dd --- /dev/null +++ b/test/data/image_reference_escaped.md @@ -0,0 +1,3 @@ +![Markdown Logo][image] + +[image]: /md.png diff --git a/test/data/image_title_escaped.html b/test/data/image_title_escaped.html new file mode 100644 index 000000000..82c155f61 --- /dev/null +++ b/test/data/image_title_escaped.html @@ -0,0 +1 @@ +

alt

\ No newline at end of file diff --git a/test/data/image_title_escaped.md b/test/data/image_title_escaped.md new file mode 100644 index 000000000..3e58ee555 --- /dev/null +++ b/test/data/image_title_escaped.md @@ -0,0 +1 @@ +![alt](/md.png "title") \ No newline at end of file diff --git a/test/data/implicit_reference_escaped.html b/test/data/implicit_reference_escaped.html new file mode 100644 index 000000000..24b51c1b0 --- /dev/null +++ b/test/data/implicit_reference_escaped.html @@ -0,0 +1,4 @@ +

an implicit reference link

+

an implicit reference link with an empty link definition

+

an implicit reference link followed by another

+

an explicit reference link with a title

\ No newline at end of file diff --git a/test/data/implicit_reference_escaped.md b/test/data/implicit_reference_escaped.md new file mode 100644 index 000000000..f850df964 --- /dev/null +++ b/test/data/implicit_reference_escaped.md @@ -0,0 +1,13 @@ +an [implicit] reference link + +[implicit]: http://example.com + +an [implicit][] reference link with an empty link definition + +an [implicit][] reference link followed by [another][] + +[another]: http://cnn.com + +an [explicit][example] reference link with a title + +[example]: http://example.com "Example" \ No newline at end of file diff --git a/test/data/inline_link_escaped.html b/test/data/inline_link_escaped.html new file mode 100644 index 000000000..2b9e649d6 --- /dev/null +++ b/test/data/inline_link_escaped.html @@ -0,0 +1,4 @@ +

link and another link

+

link

+

MD Logo

+

MD Logo and text

\ No newline at end of file diff --git a/test/data/inline_link_escaped.md b/test/data/inline_link_escaped.md new file mode 100644 index 000000000..cd8e5a63f --- /dev/null +++ b/test/data/inline_link_escaped.md @@ -0,0 +1,7 @@ +[link](http://example.com) and [another link](/tests/) + +[`link`](http://example.com) + +[![MD Logo](http://parsedown.org/md.png)](http://example.com) + +[![MD Logo](http://parsedown.org/md.png) and text](http://example.com) \ No newline at end of file diff --git a/test/data/inline_link_title_escaped.html b/test/data/inline_link_title_escaped.html new file mode 100644 index 000000000..70e589aa8 --- /dev/null +++ b/test/data/inline_link_title_escaped.html @@ -0,0 +1 @@ +

single quotes and double quotes

\ No newline at end of file diff --git a/test/data/inline_link_title_escaped.md b/test/data/inline_link_title_escaped.md new file mode 100644 index 000000000..162b832ac --- /dev/null +++ b/test/data/inline_link_title_escaped.md @@ -0,0 +1 @@ +[single quotes](http://example.com 'Title') and [double quotes](http://example.com "Title") \ No newline at end of file diff --git a/test/data/inline_title_escaped.html b/test/data/inline_title_escaped.html new file mode 100644 index 000000000..bbab93b6c --- /dev/null +++ b/test/data/inline_title_escaped.html @@ -0,0 +1 @@ +

single quotes and double quotes

\ No newline at end of file diff --git a/test/data/inline_title_escaped.md b/test/data/inline_title_escaped.md new file mode 100644 index 000000000..cb09344a1 --- /dev/null +++ b/test/data/inline_title_escaped.md @@ -0,0 +1 @@ +[single quotes](http://example.com 'Example') and [double quotes](http://example.com "Example") \ No newline at end of file diff --git a/test/data/lazy_blockquote_escaped.html b/test/data/lazy_blockquote_escaped.html new file mode 100644 index 000000000..0a2a2aaf9 --- /dev/null +++ b/test/data/lazy_blockquote_escaped.html @@ -0,0 +1,6 @@ +
+

quote +the rest of it

+

another paragraph +the rest of it

+
\ No newline at end of file diff --git a/test/data/lazy_blockquote_escaped.md b/test/data/lazy_blockquote_escaped.md new file mode 100644 index 000000000..48f645f94 --- /dev/null +++ b/test/data/lazy_blockquote_escaped.md @@ -0,0 +1,5 @@ +> quote +the rest of it + +> another paragraph +the rest of it \ No newline at end of file diff --git a/test/data/lazy_list_escaped.html b/test/data/lazy_list_escaped.html new file mode 100644 index 000000000..1a5199249 --- /dev/null +++ b/test/data/lazy_list_escaped.html @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/test/data/lazy_list_escaped.md b/test/data/lazy_list_escaped.md new file mode 100644 index 000000000..62ad9d719 --- /dev/null +++ b/test/data/lazy_list_escaped.md @@ -0,0 +1,2 @@ +- li +the rest of it \ No newline at end of file diff --git a/test/data/line_break_escaped.html b/test/data/line_break_escaped.html new file mode 100644 index 000000000..5f37d854c --- /dev/null +++ b/test/data/line_break_escaped.html @@ -0,0 +1,2 @@ +

line
+line

\ No newline at end of file diff --git a/test/data/line_break_escaped.md b/test/data/line_break_escaped.md new file mode 100644 index 000000000..04dff43e0 --- /dev/null +++ b/test/data/line_break_escaped.md @@ -0,0 +1,2 @@ +line +line \ No newline at end of file diff --git a/test/data/multiline_list_paragraph_escaped.html b/test/data/multiline_list_paragraph_escaped.html new file mode 100644 index 000000000..3247bd227 --- /dev/null +++ b/test/data/multiline_list_paragraph_escaped.html @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/test/data/multiline_list_paragraph_escaped.md b/test/data/multiline_list_paragraph_escaped.md new file mode 100644 index 000000000..f5b42729f --- /dev/null +++ b/test/data/multiline_list_paragraph_escaped.md @@ -0,0 +1,4 @@ +- li + + line + line \ No newline at end of file diff --git a/test/data/nested_block-level_html_escaped.html b/test/data/nested_block-level_html_escaped.html new file mode 100644 index 000000000..e6474c3ea --- /dev/null +++ b/test/data/nested_block-level_html_escaped.html @@ -0,0 +1,10 @@ +

<div> +parent +<div> +child +</div> +<pre> +adopted child +</pre> +</div>

+

outside

\ No newline at end of file diff --git a/test/data/nested_block-level_html_escaped.md b/test/data/nested_block-level_html_escaped.md new file mode 100644 index 000000000..5e01e1097 --- /dev/null +++ b/test/data/nested_block-level_html_escaped.md @@ -0,0 +1,11 @@ +
+_parent_ +
+_child_ +
+
+_adopted child_
+
+
+ +_outside_ \ No newline at end of file diff --git a/test/data/ordered_list_escaped.html b/test/data/ordered_list_escaped.html new file mode 100644 index 000000000..b6c5216ca --- /dev/null +++ b/test/data/ordered_list_escaped.html @@ -0,0 +1,13 @@ +
    +
  1. one
  2. +
  3. two
  4. +
+

repeating numbers:

+
    +
  1. one
  2. +
  3. two
  4. +
+

large numbers:

+
    +
  1. one
  2. +
\ No newline at end of file diff --git a/test/data/ordered_list_escaped.md b/test/data/ordered_list_escaped.md new file mode 100644 index 000000000..b307032cf --- /dev/null +++ b/test/data/ordered_list_escaped.md @@ -0,0 +1,11 @@ +1. one +2. two + +repeating numbers: + +1. one +1. two + +large numbers: + +123. one \ No newline at end of file diff --git a/test/data/paragraph_list_escaped.html b/test/data/paragraph_list_escaped.html new file mode 100644 index 000000000..ced1c43ee --- /dev/null +++ b/test/data/paragraph_list_escaped.html @@ -0,0 +1,12 @@ +

paragraph

+ +

paragraph

+ \ No newline at end of file diff --git a/test/data/paragraph_list_escaped.md b/test/data/paragraph_list_escaped.md new file mode 100644 index 000000000..b973908ce --- /dev/null +++ b/test/data/paragraph_list_escaped.md @@ -0,0 +1,9 @@ +paragraph +- li +- li + +paragraph + + * li + + * li \ No newline at end of file diff --git a/test/data/reference_title_escaped.html b/test/data/reference_title_escaped.html new file mode 100644 index 000000000..8f2be944c --- /dev/null +++ b/test/data/reference_title_escaped.html @@ -0,0 +1,2 @@ +

double quotes and single quotes and parentheses

+

[invalid title]: http://example.com example title

\ No newline at end of file diff --git a/test/data/reference_title_escaped.md b/test/data/reference_title_escaped.md new file mode 100644 index 000000000..43cb21708 --- /dev/null +++ b/test/data/reference_title_escaped.md @@ -0,0 +1,6 @@ +[double quotes] and [single quotes] and [parentheses] + +[double quotes]: http://example.com "example title" +[single quotes]: http://example.com 'example title' +[parentheses]: http://example.com (example title) +[invalid title]: http://example.com example title \ No newline at end of file diff --git a/test/data/self-closing_html_escaped.html b/test/data/self-closing_html_escaped.html new file mode 100644 index 000000000..df415ebb9 --- /dev/null +++ b/test/data/self-closing_html_escaped.html @@ -0,0 +1,12 @@ +

<hr> +paragraph +<hr/> +paragraph +<hr /> +paragraph +<hr class="foo" id="bar" /> +paragraph +<hr class="foo" id="bar"/> +paragraph +<hr class="foo" id="bar" > +paragraph

\ No newline at end of file diff --git a/test/data/self-closing_html_escaped.md b/test/data/self-closing_html_escaped.md new file mode 100644 index 000000000..acb20327d --- /dev/null +++ b/test/data/self-closing_html_escaped.md @@ -0,0 +1,12 @@ +
+paragraph +
+paragraph +
+paragraph +
+paragraph +
+paragraph +
+paragraph \ No newline at end of file diff --git a/test/data/separated_nested_list_escaped.html b/test/data/separated_nested_list_escaped.html new file mode 100644 index 000000000..80a5cae26 --- /dev/null +++ b/test/data/separated_nested_list_escaped.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/test/data/separated_nested_list_escaped.md b/test/data/separated_nested_list_escaped.md new file mode 100644 index 000000000..d7cd1af79 --- /dev/null +++ b/test/data/separated_nested_list_escaped.md @@ -0,0 +1,4 @@ +- li + + - li + - li \ No newline at end of file diff --git a/test/data/setext_header_escaped.html b/test/data/setext_header_escaped.html new file mode 100644 index 000000000..60aac0815 --- /dev/null +++ b/test/data/setext_header_escaped.html @@ -0,0 +1,5 @@ +

h1

+

h2

+

single character

+

not a header

+
\ No newline at end of file diff --git a/test/data/setext_header_escaped.md b/test/data/setext_header_escaped.md new file mode 100644 index 000000000..c43b52c36 --- /dev/null +++ b/test/data/setext_header_escaped.md @@ -0,0 +1,12 @@ +h1 +== + +h2 +-- + +single character +- + +not a header + +------------ \ No newline at end of file diff --git a/test/data/simple_blockquote_escaped.html b/test/data/simple_blockquote_escaped.html new file mode 100644 index 000000000..8225d57cc --- /dev/null +++ b/test/data/simple_blockquote_escaped.html @@ -0,0 +1,11 @@ +
+

quote

+
+

indented:

+
+

quote

+
+

no space after >:

+
+

quote

+
\ No newline at end of file diff --git a/test/data/simple_blockquote_escaped.md b/test/data/simple_blockquote_escaped.md new file mode 100644 index 000000000..22b6b11a9 --- /dev/null +++ b/test/data/simple_blockquote_escaped.md @@ -0,0 +1,7 @@ +> quote + +indented: + > quote + +no space after `>`: +>quote \ No newline at end of file diff --git a/test/data/simple_table_escaped.html b/test/data/simple_table_escaped.html new file mode 100644 index 000000000..64b7a9a23 --- /dev/null +++ b/test/data/simple_table_escaped.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + +
header 1header 2
cell 1.1cell 1.2
cell 2.1cell 2.2
+
+ + + + + + + + + + + + + + + + + +
header 1header 2
cell 1.1cell 1.2
cell 2.1cell 2.2
\ No newline at end of file diff --git a/test/data/simple_table_escaped.md b/test/data/simple_table_escaped.md new file mode 100644 index 000000000..466d140e3 --- /dev/null +++ b/test/data/simple_table_escaped.md @@ -0,0 +1,11 @@ +header 1 | header 2 +-------- | -------- +cell 1.1 | cell 1.2 +cell 2.1 | cell 2.2 + +--- + +header 1 | header 2 +:------- | -------- +cell 1.1 | cell 1.2 +cell 2.1 | cell 2.2 \ No newline at end of file diff --git a/test/data/span-level_html_escaped.html b/test/data/span-level_html_escaped.html new file mode 100644 index 000000000..e24d6522d --- /dev/null +++ b/test/data/span-level_html_escaped.html @@ -0,0 +1,5 @@ +

an <b>important</b> <a href=''>link</a>

+

broken<br/> +line

+

<b>inline tag</b> at the beginning

+

<span>http://example.com</span>

\ No newline at end of file diff --git a/test/data/span-level_html_escaped.md b/test/data/span-level_html_escaped.md new file mode 100644 index 000000000..f22196555 --- /dev/null +++ b/test/data/span-level_html_escaped.md @@ -0,0 +1,8 @@ +an important link + +broken
+line + +inline tag at the beginning + +http://example.com \ No newline at end of file diff --git a/test/data/sparse_dense_list_escaped.html b/test/data/sparse_dense_list_escaped.html new file mode 100644 index 000000000..095bc7396 --- /dev/null +++ b/test/data/sparse_dense_list_escaped.html @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/test/data/sparse_dense_list_escaped.md b/test/data/sparse_dense_list_escaped.md new file mode 100644 index 000000000..576842277 --- /dev/null +++ b/test/data/sparse_dense_list_escaped.md @@ -0,0 +1,4 @@ +- li + +- li +- li \ No newline at end of file diff --git a/test/data/sparse_list_escaped.html b/test/data/sparse_list_escaped.html new file mode 100644 index 000000000..452b2b86d --- /dev/null +++ b/test/data/sparse_list_escaped.html @@ -0,0 +1,15 @@ + +
+ \ No newline at end of file diff --git a/test/data/sparse_list_escaped.md b/test/data/sparse_list_escaped.md new file mode 100644 index 000000000..362a35f57 --- /dev/null +++ b/test/data/sparse_list_escaped.md @@ -0,0 +1,9 @@ +- li + +- li + +--- + +- li + + - indented li \ No newline at end of file diff --git a/test/data/special_characters.html b/test/data/special_characters.html index 8199abc19..3b652c338 100644 --- a/test/data/special_characters.html +++ b/test/data/special_characters.html @@ -1,6 +1,6 @@

AT&T has an ampersand in their name

this & that

-

4 < 5 and 6 > 5

+

4 < 5 and 6 > 5

http://example.com/autolink?a=1&b=2

inline link

reference link

\ No newline at end of file diff --git a/test/data/special_characters_escaped.html b/test/data/special_characters_escaped.html new file mode 100644 index 000000000..3b652c338 --- /dev/null +++ b/test/data/special_characters_escaped.html @@ -0,0 +1,6 @@ +

AT&T has an ampersand in their name

+

this & that

+

4 < 5 and 6 > 5

+

http://example.com/autolink?a=1&b=2

+

inline link

+

reference link

\ No newline at end of file diff --git a/test/data/special_characters_escaped.md b/test/data/special_characters_escaped.md new file mode 100644 index 000000000..111b03b63 --- /dev/null +++ b/test/data/special_characters_escaped.md @@ -0,0 +1,13 @@ +AT&T has an ampersand in their name + +this & that + +4 < 5 and 6 > 5 + + + +[inline link](/script?a=1&b=2) + +[reference link][1] + +[1]: http://example.com/?a=1&b=2 \ No newline at end of file diff --git a/test/data/strikethrough_escaped.html b/test/data/strikethrough_escaped.html new file mode 100644 index 000000000..2a9da9821 --- /dev/null +++ b/test/data/strikethrough_escaped.html @@ -0,0 +1,3 @@ +

strikethrough

+

here's one followed by another one

+

~~ this ~~ is not one neither is ~this~

\ No newline at end of file diff --git a/test/data/strikethrough_escaped.md b/test/data/strikethrough_escaped.md new file mode 100644 index 000000000..d169144d2 --- /dev/null +++ b/test/data/strikethrough_escaped.md @@ -0,0 +1,5 @@ +~~strikethrough~~ + +here's ~~one~~ followed by ~~another one~~ + +~~ this ~~ is not one neither is ~this~ \ No newline at end of file diff --git a/test/data/strong_em_escaped.html b/test/data/strong_em_escaped.html new file mode 100644 index 000000000..b709c9914 --- /dev/null +++ b/test/data/strong_em_escaped.html @@ -0,0 +1,6 @@ +

em strong em

+

strong em em

+

em strong em em

+

em strong em

+

strong em em

+

em strong em em

\ No newline at end of file diff --git a/test/data/strong_em_escaped.md b/test/data/strong_em_escaped.md new file mode 100644 index 000000000..f2aa3c782 --- /dev/null +++ b/test/data/strong_em_escaped.md @@ -0,0 +1,11 @@ +*em **strong em*** + +***strong em** em* + +*em **strong em** em* + +_em __strong em___ + +___strong em__ em_ + +_em __strong em__ em_ \ No newline at end of file diff --git a/test/data/tab-indented_code_block_escaped.html b/test/data/tab-indented_code_block_escaped.html new file mode 100644 index 000000000..7c140de73 --- /dev/null +++ b/test/data/tab-indented_code_block_escaped.html @@ -0,0 +1,6 @@ +
<?php
+
+$message = 'Hello World!';
+echo $message;
+
+echo "following a blank line";
\ No newline at end of file diff --git a/test/data/tab-indented_code_block_escaped.md b/test/data/tab-indented_code_block_escaped.md new file mode 100644 index 000000000..a405a1609 --- /dev/null +++ b/test/data/tab-indented_code_block_escaped.md @@ -0,0 +1,6 @@ + + + +header 1 +header 2 + + + + +cell 1.1 +cell 1.2 + + +cell 2.1 +cell 2.2 + + + \ No newline at end of file diff --git a/test/data/table_inline_markdown_escaped.md b/test/data/table_inline_markdown_escaped.md new file mode 100644 index 000000000..c2fe1080c --- /dev/null +++ b/test/data/table_inline_markdown_escaped.md @@ -0,0 +1,4 @@ +| _header_ 1 | header 2 | +| ------------ | ------------ | +| _cell_ 1.1 | ~~cell~~ 1.2 | +| `cell` 2.1 | cell 2.2 | \ No newline at end of file diff --git a/test/data/text_reference_escaped.html b/test/data/text_reference_escaped.html new file mode 100644 index 000000000..11e4d37ff --- /dev/null +++ b/test/data/text_reference_escaped.html @@ -0,0 +1,8 @@ +

reference link

+

one with a semantic name

+

[one][404] with no definition

+

multiline +one defined on 2 lines

+

one with a mixed case label and an upper case definition

+

one with the a label on the next line

+

link

\ No newline at end of file diff --git a/test/data/text_reference_escaped.md b/test/data/text_reference_escaped.md new file mode 100644 index 000000000..1a66a5cf6 --- /dev/null +++ b/test/data/text_reference_escaped.md @@ -0,0 +1,21 @@ +[reference link][1] + +[1]: http://example.com + +[one][website] with a semantic name + +[website]: http://example.com + +[one][404] with no definition + +[multiline +one][website] defined on 2 lines + +[one][Label] with a mixed case label and an upper case definition + +[LABEL]: http://example.com + +[one] +[1] with the a label on the next line + +[`link`][website] \ No newline at end of file diff --git a/test/data/unordered_list_escaped.html b/test/data/unordered_list_escaped.html new file mode 100644 index 000000000..cd95567b7 --- /dev/null +++ b/test/data/unordered_list_escaped.html @@ -0,0 +1,10 @@ +
    +
  • li
  • +
  • li
  • +
+

mixed markers:

+
    +
  • li
  • +
  • li
  • +
  • li
  • +
\ No newline at end of file diff --git a/test/data/unordered_list_escaped.md b/test/data/unordered_list_escaped.md new file mode 100644 index 000000000..cf62c99f2 --- /dev/null +++ b/test/data/unordered_list_escaped.md @@ -0,0 +1,8 @@ +- li +- li + +mixed markers: + +* li ++ li +- li \ No newline at end of file diff --git a/test/data/untidy_table_escaped.html b/test/data/untidy_table_escaped.html new file mode 100644 index 000000000..88e1c2bd4 --- /dev/null +++ b/test/data/untidy_table_escaped.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + +
header 1header 2
cell 1.1cell 1.2
cell 2.1cell 2.2
\ No newline at end of file diff --git a/test/data/untidy_table_escaped.md b/test/data/untidy_table_escaped.md new file mode 100644 index 000000000..8524eb184 --- /dev/null +++ b/test/data/untidy_table_escaped.md @@ -0,0 +1,4 @@ +| header 1 | header 2 | +| ------------- | ----------- | +| cell 1.1 | cell 1.2 | +| cell 2.1 | cell 2.2 | \ No newline at end of file diff --git a/test/data/url_autolinking_escaped.html b/test/data/url_autolinking_escaped.html new file mode 100644 index 000000000..58ca94c6b --- /dev/null +++ b/test/data/url_autolinking_escaped.html @@ -0,0 +1,3 @@ +

an autolink http://example.com

+

inside of brackets [http://example.com], inside of braces {http://example.com}, inside of parentheses (http://example.com)

+

trailing slash http://example.com/ and http://example.com/path/

\ No newline at end of file diff --git a/test/data/url_autolinking_escaped.md b/test/data/url_autolinking_escaped.md new file mode 100644 index 000000000..840f35404 --- /dev/null +++ b/test/data/url_autolinking_escaped.md @@ -0,0 +1,5 @@ +an autolink http://example.com + +inside of brackets [http://example.com], inside of braces {http://example.com}, inside of parentheses (http://example.com) + +trailing slash http://example.com/ and http://example.com/path/ \ No newline at end of file diff --git a/test/data/whitespace_escaped.html b/test/data/whitespace_escaped.html new file mode 100644 index 000000000..f2dd7a002 --- /dev/null +++ b/test/data/whitespace_escaped.html @@ -0,0 +1 @@ +
code
\ No newline at end of file diff --git a/test/data/whitespace_escaped.md b/test/data/whitespace_escaped.md new file mode 100644 index 000000000..4cf926a8a --- /dev/null +++ b/test/data/whitespace_escaped.md @@ -0,0 +1,5 @@ + + + code + + \ No newline at end of file