Skip to content

Commit

Permalink
Litedown: skip the next auto line break when a forced line break is used
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jul 21, 2019
1 parent 8d6c632 commit 27f7090
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4784,6 +4784,8 @@ s9e\TextFormatter\Tests\Plugins\Litedown\Parser\Passes\ForcedLineBreaks
[x] Parsing tests with data set #5
[x] Parsing tests with data set #6
[x] Parsing tests with data set #7
[x] Parsing tests with data set #8
[x] Parsing tests with data set #9
[x] Parsing tests (JavaScript) with data set #0
[x] Parsing tests (JavaScript) with data set #1
[x] Parsing tests (JavaScript) with data set #2
Expand All @@ -4792,6 +4794,8 @@ s9e\TextFormatter\Tests\Plugins\Litedown\Parser\Passes\ForcedLineBreaks
[x] Parsing tests (JavaScript) with data set #5
[x] Parsing tests (JavaScript) with data set #6
[x] Parsing tests (JavaScript) with data set #7
[x] Parsing tests (JavaScript) with data set #8
[x] Parsing tests (JavaScript) with data set #9
[x] Parsing+rendering tests with data set #0

s9e\TextFormatter\Tests\Plugins\Litedown\Parser\Passes\Images
Expand Down
4 changes: 3 additions & 1 deletion src/Plugins/Litedown/Parser/Passes/ForcedLineBreaks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ function parse()
var pos = text.indexOf(" \n");
while (pos > 0)
{
addBrTag(pos + 2);
addBrTag(pos + 2).cascadeInvalidationTo(
addVerbatim(pos + 2, 1)
);
pos = text.indexOf(" \n", pos + 3);
}
}
4 changes: 3 additions & 1 deletion src/Plugins/Litedown/Parser/Passes/ForcedLineBreaks.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public function parse()
$pos = $this->text->indexOf(" \n");
while ($pos !== false)
{
$this->parser->addBrTag($pos + 2);
$this->parser->addBrTag($pos + 2)->cascadeInvalidationTo(
$this->parser->addVerbatim($pos + 2, 1)
);
$pos = $this->text->indexOf(" \n", $pos + 3);
}
}
Expand Down
32 changes: 32 additions & 0 deletions tests/Plugins/Litedown/Parser/Passes/ForcedLineBreaksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,38 @@ public function getParsingTests()
'<p>bar</p> </r>'
]
],
[
[
'forced ',
'linebreak'
],
[
'<t><p>forced <br/>',
'linebreak</p></t>'
],
[],
function ($configurator)
{
$configurator->rootRules->enableAutoLineBreaks();
}
],
[
[
'forced ',
'',
'linebreak'
],
[
'<t><p>forced</p> ',
'',
'<p>linebreak</p></t>'
],
[],
function ($configurator)
{
$configurator->rootRules->enableAutoLineBreaks();
}
],
]);
}

Expand Down

0 comments on commit 27f7090

Please sign in to comment.