text = $text; $this->level = $level; $this->acquired = true; } /** * @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 (! isset($Block) || ! $Block instanceof Paragraph || $Context->previousEmptyLines() > 0) { return null; } if ($Context->line()->indent() < 4 and \chop(\chop($Context->line()->text(), " \t"), $Context->line()->text()[0]) === '') { $level = $Context->line()->text()[0] === '=' ? 1 : 2; return new self($Block->text(), $level); } return null; } /** * @return Handler */ public function stateRenderable(Parsedown $Parsedown) { return new Handler( /** @return Element */ function (State $State) use ($Parsedown) { return new Element( 'h' . \strval($this->level), [], $State->applyTo($Parsedown->lineElements($this->text)) ); } ); } }