Page MenuHomePhabricator

Preformatted multiline text in lists doesn't work anymore
Closed, ResolvedPublic

Description

Author: irohloff

Description:
The following worked before (Mediawiki 1.6.?) :

  1. Line A
  2. Line B <pre><nowiki> This is a multiline text inside a list </nowiki></pre>
  3. Line C

With Mediawiki 1.7.1 this is rendered wrong. (The multiline will break the
numbered list.)

I already found out what the problem is:
In includes/Parse.php the strip() method changed (since mediawiki 1.6.?).
This method calls Parser::extractTagsAndParams() to replace all tags with unique
identifiers.
Later these unique identifiers are then "unstripped" again to render the page.

Now the new scheme how the tags are unstripped unfortunately doesn't handle
nested tags
(like in the above <pre><nowiki> example).

Mediawiki 1.6.? first searched for "nowiki" tags and then for other tags.

With the current MediaWiki 1.7.1 this order isn't used anymore, which results in
the bug
(The <pre> is found first, which seems to prevent the <nowiki> tag to get parsed
in the
"right" way.)

I think in general the nesting of tags has to be fixed more thoroughly at a
later point of time.

Anyway: for the described problem here is a patch which solves it:

-----------------------Snip --------------------

diff -ur mediawiki-1.7.1/includes/Parser.php
/srv/www/htdocs/wiki/includes/Parser.php

  • mediawiki-1.7.1/includes/Parser.php 2006-07-09 07:45:26.000000000 +0200

+++ /srv/www/htdocs/wiki/includes/Parser.php 2006-09-07 17:53:06.294627168 +0200
@@ -478,7 +478,7 @@

$commentState = array();

$elements = array_merge(
  • array( 'nowiki', 'gallery' ),

+ array( 'gallery' ),

  array_keys( $this->mTagHooks ) );
global $wgRawHtml;
if( $wgRawHtml ) {

@@ -493,10 +493,14 @@

  if ( !in_array ( $v , $dontstrip ) ) continue;
  unset ( $elements[$k] );
}
  • $matches = array();
  • $text = Parser::extractTagsAndParams( $elements, $text, $matches,

$uniq_prefix );

+ $matchesNoWiki = array();
+ $matchesOthers = array();
+
+ $text = Parser::extractTagsAndParams( array('nowiki'), $text,$matchesNoWiki,
$uniq_prefix );
+ $text = Parser::extractTagsAndParams( $elements, $text, $matchesOthers,
$uniq_prefix );
+ $matches = array_merge($matchesNoWiki, $matchesOthers);
+

foreach( $matches as $marker => $data ) {
  list( $element, $content, $params, $tag ) = $data;
  if( $render ) {

-----------------------Snip --------------------

Actually with this patch, the "renderPreTag" method in Parser.php should work
without the
"Backwards-compatibility hack", but I haven't tried that.


Version: 1.7.x
Severity: normal
OS: Linux
Platform: PC

Details

Reference
bz7417

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:22 PM
bzimport set Reference to bz7417.
bzimport added a subscriber: Unknown Object (MLST).
  • This bug has been marked as a duplicate of 1581 ***