3 * Created on Dec 01, 2007
5 * Copyright © 2007 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
28 class ApiParse
extends ApiBase
{
30 /** @var String $section */
31 private $section = null;
33 /** @var Content $content */
34 private $content = null;
36 /** @var Content $pstContent */
37 private $pstContent = null;
39 public function execute() {
40 // The data is hot but user-dependent, like page views, so we set vary cookies
41 $this->getMain()->setCacheMode( 'anon-public-user-private' );
44 $params = $this->extractRequestParams();
45 $text = $params['text'];
46 $title = $params['title'];
47 if ( $title === null ) {
48 $titleProvided = false;
49 // A title is needed for parsing, so arbitrarily choose one
52 $titleProvided = true;
55 $page = $params['page'];
56 $pageid = $params['pageid'];
57 $oldid = $params['oldid'];
59 $model = $params['contentmodel'];
60 $format = $params['contentformat'];
62 if ( !is_null( $page ) && ( !is_null( $text ) ||
$titleProvided ) ) {
64 'The page parameter cannot be used together with the text and title parameters',
69 $prop = array_flip( $params['prop'] );
71 if ( isset( $params['section'] ) ) {
72 $this->section
= $params['section'];
74 $this->section
= false;
77 // The parser needs $wgTitle to be set, apparently the
78 // $title parameter in Parser::parse isn't enough *sigh*
79 // TODO: Does this still need $wgTitle?
80 global $wgParser, $wgTitle;
82 // Currently unnecessary, code to act as a safeguard against any change
83 // in current behavior of uselang
85 if ( isset( $params['uselang'] )
86 && $params['uselang'] != $this->getContext()->getLanguage()->getCode()
88 $oldLang = $this->getContext()->getLanguage(); // Backup language
89 $this->getContext()->setLanguage( Language
::factory( $params['uselang'] ) );
95 $result = $this->getResult();
97 if ( !is_null( $oldid ) ||
!is_null( $pageid ) ||
!is_null( $page ) ) {
98 if ( !is_null( $oldid ) ) {
99 // Don't use the parser cache
100 $rev = Revision
::newFromID( $oldid );
102 $this->dieUsage( "There is no revision ID $oldid", 'missingrev' );
104 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
105 $this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' );
108 $titleObj = $rev->getTitle();
109 $wgTitle = $titleObj;
110 $pageObj = WikiPage
::factory( $titleObj );
111 $popts = $this->makeParserOptions( $pageObj, $params );
113 // If for some reason the "oldid" is actually the current revision, it may be cached
114 if ( $rev->isCurrent() ) {
115 // May get from/save to parser cache
116 $p_result = $this->getParsedContent( $pageObj, $popts,
117 $pageid, isset( $prop['wikitext'] ) );
118 } else { // This is an old revision, so get the text differently
119 $this->content
= $rev->getContent( Revision
::FOR_THIS_USER
, $this->getUser() );
121 if ( $this->section
!== false ) {
122 $this->content
= $this->getSectionContent( $this->content
, 'r' . $rev->getId() );
125 // Should we save old revision parses to the parser cache?
126 $p_result = $this->content
->getParserOutput( $titleObj, $rev->getId(), $popts );
128 } else { // Not $oldid, but $pageid or $page
129 if ( $params['redirects'] ) {
134 if ( !is_null( $pageid ) ) {
135 $reqParams['pageids'] = $pageid;
137 $reqParams['titles'] = $page;
139 $req = new FauxRequest( $reqParams );
140 $main = new ApiMain( $req );
142 $data = $main->getResultData();
143 $redirValues = isset( $data['query']['redirects'] )
144 ?
$data['query']['redirects']
147 foreach ( (array)$redirValues as $r ) {
150 $pageParams = array( 'title' => $to );
151 } elseif ( !is_null( $pageid ) ) {
152 $pageParams = array( 'pageid' => $pageid );
154 $pageParams = array( 'title' => $page );
157 $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
158 $titleObj = $pageObj->getTitle();
159 if ( !$titleObj ||
!$titleObj->exists() ) {
160 $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
162 $wgTitle = $titleObj;
164 if ( isset( $prop['revid'] ) ) {
165 $oldid = $pageObj->getLatest();
168 $popts = $this->makeParserOptions( $pageObj, $params );
170 // Potentially cached
171 $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
172 isset( $prop['wikitext'] ) );
174 } else { // Not $oldid, $pageid, $page. Hence based on $text
175 $titleObj = Title
::newFromText( $title );
176 if ( !$titleObj ||
$titleObj->isExternal() ) {
177 $this->dieUsageMsg( array( 'invalidtitle', $title ) );
179 $wgTitle = $titleObj;
180 if ( $titleObj->canExist() ) {
181 $pageObj = WikiPage
::factory( $titleObj );
183 // Do like MediaWiki::initializeArticle()
184 $article = Article
::newFromTitle( $titleObj, $this->getContext() );
185 $pageObj = $article->getPage();
188 $popts = $this->makeParserOptions( $pageObj, $params );
190 if ( is_null( $text ) ) {
191 if ( $titleProvided && ( $prop ||
$params['generatexml'] ) ) {
193 "'title' used without 'text', and parsed page properties were requested " .
194 "(did you mean to use 'page' instead of 'title'?)"
197 // Prevent warning from ContentHandler::makeContent()
201 // If we are parsing text, do not use the content model of the default
202 // API title, but default to wikitext to keep BC.
203 if ( !$titleProvided && is_null( $model ) ) {
204 $model = CONTENT_MODEL_WIKITEXT
;
205 $this->setWarning( "No 'title' or 'contentmodel' was given, assuming $model." );
209 $this->content
= ContentHandler
::makeContent( $text, $titleObj, $model, $format );
210 } catch ( MWContentSerializationException
$ex ) {
211 $this->dieUsage( $ex->getMessage(), 'parseerror' );
214 if ( $this->section
!== false ) {
215 $this->content
= $this->getSectionContent( $this->content
, $titleObj->getText() );
218 if ( $params['pst'] ||
$params['onlypst'] ) {
219 $this->pstContent
= $this->content
->preSaveTransform( $titleObj, $this->getUser(), $popts );
221 if ( $params['onlypst'] ) {
222 // Build a result and bail out
223 $result_array = array();
224 $result_array['text'] = array();
225 ApiResult
::setContent( $result_array['text'], $this->pstContent
->serialize( $format ) );
226 if ( isset( $prop['wikitext'] ) ) {
227 $result_array['wikitext'] = array();
228 ApiResult
::setContent( $result_array['wikitext'], $this->content
->serialize( $format ) );
230 $result->addValue( null, $this->getModuleName(), $result_array );
235 // Not cached (save or load)
236 if ( $params['pst'] ) {
237 $p_result = $this->pstContent
->getParserOutput( $titleObj, null, $popts );
239 $p_result = $this->content
->getParserOutput( $titleObj, null, $popts );
243 $result_array = array();
245 $result_array['title'] = $titleObj->getPrefixedText();
247 if ( !is_null( $oldid ) ) {
248 $result_array['revid'] = intval( $oldid );
251 if ( $params['redirects'] && !is_null( $redirValues ) ) {
252 $result_array['redirects'] = $redirValues;
255 if ( $params['disabletoc'] ) {
256 $p_result->setTOCEnabled( false );
259 if ( isset( $prop['text'] ) ) {
260 $result_array['text'] = array();
261 ApiResult
::setContent( $result_array['text'], $p_result->getText() );
264 if ( !is_null( $params['summary'] ) ) {
265 $result_array['parsedsummary'] = array();
266 ApiResult
::setContent(
267 $result_array['parsedsummary'],
268 Linker
::formatComment( $params['summary'], $titleObj )
272 if ( isset( $prop['langlinks'] ) ||
isset( $prop['languageshtml'] ) ) {
273 $langlinks = $p_result->getLanguageLinks();
275 if ( $params['effectivelanglinks'] ) {
276 // Link flags are ignored for now, but may in the future be
277 // included in the result.
278 $linkFlags = array();
279 wfRunHooks( 'LanguageLinks', array( $titleObj, &$langlinks, &$linkFlags ) );
285 if ( isset( $prop['langlinks'] ) ) {
286 $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
288 if ( isset( $prop['languageshtml'] ) ) {
289 $languagesHtml = $this->languagesHtml( $langlinks );
291 $result_array['languageshtml'] = array();
292 ApiResult
::setContent( $result_array['languageshtml'], $languagesHtml );
294 if ( isset( $prop['categories'] ) ) {
295 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
297 if ( isset( $prop['categorieshtml'] ) ) {
298 $categoriesHtml = $this->categoriesHtml( $p_result->getCategories() );
299 $result_array['categorieshtml'] = array();
300 ApiResult
::setContent( $result_array['categorieshtml'], $categoriesHtml );
302 if ( isset( $prop['links'] ) ) {
303 $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
305 if ( isset( $prop['templates'] ) ) {
306 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
308 if ( isset( $prop['images'] ) ) {
309 $result_array['images'] = array_keys( $p_result->getImages() );
311 if ( isset( $prop['externallinks'] ) ) {
312 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
314 if ( isset( $prop['sections'] ) ) {
315 $result_array['sections'] = $p_result->getSections();
318 if ( isset( $prop['displaytitle'] ) ) {
319 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
320 $p_result->getDisplayTitle() :
321 $titleObj->getPrefixedText();
324 if ( isset( $prop['headitems'] ) ||
isset( $prop['headhtml'] ) ) {
325 $context = $this->getContext();
326 $context->setTitle( $titleObj );
327 $context->getOutput()->addParserOutputNoText( $p_result );
329 if ( isset( $prop['headitems'] ) ) {
330 $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
332 $css = $this->formatCss( $context->getOutput()->buildCssLinksArray() );
334 $scripts = array( $context->getOutput()->getHeadScripts() );
336 $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
339 if ( isset( $prop['headhtml'] ) ) {
340 $result_array['headhtml'] = array();
341 ApiResult
::setContent(
342 $result_array['headhtml'],
343 $context->getOutput()->headElement( $context->getSkin() )
348 if ( isset( $prop['iwlinks'] ) ) {
349 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
352 if ( isset( $prop['wikitext'] ) ) {
353 $result_array['wikitext'] = array();
354 ApiResult
::setContent( $result_array['wikitext'], $this->content
->serialize( $format ) );
355 if ( !is_null( $this->pstContent
) ) {
356 $result_array['psttext'] = array();
357 ApiResult
::setContent( $result_array['psttext'], $this->pstContent
->serialize( $format ) );
360 if ( isset( $prop['properties'] ) ) {
361 $result_array['properties'] = $this->formatProperties( $p_result->getProperties() );
364 if ( $params['generatexml'] ) {
365 if ( $this->content
->getModel() != CONTENT_MODEL_WIKITEXT
) {
366 $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
369 $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS
);
370 $dom = $wgParser->preprocessToDom( $this->content
->getNativeData() );
371 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
372 $xml = $dom->saveXML();
374 $xml = $dom->__toString();
376 $result_array['parsetree'] = array();
377 ApiResult
::setContent( $result_array['parsetree'], $xml );
380 $result_mapping = array(
383 'categories' => 'cl',
387 'externallinks' => 'el',
391 'properties' => 'pp',
393 $this->setIndexedTagNames( $result_array, $result_mapping );
394 $result->addValue( null, $this->getModuleName(), $result_array );
396 if ( !is_null( $oldLang ) ) {
397 $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
402 * Constructs a ParserOptions object
404 * @param WikiPage $pageObj
405 * @param array $params
407 * @return ParserOptions
409 protected function makeParserOptions( WikiPage
$pageObj, array $params ) {
410 wfProfileIn( __METHOD__
);
412 $popts = $pageObj->makeParserOptions( $this->getContext() );
413 $popts->enableLimitReport( !$params['disablepp'] );
414 $popts->setIsPreview( $params['preview'] ||
$params['sectionpreview'] );
415 $popts->setIsSectionPreview( $params['sectionpreview'] );
417 wfProfileOut( __METHOD__
);
423 * @param $page WikiPage
424 * @param $popts ParserOptions
426 * @param $getWikitext Bool
427 * @return ParserOutput
429 private function getParsedContent( WikiPage
$page, $popts, $pageId = null, $getWikitext = false ) {
430 $this->content
= $page->getContent( Revision
::RAW
); //XXX: really raw?
432 if ( $this->section
!== false && $this->content
!== null ) {
433 $this->content
= $this->getSectionContent(
435 !is_null( $pageId ) ?
'page id ' . $pageId : $page->getTitle()->getText()
438 // Not cached (save or load)
439 return $this->content
->getParserOutput( $page->getTitle(), null, $popts );
442 // Try the parser cache first
443 // getParserOutput will save to Parser cache if able
444 $pout = $page->getParserOutput( $popts );
446 $this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' );
448 if ( $getWikitext ) {
449 $this->content
= $page->getContent( Revision
::RAW
);
455 private function getSectionContent( Content
$content, $what ) {
456 // Not cached (save or load)
457 $section = $content->getSection( $this->section
);
458 if ( $section === false ) {
459 $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );
461 if ( $section === null ) {
462 $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
469 private function formatLangLinks( $links ) {
471 foreach ( $links as $link ) {
473 $bits = explode( ':', $link, 2 );
474 $title = Title
::newFromText( $link );
476 $entry['lang'] = $bits[0];
478 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
480 ApiResult
::setContent( $entry, $bits[1] );
487 private function formatCategoryLinks( $links ) {
494 // Fetch hiddencat property
496 $lb->setArray( array( NS_CATEGORY
=> $links ) );
497 $db = $this->getDB();
498 $res = $db->select( array( 'page', 'page_props' ),
499 array( 'page_title', 'pp_propname' ),
500 $lb->constructSet( 'page', $db ),
503 array( 'page_props' => array(
504 'LEFT JOIN', array( 'pp_propname' => 'hiddencat', 'pp_page = page_id' )
507 $hiddencats = array();
508 foreach ( $res as $row ) {
509 $hiddencats[$row->page_title
] = isset( $row->pp_propname
);
512 foreach ( $links as $link => $sortkey ) {
514 $entry['sortkey'] = $sortkey;
515 ApiResult
::setContent( $entry, $link );
516 if ( !isset( $hiddencats[$link] ) ) {
517 $entry['missing'] = '';
518 } elseif ( $hiddencats[$link] ) {
519 $entry['hidden'] = '';
527 private function categoriesHtml( $categories ) {
528 $context = $this->getContext();
529 $context->getOutput()->addCategoryLinks( $categories );
531 return $context->getSkin()->getCategories();
535 * @deprecated since 1.18 No modern skin generates language links this way,
536 * please use language links data to generate your own HTML.
537 * @param $languages array
540 private function languagesHtml( $languages ) {
541 wfDeprecated( __METHOD__
, '1.18' );
542 $this->setWarning( '"action=parse&prop=languageshtml" is deprecated ' .
543 'and will be removed in MediaWiki 1.24. Use "prop=langlinks" ' .
544 'to generate your own HTML.' );
546 global $wgContLang, $wgHideInterlanguageLinks;
548 if ( $wgHideInterlanguageLinks ||
count( $languages ) == 0 ) {
552 $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() .
553 wfMessage( 'colon-separator' )->text() );
556 foreach ( $languages as $l ) {
557 $nt = Title
::newFromText( $l );
558 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
560 $langs[] = Html
::element( 'a',
561 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => 'external' ),
562 $text == '' ?
$l : $text );
565 $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs );
567 if ( $wgContLang->isRTL() ) {
568 $s = Html
::rawElement( 'span', array( 'dir' => 'LTR' ), $s );
574 private function formatLinks( $links ) {
576 foreach ( $links as $ns => $nslinks ) {
577 foreach ( $nslinks as $title => $id ) {
580 ApiResult
::setContent( $entry, Title
::makeTitle( $ns, $title )->getFullText() );
582 $entry['exists'] = '';
591 private function formatIWLinks( $iw ) {
593 foreach ( $iw as $prefix => $titles ) {
594 foreach ( array_keys( $titles ) as $title ) {
596 $entry['prefix'] = $prefix;
598 $title = Title
::newFromText( "{$prefix}:{$title}" );
600 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
603 ApiResult
::setContent( $entry, $title->getFullText() );
611 private function formatHeadItems( $headItems ) {
613 foreach ( $headItems as $tag => $content ) {
615 $entry['tag'] = $tag;
616 ApiResult
::setContent( $entry, $content );
623 private function formatProperties( $properties ) {
625 foreach ( $properties as $name => $value ) {
627 $entry['name'] = $name;
628 ApiResult
::setContent( $entry, $value );
635 private function formatCss( $css ) {
637 foreach ( $css as $file => $link ) {
639 $entry['file'] = $file;
640 ApiResult
::setContent( $entry, $link );
647 private function setIndexedTagNames( &$array, $mapping ) {
648 foreach ( $mapping as $key => $name ) {
649 if ( isset( $array[$key] ) ) {
650 $this->getResult()->setIndexedTagName( $array[$key], $name );
655 public function getAllowedParams() {
662 ApiBase
::PARAM_TYPE
=> 'integer',
664 'redirects' => false,
666 ApiBase
::PARAM_TYPE
=> 'integer',
669 ApiBase
::PARAM_DFLT
=> 'text|langlinks|categories|links|templates|' .
670 'images|externallinks|sections|revid|displaytitle|iwlinks|properties',
671 ApiBase
::PARAM_ISMULTI
=> true,
672 ApiBase
::PARAM_TYPE
=> array(
694 'effectivelanglinks' => false,
697 'disablepp' => false,
698 'generatexml' => false,
700 'sectionpreview' => false,
701 'disabletoc' => false,
702 'contentformat' => array(
703 ApiBase
::PARAM_TYPE
=> ContentHandler
::getAllContentFormats(),
705 'contentmodel' => array(
706 ApiBase
::PARAM_TYPE
=> ContentHandler
::getContentModels(),
711 public function getParamDescription() {
712 $p = $this->getModulePrefix();
713 $wikitext = CONTENT_MODEL_WIKITEXT
;
716 'text' => "Text to parse. Use {$p}title or {$p}contentmodel to control the content model",
717 'summary' => 'Summary to parse',
718 'redirects' => "If the {$p}page or the {$p}pageid parameter is set to a redirect, resolve it",
719 'title' => "Title of page the text belongs to. " .
720 "If omitted, \"API\" is used as the title with content model $wikitext",
721 'page' => "Parse the content of this page. Cannot be used together with {$p}text and {$p}title",
722 'pageid' => "Parse the content of this page. Overrides {$p}page",
723 'oldid' => "Parse the content of this revision. Overrides {$p}page and {$p}pageid",
725 'Which pieces of information to get',
726 ' text - Gives the parsed text of the wikitext',
727 ' langlinks - Gives the language links in the parsed wikitext',
728 ' categories - Gives the categories in the parsed wikitext',
729 ' categorieshtml - Gives the HTML version of the categories',
730 ' languageshtml - DEPRECATED. Will be removed in MediaWiki 1.24.',
731 ' Gives the HTML version of the language links',
732 ' links - Gives the internal links in the parsed wikitext',
733 ' templates - Gives the templates in the parsed wikitext',
734 ' images - Gives the images in the parsed wikitext',
735 ' externallinks - Gives the external links in the parsed wikitext',
736 ' sections - Gives the sections in the parsed wikitext',
737 ' revid - Adds the revision ID of the parsed page',
738 ' displaytitle - Adds the title of the parsed wikitext',
739 ' headitems - Gives items to put in the <head> of the page',
740 ' headhtml - Gives parsed <head> of the page',
741 ' iwlinks - Gives interwiki links in the parsed wikitext',
742 ' wikitext - Gives the original wikitext that was parsed',
743 ' properties - Gives various properties defined in the parsed wikitext',
745 'effectivelanglinks' => array(
746 'Includes language links supplied by extensions',
747 '(for use with prop=langlinks|languageshtml)',
750 'Do a pre-save transform on the input before parsing it',
751 "Only valid when used with {$p}text",
754 'Do a pre-save transform (PST) on the input, but don\'t parse it',
755 'Returns the same wikitext, after a PST has been applied.',
756 "Only valid when used with {$p}text",
758 'uselang' => 'Which language to parse the request in',
759 'section' => 'Only retrieve the content of this section number',
760 'disablepp' => 'Disable the PP Report from the parser output',
761 'generatexml' => "Generate XML parse tree (requires contentmodel=$wikitext)",
762 'preview' => 'Parse in preview mode',
763 'sectionpreview' => 'Parse in section preview mode (enables preview mode too)',
764 'disabletoc' => 'Disable table of contents in output',
765 'contentformat' => array(
766 'Content serialization format used for the input text',
767 "Only valid when used with {$p}text",
769 'contentmodel' => array(
770 "Content model of the input text. Default is the model of the " .
771 "specified ${p}title, or $wikitext if ${p}title is not specified",
772 "Only valid when used with {$p}text",
777 public function getDescription() {
778 $p = $this->getModulePrefix();
781 'Parses content and returns parser output',
782 'See the various prop-Modules of action=query to get information from the current' .
784 'There are several ways to specify the text to parse:',
785 "1) Specify a page or revision, using {$p}page, {$p}pageid, or {$p}oldid.",
786 "2) Specify content explicitly, using {$p}text, {$p}title, and {$p}contentmodel.",
787 "3) Specify only a summary to parse. {$p}prop should be given an empty value.",
791 public function getPossibleErrors() {
792 return array_merge( parent
::getPossibleErrors(), array(
795 'info' => 'The page parameter cannot be used together with the text and title parameters'
797 array( 'code' => 'missingrev', 'info' => 'There is no revision ID oldid' ),
799 'code' => 'permissiondenied',
800 'info' => 'You don\'t have permission to view deleted revisions'
802 array( 'code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist' ),
803 array( 'code' => 'nosuchsection', 'info' => 'There is no section sectionnumber in page' ),
804 array( 'nosuchpageid' ),
805 array( 'invalidtitle', 'title' ),
806 array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
808 'code' => 'notwikitext',
809 'info' => 'The requested operation is only supported on wikitext content.'
814 public function getExamples() {
816 'api.php?action=parse&page=Project:Sandbox' => 'Parse a page',
817 'api.php?action=parse&text={{Project:Sandbox}}' => 'Parse wikitext',
818 'api.php?action=parse&text={{PAGENAME}}&title=Test'
819 => 'Parse wikitext, specifying the page title',
820 'api.php?action=parse&summary=Some+[[link]]&prop=' => 'Parse a summary',
824 public function getHelpUrls() {
825 return 'https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse';