mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Expand public API of Components
Ref: https://github.com/erusev/parsedown/issues/694
This commit is contained in:
@@ -92,6 +92,14 @@ final class BlockQuote implements ContinuableBlock
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: Block[], 1: State}
|
||||
*/
|
||||
public function contents(State $State)
|
||||
{
|
||||
return Parsedown::blocks($this->Lines, $State);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element>
|
||||
*/
|
||||
@@ -100,10 +108,9 @@ final class BlockQuote implements ContinuableBlock
|
||||
return new Handler(
|
||||
/** @return Element */
|
||||
function (State $State) {
|
||||
list($StateRenderables, $State) = Parsedown::lines(
|
||||
$this->Lines,
|
||||
$State
|
||||
);
|
||||
list($Blocks, $State) = $this->contents($State);
|
||||
|
||||
$StateRenderables = Parsedown::stateRenderablesFrom($Blocks);
|
||||
|
||||
$Renderables = $State->applyTo($StateRenderables);
|
||||
$Renderables[] = new Text("\n");
|
||||
|
||||
@@ -101,15 +101,29 @@ final class FencedCode implements ContinuableBlock
|
||||
return new self($newCode, $this->infostring, $this->marker, $this->openerLength, false);
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function infostring()
|
||||
{
|
||||
return $this->infostring;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function code()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Element
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
$infostring = $this->infostring();
|
||||
|
||||
return new Element('pre', [], [new Element(
|
||||
'code',
|
||||
$this->infostring !== '' ? ['class' => "language-{$this->infostring}"] : [],
|
||||
[new Text($this->code)]
|
||||
$infostring !== '' ? ['class' => "language-{$infostring}"] : [],
|
||||
[new Text($this->code())]
|
||||
)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,18 @@ final class Header implements Block
|
||||
return new self($text, $level);
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function text()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/** @return 1|2|3|4|5|6 */
|
||||
public function level()
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element>
|
||||
*/
|
||||
@@ -85,9 +97,9 @@ final class Header implements Block
|
||||
/** @return Element */
|
||||
function (State $State) {
|
||||
return new Element(
|
||||
'h' . \strval($this->level),
|
||||
'h' . \strval($this->level()),
|
||||
[],
|
||||
$State->applyTo(Parsedown::line($this->text, $State))
|
||||
$State->applyTo(Parsedown::line($this->text(), $State))
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -74,6 +74,12 @@ final class IndentedCode implements ContinuableBlock
|
||||
return new self($newCode);
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function code()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Element
|
||||
*/
|
||||
@@ -82,7 +88,7 @@ final class IndentedCode implements ContinuableBlock
|
||||
return new Element(
|
||||
'pre',
|
||||
[],
|
||||
[new Element('code', [], [new Text($this->code)])]
|
||||
[new Element('code', [], [new Text($this->code())])]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +149,12 @@ final class Markup implements ContinuableBlock
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function html()
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element|RawHtml>
|
||||
*/
|
||||
@@ -158,9 +164,9 @@ final class Markup implements ContinuableBlock
|
||||
/** @return Element|RawHtml */
|
||||
function (State $State) {
|
||||
if ($State->get(SafeMode::class)->isEnabled()) {
|
||||
return new Element('p', [], [new Text($this->html)]);
|
||||
return new Element('p', [], [new Text($this->html())]);
|
||||
} else {
|
||||
return new RawHtml($this->html);
|
||||
return new RawHtml($this->html());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -69,7 +69,7 @@ final class Paragraph implements ContinuableBlock
|
||||
return new Element(
|
||||
'p',
|
||||
[],
|
||||
$State->applyTo(Parsedown::line(\trim($this->text), $State))
|
||||
$State->applyTo(Parsedown::line(\trim($this->text()), $State))
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -68,6 +68,18 @@ final class SetextHeader implements AcquisitioningBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function text()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/** @return 1|2 */
|
||||
public function level()
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element>
|
||||
*/
|
||||
@@ -77,9 +89,9 @@ final class SetextHeader implements AcquisitioningBlock
|
||||
/** @return Element */
|
||||
function (State $State) {
|
||||
return new Element(
|
||||
'h' . \strval($this->level),
|
||||
'h' . \strval($this->level()),
|
||||
[],
|
||||
$State->applyTo(Parsedown::line($this->text, $State))
|
||||
$State->applyTo(Parsedown::line($this->text(), $State))
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ final class TList implements ContinuableBlock
|
||||
/** @var Lines[] */
|
||||
private $Lis;
|
||||
|
||||
/** @var string|null */
|
||||
/** @var int|null */
|
||||
private $listStart;
|
||||
|
||||
/** @var bool */
|
||||
@@ -44,7 +44,7 @@ final class TList implements ContinuableBlock
|
||||
|
||||
/**
|
||||
* @param Lines[] $Lis
|
||||
* @param string|null $listStart
|
||||
* @param int|null $listStart
|
||||
* @param bool $isLoose
|
||||
* @param int $indent
|
||||
* @param 'ul'|'ol' $type
|
||||
@@ -123,15 +123,15 @@ final class TList implements ContinuableBlock
|
||||
|
||||
$markerTypeRegex = \preg_quote($markerType, '/');
|
||||
|
||||
/** @var string|null */
|
||||
/** @var int|null */
|
||||
$listStart = null;
|
||||
|
||||
if ($type === 'ol') {
|
||||
/** @psalm-suppress PossiblyFalseArgument */
|
||||
$listStart = \ltrim(\strstr($matches[1], $markerType, true), '0') ?: '0';
|
||||
$listStart = \intval(\strstr($matches[1], $markerType, true) ?: '0');
|
||||
|
||||
if (
|
||||
$listStart !== '1'
|
||||
$listStart !== 1
|
||||
&& isset($Block)
|
||||
&& $Block instanceof Paragraph
|
||||
&& ! $Context->previousEmptyLines() > 0
|
||||
@@ -272,6 +272,32 @@ final class TList implements ContinuableBlock
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: Block[], 1: State}[]
|
||||
*/
|
||||
public function items(State $State)
|
||||
{
|
||||
return \array_map(
|
||||
/** @return array{0: Block[], 1: State} */
|
||||
function (Lines $Lines) use ($State) {
|
||||
return Parsedown::blocks($Lines, $State);
|
||||
},
|
||||
$this->Lis
|
||||
);
|
||||
}
|
||||
|
||||
/** @return 'ol'|'ul' */
|
||||
public function type()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/** @return int|null */
|
||||
public function listStart()
|
||||
{
|
||||
return $this->listStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element>
|
||||
*/
|
||||
@@ -280,21 +306,24 @@ final class TList implements ContinuableBlock
|
||||
return new Handler(
|
||||
/** @return Element */
|
||||
function (State $State) {
|
||||
$listStart = $this->listStart();
|
||||
|
||||
return new Element(
|
||||
$this->type,
|
||||
$this->type(),
|
||||
(
|
||||
isset($this->listStart) && $this->listStart !== '1'
|
||||
? ['start' => $this->listStart]
|
||||
isset($listStart) && $listStart !== 1
|
||||
? ['start' => \strval($listStart)]
|
||||
: []
|
||||
),
|
||||
\array_map(
|
||||
/** @return Element */
|
||||
function (Lines $Lines) use ($State) {
|
||||
list($StateRenderables, $State) = Parsedown::lines(
|
||||
$Lines,
|
||||
$State
|
||||
);
|
||||
/**
|
||||
* @param array{0: Block[], 1: State} $Item
|
||||
* @return Element
|
||||
* */
|
||||
function ($Item) {
|
||||
list($Blocks, $State) = $Item;
|
||||
|
||||
$StateRenderables = Parsedown::stateRenderablesFrom($Blocks);
|
||||
$Renderables = $State->applyTo($StateRenderables);
|
||||
|
||||
if (! $this->isLoose
|
||||
@@ -309,7 +338,7 @@ final class TList implements ContinuableBlock
|
||||
|
||||
return new Element('li', [], $Renderables);
|
||||
},
|
||||
$this->Lis
|
||||
$this->items($State)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Erusev\Parsedown\AST\StateRenderable;
|
||||
use Erusev\Parsedown\Components\AcquisitioningBlock;
|
||||
use Erusev\Parsedown\Components\Block;
|
||||
use Erusev\Parsedown\Components\ContinuableBlock;
|
||||
use Erusev\Parsedown\Components\Inline;
|
||||
use Erusev\Parsedown\Html\Renderables\Element;
|
||||
use Erusev\Parsedown\Parsedown;
|
||||
use Erusev\Parsedown\Parsing\Context;
|
||||
@@ -174,6 +175,51 @@ final class Table implements AcquisitioningBlock, ContinuableBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return array<int, Inline[]> */
|
||||
public function headerRow(State $State)
|
||||
{
|
||||
return \array_map(
|
||||
/**
|
||||
* @param string $cell
|
||||
* @return Inline[]
|
||||
*/
|
||||
function ($cell) use ($State) {
|
||||
return Parsedown::inlines($cell, $State);
|
||||
},
|
||||
$this->headerCells
|
||||
);
|
||||
}
|
||||
|
||||
/** @return array<int, Inline[]>[] */
|
||||
public function rows(State $State)
|
||||
{
|
||||
return \array_map(
|
||||
/**
|
||||
* @param array<int, string> $cells
|
||||
* @return array<int, Inline[]>
|
||||
*/
|
||||
function ($cells) use ($State) {
|
||||
return \array_map(
|
||||
/**
|
||||
* @param string $cell
|
||||
* @return Inline[]
|
||||
*/
|
||||
function ($cell) use ($State) {
|
||||
return Parsedown::inlines($cell, $State);
|
||||
},
|
||||
$cells
|
||||
);
|
||||
},
|
||||
$this->rows
|
||||
);
|
||||
}
|
||||
|
||||
/** @return array<int, _Alignment|null> */
|
||||
public function alignments()
|
||||
{
|
||||
return $this->alignments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element>
|
||||
*/
|
||||
@@ -185,44 +231,44 @@ final class Table implements AcquisitioningBlock, ContinuableBlock
|
||||
return new Element('table', [], [
|
||||
new Element('thead', [], [new Element('tr', [], \array_map(
|
||||
/**
|
||||
* @param string $cell
|
||||
* @param Inline[] $Cell
|
||||
* @param _Alignment|null $alignment
|
||||
* @return Element
|
||||
*/
|
||||
function ($cell, $alignment) use ($State) {
|
||||
function ($Cell, $alignment) use ($State) {
|
||||
return new Element(
|
||||
'th',
|
||||
isset($alignment) ? ['style' => "text-align: $alignment;"] : [],
|
||||
$State->applyTo(Parsedown::line($cell, $State))
|
||||
$State->applyTo(Parsedown::stateRenderablesFrom($Cell))
|
||||
);
|
||||
},
|
||||
$this->headerCells,
|
||||
$this->alignments
|
||||
$this->headerRow($State),
|
||||
$this->alignments()
|
||||
))]),
|
||||
new Element('tbody', [], \array_map(
|
||||
/**
|
||||
* @param array<int, string> $cells
|
||||
* @param Inline[][] $Cells
|
||||
* @return Element
|
||||
*/
|
||||
function ($cells) use ($State) {
|
||||
function ($Cells) use ($State) {
|
||||
return new Element('tr', [], \array_map(
|
||||
/**
|
||||
* @param string $cell
|
||||
* @param Inline[] $Cell
|
||||
* @param _Alignment|null $alignment
|
||||
* @return Element
|
||||
*/
|
||||
function ($cell, $alignment) use ($State) {
|
||||
function ($Cell, $alignment) use ($State) {
|
||||
return new Element(
|
||||
'td',
|
||||
isset($alignment) ? ['style' => "text-align: $alignment;"] : [],
|
||||
$State->applyTo(Parsedown::line($cell, $State))
|
||||
$State->applyTo(Parsedown::stateRenderablesFrom($Cell))
|
||||
);
|
||||
},
|
||||
$cells,
|
||||
\array_slice($this->alignments, 0, \count($cells))
|
||||
$Cells,
|
||||
\array_slice($this->alignments(), 0, \count($Cells))
|
||||
));
|
||||
},
|
||||
$this->rows
|
||||
$this->rows($State)
|
||||
))
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -59,12 +59,18 @@ final class Code implements Inline
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function text()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Element
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
return new Element('code', [], [new Text($this->text)]);
|
||||
return new Element('code', [], [new Text($this->text())]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,6 +78,6 @@ final class Code implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,24 @@ final class Email implements Inline
|
||||
}
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function text()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function url()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Element
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
return new Element('a', ['href' => $this->url], [new Text($this->text)]);
|
||||
return new Element('a', ['href' => $this->url()], [new Text($this->text())]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,6 +79,6 @@ final class Email implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,12 @@ final class Emphasis implements Inline
|
||||
return new self($matches[1], $emphasis, \strlen($matches[0]));
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function text()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element>
|
||||
*/
|
||||
@@ -80,7 +86,7 @@ final class Emphasis implements Inline
|
||||
return new Element(
|
||||
$this->type,
|
||||
[],
|
||||
$State->applyTo(Parsedown::line($this->text, $State))
|
||||
$State->applyTo(Parsedown::line($this->text(), $State))
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -91,6 +97,6 @@ final class Emphasis implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,18 @@ final class EscapeSequence implements Inline
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function char()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Text
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->char());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +61,6 @@ final class EscapeSequence implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->char());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,24 @@ final class Image implements Inline
|
||||
return new self($Link);
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function label()
|
||||
{
|
||||
return $this->Link->label();
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function url()
|
||||
{
|
||||
return $this->Link->url();
|
||||
}
|
||||
|
||||
/** @return string|null */
|
||||
public function title()
|
||||
{
|
||||
return $this->Link->title();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element|Text>
|
||||
*/
|
||||
@@ -61,9 +79,9 @@ final class Image implements Inline
|
||||
/** @return Element|Text */
|
||||
function (State $State) {
|
||||
$attributes = [
|
||||
'src' => $this->Link->url(),
|
||||
'src' => $this->url(),
|
||||
'alt' => \array_reduce(
|
||||
Parsedown::inlines($this->Link->label(), $State),
|
||||
Parsedown::inlines($this->label(), $State),
|
||||
/**
|
||||
* @param string $text
|
||||
* @return string
|
||||
@@ -78,7 +96,7 @@ final class Image implements Inline
|
||||
),
|
||||
];
|
||||
|
||||
$title = $this->Link->title();
|
||||
$title = $this->title();
|
||||
|
||||
if (isset($title)) {
|
||||
$attributes['title'] = $title;
|
||||
@@ -98,6 +116,6 @@ final class Image implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->Link->label());
|
||||
return new Text($this->label());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +118,12 @@ final class Link implements Inline
|
||||
return new Handler(
|
||||
/** @return Element|Text */
|
||||
function (State $State) {
|
||||
$attributes = ['href' => $this->url];
|
||||
$attributes = ['href' => $this->url()];
|
||||
|
||||
if (isset($this->title)) {
|
||||
$attributes['title'] = $this->title;
|
||||
$title = $this->title();
|
||||
|
||||
if (isset($title)) {
|
||||
$attributes['title'] = $title;
|
||||
}
|
||||
|
||||
if ($State->get(SafeMode::class)->isEnabled()) {
|
||||
@@ -135,7 +137,7 @@ final class Link implements Inline
|
||||
return new Element(
|
||||
'a',
|
||||
$attributes,
|
||||
$State->applyTo(Parsedown::line($this->label, $State))
|
||||
$State->applyTo(Parsedown::line($this->label(), $State))
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -146,6 +148,6 @@ final class Link implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->label);
|
||||
return new Text($this->label());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,12 @@ final class Markup implements Inline
|
||||
}
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function html()
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Text|RawHtml>
|
||||
*/
|
||||
@@ -60,9 +66,9 @@ final class Markup implements Inline
|
||||
/** @return Text|RawHtml */
|
||||
function (State $State) {
|
||||
if ($State->get(SafeMode::class)->isEnabled()) {
|
||||
return new Text($this->html);
|
||||
return new Text($this->html());
|
||||
} else {
|
||||
return new RawHtml($this->html);
|
||||
return new RawHtml($this->html());
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -73,6 +79,6 @@ final class Markup implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->html);
|
||||
return new Text($this->html());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ final class PlainText implements Inline
|
||||
* @param State $State
|
||||
* @return static
|
||||
*/
|
||||
public static function build(Excerpt $Excerpt, State $State = null)
|
||||
public static function build(Excerpt $Excerpt, State $State)
|
||||
{
|
||||
return new self($Excerpt->text());
|
||||
}
|
||||
@@ -45,7 +45,7 @@ final class PlainText implements Inline
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->text());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +53,6 @@ final class PlainText implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,13 +39,19 @@ final class SpecialCharacter implements Inline
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function charCode()
|
||||
{
|
||||
return $this->charCodeHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RawHtml
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
return new RawHtml(
|
||||
'&' . (new Text($this->charCodeHtml))->getHtml() . ';'
|
||||
'&' . (new Text($this->charCode()))->getHtml() . ';'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,6 +60,6 @@ final class SpecialCharacter implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text('&'.$this->charCodeHtml.';');
|
||||
return new Text('&'.$this->charCode().';');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,12 @@ final class Strikethrough implements Inline
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function text()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Handler<Element>
|
||||
*/
|
||||
@@ -55,7 +61,7 @@ final class Strikethrough implements Inline
|
||||
return new Element(
|
||||
'del',
|
||||
[],
|
||||
$State->applyTo(Parsedown::line($this->text, $State))
|
||||
$State->applyTo(Parsedown::line($this->text(), $State))
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -66,6 +72,6 @@ final class Strikethrough implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->text);
|
||||
return new Text($this->text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +55,18 @@ final class Url implements Inline
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function url()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Element
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
return new Element('a', ['href' => $this->url], [new Text($this->url)]);
|
||||
return new Element('a', ['href' => $this->url()], [new Text($this->url())]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,6 +74,6 @@ final class Url implements Inline
|
||||
*/
|
||||
public function bestPlaintext()
|
||||
{
|
||||
return new Text($this->url);
|
||||
return new Text($this->url());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,18 @@ final class UrlTag implements Inline
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function url()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Element
|
||||
*/
|
||||
public function stateRenderable()
|
||||
{
|
||||
return new Element('a', ['href' => $this->url], [new Text($this->url)]);
|
||||
return new Element('a', ['href' => $this->url()], [new Text($this->url())]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -220,7 +220,7 @@ final class Parsedown
|
||||
continue;
|
||||
}
|
||||
|
||||
$Inlines[] = Plaintext::build($Excerpt->choppingUpToOffset($startPosition));
|
||||
$Inlines[] = Plaintext::build($Excerpt->choppingUpToOffset($startPosition), $State);
|
||||
|
||||
$Inlines[] = $Inline;
|
||||
|
||||
@@ -234,7 +234,7 @@ final class Parsedown
|
||||
$Excerpt = $Excerpt->addingToOffset(1);
|
||||
}
|
||||
|
||||
$Inlines[] = Plaintext::build($Excerpt->choppingFromOffset(0));
|
||||
$Inlines[] = Plaintext::build($Excerpt->choppingFromOffset(0), $State);
|
||||
|
||||
return $Inlines;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user