Extension talk:SyntaxHighlight

Jump to: navigation, search

About this board

Edit description


Previous discussion was archived at Extension talk:SyntaxHighlight/Archive 2017 on 2017-03-29.

By clicking "Add topic", you agree to our Terms of Use and agree to irrevocably release your text under the CC BY-SA 3.0 License and GFDL

Unexpected output from Pygments encountered

Ganomix (talkcontribs)

For some reason, syntaxhighlight isn't working for me. If I type e.g.:

<syntaxhighlight lang="python">
print "hello world"

I then get the following error:

[9b512e3be13749e9a6105d0f] /wiki/index.php?title=Test222&action=submit MWException from line 168 of C:\inetpub\wwwroot\wiki\extensions\SyntaxHighlight_GeSHi\SyntaxHighlight_GeSHi.class.php: Unexpected output from Pygments encountered Backtrace:

0 C:\inetpub\wwwroot\wiki\includes\parser\Parser.php(4262): SyntaxHighlight_GeSHi::parserHook(string, array, Parser, PPFrame_DOM)
1 C:\inetpub\wwwroot\wiki\includes\parser\Preprocessor_DOM.php(1260): Parser->extensionSubstitution(array, PPFrame_DOM)
2 C:\inetpub\wwwroot\wiki\includes\parser\Parser.php(3366): PPFrame_DOM->expand(DOMElement, integer)
3 C:\inetpub\wwwroot\wiki\includes\parser\Parser.php(1248): Parser->replaceVariables(string)
4 C:\inetpub\wwwroot\wiki\includes\parser\Parser.php(446): Parser->internalParse(string)
5 C:\inetpub\wwwroot\wiki\includes\content\WikitextContent.php(331): Parser->parse(string, Title, ParserOptions, boolean, boolean, NULL)
6 C:\inetpub\wwwroot\wiki\includes\content\AbstractContent.php(497): WikitextContent->fillParserOutput(Title, NULL, ParserOptions, boolean, ParserOutput)
7 C:\inetpub\wwwroot\wiki\includes\EditPage.php(3707): AbstractContent->getParserOutput(Title, NULL, ParserOptions)
8 C:\inetpub\wwwroot\wiki\includes\EditPage.php(2492): EditPage->getPreviewText()
9 C:\inetpub\wwwroot\wiki\includes\EditPage.php(600): EditPage->showEditForm()
10 C:\inetpub\wwwroot\wiki\includes\actions\EditAction.php(59): EditPage->edit()
11 C:\inetpub\wwwroot\wiki\includes\actions\SubmitAction.php(38): EditAction->show()
12 C:\inetpub\wwwroot\wiki\includes\MediaWiki.php(503): SubmitAction->show()
13 C:\inetpub\wwwroot\wiki\includes\MediaWiki.php(288): MediaWiki->performAction(Article, Title)
14 C:\inetpub\wwwroot\wiki\includes\MediaWiki.php(745): MediaWiki->performRequest()
15 C:\inetpub\wwwroot\wiki\includes\MediaWiki.php(519): MediaWiki->main()
16 C:\inetpub\wwwroot\wiki\index.php(43): MediaWiki->run()
17 {main}

Any ideas on how to fix this issue?

I am running MediaWiki 1.27.1 and Syntaxhighlight 2.0 (36820f3).

Ganomix (talkcontribs)

I updated pygments from version 2.1.3 to 2.2.0 and set $wgPygmentizePath = "c:\\Python27\\Scripts\\pygmentize.exe"; in LocalSettings.php.

That seems to have fixed the problem.

Lanthanis (talkcontribs)

I uninstalled pygments 2.2 (Python 2.7) and pygments 2.2 (Python 3.6) and installed it again (Python 3.6) with pip3 install pygments. After a restart it worked.

MW 1.28.2 PHP 7.1.3

Reply to "Unexpected output from Pygments encountered"
Zewas (talkcontribs)

I'm using MediaWiki 1.28.2 and SyntaxHighlight 2.0. My system is a 64 bit Windows 10 machine.

