Commit 47d8a138 authored by Emanuil Rusev's avatar Emanuil Rusev
Browse files

implement automatic line breaks as an option

parent fd42f2e8
......@@ -33,6 +33,19 @@ class Parsedown
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
#
......@@ -658,7 +671,7 @@ class Parsedown
'_' => '/^_(.*?)__(.+?)__(.*?)_/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())
{
......@@ -717,14 +730,6 @@ class Parsedown
switch ($closest_marker)
{
case " \n":
$markup .= '<br />';
$offset = 2;
break;
case '![':
case '[':
......@@ -979,6 +984,8 @@ class Parsedown
$markers[$closest_marker_index] = $closest_marker;
}
$markup = str_replace($this->break_marker, '<br />'."\n", $markup);
return $markup;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment