Page MenuHomePhabricator

Haskell: highlights single quote as strings
Closed, ResolvedPublic

Description

Author: feiyuanbw

Description:
Bug: In the lang="haskell" mode, any single quotes (apostrophes) are treated as if they were delimiters for a string.

Expected: Single quotes should be treated as normal characters used for identifiers.


Version: master
Severity: minor

Details

Reference
bz52509

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:50 AM
bzimport added a project: SyntaxHighlight.
bzimport set Reference to bz52509.
bzimport added a subscriber: Unknown Object (MLST).

The effects of this issue in the Haskell Wikibook are nasty [1]. Upstream, here is a bug report [2] and a proposed patch [3], but both were seemingly ignored.

[1] For instance, https://en.wikibooks.org/w/index.php?title=Haskell/Understanding_monads/State&oldid=2550766#Implementation_with_Functional_Purity .

[2] http://sourceforge.net/p/geshi/bugs/217/

[3] http://sourceforge.net/p/geshi/bugs/219/

Change 86395 had a related patch set uploaded by Ori.livneh:
Haskell syntax: omit single quotes from QUOTEMARKS

https://gerrit.wikimedia.org/r/86395

Change 86395 merged by Adamw:
Haskell syntax: omit single quotes from QUOTEMARKS

https://gerrit.wikimedia.org/r/86395

Thank you for the patch! Looking forward to its arrival at Wikibooks.

The change has caused incorrect rendering of double quotes in Char literals. For example, see second snippet in https://en.wikibooks.org/w/index.php?title=Write_Yourself_a_Scheme_in_48_Hours/Parsing&oldid=2627491#Return_Values

Indeed; though we exchanged an issue which shown up often for a less frequently seen one the situation is not ideal. To fix this issue and a few other annoyances, I am working on patches to haskell.php; they will be submitted uptsream.

(In reply to Daniel Mlot from comment #6)

Indeed; though we exchanged an issue which shown up often for a less
frequently seen one the situation is not ideal. To fix this issue and a few
other annoyances, I am working on patches to haskell.php; they will be
submitted uptsream.

It looks like these have been done? https://github.com/GeSHi/geshi-1.0/blob/master/src/geshi/haskell.php :)

Change 150622 had a related patch set uploaded by Reedy:
Update GeSHi from upstream

https://gerrit.wikimedia.org/r/150622

The above patchset was merged and has actually undone this change in our core, but did bring multiple other enhancements.

I have created an upstream pull request: https://github.com/GeSHi/geshi-1.0/pull/30 for this particular problem though.

Change 150622 merged by jenkins-bot:
Update GeSHi from upstream

https://gerrit.wikimedia.org/r/150622

This is currently broken on Wikipedia. Is a fix just in the pipeline waiting for Wikipedia to upgrade or has this been abandoned? How do I see which version of GeSHi Wikipedia is currently running?

The above patchset was merged and has actually undone this change in our core, but did bring multiple other enhancements.

It is more important to not highlight apostrophes in variable names (used as primes; e.g. x' = x + 1) than to have highlighting of character literals (e.g. ['s', 't', 'r', 'i', 'n', 'g', '\x2032']) because character literals are consistently small (2 apostrophe characters and the quoted character, which in its longest form is an escaped character code) whereas the mishighlighting caused by treating apostrophes in variable names as quotes can span across multiple lines indefinitely. In such cases, this means that the Haskell highlighting isn't even usable.
    Of course, ideally, it would be best if character literals were highlighted without messing up highlighting when apostrophes are used in variable names, but this isn't so critical to the overall use of the Haskell highlighting as having unhighlighted character literals isn't a so much a reason not to use the highlighting altogether.
    Here's an example of where this bug means that it is best not to use the Haskell syntax highlighting at all; see second source block: https://en.wikipedia.org/w/index.php?title=Comparison_of_programming_languages_%28mapping%29&oldid=636257814#Haskell

Post-scriptum: I apologise for being partly responsible for the mess of patches above. I set out to write a proper fix (using a regex to find literal chars) and do some low-hanging improvements, but stopped work before dealing with the main issue. My incomplete patches were pulled by upstream while I was away. Fortunately, none of that matters anymore now that the extension has switched to Pygments.