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

LJ lukehjohnson at gmail.com
Mon Feb 6 05:17:31 UTC 2006


Cynicism aside Rob, I appreciate the reply.

Did a bit more digging, and found this 'bug' in bugzilla:
http://bugzilla.wikimedia.org/show_bug.cgi?id=1772
Seems like it's been around awhile.  I updated the version, added a note,
and voted for it.

For the time being I can work around it by limiting the text I insert
between my tags (no newlines).  However, I'd like to publish my extension,
and I'm unlikely to do so if I have to have the caveat of: 'you have to
format the tagged content just-so...'.

Don't know if my previous global flag or callable method ideas have much
merit ( or are feasible to integrate into the parser structure ).  But, it'd
be nice if a developer latched on to them... :)

LJ

On 2/4/06, LJ <lukehjohnson at 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_modification_of_my_extension.27s_HTML_output.3F
> ... 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_wikitext_in_my_extension.3F
>
> 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.phpyet).  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



More information about the MediaWiki-l mailing list