Closed ramanshah closed 7 years ago
Thanks for the bug report! I agree that this is a problem that needs to be fixed!
To calibrate expectations: I'm new to this job (and by "job" I mean volunteering), and don't know a whole lot about the wiki yet. So it might take a while for me to fix this. But I will definitely look into it when I get a chance!
Of course, we're all volunteers :)
I don't know the first thing about the wiki rendering system. If you can point me to documentation, I can look at it, too, to try and figure if and how one can configure its tokenizer.
Thanks! I'm afraid I know about as much as you do. I suspect there's a plug-in for syntax highlighting, but I'll need to do a little research to find its name and documentation.
According to Special:Version, the wiki is using the SyntaxHighlight extension, which in turn uses GeSHi - Generic Syntax Highlighter.
It appears that the current version of SyntaxHighlight uses pygments instead of GeSHi. So I should probably look into upgrading to the latest version of SyntaxHighlight, and see if pygments handles Haskell syntax better than GeSHi does.
I'm unclear where the <haskell>
tag is coming from, though, because the SyntaxHighlight documentation only mentions <syntaxhighlight>
and <source>
as tags, with lang
as an attribute. It doesn't say anything about being able to use a language name as a tag name. I wonder if that is some sort of customization specific to the Haskell wiki?
I checked the LocalSettings.php of our wiki, and found the following:
# Make <haskell> a synonym for <source lang='haskell'>.
#
# The following is pretty hackish, but otherwise we'd have to edit the
# extension code.
function haskellKeywordHook( $text, $args = array(), $parser ) {
$args["lang"] = "haskell";
return SyntaxHighlight_GeSHi::parserHook( $text, $args, $parser );
}
function haskKeywordHook( $text, $args = array(), $parser ) {
$args['lang'] = 'haskell';
$args['enclose'] = 'div';
$out = SyntaxHighlight_GeSHi::parserHook( $text, $args, $parser );
return '<div class="inline-code">' . $out . '</div>';
}
function addHaskellKeywordHook() {
global $wgParser;
$wgParser->setHook( 'haskell', 'haskellKeywordHook' );
$wgParser->setHook( 'hask', 'haskKeywordHook' );
return true;
}
Thanks, @gbaz ! It sounds then like upgrading SyntaxHighlight won't affect the ability of the <haskell>
tag to work.
On the other hand, it looks like upgrading SyntaxHighlight won't be straightforward, because the current version of SyntaxHighlight requires MediaWiki 1.23 or higher, and we only have MediaWiki 1.19. So going to the latest SyntaxHighlight would require upgrading MediaWiki, which would probably be a good thing, but sounds pretty scary, given how little I still understand. I'm very afraid I would break something.
Maybe one thing I can offer is to run the above solution through pygments
to verify if that will help.
Yay, pygments
has a nice web interface for demo purposes:
http://pygments.org/demo/6344635/
In case of broken links, it looks good and certainly resolves the title issue with the rendering:
Also relevant: The underlying issue appears to have been fixed in GeSHi
, in case a GeSHi
upgrade is easier than an upgrade of the wiki engine to support pygments
:
Hmm, but it looks like they stopped cutting releases years ago.
Thanks, @ramanshah ! I might look into updating GeSHi, since that seems easier and lower risk.
On the other hand, we now have another request, #7, to upgrade MediaWiki. Apparently there are some security issues with the version we're running. So maybe I should just bite the bullet and upgrade MediaWiki.
I've been attempting to upgrade GeSHi, but so far I've been unsuccessful.
GeSHi is installed in /usr/share/php-geshi
, as part of the php-geshi
apt package. There is no newer version of the php-geshi
package available, so we can't upgrade with apt.
PHP's package manager appears to be called PEAR. I installed PEAR and attempted to use it, but PEAR doesn't seem to know anything about a package named geshi
or GeSHi
.
The GeSHi documentation suggests just installing by copying files. So, I checked out the geshi-1.0 Git repository into wikiadmin
's home directory. I moved the existing /usr/share/php-geshi
to /usr/share/php-geshi-old
, and then created a new /usr/share/php-geshi
. I copied the geshi.php
and geshi
directory from the Git checkout to /usr/share/php-geshi
.
I wasn't sure if anything needed to be restarted to pick up the changed files, so I did service nginx restart
and service php5-fpm restart
for good measure.
However, after doing all this, the syntax highlighting is still incorrect. Not sure what to try next.
OK, it looks like there was some sort of caching going on. I edited the Sandbox page, and now it looks OK. So I think the problem is fixed, but you'll need to make a trivial edit to each page that has incorrect highlighting, to defeat the cache.
I'm going to mark this as closed, but please let me know if you run into any issues.
Hi Patrick,
Thank you for this update and the explanations. Looking at the Sandbox page it seems to be fixed.
Jean-Hugues
2017-02-14 10:57 GMT+02:00 Patrick Pelletier notifications@github.com:
OK, it looks like there was some sort of caching going on. I edited the Sandbox https://wiki.haskell.org/Sandbox page, and now it looks OK. So I think the problem is fixed, but you'll need to make a trivial edit to each page that has incorrect highlighting, to defeat the cache.
I'm going to mark this as closed, but please let me know if you run into any issues.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ppelleti/haskell-wiki-bugs/issues/6#issuecomment-279646105, or mute the thread https://github.com/notifications/unsubscribe-auth/AVATSgu1ScS1Sze0JpZIDUd5vJHmdKFxks5rcWxdgaJpZM4Llt3k .
Wonderful! Thanks for fixing this, Patrick!
First of all, I'm really enjoying the 99 Haskell problems and did a bunch of them this weekend as I try to start getting fluency with Haskell in earnest. Thanks!
The tick character
'
used to denote alternative implementations of a function are being interpreted as single quotes in a language where single quotes denote multi-line strings. To wit, in the solution to question 1:looks like this: