mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Fix whitespace errors
This commit is contained in:
parent
42d21a2413
commit
a2bca78f7e
@ -7,6 +7,7 @@ use Erusev\Parsedown\AST\StateRenderable;
|
|||||||
use Erusev\Parsedown\Components\Block;
|
use Erusev\Parsedown\Components\Block;
|
||||||
use Erusev\Parsedown\Components\ContinuableBlock;
|
use Erusev\Parsedown\Components\ContinuableBlock;
|
||||||
use Erusev\Parsedown\Html\Renderables\Element;
|
use Erusev\Parsedown\Html\Renderables\Element;
|
||||||
|
use Erusev\Parsedown\Html\Renderables\Text;
|
||||||
use Erusev\Parsedown\Parsedown;
|
use Erusev\Parsedown\Parsedown;
|
||||||
use Erusev\Parsedown\Parsing\Context;
|
use Erusev\Parsedown\Parsing\Context;
|
||||||
use Erusev\Parsedown\Parsing\Line;
|
use Erusev\Parsedown\Parsing\Line;
|
||||||
@ -106,6 +107,7 @@ final class BlockQuote implements ContinuableBlock
|
|||||||
);
|
);
|
||||||
|
|
||||||
$Renderables = $State->applyTo($StateRenderables);
|
$Renderables = $State->applyTo($StateRenderables);
|
||||||
|
$Renderables[] = new Text("\n");
|
||||||
|
|
||||||
return new Element('blockquote', [], $Renderables);
|
return new Element('blockquote', [], $Renderables);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ final class SetextHeader implements Block
|
|||||||
if ($Context->line()->indent() < 4 && \chop(\chop($Context->line()->text(), " \t"), $Context->line()->text()[0]) === '') {
|
if ($Context->line()->indent() < 4 && \chop(\chop($Context->line()->text(), " \t"), $Context->line()->text()[0]) === '') {
|
||||||
$level = $Context->line()->text()[0] === '=' ? 1 : 2;
|
$level = $Context->line()->text()[0] === '=' ? 1 : 2;
|
||||||
|
|
||||||
return new self($Block->text(), $level);
|
return new self(\trim($Block->text()), $level);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -40,11 +40,18 @@ final class Code implements Inline
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (\preg_match(
|
if (\preg_match(
|
||||||
'/^(['.$marker.']++)[ ]*+(.*?)[ ]*+(?<!['.$marker.'])\1(?!'.$marker.')/s',
|
'/^(['.$marker.']++)(.*?)(?<!['.$marker.'])\1(?!'.$marker.')/s',
|
||||||
$Excerpt->text(),
|
$Excerpt->text(),
|
||||||
$matches
|
$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]));
|
return new self($text, \strlen($matches[0]));
|
||||||
}
|
}
|
||||||
|
1
tests/commonmark/324-Code_spans.html
Normal file
1
tests/commonmark/324-Code_spans.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p><code>foo bar baz</code></p>
|
5
tests/commonmark/324-Code_spans.md
Normal file
5
tests/commonmark/324-Code_spans.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
``
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
``
|
1
tests/commonmark/326-Code_spans.html
Normal file
1
tests/commonmark/326-Code_spans.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p><code>foo bar baz</code></p>
|
2
tests/commonmark/326-Code_spans.md
Normal file
2
tests/commonmark/326-Code_spans.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
`foo bar
|
||||||
|
baz`
|
1
tests/commonmark/621-Hard_line_breaks.html
Normal file
1
tests/commonmark/621-Hard_line_breaks.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p><code>code span</code></p>
|
2
tests/commonmark/621-Hard_line_breaks.md
Normal file
2
tests/commonmark/621-Hard_line_breaks.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
`code
|
||||||
|
span`
|
Loading…
x
Reference in New Issue
Block a user