MediaWiki GeSHi: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
This extension adds the <tt>&lt;source&gt;</tt> tag to present formatted source code. See official [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi page].
'''SyntaxHighlight GeSHi''' is a MediaWiki extension that adds the <tt>&lt;source&gt;</tt> tag to present formatted source code.

This page is part of the pages dedicated to [[Mediawiki]].

* [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi Extension:SyntaxHighlight_GeSHi] on mediawiki.


== Restoring old <tt>&lt;pre&gt;</tt> formatting ==
== Restoring old <tt>&lt;pre&gt;</tt> formatting ==

Revision as of 19:19, 13 February 2014

SyntaxHighlight GeSHi is a MediaWiki extension that adds the <source> tag to present formatted source code.

This page is part of the pages dedicated to Mediawiki.

Restoring old <pre> formatting

Since at least version r24298 (July 21, 2007) (with GeSHi version 1.0.8), <source> tag does not match usual formatting applied for <pre> tags. This is because the extension applies by default the new GeSHi header style GESHI_HEADER_PRE_VALID. We describe below different solutions to restore the old formatting:

  • Define a custom style in MediaWiki:Common.css — This is probably the easiest & safest method, and also it allows to customize the output. For instance the following style adds a left border + background by default, unless if the <source> tag is enclosed in a <div class="noborder">
    /** GeSHi Syntax Highlight - custom styles */
    /** ... by default, we add a left border + left padding + left margin + lightgray background (for clarity) */
    div.mw-geshi
    {
    	margin: 0.5em 0em 0.5em 2em; 
    	padding: 0em 0em 0em 1em; 
    	border-left: 1px dashed #2f6fab;
    	background-color: #f9f9f9;
    }
     
    /** ... except if the <source> tag is enclosed in a <div class="noborder"> */
    div.noborder div.mw-geshi
    {
    	margin: 0px;
    	padding: 0px;
    	border-left: none;
    	background-color: inherit;
    }
    
  • Patch GeSHi — The following patch restores the old pre format. It also introduces a new option prevalid to attribute enclose to force application of header style GESHI_HEADER_PRE_VALID.
  • Add a custom .css to php - Another solution is discussed here. The proposed solution is to edit file "SyntaxHighlight_GeSHi.class.php". Go to line 192, which should look like
    $css[] = ".source-$lang {line-height: normal;}";
    

    Change this to

    $css[] = ".source-$lang {padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em;}";
    

    and you have restored the pre css formatting.