haskell / haskell-wiki-configuration

Issue tracking for Haskell Wiki
https://wiki.haskell.org/
4 stars 4 forks source link

Variable names ending with an apostrophe are not parsed correctly by GeSHi syntax highlighter #8

Closed jhenligne closed 7 years ago

jhenligne commented 7 years ago

GeSHi is quite old (last version is date August 2012). Newer syntax highlighter could improve code readability and correct error mentioned in the title.

As an example, here is how a sample of example 12 in All About Monads looks like now:

geshi

And how it could look like with another library, Prism in that case:

prism

It is also worth noting GeSHi is a PHP library while Prism is written in JavaScript. Prism inclusion in HTML code is very lightweight compared to GeSHi which add formatting <span> tags everywhere, as a result HTML pages would be lighter, even with css and js files included.

jhenligne commented 7 years ago

Arf! I should have read previous Issues as I just realize this bug was described in Issue #6...

Nevertheless it may be a chance because following another lead drove me to realize how verbose is the SyntaxHighlight extension of MediaWiki.

Comparing HTML produced by it on Extension:SyntaxHighlight page with the use of Prism library is enlightening.

On Usage subtitle here is the Python code example (HTML):

<div class="mw-highlight mw-content-ltr" dir="ltr"> <pre><span class="lineno">1 </span><span class="k">def</span> <span class="nf">quickSort</span><span class="p">(</span><span class="n">arr</span><span class="p">):</span> <span class="lineno">2 </span> <span class="n">less</span> <span class="o">=</span> <span class="p">[]</span> <span class="lineno">3 </span> <span class="n">pivotList</span> <span class="o">=</span> <span class="p">[]</span> <span class="lineno">4 </span> <span class="n">more</span> <span class="o">=</span> <span class="p">[]</span> <span class="lineno">5 </span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span> <span class="o"><=</span> <span class="mi">1</span><span class="p">:</span> <span class="lineno">6 </span> <span class="k">return</span> <span class="n">arr</span> <span class="lineno">7 </span> <span class="k">else</span><span class="p">:</span> <span class="lineno">8 </span> <span class="k">pass</span> </pre></div>

Equivalent display with Prism (HTML): <pre class="line-numbers"><code class="language-python"> def quickSort(arr): less = [] pivotList = [] more = [] if len(arr) <= 1: return arr else: pass </pre></code>

Notice how similar is MediaWiki markup (HTML): <syntaxhighlight lang="python" line='line'> def quickSort(arr): less = [] pivotList = [] more = [] if len(arr) <= 1: return arr else: pass </syntaxhighlight>

I don't know how risky it is to update MediaWiki and I don't know if it is possible to hack it to use an external library like Prism but it may be a cheaper fix.

mignon-p commented 7 years ago

I think the easiest, lowest-risk approach would be to update to the last version of GeSHi, which has fixed this problem. I will try to look into that soon.

Long-term, when #7 is fixed, we'll be using Pygments, which also has fixed this problem.

I don't think switching to a third syntax highlighter, other than GeSHi or Pygments, is going to be attractive unless it already has a MediaWiki plug-in, because I'd like to avoid maintaining custom code. I'd rather use MediaWiki "out of the box" as much as possible, because this will make maintenance easier.

Meanwhile, I'm going to close this bug, since it is a duplicate of #6, which is still open.