/**
  * APIAfterExecute hook handler
  * @see: https://www.mediawiki.org/wiki/Manual:Hooks/
  * @param ApiBase $module
  * @return bool
  */
 public static function onAPIAfterExecute(ApiBase &$module)
 {
     global $wgMFSpecialCaseMainPage;
     if ($module->getModuleName() == 'parse') {
         if (defined('ApiResult::META_CONTENT')) {
             $data = $module->getResult()->getResultData();
         } else {
             $data = $module->getResultData();
         }
         $params = $module->extractRequestParams();
         if (isset($data['parse']['text']) && $params['mobileformat']) {
             $result = $module->getResult();
             $result->reset();
             $title = Title::newFromText($data['parse']['title']);
             $text = $data['parse']['text'];
             if (is_array($text)) {
                 if (defined('ApiResult::META_CONTENT') && isset($text[ApiResult::META_CONTENT])) {
                     $contentKey = $text[ApiResult::META_CONTENT];
                 } else {
                     $contentKey = '*';
                 }
                 $html = MobileFormatter::wrapHTML($text[$contentKey]);
             } else {
                 $html = MobileFormatter::wrapHTML($text);
             }
             $mf = new MobileFormatter($html, $title);
             $mf->setRemoveMedia($params['noimages']);
             $mf->setIsMainPage($params['mainpage'] && $wgMFSpecialCaseMainPage);
             $mf->enableExpandableSections(!$params['mainpage']);
             // HACK: need a nice way to request a TOC- and edit link-free HTML in the first place
             // FIXME: Should this be .mw-editsection?
             $mf->remove(array('.toc', 'mw-editsection', '.mw-headline-anchor'));
             $mf->filterContent();
             if (is_array($text)) {
                 $text[$contentKey] = $mf->getText();
             } else {
                 $text = $mf->getText();
             }
             $data['parse']['text'] = $text;
             $result->addValue(null, $module->getModuleName(), $data['parse']);
         }
     }
     return true;
 }