Fix whitespace errors

This commit is contained in:
Aidan Woods 2019-01-28 20:30:56 +00:00
parent 42d21a2413
commit a2bca78f7e
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
9 changed files with 24 additions and 3 deletions

View File

@ -7,6 +7,7 @@ use Erusev\Parsedown\AST\StateRenderable;
use Erusev\Parsedown\Components\Block;
use Erusev\Parsedown\Components\ContinuableBlock;
use Erusev\Parsedown\Html\Renderables\Element;
use Erusev\Parsedown\Html\Renderables\Text;
use Erusev\Parsedown\Parsedown;
use Erusev\Parsedown\Parsing\Context;
use Erusev\Parsedown\Parsing\Line;
@ -106,6 +107,7 @@ final class BlockQuote implements ContinuableBlock
);
$Renderables = $State->applyTo($StateRenderables);
$Renderables[] = new Text("\n");
return new Element('blockquote', [], $Renderables);
}

View File

@ -49,7 +49,7 @@ final class SetextHeader implements Block
if ($Context->line()->indent() < 4 && \chop(\chop($Context->line()->text(), " \t"), $Context->line()->text()[0]) === '') {
$level = $Context->line()->text()[0] === '=' ? 1 : 2;
return new self($Block->text(), $level);
return new self(\trim($Block->text()), $level);
}
return null;

View File

@ -40,11 +40,18 @@ final class Code implements Inline
}
if (\preg_match(
'/^(['.$marker.']++)[ ]*+(.*?)[ ]*+(?<!['.$marker.'])\1(?!'.$marker.')/s',
'/^(['.$marker.']++)(.*?)(?<!['.$marker.'])\1(?!'.$marker.')/s',
$Excerpt->text(),
$matches
)) {
$text = \preg_replace('/[ ]*+\n/', ' ', $matches[2]);
$text = \str_replace("\n", ' ', $matches[2]);
$firstChar = \substr($text, 0, 1);
$lastChar = \substr($text, -1);
if ($firstChar === ' ' && $lastChar === ' ') {
$text = \substr(\substr($text, 1), 0, -1);
}
return new self($text, \strlen($matches[0]));
}

View File

@ -0,0 +1 @@
<p><code>foo bar baz</code></p>

View File

@ -0,0 +1,5 @@
``
foo
bar
baz
``

View File

@ -0,0 +1 @@
<p><code>foo bar baz</code></p>

View File

@ -0,0 +1,2 @@
`foo bar
baz`

View File

@ -0,0 +1 @@
<p><code>code span</code></p>

View File

@ -0,0 +1,2 @@
`code
span`