mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
previousEmptyLines -> precedingEmptyLines
This commit is contained in:
parent
7610eacbf9
commit
a6c17f449e
@ -62,7 +62,7 @@ final class BlockQuote implements ContinuableBlock
|
|||||||
*/
|
*/
|
||||||
public function advance(Context $Context, State $State)
|
public function advance(Context $Context, State $State)
|
||||||
{
|
{
|
||||||
if ($Context->previousEmptyLines() > 0) {
|
if ($Context->precedingEmptyLines() > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ final class BlockQuote implements ContinuableBlock
|
|||||||
return new self($Lines);
|
return new self($Lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $Context->previousEmptyLines() > 0) {
|
if (! $Context->precedingEmptyLines() > 0) {
|
||||||
$indentOffset = $Context->line()->indentOffset() + $Context->line()->indent();
|
$indentOffset = $Context->line()->indentOffset() + $Context->line()->indent();
|
||||||
$Lines = $this->Lines->appendingTextLines($Context->line()->text(), $indentOffset);
|
$Lines = $this->Lines->appendingTextLines($Context->line()->text(), $indentOffset);
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ final class FencedCode implements ContinuableBlock
|
|||||||
|
|
||||||
$newCode = $this->code;
|
$newCode = $this->code;
|
||||||
|
|
||||||
$newCode .= $Context->previousEmptyLinesText();
|
$newCode .= $Context->precedingEmptyLinesText();
|
||||||
|
|
||||||
if (($len = \strspn($Context->line()->text(), $this->marker)) >= $this->openerLength
|
if (($len = \strspn($Context->line()->text(), $this->marker)) >= $this->openerLength
|
||||||
&& \chop(\substr($Context->line()->text(), $len), ' ') === ''
|
&& \chop(\substr($Context->line()->text(), $len), ' ') === ''
|
||||||
|
@ -35,7 +35,7 @@ final class IndentedCode implements ContinuableBlock
|
|||||||
State $State,
|
State $State,
|
||||||
Block $Block = null
|
Block $Block = null
|
||||||
) {
|
) {
|
||||||
if (isset($Block) && $Block instanceof Paragraph && ! $Context->previousEmptyLines() > 0) {
|
if (isset($Block) && $Block instanceof Paragraph && ! $Context->precedingEmptyLines() > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,8 +61,8 @@ final class IndentedCode implements ContinuableBlock
|
|||||||
|
|
||||||
$offset = $Context->line()->indentOffset();
|
$offset = $Context->line()->indentOffset();
|
||||||
|
|
||||||
if ($Context->previousEmptyLines() > 0) {
|
if ($Context->precedingEmptyLines() > 0) {
|
||||||
foreach (\explode("\n", $Context->previousEmptyLinesText()) as $line) {
|
foreach (\explode("\n", $Context->precedingEmptyLinesText()) as $line) {
|
||||||
$newCode .= (new Line($line, $offset))->ltrimBodyUpto(4) . "\n";
|
$newCode .= (new Line($line, $offset))->ltrimBodyUpto(4) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ final class Markup implements ContinuableBlock
|
|||||||
$tail = $matches[1];
|
$tail = $matches[1];
|
||||||
|
|
||||||
if (! \array_key_exists($element, self::SPECIAL_HTML_BLOCK_TAGS)
|
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)
|
&& \preg_match('/^\s*+$/', $tail)
|
||||||
) {
|
) {
|
||||||
return new self($rawLine, 7);
|
return new self($rawLine, 7);
|
||||||
@ -200,7 +200,7 @@ final class Markup implements ContinuableBlock
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($type === 6 || $type === 7) && $Context->previousEmptyLines() > 0) {
|
if (($type === 6 || $type === 7) && $Context->precedingEmptyLines() > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ final class Markup implements ContinuableBlock
|
|||||||
$closed = self::closes12345TypeMarkup($type, $Context->line()->text());
|
$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();
|
$html .= $Context->line()->rawLine();
|
||||||
|
|
||||||
return new self($html, $type, $closed);
|
return new self($html, $type, $closed);
|
||||||
|
@ -45,7 +45,7 @@ final class Paragraph implements ContinuableBlock
|
|||||||
*/
|
*/
|
||||||
public function advance(Context $Context, State $State)
|
public function advance(Context $Context, State $State)
|
||||||
{
|
{
|
||||||
if ($Context->previousEmptyLines() > 0) {
|
if ($Context->precedingEmptyLines() > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ final class SetextHeader implements AcquisitioningBlock
|
|||||||
State $State,
|
State $State,
|
||||||
Block $Block = null
|
Block $Block = null
|
||||||
) {
|
) {
|
||||||
if (! isset($Block) || ! $Block instanceof Paragraph || $Context->previousEmptyLines() > 0) {
|
if (! isset($Block) || ! $Block instanceof Paragraph || $Context->precedingEmptyLines() > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ final class TList implements ContinuableBlock
|
|||||||
$listStart !== 1
|
$listStart !== 1
|
||||||
&& isset($Block)
|
&& isset($Block)
|
||||||
&& $Block instanceof Paragraph
|
&& $Block instanceof Paragraph
|
||||||
&& ! $Context->previousEmptyLines() > 0
|
&& ! $Context->precedingEmptyLines() > 0
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -161,11 +161,11 @@ final class TList implements ContinuableBlock
|
|||||||
*/
|
*/
|
||||||
public function advance(Context $Context, State $State)
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$newlines = \str_repeat("\n", $Context->previousEmptyLines());
|
$newlines = \str_repeat("\n", $Context->precedingEmptyLines());
|
||||||
|
|
||||||
$requiredIndent = $this->indent + \strlen($this->marker) + $this->afterMarkerSpaces;
|
$requiredIndent = $this->indent + \strlen($this->marker) + $this->afterMarkerSpaces;
|
||||||
$isLoose = $this->isLoose;
|
$isLoose = $this->isLoose;
|
||||||
@ -182,7 +182,7 @@ final class TList implements ContinuableBlock
|
|||||||
if ($Context->line()->indent() < $requiredIndent
|
if ($Context->line()->indent() < $requiredIndent
|
||||||
&& \preg_match($regex, $Context->line()->text(), $matches)
|
&& \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);
|
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingBlankLines(1);
|
||||||
|
|
||||||
$isLoose = true;
|
$isLoose = true;
|
||||||
@ -224,8 +224,8 @@ final class TList implements ContinuableBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Context->line()->indent() >= $requiredIndent) {
|
if ($Context->line()->indent() >= $requiredIndent) {
|
||||||
if ($Context->previousEmptyLines() > 0) {
|
if ($Context->precedingEmptyLines() > 0) {
|
||||||
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingBlankLines($Context->previousEmptyLines());
|
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingBlankLines($Context->precedingEmptyLines());
|
||||||
|
|
||||||
$isLoose = true;
|
$isLoose = true;
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ final class TList implements ContinuableBlock
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $Context->previousEmptyLines() > 0) {
|
if (! $Context->precedingEmptyLines() > 0) {
|
||||||
$text = $Context->line()->ltrimBodyUpto($requiredIndent);
|
$text = $Context->line()->ltrimBodyUpto($requiredIndent);
|
||||||
|
|
||||||
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingTextLines(
|
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingTextLines(
|
||||||
|
@ -96,7 +96,7 @@ final class Table implements AcquisitioningBlock, ContinuableBlock
|
|||||||
*/
|
*/
|
||||||
public function advance(Context $Context, State $State)
|
public function advance(Context $Context, State $State)
|
||||||
{
|
{
|
||||||
if ($Context->previousEmptyLines() > 0) {
|
if ($Context->precedingEmptyLines() > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,20 +8,20 @@ final class Context
|
|||||||
private $Line;
|
private $Line;
|
||||||
|
|
||||||
/** @var int|null */
|
/** @var int|null */
|
||||||
private $previousEmptyLines;
|
private $precedingEmptyLines;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $previousEmptyLinesText;
|
private $precedingEmptyLinesText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Line $Line
|
* @param Line $Line
|
||||||
* @param string $previousEmptyLinesText
|
* @param string $precedingEmptyLinesText
|
||||||
*/
|
*/
|
||||||
public function __construct($Line, $previousEmptyLinesText)
|
public function __construct($Line, $precedingEmptyLinesText)
|
||||||
{
|
{
|
||||||
$this->Line = $Line;
|
$this->Line = $Line;
|
||||||
$this->previousEmptyLinesText = $previousEmptyLinesText;
|
$this->precedingEmptyLinesText = $precedingEmptyLinesText;
|
||||||
$this->previousEmptyLines = null;
|
$this->precedingEmptyLines = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return Line */
|
/** @return Line */
|
||||||
@ -31,18 +31,18 @@ final class Context
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return int */
|
/** @return int */
|
||||||
public function previousEmptyLines()
|
public function precedingEmptyLines()
|
||||||
{
|
{
|
||||||
if (! isset($this->previousEmptyLines)) {
|
if (! isset($this->precedingEmptyLines)) {
|
||||||
$this->previousEmptyLines = \substr_count($this->previousEmptyLinesText, "\n");
|
$this->precedingEmptyLines = \substr_count($this->precedingEmptyLinesText, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->previousEmptyLines;
|
return $this->precedingEmptyLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return string */
|
/** @return string */
|
||||||
public function previousEmptyLinesText()
|
public function precedingEmptyLinesText()
|
||||||
{
|
{
|
||||||
return $this->previousEmptyLinesText;
|
return $this->precedingEmptyLinesText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ final class Lines
|
|||||||
|
|
||||||
if (! $containsBlankLines) {
|
if (! $containsBlankLines) {
|
||||||
foreach ($Contexts as $Context) {
|
foreach ($Contexts as $Context) {
|
||||||
if ($Context->previousEmptyLines() > 0) {
|
if ($Context->precedingEmptyLines() > 0) {
|
||||||
$containsBlankLines = true;
|
$containsBlankLines = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ final class Lines
|
|||||||
|
|
||||||
$NextLines->Contexts[0] = new Context(
|
$NextLines->Contexts[0] = new Context(
|
||||||
$NextLines->Contexts[0]->line(),
|
$NextLines->Contexts[0]->line(),
|
||||||
$NextLines->Contexts[0]->previousEmptyLinesText() . $Lines->trailingBlankLinesText
|
$NextLines->Contexts[0]->precedingEmptyLinesText() . $Lines->trailingBlankLinesText
|
||||||
);
|
);
|
||||||
|
|
||||||
$Lines->Contexts = \array_merge($Lines->Contexts, $NextLines->Contexts);
|
$Lines->Contexts = \array_merge($Lines->Contexts, $NextLines->Contexts);
|
||||||
@ -162,10 +162,10 @@ final class Lines
|
|||||||
|
|
||||||
$Context = new Context(
|
$Context = new Context(
|
||||||
$Context->line(),
|
$Context->line(),
|
||||||
$Context->previousEmptyLinesText() . $Lines->trailingBlankLinesText
|
$Context->precedingEmptyLinesText() . $Lines->trailingBlankLinesText
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($Context->previousEmptyLines() > 0) {
|
if ($Context->precedingEmptyLines() > 0) {
|
||||||
$Lines->containsBlankLines = true;
|
$Lines->containsBlankLines = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user