Extension talk:SyntaxHighlight GeSHi

From MediaWiki.org
Jump to: navigation, search
Please do not make requests for support for languages or bug reports for highlighting errors on this page. This extension uses the GeSHi library, which is not maintained by the MediaWiki developers. Bug reports and feature requests for the highlighting should be made to the GeSHi developers.
An archive box Archives 

2011[edit | edit source]

Border around every line when line numbers are displayed[edit | edit source]

I installed rev:50696 on MediaWiki 1.16. I followed the discussion in the 2008 archives about editing the SyntaxHighlight_GeSHi.class.php and the main.css files in order to display the usual <pre> border and background. When I display code using the <syntaxhilight> tool with only the language specification, everything works fine. But when I ask for the line numbers to be displayed, there is a border around every line, which is really ugly. Here is a printscreen of my wiki :

SyntaxHighlightGeShi LineDisplayProblem.JPG

Any idea on how to fix this? Thanks! -- Nouklea

After help from the Support Desk, I reinstalled the extension and undo the changes I made to the skin's css files. I then added the following code to the my MediaWiki.css page (not MyWiki.css page!), and the problem was solved.

div.mw-geshi {
  padding: 1em; 
  margin: 1em 0; 
  border: 1px dashed #2f6fab;
  background-color: #f9f9f9;

Problem solved... — Preceding unsigned comment added by Nouklea (talkcontribs) 16:27, 1 November 2011‎

ThX Nouklea, this really helped me. But I modified the skin's css file and add above since I could not find MediaWiki.css. Fortunately, it worked. — Preceding unsigned comment added by (talkcontribs) 09:53, 14 December 2011‎

1.0em/1.2em[edit | edit source]

The plugin for v1.16, r62591 uses aforementioned notation. Which is a rather obscure way to say "1em font-size and 1.2em line-height, please". Sadly, this fails in both FF4 and Safari 5 (which seem to consider it a division). I recommend against using it. 13:14, 20 May 2011 (UTC)

I proposed to get rid of this styling in Gerrit change 15781.  « Saper // talk »  11:29, 17 July 2012 (UTC)

Change background color[edit | edit source]

I wanted to be able to change the background color of the highlighted code, so I took the liberty of adding the functionality. Here's the patch to apply to SyntaxHighlight_GeSHi.class.php

>            static $codeAreaNumber = 0;
>            $codeAreaNumber += 1;
>            // Background colors
>            if( isset( $args['backgroundcolor'] ) && $args['backgroundcolor'] ) {
>                    $backgroundcolor = $args['backgroundcolor'];
>                    $geshi->set_overall_style('background-color: '.$backgroundcolor, true);
>            }
>            $geshi->set_overall_id( 'codeArea'.$codeAreaNumber );
<            $parser->mOutput->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}" );
>            $parser->mOutput->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}-{$codeAreaNumber}" );
< }
\ No newline at end of file
> }

If I could find information on the maintainer of this project, I'd be happy to send the patch in. After applying the patch you can then do the following:

 <syntaxhighlight lang="cpp" backgroundcolor="#FFAAAA">

and your code would be syntax highlighted and have the specified background color. — Preceding unsigned comment added by EliRibble (talkcontribs) 21:30, 11 May 2011‎

unfortunately this causes problems when you have a padded code box. you need to include in the script to colorize the entire code box 07:35, 22 September 2011 (UTC)

How to enable download of the embedded code[edit | edit source]

I extended SyntaxHighlight GeSHi so that each code fragment can be given a button to download it as a file. You can see an example on page http://freeplane.sourceforge.net/wiki/index.php/Scripting:_Example_scripts (actually this page uses an older extension GeSHiHighlight but the idea is basically the same).

Following modifications are required:

