Highlight using Pygments rather than Geshi
GeSHi is unmaintained, lacks support for many popular modern languages, and
suffers from deep architectural flaws, chief among them the inconsistent
tokenization of different languages, each of which requires a custom
stylesheet.
Pygments is a well-maintained alternative. It is, by my count, the most popular
syntax highlighting library around. It is BSD-licensed, actively maintained,
and is widely used in PHP projects.
To keep this easy to review, this change does not include update for l10n
files, and it does not delete the geshi/ directory. I will do those in a
separate patch.
The chief change between this and the previous implementation is that errors
result in the code block not being highlighted, as opposed to not being printed
at all, having been replaced by an angry red error message. I think that is the
right user experience. If you go to StackOverflow or GitHub and try to mark up
your code block as being written in some language that their highlighter
doesn't know about, you don't get an error message -- the code simply doesn't
get highlighted.
Because we don't recursively load dependencies for extensions, to test this,
you will need to create a composer.local.json in $IP and add:
{
"extra": {
"merge-plugin": {
"include": [
"extensions/SyntaxHighlight_GeSHi/composer.json"
]
}
}
}
Then run `composer update`.
Bug: T85794
Change-Id: I07446ec9893fae3d1e394f435d3d95cf8be6bc33
2015-06-16 03:52:58 +00:00
|
|
|
{
|
2017-05-20 15:58:14 +00:00
|
|
|
"name": "mediawiki/syntax-highlight",
|
2015-10-23 22:33:06 +00:00
|
|
|
"description": "Syntax highlighting extension for MediaWiki",
|
|
|
|
"require-dev": {
|
2024-03-12 19:48:02 +00:00
|
|
|
"mediawiki/mediawiki-codesniffer": "43.0.0",
|
2024-02-10 13:09:25 +00:00
|
|
|
"mediawiki/mediawiki-phan-config": "0.14.0",
|
2021-01-30 08:19:24 +00:00
|
|
|
"mediawiki/minus-x": "1.1.1",
|
2022-05-21 08:24:16 +00:00
|
|
|
"php-parallel-lint/php-console-highlighter": "1.0.0",
|
|
|
|
"php-parallel-lint/php-parallel-lint": "1.3.2"
|
2015-10-23 22:33:06 +00:00
|
|
|
},
|
2018-03-02 23:40:34 +00:00
|
|
|
"license": "GPL-2.0-or-later",
|
2015-10-23 22:33:06 +00:00
|
|
|
"authors": [
|
|
|
|
{
|
|
|
|
"name": "Brion Vibber",
|
|
|
|
"email": "brion@wikimedia.org"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Niklas Laxström",
|
|
|
|
"email": "nlaxstrom@wikimedia.org"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Ori Livneh",
|
|
|
|
"email": "ori@wikimedia.org"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Rob Church"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Tim Starling",
|
|
|
|
"email": "tstarling@wikimedia.org"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"scripts": {
|
2017-11-04 02:49:51 +00:00
|
|
|
"fix": [
|
2020-01-13 05:13:37 +00:00
|
|
|
"minus-x fix .",
|
|
|
|
"phpcbf"
|
2017-11-04 02:49:51 +00:00
|
|
|
],
|
2015-10-23 22:33:06 +00:00
|
|
|
"test": [
|
2017-06-13 10:20:31 +00:00
|
|
|
"parallel-lint . --exclude vendor --exclude node_modules",
|
2021-10-08 03:12:12 +00:00
|
|
|
"@phpcs",
|
2017-11-04 02:49:51 +00:00
|
|
|
"minus-x check ."
|
2021-01-30 08:19:24 +00:00
|
|
|
],
|
2021-10-08 03:12:12 +00:00
|
|
|
"phan": "phan -d . --long-progress-bar",
|
|
|
|
"phpcs": "phpcs -sp --cache"
|
2024-03-12 19:48:02 +00:00
|
|
|
},
|
|
|
|
"config": {
|
|
|
|
"allow-plugins": {
|
|
|
|
"dealerdirect/phpcodesniffer-composer-installer": true
|
|
|
|
}
|
2015-10-23 22:33:06 +00:00
|
|
|
}
|
Highlight using Pygments rather than Geshi
GeSHi is unmaintained, lacks support for many popular modern languages, and
suffers from deep architectural flaws, chief among them the inconsistent
tokenization of different languages, each of which requires a custom
stylesheet.
Pygments is a well-maintained alternative. It is, by my count, the most popular
syntax highlighting library around. It is BSD-licensed, actively maintained,
and is widely used in PHP projects.
To keep this easy to review, this change does not include update for l10n
files, and it does not delete the geshi/ directory. I will do those in a
separate patch.
The chief change between this and the previous implementation is that errors
result in the code block not being highlighted, as opposed to not being printed
at all, having been replaced by an angry red error message. I think that is the
right user experience. If you go to StackOverflow or GitHub and try to mark up
your code block as being written in some language that their highlighter
doesn't know about, you don't get an error message -- the code simply doesn't
get highlighted.
Because we don't recursively load dependencies for extensions, to test this,
you will need to create a composer.local.json in $IP and add:
{
"extra": {
"merge-plugin": {
"include": [
"extensions/SyntaxHighlight_GeSHi/composer.json"
]
}
}
}
Then run `composer update`.
Bug: T85794
Change-Id: I07446ec9893fae3d1e394f435d3d95cf8be6bc33
2015-06-16 03:52:58 +00:00
|
|
|
}
|