mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
implement automatic line breaks as an option
This commit is contained in:
parent
fd42f2e864
commit
47d8a1382b
@ -33,6 +33,19 @@ class Parsedown
|
|||||||
|
|
||||||
private static $instances = array();
|
private static $instances = array();
|
||||||
|
|
||||||
|
#
|
||||||
|
# Setters
|
||||||
|
#
|
||||||
|
|
||||||
|
private $break_marker = " \n";
|
||||||
|
|
||||||
|
function set_breaks_enabled($breaks_enabled)
|
||||||
|
{
|
||||||
|
$this->break_marker = $breaks_enabled ? "\n" : " \n";
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Fields
|
# Fields
|
||||||
#
|
#
|
||||||
@ -658,7 +671,7 @@ class Parsedown
|
|||||||
'_' => '/^_(.*?)__(.+?)__(.*?)_/s',
|
'_' => '/^_(.*?)__(.+?)__(.*?)_/s',
|
||||||
);
|
);
|
||||||
|
|
||||||
private function parse_span_elements($text, $markers = array(" \n", '![', '&', '*', '<', '[', '_', '`', 'http', '~~'))
|
private function parse_span_elements($text, $markers = array('![', '&', '*', '<', '[', '_', '`', 'http', '~~'))
|
||||||
{
|
{
|
||||||
if (isset($text[2]) === false or $markers === array())
|
if (isset($text[2]) === false or $markers === array())
|
||||||
{
|
{
|
||||||
@ -717,14 +730,6 @@ class Parsedown
|
|||||||
|
|
||||||
switch ($closest_marker)
|
switch ($closest_marker)
|
||||||
{
|
{
|
||||||
case " \n":
|
|
||||||
|
|
||||||
$markup .= '<br />';
|
|
||||||
|
|
||||||
$offset = 2;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '![':
|
case '![':
|
||||||
case '[':
|
case '[':
|
||||||
|
|
||||||
@ -979,6 +984,8 @@ class Parsedown
|
|||||||
$markers[$closest_marker_index] = $closest_marker;
|
$markers[$closest_marker_index] = $closest_marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$markup = str_replace($this->break_marker, '<br />'."\n", $markup);
|
||||||
|
|
||||||
return $markup;
|
return $markup;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user