问题
I have a fresh Mediawiki installed into fresh UBUNTU 18 LTS... The ''SyntaxHighlight'' extension not works for Unix shell, lang="sh"
, lang="shell"
, lang="bash"
, ... no one is working. It is not at #Supported_languages, and there are no clues about how to install "Other markup".
At mediawiki.org/list there are no clues.
So, how to solve the problem? It is a config, env or syntax problem?
NOTES AND TESTS
Notes.
It is a corporative Wiki, no way to offer public URL... But it is a fresh, standard and controlled installation, all reproductive and standard.
The Wiki was configured with skin "Vector" and language "Brazilian Portuguese".
Tests.
Usage tests of mediawiki.org/Extension:SyntaxHighlight, the Python example.
1.1. With tag
<syntaxhighlight>
. Result: no highlight, same as<pre>
.1.2. With tag
<source>
. Result: no highlight, same as<pre>
.PHP example, fragment from wikipedia.org/PHP Syntax.
2.1. With tag
<syntaxhighlight>
. Result: no highlight, same as<pre>
.2.2. With tag
<source>
. Result: no highlight, same as<pre>
.
The code fragments used in the tests:
def quickSort(arr):
less = []
pivotList = []
more = []
if len(arr) <= 1:
return arr
else:
pass
<title>PHP "Hello, World!" program</title>
<?php echo '<p>Hello World</p>'; ?>
回答1:
MediaWiki Syntax highlighter used Pygments library, you should first download and install the extension:
Requirements
This version of the extension has been tested with Pygments 1.6, 2.0.2 and MediaWiki 1.25 as of 2015-06-19. To get releases of this extension compatible with earlier versions of MediaWiki, visit:
https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi
Download
https://github.com/wikimedia/mediawiki-extensions-SyntaxHighlight_GeSHi/archive/master.tar.gz
Installation
Add this line to your LocalSettings.php:
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
By default, this extension will use a bundled copy of Pygments 2.0.2. If you would like to use a different copy of the library, you can set $wgPygmentizePath to point to the path to the 'pygmentize' binary.
Usage
On the wiki page, you can now use "source" elements:
<source lang="php">
<?php
v = "string"; // sample initialization
?>
html text
<?php
echo v; // end of php code
?>
</source>
Parameters
For details information of these parameters, see the documentation of Pygments' HtmlFormatter at http://pygments.org/docs/formatters/#HtmlFormatter.
- lang; Defines the language.
- line; Corresponds to linenos="inline" option.
- start; Corresponds to linenostart opion.
- enclose; If set to "none", corresponds to the nowrap=1 option.
- inline; Corresponds to the nowrap=1 option.
- highlight; Corresponds to hl_lines option (comma separated).
Note
Pygments is generous about creating HTML elements: highlighting large blocks of code can easily generate enough of them to crash a browser. As a guard, syntax highlighting is turned off for code fragments larger than 100 kB.
来源:https://stackoverflow.com/questions/57297288/how-to-use-correct-lang-parameter