Code Highlight: Difference between revisions
No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 26: | Line 26: | ||
== Result == | == Result == | ||
<syntaxhighlight lang="php"> | |||
<?php | |||
$v = "string"; // sample initialization | |||
?> | |||
html text | |||
<? | |||
echo $v; // end of php code | |||
?> | |||
</syntaxhighlight> | |||
== Supported Languages == | == Supported Languages == | ||
Line 289: | Line 296: | ||
|} | |} | ||
<div style="clear:both"></div> | <div style="clear:both"></div> | ||
== Configuration == | |||
===Css=== | |||
:''This method requires [[rev:52346|r52346]] or higher of this extension.'' | |||
Add to [[MediaWiki:Geshi.css]], [[MediaWiki:Monobook.css]] or [[MediaWiki:Common.css]] pages: | |||
<syntaxhighlight lang="css"> | |||
div.mw-geshi { | |||
padding: 1em; | |||
margin: 1em 0; | |||
border: 1px dashed #2f6fab; | |||
background-color: #f9f9f9; | |||
}</syntaxhighlight> | |||
This will give all GeSHi output (except for <tt>enclose="none"</tt>) a dashed border almost identical to <pre> in monobook/main.css |
Latest revision as of 17:15, 15 November 2014
Module
Download module at SyntaxHighlight_GeSHi
tar -xzf SyntaxHighlight_GeSHi-REL1_23-4959271.tar.gz -C /var/www/mediawiki/extensions
Setup
Copy file into extensions folder Add the following code at the end of LocalSettings.php
require_once "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php"; $wgSyntaxHighlightDefaultLang = "php";
Sample code
<syntaxhighlight lang="php"> <?php $v = "string"; // sample initialization ?> html text <? echo $v; // end of php code ?> </syntaxhighlight>
Result
<?php
$v = "string"; // sample initialization
?>
html text
<?
echo $v; // end of php code
?>
Supported Languages
These are the languages known by GeSHi that can be used in the lang parameter.
Note that installed GeSHi version (can be revealed by previewing e.g. <syntaxhighlight lang="-"></syntaxhighlight>
) might not be the most recent version; see bugzilla:10967 for Wikimedia sites.
The GeSHi sources for each language can be found in VCS on SourceForge. Remember to go and select the version that the MediaWiki installation uses.
Configuration
Css
- This method requires r52346 or higher of this extension.
Add to MediaWiki:Geshi.css, MediaWiki:Monobook.css or MediaWiki:Common.css pages:
div.mw-geshi {
padding: 1em;
margin: 1em 0;
border: 1px dashed #2f6fab;
background-color: #f9f9f9;
}
This will give all GeSHi output (except for enclose="none") a dashed border almost identical to <pre> in monobook/main.css