1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Remove meaningless interrupt check

Interrupted implies previousEmptyLines > 0 in incoming Context
This commit is contained in:
Aidan Woods 2019-01-21 18:09:27 +00:00
parent 6f5780abfd
commit dac6b01d1a
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
11 changed files with 12 additions and 59 deletions

View File

@ -15,7 +15,7 @@ use Erusev\Parsedown\State;
final class BlockQuote implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
/** @var Lines */
private $Lines;
@ -64,7 +64,7 @@ final class BlockQuote implements ContinuableBlock
*/
public function advance(Context $Context)
{
if ($this->interrupted) {
if ($Context->previousEmptyLines() > 0) {
return null;
}

View File

@ -15,7 +15,7 @@ use Erusev\Parsedown\State;
final class Comment implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
/** @var string */
private $html;

View File

@ -1,28 +0,0 @@
<?php
namespace Erusev\Parsedown\Components\Blocks;
trait ContinuableBlockDefaultInterrupt
{
/** @var bool */
private $interrupted = false;
/**
* @param bool $isInterrupted
*/
public function interrupted($isInterrupted)
{
$New = clone($this);
$New->interrupted = $isInterrupted;
return $New;
}
/**
* @return bool
*/
public function isInterrupted()
{
return $this->interrupted;
}
}

View File

@ -13,7 +13,7 @@ use Erusev\Parsedown\State;
final class FencedCode implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
/** @var string */
private $code;

View File

@ -13,7 +13,7 @@ use Erusev\Parsedown\State;
final class IndentedCode implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
/** @var string */
private $code;

View File

@ -16,7 +16,7 @@ use Erusev\Parsedown\State;
final class Markup implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
const REGEX_HTML_ATTRIBUTE = '[a-zA-Z_:][\w:.-]*+(?:\s*+=\s*+(?:[^"\'=<>`\s]+|"[^"]*+"|\'[^\']*+\'))?+';
@ -59,7 +59,7 @@ final class Markup implements ContinuableBlock
*/
public function advance(Context $Context)
{
if ($this->interrupted) {
if ($Context->previousEmptyLines() > 0) {
return null;
}

View File

@ -13,7 +13,7 @@ use Erusev\Parsedown\State;
final class Paragraph implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
/** @var string */
private $text;
@ -46,7 +46,7 @@ final class Paragraph implements ContinuableBlock
*/
public function advance(Context $Context)
{
if ($this->interrupted) {
if ($Context->previousEmptyLines() > 0) {
return null;
}

View File

@ -14,7 +14,7 @@ use Erusev\Parsedown\State;
final class TList implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
/** @var Lines[] */
private $Lis;
@ -152,7 +152,7 @@ final class TList implements ContinuableBlock
*/
public function advance(Context $Context)
{
if ($this->interrupted and \end($this->Lis)->isEmpty()) {
if ($Context->previousEmptyLines() > 0 and \end($this->Lis)->isEmpty()) {
return null;
}

View File

@ -16,7 +16,7 @@ use Erusev\Parsedown\State;
*/
final class Table implements ContinuableBlock
{
use ContinuableBlockDefaultInterrupt, BlockAcquisition;
use BlockAcquisition;
/** @var array<int, _Alignment|null> */
private $alignments;

View File

@ -11,15 +11,4 @@ interface ContinuableBlock extends Block
* @return static|null
*/
public function advance(Context $Context);
/**
* @param bool $isInterrupted
* @return static
*/
public function interrupted($isInterrupted);
/**
* @return bool
*/
public function isInterrupted();
}

View File

@ -137,14 +137,6 @@ final class Parsedown
$CurrentBlock = null;
foreach ($Lines->contexts() as $Context) {
if (
isset($CurrentBlock)
&& $CurrentBlock instanceof ContinuableBlock
&& $Context->previousEmptyLines() > 0
) {
$CurrentBlock = $CurrentBlock->interrupted(true);
}
$Line = $Context->line();
if (