Page MenuHomePhabricator

<pre> tags generated by extensions should not be collapsed into <pre></pre><div> (content) </div> by Tidy
Closed, ResolvedPublic

Description

The bug happening on 1.20wmf1 on mediawiki.org

When I initially fixed[1] SyntaxHighlighter a few months back to use <pre class="mw-geshi>...geshi output</pre> instead of <div class="mw-geshi>...geshi output</div>

( .. so that PRE styles by skins apply to geshi, without requiring local wikis to maintain a copy of each skins's <pre> css style and apply it in MediaWiki:Common.css to div.mw-geshi) .. )

.. it was working fine on SVN trunk. Then I requested that fix to be merged to 1.19wmf1 then suddenly this bug was occurring, the same bug that is happening now. Back then I figured it was due to a change in 1.20 that therefor didn't work well on 1.19wmf1 so it[2] was backed out[3].

But now that 1.20wmf1 is live I'm seeing the same bug again (see attachment).

Oddly enough it still isn't happening on my localhost running git master (2nd attachment), so contrary to what I suspected a few months back it can't be due to changes in core since the branching because 1.20wmf1 was branched *today*. It has to be something specific to wmf config.


Version: unspecified
Severity: blocker
URL: https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=523532

Attached:

Screen_Shot_2012-04-11_at_5.29.39_AM.png (784×1 px, 126 KB)

Details

Reference
bz35875

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 12:12 AM
bzimport set Reference to bz35875.

Created attachment 10402
The bug NOT happening on 1.20alpha (localhost)

Attached:

Screen_Shot_2012-04-11_at_5.35.09_AM.png (781×913 px, 105 KB)

[1] r113190, bug 19416)
[2] r113198 MFT 1.19wmf1 r113190
[3] r113200 revert MFT 1.19wmf1 r113190

Rephrasing summary, not limited to list item inline context.

Confirmed that the bug doesn't happen on master locally by Roan as well. But installing Tidy made the bug appear, so I suppose that's the "wmf config specific thing" thats causing it.

content hidden as private in Bugzilla

So it turns out that...

.. although Geshi IS using <pre> internally, the reason the skin's style didn't
apply (and hence bug 19416 filed) is because it has a very strong reset. Not a
problem so we can simply wrap another <pre> around that that is loose
from Geshi (geshi's output is simply encapsulated inside of our <pre>).

... Geshi is also using a few <div>s and <span>s internally as wrappings
sometimes (not always), but those are out of the MediaWiki extension's control.

.. and Tidy does not allow a <div> to be inside a <pre> so it closes the <pre>
before the, only child, <div> starts with a </pre>, and lets the div continue
outside the <pre> and them snips out the original </pre> at the and as a
closing tag with no matching opening tag.

Another similar problem about <div> inside <button>, although that one was recognized and fixed:

http://sourceforge.net/tracker/?func=detail&atid=390963&aid=1003361&group_id=27659

Console output:

krinkle$ tidy
<button><div>..</div></button>

krinkle$ tidy
<pre><div>..</div></pre>
line 4 column 1 - Warning: missing </pre> before <div>
line 4 column 18 - Warning: inserting implicit <pre>

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

Apparently W3 agrees that no <div> is allowed inside <pre>. imho stupid since both are block-level elements (or at least behave like one), but I suppose the easiest solution is to just not use enclose=div (which is the default for whatever reason), but that is fortunately still in the little part of the container that the extension does have control over.

Are there are reasons to support enclose=div ?

If we can't find a fix, then sure, revert it and reopen bug 19416.

But like I said in comment 9 there is a simple solution, I just wanted to make sure there are no gotchas before I commit it.

Okay so to remove the support for <source enclose=div> (which could previously be set manually from wikitext), these lines would have to change in SyntaxHighlight_GeSHi.class.php:

before:

		// Override default enclose from "enclose" attribute?
		$enclose = $pre;
		if ( isset( $args['enclose'] ) ) {
			if ( $args['enclose'] === 'div' ) {
				$enclose = GESHI_HEADER_DIV;
			} elseif ( $args['enclose'] === 'none' ) {
				$enclose = GESHI_HEADER_NONE;
			}
		}

after:

		// Override default enclose from "enclose" attribute?
		$enclose = $pre;
		if ( isset( $args['enclose'] ) ) {
			if ( $args['enclose'] === 'none' ) {
				$enclose = GESHI_HEADER_NONE;
			}
		}

and that would fix it mostly, however there is still the case where line-numering are enabling and then geshi will force a <div> still because of XHTML restrictions (no table allowed in <pre>), which makes perfect sense. So it looks like we'll have to fix this from mediawiki instead and provide a class we can use to give pre-styling.

  • Bug 35968 has been marked as a duplicate of this bug. ***
  • Bug 36031 has been marked as a duplicate of this bug. ***

I suggest to purge all pages to re-render incorrectly rendered pages.