[Mediawiki-l] Unwanted <p> tags from the parser in my extension, can they be turned off?

LJ lukehjohnson at gmail.com
Sun Feb 5 05:39:54 UTC 2006


So tonight I set off writing a short little extension for mediawiki, and got
in a fight with the parser.

My extensions characteristics, in short, are that: it takes arguments from
my defined tags and the content between the tags, and inserts them into a
javascript function.

To make my javascript 'pretty', I like to stick a few \n's in the $input
strings (the content between the tags).  Of course the parser is more then
happy to turn these into:

</p><p><br />

</p><p><br />

(for 5 \n's), which really busts up the javascript.  :)

... implies the parser would have to be mucked with to prevent conversion of
the newlines.

But!!!!... a section or two above, it's stated that when you forcibly render
text with the parser, you can turn off the <p> tags with a simple 'false':

I'd think it'd be a short step to allow the extension to set a variable, or
call a method, essentially giving the parser the same 'false', as when it is
called directly: $wgOut->parse('text', false);
That sure would make life easier.
E.g. $wgParser->setHook( "MyExtension", "renderMyExtension", 'false');  ...
or maybe $wgParser->setPtag('false');

Hopefully somebody can tell me if I've missed some easy answer, or this
functionality is already there (no, I haven't read through Parser.php yet).
Or a second best: that there would be interest into adding this into nearby

I'm aware there is probably a 'long way' around this problem, i.e.: set a
hook for ParserAfterTidy, then find my tags+content, strip my tags and their
args, re-insert my args+content, and finally dump all of the page again...


More information about the MediaWiki-l mailing list