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 );
189 $textProvided = !is_null( $text );
191 if ( !$textProvided ) {
192 if ( $titleProvided && ( $prop ||
$params['generatexml'] ) ) {
194 "'title' used without 'text', and parsed page properties were requested " .
195 "(did you mean to use 'page' instead of 'title'?)"
198 // Prevent warning from ContentHandler::makeContent()
202 // If we are parsing text, do not use the content model of the default
203 // API title, but default to wikitext to keep BC.
204 if ( $textProvided && !$titleProvided && is_null( $model ) ) {
205 $model = CONTENT_MODEL_WIKITEXT
;
206 $this->setWarning( "No 'title' or 'contentmodel' was given, assuming $model." );
210 $this->content
= ContentHandler
::makeContent( $text, $titleObj, $model, $format );
211 } catch ( MWContentSerializationException
$ex ) {
212 $this->dieUsage( $ex->getMessage(), 'parseerror' );
215 if ( $this->section
!== false ) {
216 $this->content
= $this->getSectionContent( $this->content
, $titleObj->getText() );
219 if ( $params['pst'] ||
$params['onlypst'] ) {
220 $this->pstContent
= $this->content
->preSaveTransform( $titleObj, $this->getUser(), $popts );
222 if ( $params['onlypst'] ) {
223 // Build a result and bail out
224 $result_array = array();
225 $result_array['text'] = array();
226 ApiResult
::setContent( $result_array['text'], $this->pstContent
->serialize( $format ) );
227 if ( isset( $prop['wikitext'] ) ) {
228 $result_array['wikitext'] = array();
229 ApiResult
::setContent( $result_array['wikitext'], $this->content
->serialize( $format ) );
231 $result->addValue( null, $this->getModuleName(), $result_array );
236 // Not cached (save or load)
237 if ( $params['pst'] ) {
238 $p_result = $this->pstContent
->getParserOutput( $titleObj, null, $popts );
240 $p_result = $this->content
->getParserOutput( $titleObj, null, $popts );
244 $result_array = array();
246 $result_array['title'] = $titleObj->getPrefixedText();
248 if ( !is_null( $oldid ) ) {
249 $result_array['revid'] = intval( $oldid );
252 if ( $params['redirects'] && !is_null( $redirValues ) ) {
253 $result_array['redirects'] = $redirValues;
256 if ( $params['disabletoc'] ) {
257 $p_result->setTOCEnabled( false );
260 if ( isset( $prop['text'] ) ) {
261 $result_array['text'] = array();
262 ApiResult
::setContent( $result_array['text'], $p_result->getText() );
265 if ( !is_null( $params['summary'] ) ) {
266 $result_array['parsedsummary'] = array();
267 ApiResult
::setContent(
268 $result_array['parsedsummary'],
269 Linker
::formatComment( $params['summary'], $titleObj )
273 if ( isset( $prop['langlinks'] ) ||
isset( $prop['languageshtml'] ) ) {
274 $langlinks = $p_result->getLanguageLinks();
276 if ( $params['effectivelanglinks'] ) {
277 // Link flags are ignored for now, but may in the future be
278 // included in the result.
279 $linkFlags = array();
280 wfRunHooks( 'LanguageLinks', array( $titleObj, &$langlinks, &$linkFlags ) );
286 if ( isset( $prop['langlinks'] ) ) {
287 $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
289 if ( isset( $prop['languageshtml'] ) ) {
290 $languagesHtml = $this->languagesHtml( $langlinks );
292 $result_array['languageshtml'] = array();
293 ApiResult
::setContent( $result_array['languageshtml'], $languagesHtml );
295 if ( isset( $prop['categories'] ) ) {
296 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
298 if ( isset( $prop['categorieshtml'] ) ) {
299 $categoriesHtml = $this->categoriesHtml( $p_result->getCategories() );
300 $result_array['categorieshtml'] = array();
301 ApiResult
::setContent( $result_array['categorieshtml'], $categoriesHtml );
303 if ( isset( $prop['links'] ) ) {
304 $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
306 if ( isset( $prop['templates'] ) ) {
307 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
309 if ( isset( $prop['images'] ) ) {
310 $result_array['images'] = array_keys( $p_result->getImages() );
312 if ( isset( $prop['externallinks'] ) ) {
313 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
315 if ( isset( $prop['sections'] ) ) {
316 $result_array['sections'] = $p_result->getSections();
319 if ( isset( $prop['displaytitle'] ) ) {
320 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
321 $p_result->getDisplayTitle() :
322 $titleObj->getPrefixedText();
325 if ( isset( $prop['headitems'] ) ||
isset( $prop['headhtml'] ) ) {
326 $context = $this->getContext();
327 $context->setTitle( $titleObj );
328 $context->getOutput()->addParserOutputNoText( $p_result );
330 if ( isset( $prop['headitems'] ) ) {
331 $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
333 $css = $this->formatCss( $context->getOutput()->buildCssLinksArray() );
335 $scripts = array( $context->getOutput()->getHeadScripts() );
337 $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
340 if ( isset( $prop['headhtml'] ) ) {
341 $result_array['headhtml'] = array();
342 ApiResult
::setContent(
343 $result_array['headhtml'],
344 $context->getOutput()->headElement( $context->getSkin() )
349 if ( isset( $prop['iwlinks'] ) ) {
350 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
353 if ( isset( $prop['wikitext'] ) ) {
354 $result_array['wikitext'] = array();
355 ApiResult
::setContent( $result_array['wikitext'], $this->content
->serialize( $format ) );
356 if ( !is_null( $this->pstContent
) ) {
357 $result_array['psttext'] = array();
358 ApiResult
::setContent( $result_array['psttext'], $this->pstContent
->serialize( $format ) );
361 if ( isset( $prop['properties'] ) ) {
362 $result_array['properties'] = $this->formatProperties( $p_result->getProperties() );
365 if ( $params['generatexml'] ) {
366 if ( $this->content
->getModel() != CONTENT_MODEL_WIKITEXT
) {
367 $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
370 $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS
);
371 $dom = $wgParser->preprocessToDom( $this->content
->getNativeData() );
372 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
373 $xml = $dom->saveXML();
375 $xml = $dom->__toString();
377 $result_array['parsetree'] = array();
378 ApiResult
::setContent( $result_array['parsetree'], $xml );
381 $result_mapping = array(
384 'categories' => 'cl',
388 'externallinks' => 'el',
392 'properties' => 'pp',
394 $this->setIndexedTagNames( $result_array, $result_mapping );
395 $result->addValue( null, $this->getModuleName(), $result_array );
397 if ( !is_null( $oldLang ) ) {
398 $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
403 * Constructs a ParserOptions object
405 * @param WikiPage $pageObj
406 * @param array $params
408 * @return ParserOptions
410 protected function makeParserOptions( WikiPage
$pageObj, array $params ) {
411 wfProfileIn( __METHOD__
);
413 $popts = $pageObj->makeParserOptions( $this->getContext() );
414 $popts->enableLimitReport( !$params['disablepp'] );
415 $popts->setIsPreview( $params['preview'] ||
$params['sectionpreview'] );
416 $popts->setIsSectionPreview( $params['sectionpreview'] );
418 wfProfileOut( __METHOD__
);
424 * @param $page WikiPage
425 * @param $popts ParserOptions
427 * @param $getWikitext Bool
428 * @return ParserOutput
430 private function getParsedContent( WikiPage
$page, $popts, $pageId = null, $getWikitext = false ) {
431 $this->content
= $page->getContent( Revision
::RAW
); //XXX: really raw?
433 if ( $this->section
!== false && $this->content
!== null ) {
434 $this->content
= $this->getSectionContent(
436 !is_null( $pageId ) ?
'page id ' . $pageId : $page->getTitle()->getText()
439 // Not cached (save or load)
440 return $this->content
->getParserOutput( $page->getTitle(), null, $popts );
443 // Try the parser cache first
444 // getParserOutput will save to Parser cache if able
445 $pout = $page->getParserOutput( $popts );
447 $this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' );
449 if ( $getWikitext ) {
450 $this->content
= $page->getContent( Revision
::RAW
);
456 private function getSectionContent( Content
$content, $what ) {
457 // Not cached (save or load)
458 $section = $content->getSection( $this->section
);
459 if ( $section === false ) {
460 $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );
462 if ( $section === null ) {
463 $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
470 private function formatLangLinks( $links ) {
472 foreach ( $links as $link ) {
474 $bits = explode( ':', $link, 2 );
475 $title = Title
::newFromText( $link );
477 $entry['lang'] = $bits[0];
479 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
481 ApiResult
::setContent( $entry, $bits[1] );
488 private function formatCategoryLinks( $links ) {
495 // Fetch hiddencat property
497 $lb->setArray( array( NS_CATEGORY
=> $links ) );
498 $db = $this->getDB();
499 $res = $db->select( array( 'page', 'page_props' ),
500 array( 'page_title', 'pp_propname' ),
501 $lb->constructSet( 'page', $db ),
504 array( 'page_props' => array(
505 'LEFT JOIN', array( 'pp_propname' => 'hiddencat', 'pp_page = page_id' )
508 $hiddencats = array();
509 foreach ( $res as $row ) {
510 $hiddencats[$row->page_title
] = isset( $row->pp_propname
);
513 foreach ( $links as $link => $sortkey ) {
515 $entry['sortkey'] = $sortkey;
516 ApiResult
::setContent( $entry, $link );
517 if ( !isset( $hiddencats[$link] ) ) {
518 $entry['missing'] = '';
519 } elseif ( $hiddencats[$link] ) {
520 $entry['hidden'] = '';
528 private function categoriesHtml( $categories ) {
529 $context = $this->getContext();
530 $context->getOutput()->addCategoryLinks( $categories );
532 return $context->getSkin()->getCategories();
536 * @deprecated since 1.18 No modern skin generates language links this way,
537 * please use language links data to generate your own HTML.
538 * @param $languages array
541 private function languagesHtml( $languages ) {
542 wfDeprecated( __METHOD__
, '1.18' );
543 $this->setWarning( '"action=parse&prop=languageshtml" is deprecated ' .
544 'and will be removed in MediaWiki 1.24. Use "prop=langlinks" ' .
545 'to generate your own HTML.' );
547 global $wgContLang, $wgHideInterlanguageLinks;
549 if ( $wgHideInterlanguageLinks ||
count( $languages ) == 0 ) {
553 $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() .
554 wfMessage( 'colon-separator' )->text() );
557 foreach ( $languages as $l ) {
558 $nt = Title
::newFromText( $l );
559 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
561 $langs[] = Html
::element( 'a',
562 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => 'external' ),
563 $text == '' ?
$l : $text );
566 $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs );
568 if ( $wgContLang->isRTL() ) {
569 $s = Html
::rawElement( 'span', array( 'dir' => 'LTR' ), $s );
575 private function formatLinks( $links ) {
577 foreach ( $links as $ns => $nslinks ) {
578 foreach ( $nslinks as $title => $id ) {
581 ApiResult
::setContent( $entry, Title
::makeTitle( $ns, $title )->getFullText() );
583 $entry['exists'] = '';
592 private function formatIWLinks( $iw ) {
594 foreach ( $iw as $prefix => $titles ) {
595 foreach ( array_keys( $titles ) as $title ) {
597 $entry['prefix'] = $prefix;
599 $title = Title
::newFromText( "{$prefix}:{$title}" );
601 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
604 ApiResult
::setContent( $entry, $title->getFullText() );
612 private function formatHeadItems( $headItems ) {
614 foreach ( $headItems as $tag => $content ) {
616 $entry['tag'] = $tag;
617 ApiResult
::setContent( $entry, $content );
624 private function formatProperties( $properties ) {
626 foreach ( $properties as $name => $value ) {
628 $entry['name'] = $name;
629 ApiResult
::setContent( $entry, $value );
636 private function formatCss( $css ) {
638 foreach ( $css as $file => $link ) {
640 $entry['file'] = $file;
641 ApiResult
::setContent( $entry, $link );
648 private function setIndexedTagNames( &$array, $mapping ) {
649 foreach ( $mapping as $key => $name ) {
650 if ( isset( $array[$key] ) ) {
651 $this->getResult()->setIndexedTagName( $array[$key], $name );
656 public function getAllowedParams() {
663 ApiBase
::PARAM_TYPE
=> 'integer',
665 'redirects' => false,
667 ApiBase
::PARAM_TYPE
=> 'integer',
670 ApiBase
::PARAM_DFLT
=> 'text|langlinks|categories|links|templates|' .
671 'images|externallinks|sections|revid|displaytitle|iwlinks|properties',
672 ApiBase
::PARAM_ISMULTI
=> true,
673 ApiBase
::PARAM_TYPE
=> array(
695 'effectivelanglinks' => false,
698 'disablepp' => false,
699 'generatexml' => false,
701 'sectionpreview' => false,
702 'disabletoc' => false,
703 'contentformat' => array(
704 ApiBase
::PARAM_TYPE
=> ContentHandler
::getAllContentFormats(),
706 'contentmodel' => array(
707 ApiBase
::PARAM_TYPE
=> ContentHandler
::getContentModels(),
712 public function getParamDescription() {
713 $p = $this->getModulePrefix();
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, {$p}contentmodel must be specified, and \"API\" will be used as the title",
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. If omitted, ${p}title must be specified, " .
771 "and default will be the model of the specified ${p}title",
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}}&contentmodel=wikitext' => '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';