Last modified: 2012-08-14 11:44:43 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T3772, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 1772 - Unnecessary <p> paragraph tags within extension output
Unnecessary <p> paragraph tags within extension output
Status: RESOLVED DUPLICATE of bug 1319
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.5.x
All All
: Normal normal with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-03-28 16:39 UTC by Elias Torres
Modified: 2012-08-14 11:44 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Elias Torres 2005-03-28 16:39:12 UTC
If I write an extension that return somewhat complex output like this:

 $wgExtensionFunctions[] = "wfExampleExtension";
 
 function wfExampleExtension() {
     global $wgParser;
     # register the extension with the WikiText parser
     # the first parameter is the name of the new tag. In this case it defines
the tag <example> ... </example>
     # the second parameter is the callback function for processing the text
between the tags
     $wgParser->setHook( "example", "renderExample" );
 }
 
 # The callback function for converting the input text to HTML output
 function renderExample( $input ) {
	$output = <<<EOT
	<script type="text/javascript">
	
		var wa = 'Wikipedia Rocks';
		
		function showWA() {
		
			alert(wa);
			
		}
		
	</script>
	<div>
		$input
	</div> 			
EOT;
     return $output;
 }

I get the following output:

</p><p>	<script type="text/javascript">
</p><p>		var wa = 'Wikipedia Rocks';
</p><p>		function showWA() {
</p><p>			alert(wa);
</p><p>		}
</p><p>	</script>
</p>
	<div>
<p>		Hi There
</p>
	</div>
Comment 1 Antoine "hashar" Musso (WMF) 2005-03-30 09:12:27 UTC
$wgParser is a wikisyntax to html renderer. If you give it a text
it will attempt to transform it as html (and thus ad <p> everywhere).

You want to use $wgOut->addHTML() .

See the wikiforum or Findspam.php extensions for an example.
Comment 2 Elias Torres 2005-03-30 14:48:20 UTC
(In reply to comment #1)
> $wgParser is a wikisyntax to html renderer. If you give it a text
> it will attempt to transform it as html (and thus ad <p> everywhere).
> 
> You want to use $wgOut->addHTML() .
> 
> See the wikiforum or Findspam.php extensions for an example.

Thanks for the tip. However, I think that this works only for SpecialPages type
of extensions. Where the you write directly to $wgOut. Plain Extensions don't
use wgOut, they must return the transformed string passed as $input for further
processing.
Comment 3 LJ 2006-02-05 21:54:32 UTC
This is still showing up in at least 1.5.4 .  I sent a message out to the
listserv, and doesn't seem to be any good answers yet:
http://mail.wikipedia.org/pipermail/mediawiki-l/2006-February/thread.html#10022
Guess I'll add my vote, and maybe start reading through some of the Parser Code...
Comment 4 Invalid Account 2006-10-10 00:16:12 UTC
The workaround/fix in Parser.php, in function parse():

Instead of:
$text = $this->unstrip( $text, $this->mStripState );
[somecode]
$text = $this->doBlockLevels( $text, $linestart );

to:
[somecode]
$text = $this->doBlockLevels( $text, $linestart );
$text = $this->unstrip( $text, $this->mStripState );

i.e. move the unstrip() to run after doBlockLevels()
Comment 5 Jimmy Collins 2006-10-10 19:06:09 UTC
Please post patches as attachment (in unified format). Thanks.
Comment 6 Andrew Garrett 2009-03-04 05:49:15 UTC
Has this bug been fixed with the new preprocessor?
Comment 7 Tim Starling 2009-06-19 15:37:21 UTC

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links