Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Makes SQL case insensitive

Author Dave Jarvis <email>
Date 2026-02-14 20:18:56 GMT-0800
Commit a23f4f2a207dbd4e7f6a18906dcfdf8123e28e53
Parent d08184c
File.php
public function highlight( FileRenderer $renderer, string $content ): string {
$lang = match( $this->mediaType ) {
- 'text/x-php', 'application/x-php', 'application/x-httpd-php' => 'php',
- 'text/html' => 'html',
- 'text/css' => 'css',
- 'application/javascript', 'text/javascript', 'text/x-javascript' => 'javascript',
- 'application/json', 'text/json', 'application/x-json' => 'json',
- 'application/xml', 'text/xml', 'image/svg+xml' => 'xml',
- 'text/x-shellscript', 'application/x-sh' => 'bash',
- 'text/x-c', 'text/x-csrc' => 'c',
- 'text/x-c++src', 'text/x-c++', 'text/x-cpp' => 'cpp',
- 'text/x-java', 'text/x-java-source', 'application/java-archive' => 'java',
- 'text/x-python', 'application/x-python-code' => 'python',
- 'text/x-ruby', 'application/x-ruby' => 'ruby',
- 'text/x-go', 'text/go' => 'go',
- 'text/rust', 'text/x-rust' => 'rust',
- 'text/x-lua', 'text/lua' => 'lua',
- 'text/markdown', 'text/x-markdown' => 'markdown',
- 'text/x-r', 'text/x-r-source', 'application/R' => 'r',
- 'application/sql', 'text/sql', 'text/x-sql' => 'sql',
- 'text/yaml', 'text/x-yaml', 'application/yaml' => 'yaml',
- 'application/typescript', 'text/typescript' => 'typescript',
- default => null
+ 'text/x-php', 'application/x-php', 'application/x-httpd-php' => 'php',
+ 'text/html' => 'html',
+ 'text/css' => 'css',
+ 'application/javascript', 'text/javascript', 'text/x-javascript' => 'javascript',
+ 'application/json', 'text/json', 'application/x-json' => 'json',
+ 'application/xml', 'text/xml', 'image/svg+xml' => 'xml',
+ 'text/x-shellscript', 'application/x-sh' => 'bash',
+ 'text/x-c', 'text/x-csrc' => 'c',
+ 'text/x-c++src', 'text/x-c++', 'text/x-cpp' => 'cpp',
+ 'text/x-java', 'text/x-java-source', 'application/java-archive' => 'java',
+ 'text/x-python', 'application/x-python-code' => 'python',
+ 'text/x-ruby', 'application/x-ruby' => 'ruby',
+ 'text/x-go', 'text/go' => 'go',
+ 'text/rust', 'text/x-rust' => 'rust',
+ 'text/x-lua', 'text/lua' => 'lua',
+ 'text/markdown', 'text/x-markdown' => 'markdown',
+ 'text/x-r', 'text/x-r-source', 'application/R' => 'r',
+ 'application/sql', 'text/sql', 'text/x-sql' => 'sql',
+ 'text/yaml', 'text/x-yaml', 'application/yaml' => 'yaml',
+ 'application/typescript', 'text/typescript' => 'typescript',
+ default => null
};
- if ( $lang === null ) {
- $ext = strtolower( pathinfo( $this->name, PATHINFO_EXTENSION ) );
+ if( $lang === null ) {
+ $ext = strtolower( pathinfo( $this->name, PATHINFO_EXTENSION ) );
- $lang = match( $ext ) {
- 'php', 'phtml', 'php8', 'php7' => 'php',
- 'c', 'h' => 'c',
- 'cpp', 'hpp', 'cc', 'cxx' => 'cpp',
- 'java' => 'java',
- 'js', 'jsx', 'mjs' => 'javascript',
- 'ts', 'tsx' => 'typescript',
- 'go' => 'go',
- 'rs' => 'rust',
- 'py', 'pyw' => 'python',
- 'rb', 'erb' => 'ruby',
- 'lua' => 'lua',
- 'sh', 'bash', 'zsh' => 'bash',
- 'bat', 'cmd' => 'batch',
- 'md', 'markdown' => 'markdown',
- 'rmd' => 'rmd',
- 'r' => 'r',
- 'xml', 'svg' => 'xml',
- 'html', 'htm' => 'html',
- 'css' => 'css',
- 'json', 'lock' => 'json',
- 'sql' => 'sql',
- 'yaml', 'yml' => 'yaml',
- default => 'text'
- };
+ $lang = match( $ext ) {
+ 'php', 'phtml', 'php8', 'php7' => 'php',
+ 'c', 'h' => 'c',
+ 'cpp', 'hpp', 'cc', 'cxx' => 'cpp',
+ 'java' => 'java',
+ 'js', 'jsx', 'mjs' => 'javascript',
+ 'ts', 'tsx' => 'typescript',
+ 'go' => 'go',
+ 'rs' => 'rust',
+ 'py', 'pyw' => 'python',
+ 'rb', 'erb' => 'ruby',
+ 'lua' => 'lua',
+ 'sh', 'bash', 'zsh' => 'bash',
+ 'bat', 'cmd' => 'batch',
+ 'md', 'markdown' => 'markdown',
+ 'rmd' => 'rmd',
+ 'r' => 'r',
+ 'xml', 'svg' => 'xml',
+ 'html', 'htm' => 'html',
+ 'css' => 'css',
+ 'json', 'lock' => 'json',
+ 'sql' => 'sql',
+ 'yaml', 'yml' => 'yaml',
+ default => 'text'
+ };
}
private function detectMediaType( string $buffer ): string {
- if ( $buffer === '' ) return 'application/x-empty';
+ if( $buffer === '' ) return 'application/x-empty';
$finfo = new finfo( FILEINFO_MIME_TYPE );
render/LanguageDefinitions.php
],
'batch' => [
- 'comment' => '/((?i:rem)\b[^\n]*|::[^\n]*)/',
+ 'comment' => '/((?i:rem)\b[^\n]*|::[^\n]*)/',
'string' => '/("[^"]*")/',
'keyword' => '/(?i)\b(if|else|goto|for|in|do|call|exit|echo|pause|set|shift|start|cd|dir|copy|del|md|rd|cls|setlocal|endlocal|enabledelayedexpansion|defined|exist|not|errorlevel|setx|findstr|reg|nul|tokens|usebackq|equ|neq|lss|leq|gtr|geq)\b/',
],
'xml' => [
- 'comment' => '/(<!--.*?-->)/s',
+ 'comment' => '/()/s',
'string' => '/' . $str . '/',
'keyword' => '/(<\/?[a-zA-Z0-9:-]+|\s*\/?>|<\?xml|\?>)/',
'variable' => '/([a-zA-Z0-9:-]+=)/',
],
'html' => [
- 'comment' => '/(<!--.*?-->)/s',
+ 'comment' => '/()/s',
'string' => '/' . $str . '/',
'keyword' => '/(<\/?[a-zA-Z0-9:-]+|\s*\/?>)/',
'string' => '/(\'.*?\')/',
'comment' => '/(--[^\r\n]*|\/\*.*?\*\/)/ms',
- 'keyword' => '/\b(SELECT|FROM|WHERE|INSERT|UPDATE|DELETE|JOIN|LEFT|RIGHT|INNER|OUTER|ON|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|CREATE|TABLE|DROP|ALTER|INDEX|KEY|PRIMARY|FOREIGN|CONSTRAINT|DEFAULT|NULL|NOT|AND|OR|IN|VALUES|SET|AS|DISTINCT|UNION|ALL|CASE|WHEN|THEN|ELSE|END)\b/i',
+ 'keyword' => '/(?i)\b(SELECT|FROM|WHERE|INSERT|UPDATE|DELETE|JOIN|LEFT|RIGHT|INNER|OUTER|ON|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|CREATE|TABLE|DROP|ALTER|INDEX|KEY|PRIMARY|FOREIGN|CONSTRAINT|DEFAULT|NULL|NOT|AND|OR|IN|VALUES|SET|AS|DISTINCT|UNION|ALL|CASE|WHEN|THEN|ELSE|END)\b/',
'number' => '/' . $int . '/',
],
'yaml' => [
'string' => '/' . $str . '/',
'comment' => '/(#[^\r\n]*)/m',
'keyword' => '/^(\s*[a-zA-Z0-9_-]+:)/m',
'number' => '/' . $float . '/',
],
'markdown' => [
- 'comment' => '/(<!--.*?-->)/s',
+ 'comment' => '/()/s',
'keyword' => '/^(#{1,6}\s+.*)$/m',
'string' => '/(\*\*.*?\*\*|__.*?__|\*.*?\*|_.*?_)/',
'variable' => '/(\[.*?\]\(.*?\))/',
'number' => '/^(\s*[-*+]\s|\s*\d+\.\s)/m',
],
'rmd' => [
- 'comment' => '/(<!--.*?-->)/s',
+ 'comment' => '/()/s',
'keyword' => '/^(#{1,6}\s+.*)$/m',
'variable' => '/(`{3}\{r.*?`{3})/s',
],
'r' => [
'string' => '/' . $str . '/',
'comment' => '/(#[^\r\n]*)/m',
'keyword' => '/\b(if|else|repeat|while|function|for|in|next|break|TRUE|FALSE|NULL|Inf|NaN|NA)\b/',
- 'function' => '/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/',
+ 'function' => '/\b([a-zA-Z_.][a-zA-Z0-9_.]*)\s*(?=\()/',
'number' => '/' . $float . '/',
]
Delta 56 lines added, 56 lines removed