public static function guessLanguage($src, $info) { if (($html = HtmlScanner::guessLanguage($src, $info)) >= 0.2) { if (strpos($src, '{{') !== false || strpos($src, '{%') !== false) { return $html + 0.01; } } return 0.0; }
public function init() { if ($this->embeddedServer) { $this->addPattern('STOP_SERVER', $this->serverTags); } if ($this->embeddedHtml) { $this->addPattern('STOP_SCRIPT', '%</script>%'); } $opPattern = '[=!+*%\\-&^|~:?\\;,.>'; if (!($this->embeddedServer || $this->embeddedHtml)) { $opPattern .= '<]+'; } else { // build an alternation with a < followed by a lookahead $opPattern .= ']|<(?!['; // XXX this covers <? and <% but not very well if ($this->embeddedServer) { $opPattern .= '?%'; } if ($this->embeddedHtml) { $opPattern .= '/'; } $opPattern .= '])'; // closes lookahead $opPattern = "(?:{$opPattern})+"; } $opPattern = "@{$opPattern}@"; $this->addPattern('IDENT', '/[a-zA-Z_$][_$\\w]*/'); // NOTE: slash is a special case, and </ may be a script close $this->addPattern('OPERATOR', $opPattern); // we care about openers for figuring out where regular expressions are $this->addPattern('OPENER', '/[\\[\\{\\(]+/'); $this->addPattern('CLOSER', '/[\\]\\}\\)]+/'); $this->addPattern('NUMERIC', TokenPresets::$NUM_HEX); $this->addPattern('NUMERIC', TokenPresets::$NUM_REAL); $this->addPattern('SSTRING', TokenPresets::$SINGLE_STR_SL); $this->addPattern('DSTRING', TokenPresets::$DOUBLE_STR_SL); $this->addPattern('COMMENT', TokenPresets::$C_COMMENT_ML); $this->addPattern('COMMENT_SL', TokenPresets::$C_COMMENT_SL); // special case $this->addPattern('SLASH', '%/%'); $stopPatterns = array(); $xmlScanner = new HtmlScanner($this->string()); $xmlScanner->xmlLiteral = true; $xmlScanner->scripts = false; $xmlScanner->embeddedServer = $this->embeddedServer; if ($this->embeddedServer) { $xmlScanner->serverTags = $this->serverTags; } $xmlScanner->init(); $xmlScanner->pos($this->pos()); $this->addChildScanner('xml', $xmlScanner); }