| 1 |
This extension allows source code to be syntax highlighted on the wiki pages. |
| 2 |
This README file might be out of date, have a look at the extension page |
| 3 |
for updated information: |
| 4 |
|
| 5 |
https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi |
| 6 |
|
| 7 |
== Requirements == |
| 8 |
|
| 9 |
This version of the extension has been tested with Pygments 2.11.2 and |
| 10 |
MediaWiki 1.36. To get releases of this extension compatible |
| 11 |
with earlier versions of MediaWiki, visit: |
| 12 |
|
| 13 |
https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi |
| 14 |
|
| 15 |
== Installation == |
| 16 |
|
| 17 |
Add this line to your LocalSettings.php: |
| 18 |
|
| 19 |
wfLoadExtension( 'SyntaxHighlight_GeSHi' ); |
| 20 |
|
| 21 |
By default, this extension will use a bundled copy of Pygments 2.11.2. If you |
| 22 |
would like to use a different copy of the library, you can set |
| 23 |
$wgPygmentizePath to point to the path to the 'pygmentize' binary. |
| 24 |
|
| 25 |
== Usage == |
| 26 |
|
| 27 |
On the wiki page, you can now use "source" elements: |
| 28 |
|
| 29 |
<source lang="php"> |
| 30 |
<?php |
| 31 |
v = "string"; // sample initialization |
| 32 |
?> |
| 33 |
html text |
| 34 |
<?php |
| 35 |
echo v; // end of php code |
| 36 |
?> |
| 37 |
</source> |
| 38 |
|
| 39 |
== Parameters == |
| 40 |
|
| 41 |
For details information of these parameters, see the documentation of Pygments' |
| 42 |
HtmlFormatter at <https://pygments.org/docs/formatters/#HtmlFormatter>. |
| 43 |
|
| 44 |
* lang; Defines the language. |
| 45 |
* line; Corresponds to linenos="inline" option. |
| 46 |
* start; Corresponds to linenostart option. |
| 47 |
* enclose; If set to "none", corresponds to the nowrap=1 option. |
| 48 |
* inline; Corresponds to the nowrap=1 option. |
| 49 |
* highlight; Corresponds to hl_lines option (comma separated). |
| 50 |
* linelinks; Lines will have links and anchors with a prefix of the value. |
| 51 |
Similar to the lineanchors+linespans features in Pygments |
| 52 |
|
| 53 |
== Note == |
| 54 |
|
| 55 |
Pygments is generous about creating HTML elements: highlighting large blocks of |
| 56 |
code can easily generate enough of them to crash a browser. As a guard, syntax |
| 57 |
highlighting is turned off for code fragments larger than 100 kB. |