Code Highlight: Difference between revisions
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
[[Category:Extension]] | [[Category:Extension]] | ||
== Module == | == Module == | ||
Download module at | Download module at [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi_GeSHi SyntaxHighlight_GeSHi] | ||
<pre>tar -xzf SyntaxHighlight_GeSHi-REL1_23-4959271.tar.gz -C /var/www/mediawiki/extensions</pre> | <pre>tar -xzf SyntaxHighlight_GeSHi-REL1_23-4959271.tar.gz -C /var/www/mediawiki/extensions</pre> | ||
== Setup == | == Setup == | ||
Copy file into extensions folder | Copy file into extensions folder | ||
Line 13: | Line 14: | ||
== Sample code == | == Sample code == | ||
<pre> | <pre> | ||
<syntaxhighlight lang="php"> | |||
<?php | |||
$v = "string"; // sample initialization | |||
?> | |||
html text | |||
<? | |||
echo $v; // end of php code | |||
?> | |||
</syntaxhighlight> | |||
</pre> | </pre> | ||
== Result == | == Result == | ||
<syntaxhighlight lang="php"> | |||
<?php | |||
$v = "string"; // sample initialization | |||
?> | |||
html text | |||
<? | |||
echo $v; // end of php code | |||
?> | |||
</syntaxhighlight> | |||
== Supported Languages == | == Supported Languages == | ||
Line 280: | 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