diff --git a/src/Components/Blocks/BlockQuote.php b/src/Components/Blocks/BlockQuote.php index 111de6c..d1853a7 100644 --- a/src/Components/Blocks/BlockQuote.php +++ b/src/Components/Blocks/BlockQuote.php @@ -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); } diff --git a/src/Components/Blocks/SetextHeader.php b/src/Components/Blocks/SetextHeader.php index 3f59dfe..e636778 100644 --- a/src/Components/Blocks/SetextHeader.php +++ b/src/Components/Blocks/SetextHeader.php @@ -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; diff --git a/src/Components/Inlines/Code.php b/src/Components/Inlines/Code.php index 53b4de5..5e51b90 100644 --- a/src/Components/Inlines/Code.php +++ b/src/Components/Inlines/Code.php @@ -40,11 +40,18 @@ final class Code implements Inline } if (\preg_match( - '/^(['.$marker.']++)[ ]*+(.*?)[ ]*+(?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])); } diff --git a/tests/commonmark/324-Code_spans.html b/tests/commonmark/324-Code_spans.html new file mode 100644 index 0000000..5e7a223 --- /dev/null +++ b/tests/commonmark/324-Code_spans.html @@ -0,0 +1 @@ +
foo bar baz
foo bar baz
code span