/** * Tokenization rules */ public function setupRules() { parent::setupRules(); $css = new Css(); $js = new JavaScript(); $this->rules->addMany(['language.' . $js->getIdentifier() => [new OpenRule(new RegexMatcher('/<script.*?>()/'), ['factory' => new TokenFactory(LanguageToken::class), 'inject' => $js, 'language' => $this, 'postProcess' => true]), new CloseRule(new RegexMatcher('/()<\\/script>/'), ['factory' => new TokenFactory(LanguageToken::class), 'language' => $js])], 'language.' . $css->getIdentifier() => [new OpenRule(new RegexMatcher('/<style.*?>()/'), ['factory' => new TokenFactory(LanguageToken::class), 'inject' => $css, 'language' => $this, 'postProcess' => true]), new CloseRule(new RegexMatcher('/()<\\/style>/'), ['factory' => new TokenFactory(LanguageToken::class), 'language' => $css])]]); }
/** * Tokenization rules */ public function setupRules() { parent::setupRules(); $this->rules->rule('symbol.selector.class')->setContext($this->outside()); $this->rules->rule('symbol.selector.tag')->setContext($this->outside()); $this->rules->rule('symbol.selector.class.pseudo')->setContext($this->outside()); $this->rules->rule('symbol.selector.id')->setContext($this->outside()); $this->rules->rule('constant.color')->setContext(['!string', '!symbol', '!comment']); $this->rules->rule('number')->setContext(['!comment', '!symbol', '!constant', '!string', '!variable']); $this->rules->rule('call')->setContext(['!comment', '!symbol', '!constant', '!string']); $this->rules->add('operator.self', new Rule(new SubStringMatcher('&'), ['context' => $this->everywhere()])); $this->rules->add('comment.multiline', new Rule(new CommentMatcher(['//'], []), ['context' => $this->rules->rule('comment')->validator])); }