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 if ( !$titleObj->canExist() ) {
180 $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' );
182 $wgTitle = $titleObj;
183 $pageObj = WikiPage
::factory( $titleObj );
185 $popts = $this->makeParserOptions( $pageObj, $params );
187 if ( is_null( $text ) ) {
188 if ( $titleProvided && ( $prop ||
$params['generatexml'] ) ) {
190 "'title' used without 'text', and parsed page properties were requested " .
191 "(did you mean to use 'page' instead of 'title'?)"
194 // Prevent warning from ContentHandler::makeContent()
198 // If we are parsing text, do not use the content model of the default
199 // API title, but default to wikitext to keep BC.
200 if ( !$titleProvided && is_null( $model ) ) {
201 $model = CONTENT_MODEL_WIKITEXT
;
202 $this->setWarning( "No 'title' or 'contentmodel' was given, assuming $model." );
206 $this->content
= ContentHandler
::makeContent( $text, $titleObj, $model, $format );
207 } catch ( MWContentSerializationException
$ex ) {
208 $this->dieUsage( $ex->getMessage(), 'parseerror' );
211 if ( $this->section
!== false ) {
212 $this->content
= $this->getSectionContent( $this->content
, $titleObj->getText() );
215 if ( $params['pst'] ||
$params['onlypst'] ) {
216 $this->pstContent
= $this->content
->preSaveTransform( $titleObj, $this->getUser(), $popts );
218 if ( $params['onlypst'] ) {
219 // Build a result and bail out
220 $result_array = array();
221 $result_array['text'] = array();
222 ApiResult
::setContent( $result_array['text'], $this->pstContent
->serialize( $format ) );
223 if ( isset( $prop['wikitext'] ) ) {
224 $result_array['wikitext'] = array();
225 ApiResult
::setContent( $result_array['wikitext'], $this->content
->serialize( $format ) );
227 $result->addValue( null, $this->getModuleName(), $result_array );
232 // Not cached (save or load)
233 if ( $params['pst'] ) {
234 $p_result = $this->pstContent
->getParserOutput( $titleObj, null, $popts );
236 $p_result = $this->content
->getParserOutput( $titleObj, null, $popts );
240 $result_array = array();
242 $result_array['title'] = $titleObj->getPrefixedText();
244 if ( !is_null( $oldid ) ) {
245 $result_array['revid'] = intval( $oldid );
248 if ( $params['redirects'] && !is_null( $redirValues ) ) {
249 $result_array['redirects'] = $redirValues;
252 if ( $params['disabletoc'] ) {
253 $p_result->setTOCEnabled( false );
256 if ( isset( $prop['text'] ) ) {
257 $result_array['text'] = array();
258 ApiResult
::setContent( $result_array['text'], $p_result->getText() );
261 if ( !is_null( $params['summary'] ) ) {
262 $result_array['parsedsummary'] = array();
263 ApiResult
::setContent(
264 $result_array['parsedsummary'],
265 Linker
::formatComment( $params['summary'], $titleObj )
269 if ( isset( $prop['langlinks'] ) ||
isset( $prop['languageshtml'] ) ) {
270 $langlinks = $p_result->getLanguageLinks();
272 if ( $params['effectivelanglinks'] ) {
273 // Link flags are ignored for now, but may in the future be
274 // included in the result.
275 $linkFlags = array();
276 wfRunHooks( 'LanguageLinks', array( $titleObj, &$langlinks, &$linkFlags ) );
282 if ( isset( $prop['langlinks'] ) ) {
283 $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
285 if ( isset( $prop['languageshtml'] ) ) {
286 $languagesHtml = $this->languagesHtml( $langlinks );
288 $result_array['languageshtml'] = array();
289 ApiResult
::setContent( $result_array['languageshtml'], $languagesHtml );
291 if ( isset( $prop['categories'] ) ) {
292 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
294 if ( isset( $prop['categorieshtml'] ) ) {
295 $categoriesHtml = $this->categoriesHtml( $p_result->getCategories() );
296 $result_array['categorieshtml'] = array();
297 ApiResult
::setContent( $result_array['categorieshtml'], $categoriesHtml );
299 if ( isset( $prop['links'] ) ) {
300 $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
302 if ( isset( $prop['templates'] ) ) {
303 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
305 if ( isset( $prop['images'] ) ) {
306 $result_array['images'] = array_keys( $p_result->getImages() );
308 if ( isset( $prop['externallinks'] ) ) {
309 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
311 if ( isset( $prop['sections'] ) ) {
312 $result_array['sections'] = $p_result->getSections();
315 if ( isset( $prop['displaytitle'] ) ) {
316 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
317 $p_result->getDisplayTitle() :
318 $titleObj->getPrefixedText();
321 if ( isset( $prop['headitems'] ) ||
isset( $prop['headhtml'] ) ) {
322 $context = $this->getContext();
323 $context->setTitle( $titleObj );
324 $context->getOutput()->addParserOutputNoText( $p_result );
326 if ( isset( $prop['headitems'] ) ) {
327 $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
329 $css = $this->formatCss( $context->getOutput()->buildCssLinksArray() );
331 $scripts = array( $context->getOutput()->getHeadScripts() );
333 $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
336 if ( isset( $prop['headhtml'] ) ) {
337 $result_array['headhtml'] = array();
338 ApiResult
::setContent(
339 $result_array['headhtml'],
340 $context->getOutput()->headElement( $context->getSkin() )
345 if ( isset( $prop['iwlinks'] ) ) {
346 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
349 if ( isset( $prop['wikitext'] ) ) {
350 $result_array['wikitext'] = array();
351 ApiResult
::setContent( $result_array['wikitext'], $this->content
->serialize( $format ) );
352 if ( !is_null( $this->pstContent
) ) {
353 $result_array['psttext'] = array();
354 ApiResult
::setContent( $result_array['psttext'], $this->pstContent
->serialize( $format ) );
357 if ( isset( $prop['properties'] ) ) {
358 $result_array['properties'] = $this->formatProperties( $p_result->getProperties() );
361 if ( $params['generatexml'] ) {
362 if ( $this->content
->getModel() != CONTENT_MODEL_WIKITEXT
) {
363 $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
366 $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS
);
367 $dom = $wgParser->preprocessToDom( $this->content
->getNativeData() );
368 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
369 $xml = $dom->saveXML();
371 $xml = $dom->__toString();
373 $result_array['parsetree'] = array();
374 ApiResult
::setContent( $result_array['parsetree'], $xml );
377 $result_mapping = array(
380 'categories' => 'cl',
384 'externallinks' => 'el',
388 'properties' => 'pp',
390 $this->setIndexedTagNames( $result_array, $result_mapping );
391 $result->addValue( null, $this->getModuleName(), $result_array );
393 if ( !is_null( $oldLang ) ) {
394 $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
399 * Constructs a ParserOptions object
401 * @param WikiPage $pageObj
402 * @param array $params
404 * @return ParserOptions
406 protected function makeParserOptions( WikiPage
$pageObj, array $params ) {
407 wfProfileIn( __METHOD__
);
409 $popts = $pageObj->makeParserOptions( $this->getContext() );
410 $popts->enableLimitReport( !$params['disablepp'] );
411 $popts->setIsPreview( $params['preview'] ||
$params['sectionpreview'] );
412 $popts->setIsSectionPreview( $params['sectionpreview'] );
414 wfProfileOut( __METHOD__
);
420 * @param $page WikiPage
421 * @param $popts ParserOptions
423 * @param $getWikitext Bool
424 * @return ParserOutput
426 private function getParsedContent( WikiPage
$page, $popts, $pageId = null, $getWikitext = false ) {
427 $this->content
= $page->getContent( Revision
::RAW
); //XXX: really raw?
429 if ( $this->section
!== false && $this->content
!== null ) {
430 $this->content
= $this->getSectionContent(
432 !is_null( $pageId ) ?
'page id ' . $pageId : $page->getTitle()->getText()
435 // Not cached (save or load)
436 return $this->content
->getParserOutput( $page->getTitle(), null, $popts );
439 // Try the parser cache first
440 // getParserOutput will save to Parser cache if able
441 $pout = $page->getParserOutput( $popts );
443 $this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' );
445 if ( $getWikitext ) {
446 $this->content
= $page->getContent( Revision
::RAW
);
452 private function getSectionContent( Content
$content, $what ) {
453 // Not cached (save or load)
454 $section = $content->getSection( $this->section
);
455 if ( $section === false ) {
456 $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );
458 if ( $section === null ) {
459 $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
466 private function formatLangLinks( $links ) {
468 foreach ( $links as $link ) {
470 $bits = explode( ':', $link, 2 );
471 $title = Title
::newFromText( $link );
473 $entry['lang'] = $bits[0];
475 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
477 ApiResult
::setContent( $entry, $bits[1] );
484 private function formatCategoryLinks( $links ) {
491 // Fetch hiddencat property
493 $lb->setArray( array( NS_CATEGORY
=> $links ) );
494 $db = $this->getDB();
495 $res = $db->select( array( 'page', 'page_props' ),
496 array( 'page_title', 'pp_propname' ),
497 $lb->constructSet( 'page', $db ),
500 array( 'page_props' => array(
501 'LEFT JOIN', array( 'pp_propname' => 'hiddencat', 'pp_page = page_id' )
504 $hiddencats = array();
505 foreach ( $res as $row ) {
506 $hiddencats[$row->page_title
] = isset( $row->pp_propname
);
509 foreach ( $links as $link => $sortkey ) {
511 $entry['sortkey'] = $sortkey;
512 ApiResult
::setContent( $entry, $link );
513 if ( !isset( $hiddencats[$link] ) ) {
514 $entry['missing'] = '';
515 } elseif ( $hiddencats[$link] ) {
516 $entry['hidden'] = '';
524 private function categoriesHtml( $categories ) {
525 $context = $this->getContext();
526 $context->getOutput()->addCategoryLinks( $categories );
528 return $context->getSkin()->getCategories();
532 * @deprecated since 1.18 No modern skin generates language links this way,
533 * please use language links data to generate your own HTML.
534 * @param $languages array
537 private function languagesHtml( $languages ) {
538 wfDeprecated( __METHOD__
, '1.18' );
539 $this->setWarning( '"action=parse&prop=languageshtml" is deprecated ' .
540 'and will be removed in MediaWiki 1.24. Use "prop=langlinks" ' .
541 'to generate your own HTML.' );
543 global $wgContLang, $wgHideInterlanguageLinks;
545 if ( $wgHideInterlanguageLinks ||
count( $languages ) == 0 ) {
549 $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() .
550 wfMessage( 'colon-separator' )->text() );
553 foreach ( $languages as $l ) {
554 $nt = Title
::newFromText( $l );
555 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
557 $langs[] = Html
::element( 'a',
558 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => 'external' ),
559 $text == '' ?
$l : $text );
562 $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs );
564 if ( $wgContLang->isRTL() ) {
565 $s = Html
::rawElement( 'span', array( 'dir' => 'LTR' ), $s );
571 private function formatLinks( $links ) {
573 foreach ( $links as $ns => $nslinks ) {
574 foreach ( $nslinks as $title => $id ) {
577 ApiResult
::setContent( $entry, Title
::makeTitle( $ns, $title )->getFullText() );
579 $entry['exists'] = '';
588 private function formatIWLinks( $iw ) {
590 foreach ( $iw as $prefix => $titles ) {
591 foreach ( array_keys( $titles ) as $title ) {
593 $entry['prefix'] = $prefix;
595 $title = Title
::newFromText( "{$prefix}:{$title}" );
597 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
600 ApiResult
::setContent( $entry, $title->getFullText() );
608 private function formatHeadItems( $headItems ) {
610 foreach ( $headItems as $tag => $content ) {
612 $entry['tag'] = $tag;
613 ApiResult
::setContent( $entry, $content );
620 private function formatProperties( $properties ) {
622 foreach ( $properties as $name => $value ) {
624 $entry['name'] = $name;
625 ApiResult
::setContent( $entry, $value );
632 private function formatCss( $css ) {
634 foreach ( $css as $file => $link ) {
636 $entry['file'] = $file;
637 ApiResult
::setContent( $entry, $link );
644 private function setIndexedTagNames( &$array, $mapping ) {
645 foreach ( $mapping as $key => $name ) {
646 if ( isset( $array[$key] ) ) {
647 $this->getResult()->setIndexedTagName( $array[$key], $name );
652 public function getAllowedParams() {
659 ApiBase
::PARAM_TYPE
=> 'integer',
661 'redirects' => false,
663 ApiBase
::PARAM_TYPE
=> 'integer',
666 ApiBase
::PARAM_DFLT
=> 'text|langlinks|categories|links|templates|' .
667 'images|externallinks|sections|revid|displaytitle|iwlinks|properties',
668 ApiBase
::PARAM_ISMULTI
=> true,
669 ApiBase
::PARAM_TYPE
=> array(
691 'effectivelanglinks' => false,
694 'disablepp' => false,
695 'generatexml' => false,
697 'sectionpreview' => false,
698 'disabletoc' => false,
699 'contentformat' => array(
700 ApiBase
::PARAM_TYPE
=> ContentHandler
::getAllContentFormats(),
702 'contentmodel' => array(
703 ApiBase
::PARAM_TYPE
=> ContentHandler
::getContentModels(),
708 public function getParamDescription() {
709 $p = $this->getModulePrefix();
710 $wikitext = CONTENT_MODEL_WIKITEXT
;
713 'text' => "Text to parse. Use {$p}title or {$p}contentmodel to control the content model",
714 'summary' => 'Summary to parse',
715 'redirects' => "If the {$p}page or the {$p}pageid parameter is set to a redirect, resolve it",
716 'title' => "Title of page the text belongs to. " .
717 "If omitted, \"API\" is used as the title with content model $wikitext",
718 'page' => "Parse the content of this page. Cannot be used together with {$p}text and {$p}title",
719 'pageid' => "Parse the content of this page. Overrides {$p}page",
720 'oldid' => "Parse the content of this revision. Overrides {$p}page and {$p}pageid",
722 'Which pieces of information to get',
723 ' text - Gives the parsed text of the wikitext',
724 ' langlinks - Gives the language links in the parsed wikitext',
725 ' categories - Gives the categories in the parsed wikitext',
726 ' categorieshtml - Gives the HTML version of the categories',
727 ' languageshtml - DEPRECATED. Will be removed in MediaWiki 1.24.',
728 ' Gives the HTML version of the language links',
729 ' links - Gives the internal links in the parsed wikitext',
730 ' templates - Gives the templates in the parsed wikitext',
731 ' images - Gives the images in the parsed wikitext',
732 ' externallinks - Gives the external links in the parsed wikitext',
733 ' sections - Gives the sections in the parsed wikitext',
734 ' revid - Adds the revision ID of the parsed page',
735 ' displaytitle - Adds the title of the parsed wikitext',
736 ' headitems - Gives items to put in the <head> of the page',
737 ' headhtml - Gives parsed <head> of the page',
738 ' iwlinks - Gives interwiki links in the parsed wikitext',
739 ' wikitext - Gives the original wikitext that was parsed',
740 ' properties - Gives various properties defined in the parsed wikitext',
742 'effectivelanglinks' => array(
743 'Includes language links supplied by extensions',
744 '(for use with prop=langlinks|languageshtml)',
747 'Do a pre-save transform on the input before parsing it',
748 "Only valid when used with {$p}text",
751 'Do a pre-save transform (PST) on the input, but don\'t parse it',
752 'Returns the same wikitext, after a PST has been applied.',
753 "Only valid when used with {$p}text",
755 'uselang' => 'Which language to parse the request in',
756 'section' => 'Only retrieve the content of this section number',
757 'disablepp' => 'Disable the PP Report from the parser output',
758 'generatexml' => "Generate XML parse tree (requires contentmodel=$wikitext)",
759 'preview' => 'Parse in preview mode',
760 'sectionpreview' => 'Parse in section preview mode (enables preview mode too)',
761 'disabletoc' => 'Disable table of contents in output',
762 'contentformat' => array(
763 'Content serialization format used for the input text',
764 "Only valid when used with {$p}text",
766 'contentmodel' => array(
767 "Content model of the input text. Default is the model of the " .
768 "specified ${p}title, or $wikitext if ${p}title is not specified",
769 "Only valid when used with {$p}text",
774 public function getDescription() {
775 $p = $this->getModulePrefix();
778 'Parses content and returns parser output',
779 'See the various prop-Modules of action=query to get information from the current' .
781 'There are several ways to specify the text to parse:',
782 "1) Specify a page or revision, using {$p}page, {$p}pageid, or {$p}oldid.",
783 "2) Specify content explicitly, using {$p}text, {$p}title, and {$p}contentmodel.",
784 "3) Specify only a summary to parse. {$p}prop should be given an empty value.",
788 public function getPossibleErrors() {
789 return array_merge( parent
::getPossibleErrors(), array(
792 'info' => 'The page parameter cannot be used together with the text and title parameters'
794 array( 'code' => 'missingrev', 'info' => 'There is no revision ID oldid' ),
796 'code' => 'permissiondenied',
797 'info' => 'You don\'t have permission to view deleted revisions'
799 array( 'code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist' ),
800 array( 'code' => 'nosuchsection', 'info' => 'There is no section sectionnumber in page' ),
801 array( 'nosuchpageid' ),
802 array( 'invalidtitle', 'title' ),
803 array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
805 'code' => 'notwikitext',
806 'info' => 'The requested operation is only supported on wikitext content.'
808 array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ),
812 public function getExamples() {
814 'api.php?action=parse&page=Project:Sandbox' => 'Parse a page',
815 'api.php?action=parse&text={{Project:Sandbox}}' => 'Parse wikitext',
816 'api.php?action=parse&text={{PAGENAME}}&title=Test'
817 => 'Parse wikitext, specifying the page title',
818 'api.php?action=parse&summary=Some+[[link]]&prop=' => 'Parse a summary',
822 public function getHelpUrls() {
823 return 'https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse';