mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
markup formatting shouldn't impact results
This commit is contained in:
parent
aa3d4d6eb7
commit
46196c1ac3
@ -22,10 +22,7 @@ class CommonMarkTest extends PHPUnit_Framework_TestCase
|
|||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
|
|
||||||
$actualHtml = $parsedown->text($markdown);
|
$actualHtml = $parsedown->text($markdown);
|
||||||
|
$actualHtml = $this->normalizeMarkup($actualHtml);
|
||||||
# trim for better compatibility of the HTML output
|
|
||||||
$actualHtml = trim($actualHtml);
|
|
||||||
$expectedHtml = trim($expectedHtml);
|
|
||||||
|
|
||||||
$this->assertEquals($expectedHtml, $actualHtml);
|
$this->assertEquals($expectedHtml, $actualHtml);
|
||||||
}
|
}
|
||||||
@ -46,10 +43,13 @@ class CommonMarkTest extends PHPUnit_Framework_TestCase
|
|||||||
$currentSection = $matches[3];
|
$currentSection = $matches[3];
|
||||||
} else {
|
} else {
|
||||||
$testCount++;
|
$testCount++;
|
||||||
$markdown = preg_replace('/→/', "\t", $matches[1]);
|
$markdown = $matches[1];
|
||||||
|
$markdown = preg_replace('/→/', "\t", $markdown);
|
||||||
|
$expectedHtml = $matches[2];
|
||||||
|
$expectedHtml = $this->normalizeMarkup($expectedHtml);
|
||||||
$tests []= array(
|
$tests []= array(
|
||||||
$markdown, # markdown
|
$markdown, # markdown
|
||||||
$matches[2], # html
|
$expectedHtml, # html
|
||||||
$currentSection, # section
|
$currentSection, # section
|
||||||
$testCount, # number
|
$testCount, # number
|
||||||
);
|
);
|
||||||
@ -60,4 +60,15 @@ class CommonMarkTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return $tests;
|
return $tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function normalizeMarkup($markup)
|
||||||
|
{
|
||||||
|
$markup = preg_replace("/\n+/", "\n", $markup);
|
||||||
|
$markup = preg_replace('/^\s+/m', '', $markup);
|
||||||
|
$markup = preg_replace('/^((?:<[\w]+>)+)\n/m', '$1', $markup);
|
||||||
|
$markup = preg_replace('/\n((?:<\/[\w]+>)+)$/m', '$1', $markup);
|
||||||
|
$markup = trim($markup);
|
||||||
|
|
||||||
|
return $markup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user