1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

leading spaces should not get trimmed

This commit is contained in:
Emanuil Rusev 2013-11-09 22:23:56 +02:00
parent ee9a1e92c0
commit 8e6f4cf7b8
3 changed files with 18 additions and 2 deletions

View File

@ -210,10 +210,15 @@ class Parsedown
goto paragraph;
}
# Code
# Code Block
if ($line[0] === ' ' and preg_match('/^[ ]{4}(.*)/', $line, $matches))
{
if (trim($line) === '')
{
continue;
}
if ($element['type'] === 'code')
{
if (isset($element['interrupted']))
@ -279,6 +284,11 @@ class Parsedown
$pure_line = $line[0] !== ' ' ? $line : ltrim($line);
if ($pure_line === '')
{
continue;
}
# Link Reference
if ($pure_line[0] === '[' and preg_match('/^\[(.+?)\]:[ ]*([^ ]+)/', $pure_line, $matches))

View File

@ -0,0 +1 @@
<pre><code>This text starts with a line that consists of 4 spaces and it ends with one. This is a code block to make sure that leading spaces don't get trimmed.</code></pre>

5
tests/data/whitespace.md Normal file
View File

@ -0,0 +1,5 @@
This text starts with a line that consists of 4 spaces and it ends with one. This is a code block to make sure that leading spaces don't get trimmed.