public function getParserOutput(Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true)
 {
     // If you want to have more control over parsing than getHtml() gives you,
     // you can control the construction of the ParserOutput object and add
     // meta data like categories, etc. based on the content.
     return parent::getParserOutput($title, $revId, $options, $generateHtml);
 }
Ejemplo n.º 2
0
 /**
  * Wraps HTML representation of content.
  *
  * If the schema already exists and if the SyntaxHiglight GeSHi
  * extension is installed, use it to render code snippets
  * showing how to use schema.
  *
  * @see https://mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi
  *
  * @param $title Title
  * @param $revId int|null Revision ID
  * @param $options ParserOptions|null
  * @param $generateHtml bool Whether or not to generate HTML
  * @return ParserOutput
  */
 public function getParserOutput(Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true)
 {
     $out = parent::getParserOutput($title, $revId, $options, $generateHtml);
     if ($revId !== null && class_exists('SyntaxHighlight_GeSHi')) {
         $html = '';
         $highlighter = new SyntaxHighlight_GeSHi();
         foreach (self::getCodeSamples($title->getDBkey(), $revId) as $lang => $code) {
             $geshi = $highlighter->prepare($code, $lang);
             $out->addHeadItem($highlighter::buildHeadItem($geshi), "source-{$lang}");
             $html .= Xml::tags('h2', array(), $lang) . $geshi->parse_code();
         }
         // The glyph is '< >' from the icon font 'Entypo' (see ../modules).
         $html = Xml::tags('div', array('class' => 'mw-json-schema-code-glyph'), '&#xe714;') . Xml::tags('div', array('class' => 'mw-json-schema-code-samples'), $html);
         $out->setText($html . $out->mText);
     }
     return $out;
 }