mirror of
https://github.com/pierre42100/comunic
synced 2025-07-12 13:02:59 +00:00
First commit
This commit is contained in:
31
3rdparty/luminous/languages/xml.php
vendored
Executable file
31
3rdparty/luminous/languages/xml.php
vendored
Executable file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* HTML is the 'root' scanner, we just override a couple of config settings
|
||||
* here, to prevent it from looking for CSS or JS.
|
||||
*/
|
||||
class LuminousXMLScanner extends LuminousHTMLScanner {
|
||||
public $scripts = false;
|
||||
public $embedded_server = false;
|
||||
|
||||
public static function guess_language($src, $info) {
|
||||
if (strpos(ltrim($src), '<?xml') === 0) return 1.0;
|
||||
// don't catch HTML doctypes
|
||||
if (strpos($src, '<!DOCTYPE') !== false) return 0;
|
||||
$p = 0;
|
||||
// simple tag
|
||||
$lines = preg_match_all('/$/m',
|
||||
preg_replace('/^\s+/m', '', $src), $m);
|
||||
// avg 1 tag every 4 lines
|
||||
if (preg_match_all('%<[!?/]?[a-zA-Z_:\\-]%', $src, $m)
|
||||
> $lines/4) $p += 0.15;
|
||||
// self closing tag
|
||||
if (strpos($src, '/>') !== false) $p += 0.05;
|
||||
// tag with attr
|
||||
if (preg_match('/<[a-zA-Z_]\w*\s+[a-zA-Z_]\w+\s*=["\']/', $src))
|
||||
$p += 0.1;
|
||||
|
||||
return $p;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user