2013-01-10 18:56:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorSyntaxHighlightingConfigOptions
|
|
|
|
extends PhabricatorApplicationConfigOptions {
|
|
|
|
|
|
|
|
public function getName() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Syntax Highlighting');
|
2013-01-10 18:56:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Options relating to syntax highlighting source code.');
|
2013-01-10 18:56:36 +01:00
|
|
|
}
|
|
|
|
|
2015-02-02 19:17:25 +01:00
|
|
|
public function getFontIcon() {
|
|
|
|
return 'fa-code';
|
|
|
|
}
|
|
|
|
|
2015-02-09 22:10:56 +01:00
|
|
|
public function getGroup() {
|
|
|
|
return 'core';
|
|
|
|
}
|
|
|
|
|
2013-01-10 18:56:36 +01:00
|
|
|
public function getOptions() {
|
2014-12-30 01:15:48 +01:00
|
|
|
$caches_href = PhabricatorEnv::getDocLink('Managing Caches');
|
|
|
|
|
2013-01-10 18:56:36 +01:00
|
|
|
return array(
|
|
|
|
$this->newOption(
|
|
|
|
'syntax-highlighter.engine',
|
|
|
|
'class',
|
|
|
|
'PhutilDefaultSyntaxHighlighterEngine')
|
|
|
|
->setBaseClass('PhutilSyntaxHighlighterEngine')
|
2014-06-09 20:36:49 +02:00
|
|
|
->setSummary(pht('Default non-pygments syntax highlighter engine.'))
|
2013-01-10 18:56:36 +01:00
|
|
|
->setDescription(
|
|
|
|
pht(
|
2014-06-09 20:36:49 +02:00
|
|
|
'Phabricator can highlight PHP by default and use Pygments for '.
|
|
|
|
'other languages if enabled. You can provide a custom '.
|
2015-05-22 09:27:56 +02:00
|
|
|
'highlighter engine by extending class %s.',
|
|
|
|
'PhutilSyntaxHighlighterEngine')),
|
2013-01-10 18:56:36 +01:00
|
|
|
$this->newOption('pygments.enabled', 'bool', false)
|
|
|
|
->setSummary(
|
2014-12-30 01:15:48 +01:00
|
|
|
pht('Should Phabricator use Pygments to highlight code?'))
|
|
|
|
->setBoolOptions(
|
|
|
|
array(
|
|
|
|
pht('Use Pygments'),
|
|
|
|
pht('Do Not Use Pygments'),
|
|
|
|
))
|
2013-01-10 18:56:36 +01:00
|
|
|
->setDescription(
|
|
|
|
pht(
|
2014-12-30 01:15:48 +01:00
|
|
|
'Phabricator supports syntax highlighting a few languages by '.
|
|
|
|
'default, but you can install Pygments (a third-party syntax '.
|
|
|
|
'highlighting tool) to provide support for many more languages.'.
|
|
|
|
"\n\n".
|
|
|
|
'To install Pygments, visit '.
|
|
|
|
'[[ http://pygments.org | pygments.org ]] and follow the '.
|
|
|
|
'download and install instructions.'.
|
|
|
|
"\n\n".
|
|
|
|
'Once Pygments is installed, enable this option '.
|
|
|
|
'(`pygments.enabled`) to make Phabricator use Pygments when '.
|
|
|
|
'highlighting source code.'.
|
|
|
|
"\n\n".
|
|
|
|
'After you install and enable Pygments, newly created source '.
|
|
|
|
'code (like diffs and pastes) should highlight correctly. '.
|
|
|
|
'You may need to clear Phabricator\'s caches to get previously '.
|
|
|
|
'existing source code to highlight. For instructions on '.
|
|
|
|
'managing caches, see [[ %s | Managing Caches ]].',
|
|
|
|
$caches_href)),
|
2013-01-10 18:56:36 +01:00
|
|
|
$this->newOption(
|
|
|
|
'pygments.dropdown-choices',
|
|
|
|
'wild',
|
|
|
|
array(
|
|
|
|
'apacheconf' => 'Apache Configuration',
|
|
|
|
'bash' => 'Bash Scripting',
|
|
|
|
'brainfuck' => 'Brainf*ck',
|
|
|
|
'c' => 'C',
|
2014-05-28 15:26:20 +02:00
|
|
|
'coffee-script' => 'CoffeeScript',
|
2013-01-10 18:56:36 +01:00
|
|
|
'cpp' => 'C++',
|
2015-06-18 14:18:08 +02:00
|
|
|
'csharp' => 'C#',
|
2013-01-10 18:56:36 +01:00
|
|
|
'css' => 'CSS',
|
|
|
|
'd' => 'D',
|
|
|
|
'diff' => 'Diff',
|
|
|
|
'django' => 'Django Templating',
|
2015-06-18 14:18:08 +02:00
|
|
|
'docker' => 'Docker',
|
2013-01-10 18:56:36 +01:00
|
|
|
'erb' => 'Embedded Ruby/ERB',
|
|
|
|
'erlang' => 'Erlang',
|
2014-05-28 15:26:20 +02:00
|
|
|
'go' => 'Golang',
|
|
|
|
'groovy' => 'Groovy',
|
2013-01-10 18:56:36 +01:00
|
|
|
'haskell' => 'Haskell',
|
|
|
|
'html' => 'HTML',
|
2015-06-18 14:18:08 +02:00
|
|
|
'http' => 'HTTP',
|
2013-06-25 17:40:29 +02:00
|
|
|
'invisible' => 'Invisible',
|
2013-01-10 18:56:36 +01:00
|
|
|
'java' => 'Java',
|
|
|
|
'js' => 'Javascript',
|
2014-05-28 15:26:20 +02:00
|
|
|
'json' => 'JSON',
|
2015-06-18 14:18:08 +02:00
|
|
|
'make' => 'Makefile',
|
2013-01-10 18:56:36 +01:00
|
|
|
'mysql' => 'MySQL',
|
2015-06-18 14:18:08 +02:00
|
|
|
'nginx' => 'Nginx Configuration',
|
2013-01-10 18:56:36 +01:00
|
|
|
'objc' => 'Objective-C',
|
|
|
|
'perl' => 'Perl',
|
|
|
|
'php' => 'PHP',
|
2015-06-18 14:18:08 +02:00
|
|
|
'postgresql' => 'PostgreSQL',
|
|
|
|
'pot' => 'Gettext Catalog',
|
2014-05-28 15:26:20 +02:00
|
|
|
'puppet' => 'Puppet',
|
2013-01-10 18:56:36 +01:00
|
|
|
'python' => 'Python',
|
|
|
|
'rainbow' => 'Rainbow',
|
|
|
|
'remarkup' => 'Remarkup',
|
2015-06-18 14:18:08 +02:00
|
|
|
'rst' => 'reStructuredText',
|
2016-01-25 15:44:20 +01:00
|
|
|
'robotframework' => 'RobotFramework',
|
2013-01-10 18:56:36 +01:00
|
|
|
'ruby' => 'Ruby',
|
2015-06-18 14:18:08 +02:00
|
|
|
'sql' => 'SQL',
|
|
|
|
'tex' => 'LaTeX',
|
|
|
|
'text' => 'Plain Text',
|
|
|
|
'twig' => 'Twig',
|
2013-01-10 18:56:36 +01:00
|
|
|
'xml' => 'XML',
|
2014-05-28 15:26:20 +02:00
|
|
|
'yaml' => 'YAML',
|
2013-01-10 18:56:36 +01:00
|
|
|
))
|
|
|
|
->setSummary(
|
2014-06-09 20:36:49 +02:00
|
|
|
pht('Set the language list which appears in dropdowns.'))
|
2013-01-10 18:56:36 +01:00
|
|
|
->setDescription(
|
|
|
|
pht(
|
2014-06-09 20:36:49 +02:00
|
|
|
'In places that we display a dropdown to syntax-highlight code, '.
|
|
|
|
'this is where that list is defined.')),
|
2013-01-10 18:56:36 +01:00
|
|
|
$this->newOption(
|
|
|
|
'syntax.filemap',
|
|
|
|
'wild',
|
|
|
|
array(
|
|
|
|
'@\.arcconfig$@' => 'js',
|
2014-05-27 15:14:06 +02:00
|
|
|
'@\.arclint$@' => 'js',
|
2013-01-10 18:56:36 +01:00
|
|
|
'@\.divinerconfig$@' => 'js',
|
|
|
|
))
|
|
|
|
->setSummary(
|
2014-06-09 20:36:49 +02:00
|
|
|
pht('Override what language files (based on filename) highlight as.'))
|
2013-01-10 18:56:36 +01:00
|
|
|
->setDescription(
|
|
|
|
pht(
|
2014-06-09 20:36:49 +02:00
|
|
|
'This is an override list of regular expressions which allows '.
|
|
|
|
'you to choose what language files are highlighted as. If your '.
|
|
|
|
'projects have certain rules about filenames or use unusual or '.
|
|
|
|
'ambiguous language extensions, you can create a mapping here. '.
|
|
|
|
'This is an ordered dictionary of regular expressions which will '.
|
|
|
|
'be tested against the filename. They should map to either an '.
|
|
|
|
'explicit language as a string value, or a numeric index into '.
|
|
|
|
'the captured groups as an integer.'))
|
2015-05-22 09:27:56 +02:00
|
|
|
->addExample('{"@\\.xyz$@": "php"}', pht('Highlight %s as PHP.', '*.xyz'))
|
2013-01-10 18:56:36 +01:00
|
|
|
->addExample(
|
|
|
|
'{"@/httpd\\.conf@": "apacheconf"}',
|
|
|
|
pht('Highlight httpd.conf as "apacheconf".'))
|
|
|
|
->addExample(
|
|
|
|
'{"@\\.([^.]+)\\.bak$@": 1}',
|
|
|
|
pht(
|
|
|
|
"Treat all '*.x.bak' file as '.x'. NOTE: We map to capturing group ".
|
|
|
|
"1 by specifying the mapping as '1'")),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|