Last modified: 2011-04-14 20:14:30 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 T16607, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 14607 - <p> tags in front of all parser functions
<p> tags in front of all parser functions
Status: RESOLVED DUPLICATE of bug 10781
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.12.x
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, testme
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-21 17:30 UTC by Sergey Chernyshev
Modified: 2011-04-14 20:14 UTC (History)
4 users (show)

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


Attachments
Patch to remove <p> tags preceding parser function output (661 bytes, patch)
2008-06-21 17:30 UTC, Sergey Chernyshev
Details
Trunk patch to remove <p> and associated comments (596 bytes, patch)
2009-10-08 12:17 UTC, Kinsey Moore
Details
Patch to fix <p> issues, remove associated comments, and fix two parser tests (1.38 KB, patch)
2009-10-08 13:53 UTC, Kinsey Moore
Details

Description Sergey Chernyshev 2008-06-21 17:30:01 UTC
Created attachment 5012 [details]
Patch to remove <p> tags preceding parser function output

As I wrote to the list, I came across undesired feature in Parser that forces </p><p> in front of all parser function output.

It was apparently introduced in 1.5.0 and is still the case in the trunk (although Parser.php is moved to includes/parser/ folder).

Here's the piece of code in question (line 2975 on 1.12.0 branch):

	# Replace raw HTML by a placeholder
	# Add a blank line preceding, to prevent it from mucking up
	# immediately preceding headings
	if ( $isHTML ) {
		$text = "\n\n" . $this->insertStripItem( $text );
	}

The problem is that the assumption that users don't want parser function output directly after the preceding text is wrong, especially when <p> tags are inserted.

I think that "\n\n" should be removed, but please correct me if I'm wrong with this.

Patch against 1.12.0 (includes/Parser.php) is attached.
Comment 1 Brion Vibber 2008-07-05 00:35:41 UTC
Obviously it doesn't happen that paragraph breaks are forced in front of all parser function output; otherwise they could not be used inside paragraphs.

Can you provide a test case?
Comment 2 Siebrand Mazeland 2008-08-13 20:14:32 UTC
+testme
Comment 3 David 2009-05-05 03:51:45 UTC
I've ran into this, too.  What has yet to be explicitly stated (though it was implied) is that this issue only occurs when 'isHTML' in the output array of a parser function is set to true.  (See http://www.mediawiki.org/wiki/Manual:Parser_functions#Controlling_the_parsing_of_output)

A simple test case to demonstrate the issue.  First a simple parser function extension:

    <?php
    $wgHooks[ 'ParserFirstCallInit' ][] = 'wfInitIsHTMLDemo';
    $wgHooks[ 'LanguageGetMagic' ][] = 'wfDemoMagic';

    function wfInitIsHTMLDemo( $parser )
    {
        $parser->setFunctionHook( 'demo', 'wfDemo' );
        return true;
    }

    function wfDemoMagic( &$magicWords )
    {
        $magicWords[ 'demo' ] = array( 0, 'demo' );
        return true;
    }

    function wfDemo( $parser )
    {
        return array( '<input type="checkbox"/>', 'noparse' => true, 'isHTML' => true );
    }

Next is some test wiki markup:

    I would like {{#demo:}} this entire line {{#demo:}} to be contained {{#demo:}} in one paragraph.

Which yields four paragraphs, all but the first starting with a checkbox.  There's little point in singling out HTML-generating parser functions when any text after a wiki heading will muck the heading up.
Comment 4 Kinsey Moore 2009-10-07 15:22:53 UTC
I have also run into this problem when attempting to inline special page transclusions, since they are also marked with isHTML.  It is currently the bane of my existence.  Removing that \n\n would fix it for me, but it seems the problem may be a bit more complicated than that.
Comment 5 Kinsey Moore 2009-10-08 04:11:46 UTC
I fooled myself by reading too much into the comments that attempt to justify the "\n\n".  I can see a need to insert things into headings, even.  A proper patch would be against trunk and would also remove the second and third comment line there.  I'll generate one tomorrow morning and add it to this issue.  Has it been noted that this issue is basically a dup of 12974?
Comment 6 Kinsey Moore 2009-10-08 12:17:59 UTC
Created attachment 6650 [details]
Trunk patch to remove <p> and associated comments

Added patch against trunk that removes the two associated comment lines as well.
Comment 7 Kinsey Moore 2009-10-08 13:41:12 UTC
Just a note, that this change breaks 2 parser tests, which will also have to be modified to check for the new output.
Comment 8 Kinsey Moore 2009-10-08 13:53:18 UTC
Created attachment 6652 [details]
Patch to fix <p> issues, remove associated comments, and fix two parser tests
Comment 9 DieBuche 2011-04-14 20:14:30 UTC

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

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


Navigation
Links