The code ends up in a plain PRE tag and the page is added to category "Pages with syntax highlighting errors". Setting $wgShowExceptionDetails did not trigger any output. On a hunch I renamed pygmentize to pygmentize.exe, tried to run it via the command line and got this error message:

Unsupported 16-Bit Application

The program or feature "\\...\pygmentize.exe" cannot start or run due to incompatibility with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit Windows compatible version is available.

Is that the problem? Do I need a different version of pygmentize? Where do I get that?

Lanthanis (talkcontribs)

So you installed a x64 version of Python ?

Maybe you should try a x32 version Python and install Pygments again.

Zewas (talkcontribs)

In case anyone's interested, here's the solution:

  1. Find the file called pygmentize in the extensions\SyntaxHighlight_GeSHi folder.
  2. Move that file to your Apache's cgi-bin. If your server is set up reasonably well only executables in that magic directory will get executed.
  3. Install Python 2.7 because pygmentize is not really an executable. It's Python byte code and requires the python.exe to run.
  4. Make sure that the Python install directory is added to your system's PATH.
  5. Rename pygmentize to pygmentize.pyc. This is Windows. Extensions are magic here. No extension, no magic.
  6. Find the cgi-bin's AddHandler directive in your httpd.conf and add .pyc to the list if it isn't there already.
  7. Edit your LocalSettings.php and add this line somewhere:
    $wgPygmentizePath = '...\\cgi-bin\\pygmentize.pyc';
  8. Restart your server.

That worked for me.

Reply to "Syntax highlighting does not work"
Launchballer (talkcontribs)

You may be interested in the following. An assistive technologies trainer put Grammarly on my laptop, and I've just gone to edit the Wikipedia article for Quaaludes and the highlighting flickers, almost to the point of becoming unusable. Any chance some research could be done?

Jdforrester (WMF) (talkcontribs)

Grammarly has nothing to do with the SyntaxHighlight extension, it's a browser plug-in that adds highlights to text as you edit, and it's both slow (as you've found) and known to be incompatible with several wiki tools. I'd recommend that you don't use it, sorry.

Reply to "Grammarly"
Mayazcherquoi (talkcontribs)

How can I force Pygmentize to render output using the "colorful" style, as per: http://pygments.org/docs/styles/ ?

I have tried setting the following:

$wgPygmentizePath = '/usr/bin/pygmentize -S colorful';

However, this will just cause Pygmentize to error out on any pages containing a SyntaxHighlight block.


Reply to "Control Pygmentize style?"

Passing code via GET param to external site

Bjohas (talkcontribs)


Is there any way that a <syntaxhighlight>ABC</syntaxhighlight> segement could produce a link to an external site passing the code via GET? I.e. could the <syntaxhighlight server="myserver?Q=">ABC</syntaxhighlight> also produce a link myserver?Q=urlencode:ABC ?

The OSM wiki is trying to do this here with templates: https://wiki.openstreetmap.org/wiki/Template:OverpassTurboExample, but the problem is that this only works if "ABC" is (wiki-)escaped, which is somewhat limiting. Ideally the unescaped ABC would be passed to <syntaxhighlight>, and syntaxhighlight could generate the link.


(Also see Help_talk:Magic_words#urlencode:syntaxhighlight.3E....2Fsyntaxhighlight.3E)

PerfektesChaos (talkcontribs)

I did not fully undestand your plan, but I answered on Help talk:Magic words.

TL;DR: {{#tag:}}

Bjohas (talkcontribs)

Many thanks!

Reply to "Passing code via GET param to external site" (talkcontribs)

It highlights c for no reason.

SELECT * FROM cable AS c


SELECT * FROM cable AS tt
Reply to "A bug in tSQL highlighting"
TheDJ (talkcontribs)
1 def quickSort(arr):
2 	less = []
3 	pivotList = []
4 	more = []
5 	if len(arr) <= 1:
6 		return arr
7 	else:
8 		pass
IKhitron (talkcontribs)

The css classes are not loaded.

Reply to "Test"
There are no older topics