Merge "Show module doc with the correct direction formatting"

This commit is contained in:
jenkins-bot 2014-05-08 19:14:25 +00:00 committed by Gerrit Code Review
commit e9fe95b451

View file

@ -42,12 +42,31 @@ class ScribuntoContent extends TextContent {
$doc->exists() ? 'scribunto-doc-page-show' : 'scribunto-doc-page-does-not-exist', $doc->exists() ? 'scribunto-doc-page-show' : 'scribunto-doc-page-does-not-exist',
$doc->getPrefixedText() $doc->getPrefixedText()
)->inContentLanguage(); )->inContentLanguage();
if ( !$msg->isDisabled() ) { if ( !$msg->isDisabled() ) {
// We need the ParserOutput for categories and such, so we // We need the ParserOutput for categories and such, so we
// can't use $msg->parse(). // can't use $msg->parse().
$docViewLang = $doc->getPageViewLanguage(); $docViewLang = $doc->getPageViewLanguage();
$docWikitext = '<div lang="' . htmlspecialchars( $docViewLang->getHtmlCode() ) . '"' $dir = $docViewLang->getDir();
. ' dir="' . $docViewLang->getDir() . "\">\n" . $msg->plain() . "\n</div>";
// Code is forced to be ltr, but the documentation can be rtl.
// Correct direction class is needed for correct formatting.
// The possible classes are
// mw-content-ltr or mw-content-rtl
$dirClass = "mw-content-$dir";
$docWikitext = Html::rawElement(
'div',
array(
'lang' => $docViewLang->getHtmlCode(),
'dir' => $dir,
'class' => $dirClass,
),
// Line breaks are needed so that wikitext would be
// appropriately isolated for correct parsing. See Bug 60664.
"\n" . $msg->plain() . "\n"
);
if ( !$options ) { if ( !$options ) {
// NOTE: use canonical options per default to produce cacheable output // NOTE: use canonical options per default to produce cacheable output
$options = ContentHandler::getForTitle( $doc )->makeParserOptions( 'canonical' ); $options = ContentHandler::getForTitle( $doc )->makeParserOptions( 'canonical' );
@ -56,6 +75,7 @@ class ScribuntoContent extends TextContent {
$options->setTargetLanguage( $doc->getPageLanguage() ); $options->setTargetLanguage( $doc->getPageLanguage() );
} }
} }
$output = $wgParser->parse( $docWikitext, $title, $options, true, true, $revId ); $output = $wgParser->parse( $docWikitext, $title, $options, true, true, $revId );
} }