Lines = $Lines; } /** * @param Context $Context * @param Block|null $Block * @param State|null $State * @return static|null */ public static function build( Context $Context, Block $Block = null, State $State = null ) { if (\preg_match('/^(>[ \t]?+)(.*+)/', $Context->line()->text(), $matches)) { $indentOffset = $Context->line()->indentOffset() + $Context->line()->indent() + \strlen($matches[1]); $recoveredSpaces = 0; if (\strlen($matches[1]) === 2 && \substr($matches[1], 1, 1) === "\t") { $recoveredSpaces = Line::tabShortage(2, $Context->line()->indentOffset() + $Context->line()->indent()); } return new self(Lines::fromTextLines( \str_repeat(' ', $recoveredSpaces) . $matches[2], $indentOffset )); } return null; } /** * @param Context $Context * @return self|null */ public function advance(Context $Context) { if ($Context->previousEmptyLines() > 0) { return null; } if ( \substr($Context->line()->text(), 0, 1) === '>' && \preg_match('/^(>[ \t]?+)(.*+)/', $Context->line()->text(), $matches) ) { $indentOffset = $Context->line()->indentOffset() + $Context->line()->indent() + \strlen($matches[1]); $recoveredSpaces = 0; if (\strlen($matches[1]) === 2 && \substr($matches[1], 1, 1) === "\t") { $recoveredSpaces = Line::tabShortage(2, $Context->line()->indentOffset() + $Context->line()->indent()); } $Lines = $this->Lines->appendingTextLines( \str_repeat(' ', $recoveredSpaces) . $matches[2], $indentOffset ); return new self($Lines); } if (! $Context->previousEmptyLines() > 0) { $indentOffset = $Context->line()->indentOffset() + $Context->line()->indent(); $Lines = $this->Lines->appendingTextLines($Context->line()->text(), $indentOffset); return new self($Lines); } return null; } /** * @return Handler */ public function stateRenderable() { return new Handler( /** @return Element */ function (State $State) { list($StateRenderables, $State) = Parsedown::lines( $this->Lines, $State ); $Renderables = $State->applyTo($StateRenderables); $Renderables[] = new Text("\n"); return new Element('blockquote', [], $Renderables); } ); } }