Extension talk:SyntaxHighlight

Jump to: navigation, search

About this board


Archives

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
Garonenur (talkcontribs)
1 INSTERT INTO test (value) VALUES (0);

It works in this wiki, but on our company-wiki (which is not open, so no links) zeros get swallowed. and

<syntaxhighlight lang="mysql" enclose="div" line>
INSTERT INTO test (value) VALUES (0);
</syntaxhighlight>

leads to the zero not being shown. I tested pygmentize on the command line and it outputs the sql correctly.

Any ideas? Questions?

MichaelFrey (talkcontribs)

Could you please state the version of Mediawiki and Extension being used?

Could you post a screenshoot and the HTML code delivered to the browser for this example?

When I render it here on mediawiki.org, the zero is encoded with:

<span class="mi">0</span>

So, I would presume, that your company wiki has done something with the CSS-class "mi".

Garonenur (talkcontribs)

hi Michael,

MediaWiki: 1.27.1

SyntaxHighlight: 2.0

Media:SQL-Render_by_SyntaxHighlight.png

Media:HTML_Result_of_SQL-Render_by_SyntaxHighlight.png

The class is set correct, but the '0's are missing in the HTML. If I change the source to something nonsens like a letter or even '00' those show up (on page and in raw html)

If anything happens to css-classes here in my wiki, it is because of me, as I have to handle the wiki.

[edit: fixed file link typo]

IKhitron (talkcontribs)

You can open the console and check the code of the element of first png.

Garonenur (talkcontribs)

which console? for which code? I have terminal acces to the ubuntu server running the wiki - or are you refering to the web-console like fire-bug?

IKhitron (talkcontribs)

You mean the first png is not from the browser? It looks very nice.

Garonenur (talkcontribs)

both images are screenshots from browser and firebug.

I just realized that I had a typo in the second file-link:

Media:HTML_Result_of_SQL-Render_by_SyntaxHighlight.png

thats the html I get for the syntax highlighted sql-code.

Garonenur (talkcontribs)

I just realized that a zero in simple <code>0</code> tags is not rendered by my wiki also, so this may have nothing to do with SyntaxHighlight.

This comment was hidden by IKhitron (history)
Reply to "Zeros in SQL go missing"
Elitre (WMF) (talkcontribs)

My apostrophes come in light blue, which makes them even less noticeable than usual, which kinda defeats the point, I think? :)

Elitre (WMF) (talkcontribs)

Aaand the page I was actually looking for for this feedback was Extension talk:CodeMirror...

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.

94.217.149.6 (talkcontribs)

Thank you very much! Your info helps me a lot. With the difference: I use IIS as Webserver.

MediaWiki Version 1.29

  1. You need to install Python 2.73 in default directory
  2. Map cgi extensions like here: http://haishibai.blogspot.de/2011/02/setting-up-python-on-iis-7_01.html(The Extension is "pyc" and not like in the link "py"!)
  3. Find the file called pygmentize in the extensions\SyntaxHighlight_GeSHi folder.Rename pygmentize to pygmentize.pyc. This is Windows. Extensions are magic here. No extension, no magic.
  4. Add this to LocalSettings.php

$wgPygmentizePath = 'C:\inetpub\wwwroot\Wiki\extensions\SyntaxHighlight_GeSHi\pygments\pygmentize.pyc';

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

wfLoadExtension( 'HighlightJS' );

$wgHighlightJsMagic = 'syntaxhighlight';

$wgHighlightJsStyle = 'tomorrow-night-bright';

Reply to "Syntax highlighting does not work"

SELinux causing "Pages with syntax highlighting errors"

1
Christopher.ursich (talkcontribs)

The problem of SELinux causing SyntaxHighlight (specifically, Pygments) to not work, and to tag the page into category "Pages with syntax highlighting errors" has been discussed on this forum previously, and in other places. MediaWiki addresses it in article SELinux, but I believe the instructions there are somewhat incorrect. I solved the problem for myself, and proposed changes to the article on Talk:SELinux. I hope this helps.

Reply to "SELinux causing "Pages with syntax highlighting errors""
Aka sektor (talkcontribs)

Not work <syntaxhighlight lang="lua">

Reply to "MW 1.29.0 bugs"
Brian denton (talkcontribs)

Syntaxhighlight works great for me, except I would like to use wiki markup/wikicode as the language. Is this implemented? I cannot find the lang argument (lang="wikicode" etc) anywhere.

IKhitron (talkcontribs)

It does not exists, unfortunately. You can try html, it can be helpful a little.

Brian denton (talkcontribs)

okay, thank you. PHP has a nice green tinge that looks kinda nice!

Reply to "Wikicode as Lang"

Unexpected output from Pygments encountered

3
Ganomix (talkcontribs)

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

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

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"
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.

Cheers.

Reply to "Control Pygmentize style?"

Passing code via GET param to external site

3
Bjohas (talkcontribs)

Hello,

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.

Thanks!

(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"