mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Make this pattern a bit more reusable
This commit is contained in:
parent
747abe7600
commit
f83ee87902
@ -60,13 +60,23 @@ final class Parsedown
|
||||
{
|
||||
list($Blocks, $State) = self::blocks($Lines, $State);
|
||||
|
||||
$StateRenderables = \array_map(
|
||||
/** @return StateRenderable */
|
||||
function (Block $Block) { return $Block->stateRenderable(); },
|
||||
$Blocks
|
||||
);
|
||||
return [self::stateRenderablesFrom($Blocks), $State];
|
||||
}
|
||||
|
||||
return [$StateRenderables, $State];
|
||||
/**
|
||||
* @param Component[] $Components
|
||||
* @return StateRenderable[]
|
||||
*/
|
||||
public static function stateRenderablesFrom($Components)
|
||||
{
|
||||
return \array_map(
|
||||
/**
|
||||
* @param Component $Component
|
||||
* @return StateRenderable
|
||||
*/
|
||||
function ($Component) { return $Component->stateRenderable(); },
|
||||
$Components
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,11 +170,7 @@ final class Parsedown
|
||||
*/
|
||||
public static function line($text, State $State)
|
||||
{
|
||||
return \array_map(
|
||||
/** @return StateRenderable */
|
||||
function (Inline $Inline) { return $Inline->stateRenderable(); },
|
||||
self::inlines($text, $State)
|
||||
);
|
||||
return self::stateRenderablesFrom(self::inlines($text, $State));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user