From a8a17a8bb058aa05a9d3b355281cc6a8da5d0fa8 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Thu, 8 May 2014 10:24:08 +0200 Subject: [PATCH] Show module doc with the correct direction formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add mw-content-(ltr|ltr) class to the documentation
. * Rewrite the div code as Html::rawElement instead of concatenating a string. Done in pairing with Niklas Laxström. Change-Id: I4d68d53df9dcf3556885552b738f2c327aaa8607 --- common/ScribuntoContent.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/common/ScribuntoContent.php b/common/ScribuntoContent.php index fedaa5c4..e100c108 100644 --- a/common/ScribuntoContent.php +++ b/common/ScribuntoContent.php @@ -42,12 +42,31 @@ class ScribuntoContent extends TextContent { $doc->exists() ? 'scribunto-doc-page-show' : 'scribunto-doc-page-does-not-exist', $doc->getPrefixedText() )->inContentLanguage(); + if ( !$msg->isDisabled() ) { // We need the ParserOutput for categories and such, so we // can't use $msg->parse(). $docViewLang = $doc->getPageViewLanguage(); - $docWikitext = '
\n" . $msg->plain() . "\n
"; + $dir = $docViewLang->getDir(); + + // 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 ) { // NOTE: use canonical options per default to produce cacheable output $options = ContentHandler::getForTitle( $doc )->makeParserOptions( 'canonical' ); @@ -56,6 +75,7 @@ class ScribuntoContent extends TextContent { $options->setTargetLanguage( $doc->getPageLanguage() ); } } + $output = $wgParser->parse( $docWikitext, $title, $options, true, true, $revId ); }