/** * @param string $content * @param int $position * @param int $state * @param \ViKon\Parser\TokenList $tokenList * * @throws \ViKon\Parser\Rule\RuleException */ public function parseToken($content, $position, $state, TokenList $tokenList) { switch ($state) { case Lexer::STATE_MATCHED: $this->handleMatchedState($content, $position, $tokenList); break; default: parent::parseToken($content, $position, $state, $tokenList); break; } }
/** * @param string $content * @param int $position * @param int $state * @param \ViKon\Parser\TokenList $tokenList * * @throws \ViKon\Parser\Rule\RuleException */ public function parseToken($content, $position, $state, TokenList $tokenList) { switch ($state) { case Lexer::STATE_MATCHED: $token = $tokenList->addToken($this->name, $position); $token->set('content', str_repeat("\n", substr_count($content, "\n"))); break; default: parent::parseToken($content, $position, $state, $tokenList); break; } }
/** * Match * * ```javascript * var s = "JavaScript syntax highlighting"; * alert(s); * ``` */ public function __construct() { parent::__construct(self::NAME, self::ORDER, '\\n```(?:[^\\n]*)?', '\\n```(?=\\n)'); }