Path: blob/master/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php
12256 views
<?php12final class PhabricatorSyntaxHighlightingConfigOptions3extends PhabricatorApplicationConfigOptions {45public function getName() {6return pht('Syntax Highlighting');7}89public function getDescription() {10return pht('Options relating to syntax highlighting source code.');11}1213public function getIcon() {14return 'fa-code';15}1617public function getGroup() {18return 'core';19}2021public function getOptions() {22$caches_href = PhabricatorEnv::getDoclink('Managing Caches');2324return array(25$this->newOption(26'syntax-highlighter.engine',27'class',28'PhutilDefaultSyntaxHighlighterEngine')29->setBaseClass('PhutilSyntaxHighlighterEngine')30->setSummary(pht('Default non-pygments syntax highlighter engine.'))31->setDescription(32pht(33'You can provide a custom highlighter engine by extending '.34'class %s.',35'PhutilSyntaxHighlighterEngine')),36$this->newOption('pygments.enabled', 'bool', false)37->setSummary(38pht('Use Pygments to highlight code?'))39->setBoolOptions(40array(41pht('Use Pygments'),42pht('Do Not Use Pygments'),43))44->setDescription(45pht(46'Syntax highlighting a supported for a few languages by '.47'default, but you can install Pygments (a third-party syntax '.48'highlighting tool) to provide support for many more languages.'.49"\n\n".50'To install Pygments, visit '.51'[[ http://pygments.org | pygments.org ]] and follow the '.52'download and install instructions.'.53"\n\n".54'Once Pygments is installed, enable this option '.55'(`pygments.enabled`) to make use of Pygments when '.56'highlighting source code.'.57"\n\n".58'After you install and enable Pygments, newly created source '.59'code (like diffs and pastes) should highlight correctly. '.60'You may need to clear caches to get previously '.61'existing source code to highlight. For instructions on '.62'managing caches, see [[ %s | Managing Caches ]].',63$caches_href)),64$this->newOption(65'pygments.dropdown-choices',66'wild',67array(68'apacheconf' => 'Apache Configuration',69'bash' => 'Bash Scripting',70'brainfuck' => 'Brainf*ck',71'c' => 'C',72'coffee-script' => 'CoffeeScript',73'cpp' => 'C++',74'csharp' => 'C#',75'css' => 'CSS',76'd' => 'D',77'diff' => 'Diff',78'django' => 'Django Templating',79'docker' => 'Docker',80'erb' => 'Embedded Ruby/ERB',81'erlang' => 'Erlang',82'go' => 'Golang',83'groovy' => 'Groovy',84'haskell' => 'Haskell',85'html' => 'HTML',86'http' => 'HTTP',87'invisible' => 'Invisible',88'java' => 'Java',89'js' => 'Javascript',90'json' => 'JSON',91'make' => 'Makefile',92'mysql' => 'MySQL',93'nginx' => 'Nginx Configuration',94'objc' => 'Objective-C',95'perl' => 'Perl',96'php' => 'PHP',97'postgresql' => 'PostgreSQL',98'pot' => 'Gettext Catalog',99'puppet' => 'Puppet',100'python' => 'Python',101'rainbow' => 'Rainbow',102'remarkup' => 'Remarkup',103'rst' => 'reStructuredText',104'robotframework' => 'RobotFramework',105'ruby' => 'Ruby',106'sql' => 'SQL',107'tex' => 'LaTeX',108'text' => 'Plain Text',109'twig' => 'Twig',110'xml' => 'XML',111'yaml' => 'YAML',112))113->setSummary(114pht('Set the language list which appears in dropdowns.'))115->setDescription(116pht(117'In places that we display a dropdown to syntax-highlight code, '.118'this is where that list is defined.')),119$this->newOption(120'syntax.filemap',121'custom:PhabricatorConfigRegexOptionType',122array(123'@\.arcconfig$@' => 'json',124'@\.arclint$@' => 'json',125'@\.divinerconfig$@' => 'json',126))127->setSummary(128pht('Override what language files (based on filename) highlight as.'))129->setDescription(130pht(131'This is an override list of regular expressions which allows '.132'you to choose what language files are highlighted as. If your '.133'projects have certain rules about filenames or use unusual or '.134'ambiguous language extensions, you can create a mapping here. '.135'This is an ordered dictionary of regular expressions which will '.136'be tested against the filename. They should map to either an '.137'explicit language as a string value, or a numeric index into '.138'the captured groups as an integer.'))139->addExample(140'{"@\\\.xyz$@": "php"}',141pht('Highlight %s as PHP.', '*.xyz'))142->addExample(143'{"@/httpd\\\.conf@": "apacheconf"}',144pht('Highlight httpd.conf as "apacheconf".'))145->addExample(146'{"@\\\.([^.]+)\\\.bak$@": 1}',147pht(148"Treat all '*.x.bak' file as '.x'. NOTE: We map to capturing group ".149"1 by specifying the mapping as '1'")),150);151}152153}154155156