file download.php with following content should be uploaded into extensions/SyntaxHighlight_GeSHi

	header("Pragma: no-cache");
	header("Expires: 0");
	if (isset($_POST["text"]) && isset($_POST["filename"])) {
	header("Content-type: application/octet-stream");
	header("Content-Disposition: attachment; filename=" . $_POST["filename"]);
	echo urldecode($_POST["text"]);
		echo "Data not found";

function parserHook in file SyntaxHighlight_GeSHi.class.php is modified near the end.

	wfProfileOut( __METHOD__ );
	return $out;

is replaced by

		global $wgScriptPath;
		$encodedText = urlencode($text);
		$filename = $args['name']. "." . $lang;
		$form = <<<EOFORM
<form action="$wgScriptPath/extensions/SyntaxHighlight_GeSHi/download.php" method="post">
<input type="hidden" name="text" value="$encodedText" />
<input type="hidden" name="filename" value="$filename" />
<input type="submit" value="download script" />
		$out = $form.$out;
	wfProfileOut( __METHOD__ );
	return $out;

DimitryPolivaev 21:41, 5 January 2011 (UTC)

It was unclear to me how this would be called on a wiki page once implemented. All you have to do is add name="filename" to your syntax highlight tag.

<syntaxhighlight lang="sas" name="example">... youre code</syntaxhighlight>

--Effulgent (talk) 09:19, 5 April 2012 (UTC)

Language[edit | edit source]

  • I'm disappointed MW Syntax isn't an option. Really disappointed. -- 20:49, 26 September 2011 (UTC)
The Geshi language files are easy to write - I wrote SPARQL syntax and it takes me 1 hour. If you'll write MW syntax don't forget to share it!!--Katkov Yury 12:27, 28 October 2011 (UTC)
  • Yes, strangely, the wiki language is not an option: <source lang=wiki>Some 'wiki' text </source>.--Nbrouard (talk) 12:21, 12 March 2012 (UTC)
    • This should probably be reported upstream.
      In case anyone is interested, the documentation on how to write a language file can be found on this page. Helder 13:10, 12 March 2012 (UTC)

Using template parameters in tag.[edit | edit source]

By default it's impossible to user triple braced parameters inside sytntaxhighlight tag. If you want to use them, you need to hack an extension a bit:

Maybe I missunderstood but isn't that what the Magic word #tag should be used for? One can have the following on the template {{#tag:syntaxhighlight|Your content goes here|attribute1=value1|attribute2=value2}} --Carandraug (talk) 18:48, 23 June 2012 (UTC)

In file SyntaxHighlight_GeSHi.class.php, line 23: substitute this line

 public static function parserHook( $text, $args = array(), $parser)

with these two lines:

 public static function parserHook( $text, $args = array(), $parser, $frame )
 $text = str_replace( "<", '<', $text );
 $text = str_replace( ">", '>', $text );
 $text = $parser->recursiveTagParse($text, $frame);

This helped me, I hope it will help you too! Dear developers, would you mind to add these two lines to your code? --Katkov Yury 01:40, 30 October 2011 (UTC)

Alternate version[edit | edit source]

I got it working this way: substitute this line

 public static function parserHook( $text, $args = array(), $parser)

with this line:

 public static function parserHook( $text, $args = array(), $parser, $frame )

place this:

 $out = $parser->recursiveTagParse($out, $frame); 


 return $out; 

at the very end of the function. — Preceding unsigned comment added by (talkcontribs) 08:50, 19 December 2011‎

Please include this! Otherwise provide a user side workaround (I can't change the files of the extension!). Thanks 17:40, 2 April 2012 (UTC)

Transclusion Trick[edit | edit source]

You can bypass this flaw by simply using the Template Transclusion trick. What i did was create a Template for the source open and close tags.


  • if used within a documentation style container, the closing tag is not used but instead is interpreted as part of the body of the code. Thereby including it in the context of the source representation.

refer to: Template:Src as a reference. Goldbishop 17:05, 5 February 2012 (UTC)

Font size issues[edit | edit source]

We use MediaWiki 1.16.5 and the default SyntaxHighlight extension, no mods. The extension works fine but the font size in Firefox 7.0.1 is very small. In IE 7.0 it looks ok. We know there are font size issues in Firefox and Chrome when using <pre> in MediaWiki 1.16. These should be fixed in 1.17. We can not move to 1.17 at the moment and fixed this temporary by adding the code below in shared.css

/* Fix so <tt>, <code>, and <pre> display in a suitable size in firefox, chrome, etc */
tt, code, pre {
    font-size: 1.25em;

There is a bug mentioning the problem Bug 26204 but it does not become clear to me if the problem can be fixed. Before we start putting energy in a solution does anybody know if there is a fix?

Jongfeli 13:47, 3 November 2011 (UTC)

Is there an established fix / workaround for this? If so, please add it. Thank you. GeneZ 16:15, 14 January 2012 (UTC)

I hope that maybe Gerrit change 15781 improves the situation.  « Saper // talk »  11:33, 17 July 2012 (UTC)

Dashed border is close to code[edit | edit source]

I just installed this extension (r90546) on my wiki (v1.18). I tried enabling the dashed border in common.css, but this didn't work. After any change I made I commented out the require... code on LocalSettings.php and refreshed my wiki page. Next I tried getting the dashed border by changing SyntaxHighlight_GeSHi.class.php and this worked, but the dashed border is very close to my text. In all the examples, there is some space between the border and text. Also, I tried enabling the Default DIV Based Rendering as shown, but then there was no dashed border, so I undid this change. — Preceding unsigned comment added by Scott216 (talkcontribs) 02:02, 18 January 2012‎

Also seeing this. Any fixes? Using the new editor if you click preview it appears fine in there. -- 00:24, 15 February 2012 (UTC)
Resolved this now. I followed the link given in method 2. Used the code change given there to resolve it. Had to disable, refresh, enable the extension before it would work though -- 00:51, 15 February 2012 (UTC)

2012[edit | edit source]

Where to save/load Geshi.css[edit | edit source]

Please add instructions on where to save the css file and, if necessary, how to telll geshi to use it. — Preceding unsigned comment added by (talkcontribs) 14:14, 23 January 2012‎

You don't have to save it anywhere. The extension automatically loads it from the MediaWiki:Geshi.css wiki page. You only need to edit that page. Krinkle 01:18, 24 January 2012 (UTC)
Hi Timo,
Yes, that seems to be working. Thanks.

Highlighting code from external links[edit | edit source]

Hi, I had a need to use syntax highlighting not on internaly written code but directly on external java source files so I added an "extlink" parameter to the <syntaxhighlight> tag. Now, just write something like:

<syntaxhighlight lang="java" extlink="http://my.server.com/my_dir/my_source.java"/>

and the content of http://my.server.com/my_dir/my_source.java will be inserted and highlighted in your page.

To add this to the extension, quite simple, just add the following lines

if ( isset( $args['extlink'] ) && $args['extlink'] ) {
  $text  = file_get_contents ( $args['extlink'] );

in SyntaxHighlight_GeSHi.php near line 50 just above the line

$geshi = self::prepare( $text, $lang );
Could this be added to the supported extension? I'd like this feature as well (but I would suggest using 'src' instead of 'extlink', analogous to HTML's <img src=.../>) In our case, the target URL would be elsewhere on our intranet, or even a File: in the wiki. Thus, ideally, the parameter would work with a File: page name (which would need to be a text file) --DavidBiesack (talk) 15:00, 10 July 2014 (UTC)

"<syntaxhighlight> is recommended"[edit | edit source]

Extension:Collection (which is used to create downloadable PDFs or books from WMF pages) doesn't support <syntaxhighlight>, only <source> (see bugzilla:29136). I wonder, therefore, if we should remove from this page the statement that "<syntaxhighlight> is recommended"? —RuakhTALK 20:10, 28 February 2012 (UTC)

Reopening the bug should be enough. syntaxhighlight is still recommended, but you can use source as a workaround until the Collection extension is fixed. Reach Out to the Truth (talk) 02:18, 29 February 2012 (UTC)
This seems to be working now, although it fails to honour the enclose=none parameter. —Phil | Talk 17:07, 27 November 2012 (UTC)

Vote to make box and border pre the default[edit | edit source]

Personally I think geshi should look like other pre boxes, should the following be included in MediaWiki:Geshi.css by default?

div.mw-geshi {
  padding: 1em; 
  margin: 1em 0; 
  border: 1px dashed #2f6fab;
  background-color: #f9f9f9;

Better still could be to remove the problem css that strips the skin default. CSS like this...

.source-winbatch li, .source-winbatch pre {
  line-height: normal;
  border: 0px none white;


.winbatch.source-winbatch .de1, .winbatch.source-winbatch .de2 {
font: normal normal 1em/1.2em monospace;
margin: 0;
padding: 0;
background: none;
vertical-align: top;

Just my thoughts. Thanks for a great extension.

I hope that maybe Gerrit change 15781 improves the situation (with empty MediaWiki:Geshi.css, which is the MediaWiki default).  « Saper // talk »  11:33, 17 July 2012 (UTC)

README still suggests to use 'source' tag[edit | edit source]

README file still suggests to use "source" tag - probably should be updated --Richlv (talk) 11:06, 2 April 2012 (UTC)

Not displaying colors when formatting?[edit | edit source]

Having this issue on 1.18, anyone else experiencing this? How do I fix?

  • Whats your sample code? did you use a valid value inside of, lang?

Support for additional class[edit | edit source]

The standard gray background and dashed border looks great for most of the snippets but we have a scenario where we have examples of good and bad snippets of code. With our previous manual way of syntax highlighting code, we were able to apply a different class to highlight the code light green with a check in the upper right for good code, light red with an X in the upper right for bad code. In order to support the same functionality with this extension, we added a new attribute to the tag and had to modify SyntaxHighlight_GeSHi.class.php, line 122 to support it. Note that you may want to add the change to the other part of the condition there.

$attribs = self::addAttribute( $attribs, 'class', 'mw-geshi mw-content-' . $attribs['dir'] . ' ' );
$addclass = isset( $args['addclass'] ) ? $args['addclass'] : '' ;
$attribs = self::addAttribute( $attribs, 'class', 'mw-geshi mw-content-' . $attribs['dir'] . ' ' . $addclass );

In addition, we had to add !important to our CSS to get it to override the other selectors:

div.code-good {
	background: #efffef url(/mediawiki-1.19/skins/common/tmhp/silk-icons/tick.png) no-repeat top right !important;
	border-color: #6c6 !important;
div.code-bad {
	background: #ffefef url(/mediawiki-1.19/skins/common/tmhp/silk-icons/cancel.png) no-repeat top right !important;
	border: 1px dashed #c66 !important;

So now we can use the new addclass attribute on the extension:

  <syntaxhighlight lang='html' addclass='code-good'>
    Some code here.

Mattsmith321 (talk) 20:35, 25 August 2012 (UTC)

I like this idea in concept, do you have a link to an example page with a few examples of this in action? ShoeMaker   ( Contributions Message )   12:15, 12 March 2013 (UTC)
Here is an example screenshot from our wiki:
SyntaxHighlight with custom class.png
Mattsmith321 (talk) 21:21, 16 October 2013 (UTC)

Dynamic CSS styles overwrite the ones from MediaWiki:Geshi.css[edit | edit source]

Hello. With MediaWiki 1.19.1 and SyntaxHighlight the dynamic CSS styles are added after the link to the MediaWiki:Geshi.css and MediaWiki:Common.css stylesheets. As a result most of the attributes defined in MediaWiki:Geshi.css are overwritten by Geshi and it is impossible to extensively modify the styles without modifying the php files.

This can be fixed by removing the "addHeadItem" call in SyntaxHighlight_GeSHi.class.php (line 105) but then all styles must be statically defined in MediaWiki:Geshi.css.

-- 00:13, 28 August 2012 (UTC)

Empty page as a result of highlighter's work[edit | edit source]

MediaWiki v.1.17.0

I installed SyntaxHighlight GeSHi like it is said in the manual:

1) got the extension into /extensions

svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SyntaxHighlight_GeSHi

2) edited LocalSettings.php


Then I tried to use it in example from manual:

    $v = "string";    // sample initialization
html text
    echo $v;         // end of php code

And it gave me empty page both at preview and saved page. Like, completly empty, blank page. What do I do wrong? 17:19, 12 September 2012 (UTC)

Got the empty page of death too. I couldn't solve the problem and I was realy frustrated, but after updating from MW 1.17 to MW 1.19.2 the problem went away by itself. I mean, I installed the extension the same way and now it works. Abagnale OS Ubuntu 11.04; MW 1.19.2; MySQL 5.1.61; PHP 5.2.17 19:24, 27 September 2012 (UTC)

Font size small in 1.20[edit | edit source]

I had a problem with the most recent version of this extension on my installation of 1.20 MediaWiki. It being that the size of the text, being rather small. I added this to MediaWiki:Geshi.css:

/* Fix so <source> tags, and .css and .js pages, get normal text size 
   also in some versions of Firefox, Safari, Konqueror, Chrome etc. */
div.mw-geshi div,
pre {
	font-family: monospace, "Courier New" !important;

This seems to fix the small text. --Inops (talk) 23:45, 25 November 2012 (UTC)
Oh, and I was getting the problems with the latest stable release of Google Chrome. --Inops (talk) 23:51, 25 November 2012 (UTC)

I'am using MW 1.20.7 with enclose="none" and the above did not work. I replaced it by
/* Fix so <source> tags, and .css and .js pages, get normal text size 
   also in some versions of Firefox, Safari, Konqueror, Chrome etc. */
pre {
	font-family: monospace, "Courier New" !important;
Sigbert (talk) 19:24, 1 November 2013 (UTC)

Download does not work[edit | edit source]


trying to obtain a download from http://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi I receive the error message Invalid response from Extension Distributor remote client. .

Any help (to get the version for MW 1.17) would be appreciated!


-- 14:05, 7 December 2012 (UTC)

Now it did work, must have been a temporary dysfunction.
-- 08:19, 10 December 2012 (UTC)

2013[edit | edit source]

How can I mimic this?[edit | edit source]

For example, if I wanted to make an extension, FooHighlight, and every instance of the word "bar" between the <foo> tags was colored purple and everything between { and } was colored green, what would I do? I am a complete newbie to PHP.

Custom User Defined Languages[edit | edit source]

Could someone make a basic how-to page to give the general idea for creating our own .css for custom languages. For example, I would like to add the ability to have it work with AHK (AutoHotKey) scripts. Thank you. -- ShoeMaker   ( Contributions Message )   14:25, 7 February 2013 (UTC)

Answering my own question here. The how-to create your own language documentation can be found at http://qbnz.com/highlighter/geshi-doc.html#language-files -- ShoeMaker   ( Contributions Message )   14:41, 7 February 2013 (UTC)

Request for pseudocode highlighting[edit | edit source]

Since pseudocode is typically used for explaining algorithm, it would be nice if this extension supports pseudocode highlighting by default. In my thought, it should highlight words like for, while, each, function, return, if, in, ... --Nullzero (talk) 18:25, 11 February 2013 (UTC)

"Please do not make requests for support for languages or bug reports for highlighting errors on this page. ... Bug reports and feature requests for the highlighting should be made to the GeSHi developers." --Iynque (talk) 15:05, 18 January 2014 (UTC)

Generic HTML[edit | edit source]

Why there is not a general value HTML for all types of (X)HTML? I dont see a reason to have there html4strict and html5 while highlight ways are the same. How I can highlight XHTML 1.0 Transitional, than?--Juandev (talk) 11:21, 15 March 2013 (UTC)

Wiki links[edit | edit source]

Is there not a way to include wiki links inside the code block?

$ echo "a + b" | calc --hex      # [[Page_About_Options|this option]] causes calc to interpret its input as hex
  • You mean like:
$ echo "a + b" | calc --hex      # [[Page_About_Options|this option]] causes calc to interpret its input as hex

Yeah - notice how the link is not rendered as a link ??? "Page_About_Options" would be the link target, "this option" would be the link text

Technical 13 (talk) 21:43, 10 May 2013 (UTC)
  • I now understand your question fully. <syntaxhighlight> is a <pre> substitute that offers highlighting. There can be no active links inside by its very definition. See W:HTML element#pre. Technical 13 (talk) 01:54, 11 May 2013 (UTC)

lang for Mediwiki Code ?[edit | edit source]

What language in your opinion is best for rendering Mediawiki code, e.g. Wiki Syntax, templates, SMW extensions ? Or does anyone think that we could petition for someone to write a "mediawiki" module for Geshi (sorry I can't). Greetings !- Daniel K. Schneider (talk) 14:00, 12 June 2013 (UTC)

  • I personally use lang="bibtex" as it seems to be the closest to me. I have thought about writing a MWML module, but do not currently have the skills to do so or the time to invest into it. Technical 13 (talk) 12:33, 17 June 2013 (UTC)
    • Cool ! thanx a lot. Yes code is much more readable than my other attemps, e.g. JavaScript, Perl, XML, ... (see here (I am trying to learn semantic mediawiki/forms and write down as I play ...) - Daniel
Useful to know. Thanx. Could this be noted in the manual page somehow? -DePiep (talk) 09:13, 12 December 2013 (UTC)

Underscore not displaying properly[edit | edit source]

I noticed that the following code isn't displaying properly...

<syntaxhighlight lang="python">
# Set count_to equal to 1 plus 2 on line 3!

count_to = 1+2

print count_to
# Set count_to equal to 1 plus 2 on line 3!

count_to = 1+2

print count_to

The underscore in the "print count_to" isn't displaying on en:User:Theopolisme/help/Matty.007 to me.

Displays just fine for me on MW and enwiki using Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1 Theopolisme (talk) 18:39, 8 July 2013 (UTC)
  • It displays properly here for me but not on en: using the exact same code. Odd. I'm using FF22 FWIW. Technical 13 (talk) 18:41, 8 July 2013 (UTC)

SASS[edit | edit source]

Any plan for including sass and/or scss source languages to the extension? 11:51, 26 July 2013 (UTC)

"Please do not make requests for support for languages or bug reports for highlighting errors on this page. ... Bug reports and feature requests for the highlighting should be made to the GeSHi developers." --Iynque (talk) 15:05, 18 January 2014 (UTC)

Use pre tags?[edit | edit source]

Is there anyway to make it automatically do syntax highlighting for code in <pre> tags? — Preceding unsigned comment added by (talkcontribs)

  • "Why would you want to do that?", would be my first question. The answer is, if you modify the php for the extension, you could make it work for any element/tag you wanted. Problem is, <pre> is part of the HTML standard, so your new users wouldn't be expecting that output from it, and might not want/like it (especially since it would return an undefined language error unless you created a default, which would be poor because there are so many languages and to assume that one will always be the most popular is a bad idea). Now, I agree that <syntaxhighlight lang="blah"> is kind of long to type out, and would request the developers of this extension to add a <sh lang="blah"> alias. Technical 13 (talk) 12:05, 26 August 2013 (UTC)

PHP 5.5 Notice[edit | edit source]

PHP Notice:  Use of undefined constant CONTENT_MODEL_CSS - assumed 'CONTENT_MODEL_CSS' in /usr/local/www/wiki/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php on line 75,

IRC[edit | edit source]

Any plan for introducing IRC as a language? E.g.,

<source lang="irc">
[12:27] <legoktm> leucosticte: $content->getNativeData()
[12:27] <legoktm> you should also probably do check that $content instanceof TextContent

Leucosticte (talk) 18:00, 17 October 2013 (UTC)

"Please do not make requests for support for languages or bug reports for highlighting errors on this page. ... Bug reports and feature requests for the highlighting should be made to the GeSHi developers." --Iynque (talk) 15:05, 18 January 2014 (UTC)
Feature request submitted! Leucosticte (talk) 15:19, 6 February 2014 (UTC)

2014[edit | edit source]

Highlight multiple lines[edit | edit source]

I can use highlight="5" to highlight line 5 of the code. Is there a way to highlight multiple lines? Maybe something like highlight="5,6,10,20" --Iynque (talk) 15:05, 18 January 2014 (UTC)

  • Well... Let's test and see what we have...
  • Just line #5
This is line {{{1}}}
This is line {{{2}}}
This is line {{{3}}}
This is line {{{4}}}
This is line {{{5}}}
This is line {{{6}}}
This is line {{{7}}}
This is line {{{8}}}
This is line {{{9}}}
  • Lines #4-6
This is line {{{1}}}
This is line {{{2}}}
This is line {{{3}}}
This is line {{{4}}}
This is line {{{5}}}
This is line {{{6}}}
This is line {{{7}}}
This is line {{{8}}}
This is line {{{9}}}
  • Lines #3, 6, 9
This is line {{{1}}}
This is line {{{2}}}
This is line {{{3}}}
This is line {{{4}}}
This is line {{{5}}}
This is line {{{6}}}
This is line {{{7}}}
This is line {{{8}}}
This is line {{{9}}}
Seems to be working (although I can barely see the highlighting color, it is there) on my FireFox26 screen. Hope this helps! Technical 13 (talk) 16:29, 18 January 2014 (UTC)

inhibit new paragraphs when inlining tags[edit | edit source]

Is there a way to stop the extension from creating a new paragraph when inlining <syntaxhight> tags?

Right now, if I do: Lorem ipsum dolor sit amet, <syntaxhighlight lang="c">#include <stdio.h></syntaxhighlight> elit. Pellentesque blandit suscipit accumsan.

The result is:

Lorem ipsum dolor sit amet,

#include <stdio.h>

elit. Pellentesque blandit suscipit accumsan.

As you can see the text within the tags gets it's own paragraph. I want it to be highlighted, but remain in the sentence.

Does this highlight Mediawiki code?[edit | edit source]

For example if I'm editing a page, does it highlight the standard Mediawiki code? Headings, bullets, templates, b old, italics, etc. --Choshi (talk) 14:23, 27 April 2014 (UTC)

+1 Thats a big question. I also asked direct for years at https://sourceforge.net/projects/geshi/ for a Mediwiki syntax and they said they will do it. The name would be Creole (markup). -- Perhelion (talk) 18:42, 9 June 2014 (UTC)
PS: Someone has already written this file here (2012) it need only be tested! -- Perhelion (talk) 18:54, 9 June 2014 (UTC)

Does not work with MediaWiki 1.16.2 ?[edit | edit source]

Hello, ive got this error with MediaWiki 1.16.2 and the last version of this gadget :
Fatal error: Call to undefined method ParserOutput::addModuleStyles() in /ap01/appl/mediawiki/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php on line 122
Any idea ? Thanks in advance :) Haroun al Mouwahid (talk) 14:26, 6 July 2014 (UTC)

Noone for helping me ? :) Haroun al Mouwahid (talk) 07:29, 10 July 2014 (UTC)

Issue with html character codes &gt; &lt;[edit | edit source]

I've not got to the bottom of the reason, but < and > are being rendered as &lt; and &gt; and in the source they are &amp;lt; and &amp;gt;

I've fixed this with the lines:

		$out = Html::rawElement( $encloseTag, $attribs, $out );
		// have a bug showing < and > as &gt;/&lt;
		$out = str_replace( "&amp;gt;", '&gt;', $out );
		$out = str_replace( "&amp;lt;", '&lt;', $out );

These should be safe in all circumstances as that text string is almost never correct (except, oddly, in describing this issue!).

using (4959271) on:

MediaWiki 1.23.2
PHP 5.5.0 (cgi-fcgi)
MySQL 5.0.24-community-nt-log

--Hoggle42 (talk) 10:33, 4 December 2014 (UTC)

2015[edit | edit source]

Code with <dl>s cause bad things[edit | edit source]

There's a bug that I'm running into:

;Here's a dt
:Here's a dd that contains code with line numbers
:<syntaxhighlight lang="lua" line="GESHI_FANCY_LINE_NUMBERS">
print "Everything is ok"
print "Everything is still ok"
: And here's one that doesn't have numbers
:<syntaxhighlight lang="lua">
print "Everything is ok"
print "Everything is no longer ok"
:That did not work so well...


Here's a dt
Here's a dd that contains code with line numbers
1 print "Everything is ok"

2 print "Everything is still ok"

And here's one that doesn't have numbers
print "Everything is ok"

print "Everything is no longer ok"

That did not work so well...

Eric Wieser (talk) 19:28, 22 May 2015 (UTC)

Loading method[edit | edit source]

Hello, It is said in the extension's wikipage that SyntaxHighlight_GeSHi should be load with :

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

In my case (mw 1.24), it breaks the server (it gives blank page for every requests)

This worked fine :

require_once "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php";

Can be a good idea to adapt the page to avoid other mistakes.

Thanks for your work !

Jona (talk) 07:41, 22 June 2015 (UTC)

Wrong C++ highlighting (solved)[edit | edit source]

This is a bug report for the C++ lexer, where can I post it? The GeSHi project in the link on the top of this site does not longer exist … --Prog (talk) 20:18, 26 June 2015 (UTC)
I have reported it at pygments, the new base of the SyntaxHighlight extension. --Prog (talk) 15:07, 28 June 2015 (UTC)

I have some wrong highlightings in the Version on de.wikibooks (same as here):

// integer literals:
234;        // decimal, OK
0234;       // octal, OK
0x1234abCD; // hexadecimal, OK
0X1234abCD; // hexadecimal, fail
0b1010;     // binary, fail
0B1010;     // binary, fail

1;        // OK
1u;       // OK
1U;       // OK
1l;       // OK
1L;       // OK
1ll;      // OK
1LL;      // OK
1ul;      // OK
1Ul;      // OK
1uL;      // OK
1UL;      // OK
1ull;     // OK
1Ull;     // OK
1uLL;     // OK
1ULL;     // OK

01;        // OK
01u;       // OK
01U;       // OK
01l;       // OK
01L;       // OK
01ll;      // OK
01LL;      // OK
01ul;      // OK
01Ul;      // OK
01uL;      // OK
01UL;      // OK
01ull;     // OK
01Ull;     // OK
01uLL;     // OK
01ULL;     // OK

0x1;        // OK
0x1u;       // OK
0x1U;       // OK
0x1l;       // OK
0x1L;       // OK
0x1ll;      // OK
0x1LL;      // OK
0x1ul;      // OK
0x1Ul;      // OK
0x1uL;      // OK
0x1UL;      // OK
0x1ull;     // OK
0x1Ull;     // OK
0x1uLL;     // OK
0x1ULL;     // OK

0b1;        // fail
0b1u;       // fail
0b1U;       // fail
0b1l;       // fail
0b1L;       // fail
0b1ll;      // fail
0b1LL;      // fail
0b1ul;      // fail
0b1Ul;      // fail
0b1uL;      // fail
0b1UL;      // fail
0b1ull;     // fail
0b1Ull;     // fail
0b1uLL;     // fail
0b1ULL;     // fail

// integer literals with ' as separator always fail:
1'123'456'789;    // same as 1234567890
0123'456;         // same as 0123456
0xABCD'1234;      // same as 0xABCD1234
0XABCD'1234;      // same as 0XABCD1234
0b1111'0000'0000; // same as 0b111100000000
0B1111'0000'0000; // same as 0B111100000000
// the ' can appear as separator on every position of an integer but for direct
// after a prefix (0, 0b, 0B, 0x or 0X), after another ' ('' is not allowed)
// and of course at the begin and after the last _digit_ (not suffix) of an integer literal

978'3'446'43981'8; // is a correct integer literal, same as 9783446439818
// (it is an ISBN, as example for a not equidistant separation use case)

// floating point literals:
4.24;    // OK
4.24f;   // OK
4.24F;   // OK
4.24l;   // The 'l' must be part of the literal
4.24L;   // The 'L' must be part of the literal

4.2e4;   // OK
4.2e+4;  // OK
4.2e-4;  // OK
4.2e4f;  // The 'f' must be part of the literal
4.2e+4f; // The 'f' must be part of the literal
4.2e-4f; // The 'f' must be part of the literal
4.2e4F;  // The 'F' must be part of the literal
4.2e+4F; // The 'F' must be part of the literal
4.2e-4F; // The 'F' must be part of the literal
4.2e4l;  // OK
4.2e+4l; // OK
4.2e-4l; // OK
4.2e4L;  // OK
4.2e+4L; // OK
4.2e-4L; // OK

4.2E4;   // OK
4.2E+4;  // OK
4.2E-4;  // OK
4.2E4f;  // The 'f' must be part of the literal
4.2E+4f; // The 'f' must be part of the literal
4.2E-4f; // The 'f' must be part of the literal
4.2E4F;  // The 'F' must be part of the literal
4.2E+4F; // The 'F' must be part of the literal
4.2E-4F; // The 'F' must be part of the literal
4.2E4l;  // OK
4.2E+4l; // OK
4.2E-4l; // OK
4.2E4L;  // OK
4.2E+4L; // OK
4.2E-4L; // OK

// character and c-string literals:
'a';            // OK
u'a';           // The 'u' must be part of the literal
U'a';           // The 'U' must be part of the literal
L'a';           // OK
"I am a Text";  // OK
u"I am a Text"; // The 'u' must be part of the literal
U"I am a Text"; // The 'U' must be part of the literal
L"I am a Text"; // OK

// also all raw string literals are not supported

// with C++17 the following literals will also become correct:
// --> begin C++17
u8"I am a Text";
// <-- end C++17

Here are the formal definitions of C++ literals:

Kind regards! --Prog (talk) 18:57, 26 June 2015 (UTC)

line property destroys copy & paste code (solved)[edit | edit source]

When I use the line property, I can't select the source without the line numbers:

1 def quickSort(arr):
2     less = []

This is very disruptive! The line property is a very nice feature, but it destroys all my code examples when I use copy & paste, so I can not use it without much trouble for the readers. --Prog (talk) 20:16, 26 June 2015 (UTC)

solved via CSS: .mw-highlight .lineno { user-select:none; } on Mediawiki:common.css. --Prog (talk) 15:37, 28 June 2015 (UTC)

MediaWiki:Geshi.css[edit | edit source]

Since the GeSHi update, all the present code is non-functional, as none of the referenced classes are no longer used. However, what is the status of MediaWiki:Geshi.css? Is it still loaded? -- [[User:Edokter]] {{talk}} 14:42, 28 June 2015 (UTC)