Manual:ParserOutput.php
MediaWiki file: ParserOutput.php | |
---|---|
Location: | includes/parser/ |
Source code: | master • 1.42.3 • 1.41.4 • 1.39.10 |
Classes: | MediaWiki\Parser\ParserOutput |
The ParserOutput class represents the rendered output of a wiki page, as parsed from wikitext. A ParserOutput object is created and cached through the ParserOutputAccess service. It extends CacheTime and implements ContentMetadataCollector.
Creation and retrieval
editNon-static methods:
- Parser::getOutput() - return the ParserOutput from the Parser.
- WikiPage::getParserOutput() - return the ParserOutput for the given ParserOptions and revision ID.
- ContentRenderer::getParserOutput() - return a ParserOutput object containing information derived from this content.
- ContentHandler::getParserOutput() - since 1.38, replacing Content::getParserOutput().
- ContentHandler::getParserOutputForIndexing() - return the ParserOutput to be used for indexing page content.
- RevisionOutputCache::get() - get the ParserOutput from RevisionOutputCache for the given RevisionRecord and ParserOptions.
- SlotRenderingProvider::getSlotParserOutput() (interface method)
- RenderedRevision::getSlotParserOutput() - get the ParserOutput for the given slot role.
- RenderedRevision::getRevisionParserOutput() - get the ParserOutput for the revision.
- ParserOutputAccess methods are not ready for use by extensions:
- ParsoidOutputAccess::getParserOutput() - equivalent method available for Parsoid.
Public methods
editThe class provides many getters, setters and boolean checkers:
Output HTML
edit- getText() - deprecated in 1.42 in favour of invoking ParserOutputTransform pipeline directly on a ParserOutput.
- setText() - set the output HTML
- hasText() - (bool) returns true if text was passed to the constructor, or set using setText()
- getRaw() - get the cacheable text with <mw:editsection> markers still included.
- addCacheMessage() - add a comment notice about cache state to the text of the page
- addWrapperDivClass() and getWrapperDivClass() - add/get a CSS class to use for the wrapping div.
- getHeadItems() and addHeadItem() - refers to text in the <head>
Titles and page properties
edit- getTitleText() and setTitleText() - Title text is the HTML text of the title in the chosen language variant.
- setDisplayTitle() and getDisplayTitle() - override/get the display title
- getPageProperty(), getPageProperties(), setPageProperty(), unsetPageProperty() - getProperty(), getProperty() and unsetProperty() are deprecated
Categories
edit- addCategory() and setCategories() - getCategoryLinks() and setCategoryLinks are deprecated
- getCategoryNames() - getCategories() is deprecated since 1.40.
- setNoGallery() and getNoGallery() - Whether or not to use gallery on category page (__NOGALLERY__).
Page components
edit- getIndicators() and setIndicator()
- Page sections:
- getSections(), setSections(),
- getNewSection(), setNewSection()
- getHideNewSection(), setHideNewSection(), hideNewSection()
- TOC (table of contents):
- getTOCHTML() and setTOCHTML() - deprecated in 1.40
- getTOCData() and setTOCData() - since 1.40
Links
edit- getLanguageLinks() and addLanguageLink() - setLanguageLinks() is deprecated since 1.38 in favour of addLanguageLink()
- getInterwikiLinks(), addInterwikiLink()
- getLinks(), addLink(), getLinksSpecial()
- isLinkInternal(),
- getExternalLinks(), addExternalLink()
Revisions, timestamps and 'speculative' properties
edit- setRevisionTimestampUsed() and getRevisionTimestampUsed()
- setRevisionUsedSha1Base36() and getRevisionUsedSha1Base36()
- getTimestamp() and setTimestamp()
- setSpeculativeRevIdUsed() abd getSpeculativeRevIdUsed()
- setSpeculativePageIdUsed() and getSpeculativePageIdUsed()
Templates, files
edit- getTemplates() and addTemplate()
- getTemplateIds()
- getImages() and addImage()
- getFileSearchOptions()
Modules and styles
edit- getModules() and addModules() - get/add ResourceLoader modules
- getModuleStyles() and addModuleStyles()
- getJsConfigVars(), setJsConfigVar(), appendJsConfigVar() - addJsConfigVars() is deprecated
- getEnableOOUI() and setEnableOOUI() - see OOUI
Policy
edit- Content Security Policy : getExtraCSPDefaultSrcs(), getExtraCSPScriptSrcs(), getExtraCSPStyleSrcs(), addExtraCSPDefaultSrc(), addExtraCSPStyleSrc(), addExtraCSPScriptSrc()
- getIndexPolicy() and setIndexPolicy()
Other
edit- getWarnings() and addWarningMsg() - addWarning() is deprecated in 1.38
- getLimitReportData()
- getLimitReportJSData()
- addOutputPageMetadata() - "accommodate very basic transcluding of a temporary OutputPage object into parser output"
- setOutputFlag(), getOutputFlag(), getAllFlags() - provide interface to various boolean flags stored in ParserOutput, e.g. NO_GALLERY, ENABLE_OOUI, etc. setFlag(), getFlag() are deprecated.
- setExtensionData(), appendExtensionData(), getExtensionData() - see extension data .
- resetParseStartTime(), resetParseStartTime(), getTimeSinceStart() - getTimeSinceStart is deprecated in 1.42 in favour of getTimeSinceStart()
- setLimitReportData()
- hasReducedExpiry() - hasDynamicContent() is deprecated
- setPreventClickjacking(), getPreventClickjacking() - preventClickjacking() is deprecated.
- updateRuntimeAdaptiveExpiry(), finalizeAdaptiveCacheExpiry()
- Metadata:
- mergeInternalMetaDataFrom()
- mergeHtmlMetaDataFrom() - HTML metadata
- mergeTrackingMetaDataFrom() - dependency tracking metadata
- collectMetadata()
- newFromJsonArray()
- __sleep(), __wakeup(), __get(), __set()
Deprecated or removed
edit- addTrackingCategory() - see Parser::addTrackingCategory or TrackingCategories::addTrackingCategory() instead.
- getOutputHooks() and addOutputHook() are deprecated. See OutputPageParserOutput instead.