GitHub MediaWiki extension

I installed the extension a few weeks ago, but it needed some massaging. As written, the content got rendered as wiki markup. I changed the extension to wrap the content in <source>, auto-detect the language from the file extension, allow overriding the language if needed, and finally to strip the leading license header (if any). This last change is a pretty nasty hack but I can’t think of a case where we would explicitly want to include license header blurbs in wiki-embedded content.

There are two main ways to use this new functionality:

  1. A new GitHubEmbed template.

  2. A lower-level github parser function.

I also updated the ImgLib2 Examples page to use GitHubEmbed, and checked that the results are identical to before.


Nice work @ctrueden !

Check the new IJ2 Python scripts page :


Thank you @ctrueden
I have replaced the inline code by using the GitHub extension for Jython Scripting.


I noticed that the syntax highlighting for Groovy on the wiki doesn’t seem to work, although it is on the list of supported languages. For example, this embedded groovy file from github is not highlighted (even when trying to specify the language with lang=groovy in the {GitHubEmbed} tag):

There are two different but confusingly named extensions for syntax highlighting:

  1. The SyntaxHighlight extension, formerly known as SyntaxHighlight_GeSHi—the extension to which you linked—uses server-side highlighting via Pygments. That one is not installed on (!).
  2. Instead, we use the SyntaxHighlighter extension, as shown on the Special:Versions page, which uses client-side highlighting via the SyntaxHighlighter library written in JavaScript.

When I installed the GitHub extension in December 2016, it did not support syntax highlighting, nor even verbatim code blocks. Therefore, I forked the GitHub extension to support syntax highlighting via SyntaxHighlighter; see imagej/mediawiki-GitHub@1637d87e.

Since then, there have been dozens of new commits to the GitHub extension upstream, including the addition of syntax highlighting via the SyntaxHighlight extension. However, upgrading to the latest version of GitHub might be disruptive. We might need to switch to—or at least enable—the SyntaxHighlight extension, and when I tried to do that in the past (during the server rebuild of summer 2016), I could not make it work, which is why we stuck with SyntaxHighlighter even though as a MediaWiki extension it seems dead (no commits in over two years).

Note that this is not the first time we have desired more languages. To address that, we forked SyntaxHighlighter and added more brushes. The weird thing this time is that there is already a shBrushGroovy.js. There was not, however, an alias mapping groovy to Groovy, so I added one. And it seems to have done the trick. :smile:

Thanks for the report, and please let me know if you notice any other missing languages!