text = $text; $this->width = $width; } /** * @param Excerpt $Excerpt * @param State $State * @return static|null */ public static function build(Excerpt $Excerpt, State $State) { $marker = \substr($Excerpt->text(), 0, 1); if ($marker !== '`') { return null; } if (\preg_match( '/^(['.$marker.']++)(.*?)(?text(), $matches )) { $text = \str_replace("\n", ' ', $matches[2]); $firstChar = \substr($text, 0, 1); $lastChar = \substr($text, -1); if ($firstChar === ' ' && $lastChar === ' ') { $text = \substr(\substr($text, 1), 0, -1); } return new self($text, \strlen($matches[0])); } return null; } /** @return string */ public function text() { return $this->text; } /** * @return Element */ public function stateRenderable() { return new Element('code', [], [new Text($this->text())]); } /** * @return Text */ public function bestPlaintext() { return new Text($this->text()); } }