mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Merge pull request #598 from aidantwoods/enhancement/set-literal-breaks
Add literalBreaks support
This commit is contained in:
commit
9b7b7348b4
@ -63,6 +63,15 @@ class Parsedown
|
||||
|
||||
protected $breaksEnabled;
|
||||
|
||||
function setLiteralBreaks($literalBreaks)
|
||||
{
|
||||
$this->literalBreaks = $literalBreaks;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected $literalBreaks;
|
||||
|
||||
function setMarkupEscaped($markupEscaped)
|
||||
{
|
||||
$this->markupEscaped = $markupEscaped;
|
||||
@ -167,7 +176,7 @@ class Parsedown
|
||||
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
if (chop($line) === '')
|
||||
if ( ! $this->literalBreaks and chop($line) === '')
|
||||
{
|
||||
if (isset($CurrentBlock))
|
||||
{
|
||||
@ -230,7 +239,15 @@ class Parsedown
|
||||
|
||||
# ~
|
||||
|
||||
$marker = $text[0];
|
||||
if (isset($text[0]))
|
||||
{
|
||||
$marker = $text[0];
|
||||
}
|
||||
elseif ($this->literalBreaks)
|
||||
{
|
||||
$marker = '\n';
|
||||
$text = ' ';
|
||||
}
|
||||
|
||||
# ~
|
||||
|
||||
|
@ -52,6 +52,7 @@ class ParsedownTest extends TestCase
|
||||
|
||||
$this->Parsedown->setSafeMode(substr($test, 0, 3) === 'xss');
|
||||
$this->Parsedown->setStrictMode(substr($test, 0, 6) === 'strict');
|
||||
$this->Parsedown->setLiteralBreaks(substr($test, 0, 14) === 'literal_breaks');
|
||||
|
||||
$actualMarkup = $this->Parsedown->text($markdown);
|
||||
|
||||
|
6
test/data/literal_breaks.html
Normal file
6
test/data/literal_breaks.html
Normal file
@ -0,0 +1,6 @@
|
||||
<p>first line
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
sixth line</p>
|
6
test/data/literal_breaks.md
Normal file
6
test/data/literal_breaks.md
Normal file
@ -0,0 +1,6 @@
|
||||
first line
|
||||
|
||||
|
||||
|
||||
|
||||
sixth line
|
Loading…
Reference in New Issue
Block a user