Skip to content

Commit 928d80a

Browse files
jaapiolinawolf
authored andcommitted
[BUGFIX] inline break needs to convert to space
An inline break needs to be converted to a space as markdown doesn't care about linebreaks in a paragraph.
1 parent c138df6 commit 928d80a

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

packages/guides-markdown/resources/config/guides-markdown.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use phpDocumentor\Guides\Markdown\Parsers\InlineParsers\InlineCodeParser;
1212
use phpDocumentor\Guides\Markdown\Parsers\InlineParsers\InlineImageParser;
1313
use phpDocumentor\Guides\Markdown\Parsers\InlineParsers\LinkParser;
14+
use phpDocumentor\Guides\Markdown\Parsers\InlineParsers\NewLineParser;
1415
use phpDocumentor\Guides\Markdown\Parsers\InlineParsers\PlainTextParser;
1516
use phpDocumentor\Guides\Markdown\Parsers\InlineParsers\StrongParser;
1617
use phpDocumentor\Guides\Markdown\Parsers\ListBlockParser;
@@ -73,6 +74,8 @@
7374
->set(InlineImageParser::class)
7475
->arg('$inlineParsers', tagged_iterator('phpdoc.guides.markdown.parser.inlineParser'))
7576
->tag('phpdoc.guides.markdown.parser.inlineParser')
77+
->set(NewLineParser::class)
78+
->tag('phpdoc.guides.markdown.parser.inlineParser')
7679

7780
->set(MarkupLanguageParser::class)
7881
->arg('$parsers', tagged_iterator('phpdoc.guides.markdown.parser.blockParser'))
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link https://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Guides\Markdown\Parsers\InlineParsers;
15+
16+
use League\CommonMark\Node\Inline\Newline;
17+
use League\CommonMark\Node\Node as CommonMarkNode;
18+
use League\CommonMark\Node\NodeWalker;
19+
use League\CommonMark\Node\NodeWalkerEvent;
20+
use phpDocumentor\Guides\MarkupLanguageParser;
21+
use phpDocumentor\Guides\Nodes\Inline\InlineNode;
22+
use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
23+
24+
/** @extends AbstractInlineParser<PlainTextInlineNode> */
25+
class NewLineParser extends AbstractInlineParser
26+
{
27+
public function __construct()
28+
{
29+
}
30+
31+
public function parse(MarkupLanguageParser $parser, NodeWalker $walker, CommonMarkNode $current): InlineNode
32+
{
33+
return new PlainTextInlineNode(' ');
34+
}
35+
36+
public function supports(NodeWalkerEvent $event): bool
37+
{
38+
return $event->isEntering() && $event->getNode() instanceof Newline;
39+
}
40+
}

tests/Integration/tests/markdown/paragraph-md/input/skip

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)