Or we could fix the sanitiser to remove all the common crap the parser inserts.
Rob Church
On 05/02/06, LJ lukehjohnson@gmail.com wrote:
Howdy,
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 /> </p> <pre>
(for 5 \n's), which really busts up the javascript. :)
http://meta.wikimedia.org/wiki/MediaWiki_extensions_FAQ#How_can_I_avoid_modi... ... 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': http://meta.wikimedia.org/wiki/MediaWiki_extensions_FAQ#How_do_I_render_wiki...
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 release?
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... bleh...
Thanks, Luke _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l