Page MenuHomePhabricator

The <pre>/<div> tag around GeSHi-highlighted code does not have a class "source"
Closed, DeclinedPublic

Description

Author: ais523

Description:
Previously (according to memory, and to comments on some bugs, such as bug 7163), the <pre> element that was generated enclosing GeSHi-highlighted code had two classes, "source" and "source-language" (where 'language' was replaced with the language name). At present (r25673) on enwiki, the source class isn't being generated, which means there's currently no easy way to add coding that affects all languages (there's such coding on [[:w:en:MediaWiki:Geshi.css]], demonstrating that the feature is wanted, but it doesn't currently work due to this bug); the code previously worked because the class used to exist, but now it doesn't and it's preventing cross-source-language colour fixes. This seems to be a regression.


Version: unspecified
Severity: normal
URL: http://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#GeSHi_update

Details

Reference
bz11274

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:55 PM
bzimport added a project: SyntaxHighlight.
bzimport set Reference to bz11274.

ais523 wrote:

(fix severity; this is a bug, not a feature request)

Peeking through the code, I don't think it ever had this second class. The GeSHi code only deals with a single class on the <pre> it generates, not two, and seems to default to the language name. When we started making using of that it started being set as 'source-{$lang}'.

Without hacking GeSHi's core code or hacking the output, we I guess could put a style on the _wrapper_ <div> which seems to be used only to set directionality.

Changing the summary -- this isn't a regression, but a wish. :)

herd wrote:

Oddly, there aren't always <pre> in the output of GeSHi anymore.

On Wikimedia: <source lang="css">.foo {}</source> currently produces:
<div dir="ltr" style="text-align: left;"><pre class="source-css"><span class="re1">.foo</span> <span class="br0">{</span><span class="br0">}</span></pre></div>

While <source lang="css" line>.foo {}</source> produces:
<div dir="ltr" style="text-align: left;"><div class="source-css" style="font-family: monospace;"><ol><li class="li1"><div class="de1"><span class="re1">.foo</span> <span class="br0">{</span><span class="br0">}</span></div></li></ol></div></div>

Meanwhile, all lang stylesheets remove the borders from <pre> that are descendants of the .source-lang, which applies to neither of these cases, but does for output like like:
<div dir="ltr" style="text-align: left;"><div class="html4strict source-html4strict" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="sc2">&lt;<span class="kw2">table</span> <span class="kw3">border</span><span class="sy0">=</span><span class="st0">&quot;1&quot;</span>&gt;</span></pre></li></pre></li></ol></div></div>

And the borders for that <pre> get removed in the inline style:
.source-html4strict li, .source-html4strict pre {
line-height: normal; border: 0px none white;
}

So simply classing all <pre> won't work. You'll probably need to class the outer object, the div setting dir="". And then probably remove the border from all descendant pre from that. Ugh.

Ms2ger wrote:

*** This bug has been marked as a duplicate of bug 16324 ***

obsolete.fax wrote:

*** Bug 16324 has been marked as a duplicate of this bug. ***

herd wrote:

(In reply to comment #7)

This bug was created because of
https://bugzilla.wikimedia.org/show_bug.cgi?id=10967

No, it was not, it existed before bug 10967 was fixed.

The old version of GeSHi output did NOT have such a class either. But it does now in the latest version (per r52346). All GeSHi output in MediaWiki, using the latest version of the GeSHi extension, will output in a <div> or <span> labelled class="mw-geshi".

There won't be one added to the pre, because there are sometimes: 1) no <pre>, 2) multiple <pre>, so that would be pretty useless. However, if you do want one, take it up with GeSHi, the Syntax Hilight extension covered by this component can only control the outermost div/span.

Also, why did you reverse the dup?