You can wrap it in Parser::stripOuterParagraph() On Monday, June 14, 2021, Sebastian Trueg <tr...@truegeex.de> wrote:
> thank you Brian. > > With a fresh parser (I am not rendering messages but a template) it works. > However, the parser always wraps my result in a <p> tag (I already removed > the <div> via "nowrap" in ParserOutput::getText). > > Can I tell the parser to not do that or do I need to manually unwrap the > text? > > Cheers, > Sebastian > > On 11.06.21 21:33, Brian Wolff wrote: > >> This is expected. You should not make assumptions about the state of the >> global Parser instance in a special page. In some circumstances (especially >> transclusions) it might be in a parse, other times it won't be. >> >> If you're rendering an i18n message, its better to use ->parse() of the >> Message class then to pass it through the parser directly. >> >> Alternatively use \MediaWiki\MediaWikiServices:: >> getInstance()->getParser()->getFreshParser() and then initialize it >> yourself by calling ->parse() on the Parser, so you always know what the >> state is for sure. >> >> -- >> Brian >> >> On Fri, Jun 11, 2021 at 9:27 AM Sebastian Trueg <tr...@truegeex.de >> <mailto:tr...@truegeex.de>> wrote: >> >> Hi everyone, >> >> my skin uses the global parser in order to render some parts of the >> navigation bar via templates (Parser::recursivePreprocess). This works >> fine on all normal pages (and even some special ones like >> Special:Version), but not on special pages like Special:AllPages. >> >> Some debugging revealed that on Special:AllPages the global parser >> object (\MediaWiki\MediaWikiServices::getInstance()->getParser()) is >> not >> properly initialized. Member variables like mOptions and mTitle are >> null >> which results in tons of NPEs. >> >> Any idea why that is? Is that a bug or am I mis-using the parser? >> >> Regards, >> Sebastian >> _______________________________________________ >> MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org >> <mailto:mediawiki-l@lists.wikimedia.org> >> List information: >> https://lists.wikimedia.org/postorius/lists/mediawiki-l.list >> s.wikimedia.org/ >> <https://lists.wikimedia.org/postorius/lists/mediawiki-l.lis >> ts.wikimedia.org/> >> >> >> _______________________________________________ >> MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org >> List information: https://lists.wikimedia.org/po >> storius/lists/mediawiki-l.lists.wikimedia.org/ >> >> > -- > Sebastian Trueg > Managing Director > TrueGeeX UG (haftungsbeschränkt) > tr...@truegeex.de > http://www.linkedin.com/in/trueg > Mobile: 0049 1762 3244 664 > _______________________________________________ > MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org > List information: https://lists.wikimedia.org/po > storius/lists/mediawiki-l.lists.wikimedia.org/ >
_______________________________________________ MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org List information: https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/