previousEmptyLines -> precedingEmptyLines

This commit is contained in:
Aidan Woods 2020-01-19 16:53:18 +00:00
parent 7610eacbf9
commit a6c17f449e
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
10 changed files with 35 additions and 35 deletions

View File

@ -62,7 +62,7 @@ final class BlockQuote implements ContinuableBlock
*/
public function advance(Context $Context, State $State)
{
if ($Context->previousEmptyLines() > 0) {
if ($Context->precedingEmptyLines() > 0) {
return null;
}
@ -82,7 +82,7 @@ final class BlockQuote implements ContinuableBlock
return new self($Lines);
}
if (! $Context->previousEmptyLines() > 0) {
if (! $Context->precedingEmptyLines() > 0) {
$indentOffset = $Context->line()->indentOffset() + $Context->line()->indent();
$Lines = $this->Lines->appendingTextLines($Context->line()->text(), $indentOffset);

View File

@ -88,7 +88,7 @@ final class FencedCode implements ContinuableBlock
$newCode = $this->code;
$newCode .= $Context->previousEmptyLinesText();
$newCode .= $Context->precedingEmptyLinesText();
if (($len = \strspn($Context->line()->text(), $this->marker)) >= $this->openerLength
&& \chop(\substr($Context->line()->text(), $len), ' ') === ''

View File

@ -35,7 +35,7 @@ final class IndentedCode implements ContinuableBlock
State $State,
Block $Block = null
) {
if (isset($Block) && $Block instanceof Paragraph && ! $Context->previousEmptyLines() > 0) {
if (isset($Block) && $Block instanceof Paragraph && ! $Context->precedingEmptyLines() > 0) {
return null;
}
@ -61,8 +61,8 @@ final class IndentedCode implements ContinuableBlock
$offset = $Context->line()->indentOffset();
if ($Context->previousEmptyLines() > 0) {
foreach (\explode("\n", $Context->previousEmptyLinesText()) as $line) {
if ($Context->precedingEmptyLines() > 0) {
foreach (\explode("\n", $Context->precedingEmptyLinesText()) as $line) {
$newCode .= (new Line($line, $offset))->ltrimBodyUpto(4) . "\n";
}

View File

@ -175,7 +175,7 @@ final class Markup implements ContinuableBlock
$tail = $matches[1];
if (! \array_key_exists($element, self::SPECIAL_HTML_BLOCK_TAGS)
&& ! (isset($Block) && $Block instanceof Paragraph && $Context->previousEmptyLines() < 1)
&& ! (isset($Block) && $Block instanceof Paragraph && $Context->precedingEmptyLines() < 1)
&& \preg_match('/^\s*+$/', $tail)
) {
return new self($rawLine, 7);
@ -200,7 +200,7 @@ final class Markup implements ContinuableBlock
return null;
}
if (($type === 6 || $type === 7) && $Context->previousEmptyLines() > 0) {
if (($type === 6 || $type === 7) && $Context->precedingEmptyLines() > 0) {
return null;
}
@ -208,7 +208,7 @@ final class Markup implements ContinuableBlock
$closed = self::closes12345TypeMarkup($type, $Context->line()->text());
}
$html = $this->html . \str_repeat("\n", $Context->previousEmptyLines() + 1);
$html = $this->html . \str_repeat("\n", $Context->precedingEmptyLines() + 1);
$html .= $Context->line()->rawLine();
return new self($html, $type, $closed);

View File

@ -45,7 +45,7 @@ final class Paragraph implements ContinuableBlock
*/
public function advance(Context $Context, State $State)
{
if ($Context->previousEmptyLines() > 0) {
if ($Context->precedingEmptyLines() > 0) {
return null;
}

View File

@ -40,7 +40,7 @@ final class SetextHeader implements AcquisitioningBlock
State $State,
Block $Block = null
) {
if (! isset($Block) || ! $Block instanceof Paragraph || $Context->previousEmptyLines() > 0) {
if (! isset($Block) || ! $Block instanceof Paragraph || $Context->precedingEmptyLines() > 0) {
return null;
}

View File

@ -134,7 +134,7 @@ final class TList implements ContinuableBlock
$listStart !== 1
&& isset($Block)
&& $Block instanceof Paragraph
&& ! $Context->previousEmptyLines() > 0
&& ! $Context->precedingEmptyLines() > 0
) {
return null;
}
@ -161,11 +161,11 @@ final class TList implements ContinuableBlock
*/
public function advance(Context $Context, State $State)
{
if ($Context->previousEmptyLines() > 0 && \end($this->Lis)->isEmpty()) {
if ($Context->precedingEmptyLines() > 0 && \end($this->Lis)->isEmpty()) {
return null;
}
$newlines = \str_repeat("\n", $Context->previousEmptyLines());
$newlines = \str_repeat("\n", $Context->precedingEmptyLines());
$requiredIndent = $this->indent + \strlen($this->marker) + $this->afterMarkerSpaces;
$isLoose = $this->isLoose;
@ -182,7 +182,7 @@ final class TList implements ContinuableBlock
if ($Context->line()->indent() < $requiredIndent
&& \preg_match($regex, $Context->line()->text(), $matches)
) {
if ($Context->previousEmptyLines() > 0) {
if ($Context->precedingEmptyLines() > 0) {
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingBlankLines(1);
$isLoose = true;
@ -224,8 +224,8 @@ final class TList implements ContinuableBlock
}
if ($Context->line()->indent() >= $requiredIndent) {
if ($Context->previousEmptyLines() > 0) {
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingBlankLines($Context->previousEmptyLines());
if ($Context->precedingEmptyLines() > 0) {
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingBlankLines($Context->precedingEmptyLines());
$isLoose = true;
}
@ -248,7 +248,7 @@ final class TList implements ContinuableBlock
);
}
if (! $Context->previousEmptyLines() > 0) {
if (! $Context->precedingEmptyLines() > 0) {
$text = $Context->line()->ltrimBodyUpto($requiredIndent);
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingTextLines(

View File

@ -96,7 +96,7 @@ final class Table implements AcquisitioningBlock, ContinuableBlock
*/
public function advance(Context $Context, State $State)
{
if ($Context->previousEmptyLines() > 0) {
if ($Context->precedingEmptyLines() > 0) {
return null;
}

View File

@ -8,20 +8,20 @@ final class Context
private $Line;
/** @var int|null */
private $previousEmptyLines;
private $precedingEmptyLines;
/** @var string */
private $previousEmptyLinesText;
private $precedingEmptyLinesText;
/**
* @param Line $Line
* @param string $previousEmptyLinesText
* @param string $precedingEmptyLinesText
*/
public function __construct($Line, $previousEmptyLinesText)
public function __construct($Line, $precedingEmptyLinesText)
{
$this->Line = $Line;
$this->previousEmptyLinesText = $previousEmptyLinesText;
$this->previousEmptyLines = null;
$this->precedingEmptyLinesText = $precedingEmptyLinesText;
$this->precedingEmptyLines = null;
}
/** @return Line */
@ -31,18 +31,18 @@ final class Context
}
/** @return int */
public function previousEmptyLines()
public function precedingEmptyLines()
{
if (! isset($this->previousEmptyLines)) {
$this->previousEmptyLines = \substr_count($this->previousEmptyLinesText, "\n");
if (! isset($this->precedingEmptyLines)) {
$this->precedingEmptyLines = \substr_count($this->precedingEmptyLinesText, "\n");
}
return $this->previousEmptyLines;
return $this->precedingEmptyLines;
}
/** @return string */
public function previousEmptyLinesText()
public function precedingEmptyLinesText()
{
return $this->previousEmptyLinesText;
return $this->precedingEmptyLinesText;
}
}

View File

@ -30,7 +30,7 @@ final class Lines
if (! $containsBlankLines) {
foreach ($Contexts as $Context) {
if ($Context->previousEmptyLines() > 0) {
if ($Context->precedingEmptyLines() > 0) {
$containsBlankLines = true;
break;
}
@ -140,7 +140,7 @@ final class Lines
$NextLines->Contexts[0] = new Context(
$NextLines->Contexts[0]->line(),
$NextLines->Contexts[0]->previousEmptyLinesText() . $Lines->trailingBlankLinesText
$NextLines->Contexts[0]->precedingEmptyLinesText() . $Lines->trailingBlankLinesText
);
$Lines->Contexts = \array_merge($Lines->Contexts, $NextLines->Contexts);
@ -162,10 +162,10 @@ final class Lines
$Context = new Context(
$Context->line(),
$Context->previousEmptyLinesText() . $Lines->trailingBlankLinesText
$Context->precedingEmptyLinesText() . $Lines->trailingBlankLinesText
);
if ($Context->previousEmptyLines() > 0) {
if ($Context->precedingEmptyLines() > 0) {
$Lines->containsBlankLines = true;
}