| | 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 ); |