text = $text; $this->level = $level; } /** * @param Context $Context * @param State $State * @param Block|null $Block * @return static|null */ public static function build( Context $Context, State $State, Block $Block = null ) { if (! isset($Block) || ! $Block instanceof Paragraph || $Context->previousEmptyLines() > 0) { return null; } $marker = \substr($Context->line()->text(), 0, 1); if ($marker !== '=' && $marker !== '-') { return null; } if ( $Context->line()->indent() < 4 && \chop(\chop($Context->line()->text(), " \t"), $marker) === '' ) { $level = ($marker === '=' ? 1 : 2); return new self(\trim($Block->text()), $level); } return null; } /** @return bool */ public function acquiredPrevious() { return true; } /** * @return Handler */ public function stateRenderable() { return new Handler( /** @return Element */ function (State $State) { return new Element( 'h' . \strval($this->level), [], $State->applyTo(Parsedown::line($this->text, $State)) ); } ); } }