Parsoid
A bidirectional parser between wikitext and HTML5
Wikimedia\Parsoid\Config\SiteConfig Class Reference

Site-level configuration interface for Parsoid. More...

+ Inheritance diagram for Wikimedia\Parsoid\Config\SiteConfig:

Public Member Functions

 registerExtensionModule ( $configOrSpec)
 Register a Parsoid extension module. More...
 
 unregisterExtensionModule (int $extId)
 Unregister a Parsoid extension module. More...
 
 getExtensionModules ()
 Return the set of Parsoid extension modules associated with this SiteConfig. More...
 
 fakeTimestamp ()
 Fake timestamp, for unit tests. More...
 
 getContentModelHandler (string $contentmodel)
 
 isExtensionTag (string $name)
 Determine whether a given name, which must have already been converted to lower case, is a valid extension tag name. More...
 
 isAnnotationTag (string $tagName)
 
 getAnnotationTags ()
 Get an array of defined annotation tags in lower case. More...
 
 getExtensionTagNameMap ()
 Get an array of defined extension tags, with the lower case name in the key, and the value being arbitrary. More...
 
 getExtTagConfig (string $tagName)
 
 getExtTagImpl (string $tagName)
 
 getExtDOMProcessors ()
 Return an array mapping extension name to an array of object factory specs for Ext\DOMProcessor objects. More...
 
 getWt2HtmlLimits ()
 
 getHtml2WtLimits ()
 
Global config
 getLogger ()
 General log channel. More...
 
 nativeGalleryEnabled ()
 "Native gallery" serialization. More...
 
 galleryOptions ()
 Default gallery options for this wiki. More...
 
 addHTMLTemplateParameters ()
 When processing template parameters, parse them to HTML and add it to the template parameters data. More...
 
 linting ()
 Whether to enable linter Backend. More...
 
 tidyWhitespaceBugMaxLength ()
 Maximum run length for Tidy whitespace bug. More...
 
 metrics ()
 Statistics aggregator, for counting and timing. More...
 
 scrubBidiChars ()
 If enabled, bidi chars adjacent to category links will be stripped in the html -> wt serialization pass. More...
 

Protected Member Functions

 getNonNativeExtensionTags ()
 Get an array of defined extension tags, with the lower case name in the key, the value arbitrary. More...
 
 processExtensionModule (ExtensionModule $ext)
 Register a Parsoid-compatible extension. More...
 
 getExtConfig ()
 

Protected Attributes

 $magicWordMap
 
 $linkTrailRegex = false
 
 $logger = null
 
 $iwMatcherBatchSize = 4096
 
 $addHTMLTemplateParameters = false
 
 $scrubBidiChars = false
 
 $linterEnabled = false
 
 $extConfig = null
 var ?array
 
 $wt2htmlLimits
 @phan-var array<string,int> More...
 
 $html2wtLimits
 @phan-var array<string,int> More...
 

Wiki config

 allowedExternalImagePrefixes ()
 Allowed external image URL prefixes. More...
 
 baseURI ()
 Site base URI. More...
 
 relativeLinkPrefix ()
 Prefix for relative links. More...
 
 bswPagePropRegexp ()
 Regex matching all double-underscore magic words. More...
 
 canonicalNamespaceId (string $name)
 Map a canonical namespace name to its index. More...
 
 namespaceId (string $name)
 Map a namespace name to its index. More...
 
 namespaceName (int $ns)
 Map a namespace index to its preferred name. More...
 
 namespaceHasSubpages (int $ns)
 Test if a namespace has subpages. More...
 
 namespaceCase (int $ns)
 Return namespace case setting. More...
 
 namespaceIsTalk (int $ns)
 Test if a namespace is a talk namespace. More...
 
 ucfirst (string $str)
 Uppercasing method for titles. More...
 
 specialPageLocalName (string $alias)
 Get the default local name for a special page. More...
 
 interwikiMagic ()
 Treat language links as magic connectors, not inline links. More...
 
 interwikiMap ()
 Interwiki link data. More...
 
 interwikiMatcher (string $href)
 Match interwiki URLs. More...
 
 iwp ()
 Wiki identifier, for cache keys. More...
 
 legalTitleChars ()
 Legal title characters. More...
 
 linkPrefixRegex ()
 Link prefix regular expression. More...
 
 linkTrailRegex ()
 Link trail regular expression. More...
 
 lang ()
 Wiki language code. More...
 
 mainpage ()
 Main page title. More...
 
 responsiveReferences ()
 Responsive references configuration. More...
 
 rtl ()
 Whether the wiki language is right-to-left. More...
 
 langConverterEnabled (string $lang)
 Whether language converter is enabled for the specified language. More...
 
 langConverterEnabledForLanguage (string $lang)
 Is the language converter enabled for this language? More...
 
 script ()
 The URL path to index.php. More...
 
 scriptpath ()
 FIXME: This is only used to compute the modules path below and maybe shouldn't be exposed. More...
 
 server ()
 The base URL of the server. More...
 
 getModulesLoadURI ()
 Get the base URL for loading resource modules This is the $wgLoadScript config value. More...
 
 redirectRegexp ()
 A regexp matching the localized 'REDIRECT' marker for this wiki. More...
 
 categoryRegexp ()
 A regexp matching the localized 'Category' prefix for this wiki. More...
 
 bswRegexp ()
 A regexp matching localized behavior switches for this wiki. More...
 
 solTransparentWikitextRegexp ()
 A regex matching a line containing just whitespace, comments, and sol transparent links and behavior switches. More...
 
 solTransparentWikitextNoWsRegexp (bool $addIncludes=false)
 A regex matching a line containing just comments and sol transparent links and behavior switches. More...
 
 timezoneOffset ()
 The wiki's time zone offset. More...
 
 variants ()
 Language variant information. More...
 
 widthOption ()
 Default thumbnail width. More...
 
 magicWords ()
 List all magic words by alias. More...
 
 mwAliases ()
 List all magic words by canonical name. More...
 
 getMagicWordForFunctionHook (string $str)
 Return canonical magic word for a function hook. More...
 
 getMagicWordForVariable (string $str)
 Return canonical magic word for a variable. More...
 
 magicWordCanonicalName (string $word)
 Get canonical magicword name for the input word. More...
 
 isMagicWord (string $word)
 Check if a string is a recognized magic word. More...
 
 getMagicWordWT (string $word, string $suggest)
 Convert the internal canonical magic word name to the wikitext alias. More...
 
 getMagicWordMatcher (string $id)
 Get a regexp matching a localized magic word, given its id. More...
 
 getMediaPrefixParameterizedAliasMatcher ()
 Get a matcher function for fetching values out of interpolated magic words which are media prefix options. More...
 
 getMaxTemplateDepth ()
 Get the maximum template depth. More...
 
 getExtResourceURLPatternMatcher ()
 Matcher for ISBN/RFC/PMID URL patterns, returning the type and number. More...
 
 makeExtResourceURL (array $match, string $href, string $content)
 Serialize ISBN/RFC/PMID URL patterns. More...
 
 getProtocolsRegex ( $excludeProtRel=false)
 Get a regex fragment matching URL protocols, quoted for an exclamation mark delimiter. More...
 
 hasValidProtocol (string $potentialLink)
 Matcher for valid protocols, must be anchored at start of string. More...
 
 findValidProtocol (string $potentialLink)
 Matcher for valid protocols, may occur at any point within string. More...
 
 linkTrail ()
 Return raw link trail regexp from config. More...
 
 getVariableIDs ()
 
 getFunctionHooks ()
 
 getMagicWords ()
 
 getParameterizedAliasMatcher (array $words)
 Get a matcher function for fetching values out of interpolated magic words, ie those with $1 in their aliases. More...
 
 getSpecialNSAliases ()
 Return name spaces aliases for the NS_SPECIAL namespace. More...
 
 getSpecialPageAliases (string $specialPage)
 Return Special Page aliases for a special page name. More...
 
 getProtocols ()
 Get the list of valid protocols. More...
 
static quoteTitleRe (string $s, string $delimiter='/')
 Quote a title regex. More...
 

Detailed Description

Site-level configuration interface for Parsoid.

This includes both global configuration and wiki-level configuration.

Member Function Documentation

◆ addHTMLTemplateParameters()

Wikimedia\Parsoid\Config\SiteConfig::addHTMLTemplateParameters ( )

When processing template parameters, parse them to HTML and add it to the template parameters data.

Returns
bool

◆ allowedExternalImagePrefixes()

Wikimedia\Parsoid\Config\SiteConfig::allowedExternalImagePrefixes ( )
abstract

Allowed external image URL prefixes.

Returns
string[] The empty array matches no URLs. The empty string matches all URLs.

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ baseURI()

Wikimedia\Parsoid\Config\SiteConfig::baseURI ( )
abstract

Site base URI.

This would be the URI found in <base href="..." />.

Returns
string

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ bswPagePropRegexp()

Wikimedia\Parsoid\Config\SiteConfig::bswPagePropRegexp ( )

Regex matching all double-underscore magic words.

Returns
string

◆ bswRegexp()

Wikimedia\Parsoid\Config\SiteConfig::bswRegexp ( )
abstract

A regexp matching localized behavior switches for this wiki.

The regexp should be delimited, but should not have boundary anchors or capture groups.

Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ canonicalNamespaceId()

Wikimedia\Parsoid\Config\SiteConfig::canonicalNamespaceId ( string  $name)
abstract

Map a canonical namespace name to its index.

Note
This replaces canonicalNamespaces
Parameters
string$nameall-lowercase and with underscores rather than spaces.
Returns
int|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ categoryRegexp()

Wikimedia\Parsoid\Config\SiteConfig::categoryRegexp ( )
abstract

A regexp matching the localized 'Category' prefix for this wiki.

The regexp should be delimited, but should not have boundary anchors or capture groups.

Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ fakeTimestamp()

Wikimedia\Parsoid\Config\SiteConfig::fakeTimestamp ( )

Fake timestamp, for unit tests.

Returns
int|null Unix timestamp, or null to not fake it

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ findValidProtocol()

Wikimedia\Parsoid\Config\SiteConfig::findValidProtocol ( string  $potentialLink)

Matcher for valid protocols, may occur at any point within string.

Parameters
string$potentialLink
Returns
bool Whether $potentialLink contains a valid protocol

◆ galleryOptions()

Wikimedia\Parsoid\Config\SiteConfig::galleryOptions ( )

Default gallery options for this wiki.

Returns
array<string,string|int|bool>

Reimplemented in Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getAnnotationTags()

Wikimedia\Parsoid\Config\SiteConfig::getAnnotationTags ( )

Get an array of defined annotation tags in lower case.

Returns
array

◆ getContentModelHandler()

Wikimedia\Parsoid\Config\SiteConfig::getContentModelHandler ( string  $contentmodel)
Parameters
string$contentmodel
Returns
ContentModelHandler|null

◆ getExtConfig()

Wikimedia\Parsoid\Config\SiteConfig::getExtConfig ( )
protected
Returns
array

◆ getExtDOMProcessors()

Wikimedia\Parsoid\Config\SiteConfig::getExtDOMProcessors ( )

Return an array mapping extension name to an array of object factory specs for Ext\DOMProcessor objects.

Returns
array

◆ getExtensionModules()

Wikimedia\Parsoid\Config\SiteConfig::getExtensionModules ( )
final

Return the set of Parsoid extension modules associated with this SiteConfig.

Returns
ExtensionModule[]

◆ getExtensionTagNameMap()

Wikimedia\Parsoid\Config\SiteConfig::getExtensionTagNameMap ( )

Get an array of defined extension tags, with the lower case name in the key, and the value being arbitrary.

Returns
array

◆ getExtResourceURLPatternMatcher()

Wikimedia\Parsoid\Config\SiteConfig::getExtResourceURLPatternMatcher ( )

Matcher for ISBN/RFC/PMID URL patterns, returning the type and number.

The match method takes a string and returns false on no match or a tuple like this on match: [ 'RFC', '12345' ]

Returns
callable

◆ getExtTagConfig()

Wikimedia\Parsoid\Config\SiteConfig::getExtTagConfig ( string  $tagName)
Parameters
string$tagNameExtension tag name
Returns
array|null

◆ getExtTagImpl()

Wikimedia\Parsoid\Config\SiteConfig::getExtTagImpl ( string  $tagName)
Parameters
string$tagNameExtension tag name
Returns
ExtensionTagHandler|null Returns the implementation of the named extension, if there is one.

◆ getFunctionHooks()

Wikimedia\Parsoid\Config\SiteConfig::getFunctionHooks ( )
abstractprotected

◆ getHtml2WtLimits()

Wikimedia\Parsoid\Config\SiteConfig::getHtml2WtLimits ( )
Returns
array<string,int>

◆ getLogger()

Wikimedia\Parsoid\Config\SiteConfig::getLogger ( )

General log channel.

Returns
LoggerInterface

◆ getMagicWordForFunctionHook()

Wikimedia\Parsoid\Config\SiteConfig::getMagicWordForFunctionHook ( string  $str)

Return canonical magic word for a function hook.

Parameters
string$str
Returns
string|null

◆ getMagicWordForVariable()

Wikimedia\Parsoid\Config\SiteConfig::getMagicWordForVariable ( string  $str)

Return canonical magic word for a variable.

Parameters
string$str
Returns
string|null

◆ getMagicWordMatcher()

Wikimedia\Parsoid\Config\SiteConfig::getMagicWordMatcher ( string  $id)
abstract

Get a regexp matching a localized magic word, given its id.

FIXME: misleading function name

Parameters
string$id
Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getMagicWords()

Wikimedia\Parsoid\Config\SiteConfig::getMagicWords ( )
abstractprotected

◆ getMagicWordWT()

Wikimedia\Parsoid\Config\SiteConfig::getMagicWordWT ( string  $word,
string  $suggest 
)

Convert the internal canonical magic word name to the wikitext alias.

Parameters
string$wordCanonical magic word name
string$suggestSuggested alias (used as fallback and preferred choice)
Returns
string

◆ getMaxTemplateDepth()

Wikimedia\Parsoid\Config\SiteConfig::getMaxTemplateDepth ( )
abstract

Get the maximum template depth.

Returns
int

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getMediaPrefixParameterizedAliasMatcher()

Wikimedia\Parsoid\Config\SiteConfig::getMediaPrefixParameterizedAliasMatcher ( )
final

Get a matcher function for fetching values out of interpolated magic words which are media prefix options.

The matcher takes a string and returns null if it doesn't match any of the words, or an associative array if it did match:

  • k: The magic word that matched
  • v: The value of $1 that was matched (the JS also returned 'a' with the specific alias that matched, but that seems to be unused and so is omitted here)
Returns
callable

◆ getModulesLoadURI()

Wikimedia\Parsoid\Config\SiteConfig::getModulesLoadURI ( )

Get the base URL for loading resource modules This is the $wgLoadScript config value.

This base class provides the default value. Derived classes should override appropriately.

Returns
string

Reimplemented in Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getNonNativeExtensionTags()

Wikimedia\Parsoid\Config\SiteConfig::getNonNativeExtensionTags ( )
abstractprotected

Get an array of defined extension tags, with the lower case name in the key, the value arbitrary.

This is the set of extension tags that are configured in M/W core. $coreExtModules may already be part of it, but eventually this distinction will disappear since all extension tags have to be defined against the Parsoid's extension API.

Returns
array

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getParameterizedAliasMatcher()

Wikimedia\Parsoid\Config\SiteConfig::getParameterizedAliasMatcher ( array  $words)
abstractprotected

Get a matcher function for fetching values out of interpolated magic words, ie those with $1 in their aliases.

The matcher takes a string and returns null if it doesn't match any of the words, or an associative array if it did match:

  • k: The magic word that matched
  • v: The value of $1 that was matched (the JS also returned 'a' with the specific alias that matched, but that seems to be unused and so is omitted here)
Parameters
string[]$wordsMagic words to match
Returns
callable

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getProtocols()

Wikimedia\Parsoid\Config\SiteConfig::getProtocols ( )
abstractprotected

Get the list of valid protocols.

Returns
array

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getProtocolsRegex()

Wikimedia\Parsoid\Config\SiteConfig::getProtocolsRegex (   $excludeProtRel = false)

Get a regex fragment matching URL protocols, quoted for an exclamation mark delimiter.

The case-insensitive option should be used.

Parameters
bool$excludeProtRelWhether to exclude protocol-relative URLs
Returns
string

◆ getSpecialNSAliases()

Wikimedia\Parsoid\Config\SiteConfig::getSpecialNSAliases ( )
abstractprotected

Return name spaces aliases for the NS_SPECIAL namespace.

Returns
array

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getSpecialPageAliases()

Wikimedia\Parsoid\Config\SiteConfig::getSpecialPageAliases ( string  $specialPage)
abstractprotected

Return Special Page aliases for a special page name.

Parameters
string$specialPage
Returns
array

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ getVariableIDs()

Wikimedia\Parsoid\Config\SiteConfig::getVariableIDs ( )
abstractprotected

◆ getWt2HtmlLimits()

Wikimedia\Parsoid\Config\SiteConfig::getWt2HtmlLimits ( )
Returns
array<string,int>

◆ hasValidProtocol()

Wikimedia\Parsoid\Config\SiteConfig::hasValidProtocol ( string  $potentialLink)

Matcher for valid protocols, must be anchored at start of string.

Parameters
string$potentialLink
Returns
bool Whether $potentialLink begins with a valid protocol

◆ interwikiMagic()

Wikimedia\Parsoid\Config\SiteConfig::interwikiMagic ( )
abstract

Treat language links as magic connectors, not inline links.

Returns
bool

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ interwikiMap()

Wikimedia\Parsoid\Config\SiteConfig::interwikiMap ( )
abstract

Interwiki link data.

Returns
array[] Keys are interwiki prefixes, values are arrays with the following keys:
  • prefix: (string) The interwiki prefix, same as the key.
  • url: (string) Target URL, containing a '$1' to be replaced by the interwiki target.
  • protorel: (bool, optional) Whether the url may be accessed by both http:// and https://.
  • local: (bool, optional) Whether the interwiki link is considered local (to the wikifarm).
  • localinterwiki: (bool, optional) Whether the interwiki link points to the current wiki.
  • language: (bool, optional) Whether the interwiki link is a language link.
  • extralanglink: (bool, optional) Whether the interwiki link is an "extra language link".
  • linktext: (string, optional) For "extra language links", the link text. (booleans marked "optional" must be omitted if false)

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ interwikiMatcher()

Wikimedia\Parsoid\Config\SiteConfig::interwikiMatcher ( string  $href)

Match interwiki URLs.

Parameters
string$hrefLink to match against
Returns
string[]|null Two values [ string $key, string $target ] on success, null on no match.

◆ isAnnotationTag()

Wikimedia\Parsoid\Config\SiteConfig::isAnnotationTag ( string  $tagName)
Parameters
string$tagNameis $tagName an annotation tag?
Returns
bool

◆ isExtensionTag()

Wikimedia\Parsoid\Config\SiteConfig::isExtensionTag ( string  $name)

Determine whether a given name, which must have already been converted to lower case, is a valid extension tag name.

Parameters
string$name
Returns
bool

◆ isMagicWord()

Wikimedia\Parsoid\Config\SiteConfig::isMagicWord ( string  $word)

Check if a string is a recognized magic word.

Parameters
string$word
Returns
bool

◆ iwp()

Wikimedia\Parsoid\Config\SiteConfig::iwp ( )
abstract

Wiki identifier, for cache keys.

Should match a key in mwApiMap()?

Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ lang()

Wikimedia\Parsoid\Config\SiteConfig::lang ( )
abstract

Wiki language code.

Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ langConverterEnabled()

Wikimedia\Parsoid\Config\SiteConfig::langConverterEnabled ( string  $lang)
abstract

Whether language converter is enabled for the specified language.

Parameters
string$langLanguage code
Returns
bool

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ langConverterEnabledForLanguage()

Wikimedia\Parsoid\Config\SiteConfig::langConverterEnabledForLanguage ( string  $lang)

Is the language converter enabled for this language?

Parameters
string$lang
Returns
bool

◆ legalTitleChars()

Wikimedia\Parsoid\Config\SiteConfig::legalTitleChars ( )
abstract

Legal title characters.

Regex is intended to match bytes, not Unicode characters.

Returns
string Regex character class (i.e. the bit that goes inside [])

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ linkPrefixRegex()

Wikimedia\Parsoid\Config\SiteConfig::linkPrefixRegex ( )
abstract

Link prefix regular expression.

Returns
string|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ linkTrail()

Wikimedia\Parsoid\Config\SiteConfig::linkTrail ( )
abstractprotected

Return raw link trail regexp from config.

Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ linkTrailRegex()

Wikimedia\Parsoid\Config\SiteConfig::linkTrailRegex ( )

Link trail regular expression.

Returns
string|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ linting()

Wikimedia\Parsoid\Config\SiteConfig::linting ( )

Whether to enable linter Backend.

Returns
bool|string[] Boolean to enable/disable all linting, or an array of enabled linting types.

◆ magicWordCanonicalName()

Wikimedia\Parsoid\Config\SiteConfig::magicWordCanonicalName ( string  $word)

Get canonical magicword name for the input word.

Parameters
string$word
Returns
string|null

◆ magicWords()

Wikimedia\Parsoid\Config\SiteConfig::magicWords ( )

List all magic words by alias.

Returns
string[] Keys are aliases, values are arrays of case-sensitive, canonical names.

◆ mainpage()

Wikimedia\Parsoid\Config\SiteConfig::mainpage ( )
abstract

Main page title.

Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ makeExtResourceURL()

Wikimedia\Parsoid\Config\SiteConfig::makeExtResourceURL ( array  $match,
string  $href,
string  $content 
)

Serialize ISBN/RFC/PMID URL patterns.

Parameters
string[]$matchAs returned by the getExtResourceURLPatternMatcher() matcher
string$hrefFallback link target, if $match is invalid.
string$contentLink text
Returns
string

◆ metrics()

Wikimedia\Parsoid\Config\SiteConfig::metrics ( )

Statistics aggregator, for counting and timing.

Returns
StatsdDataFactoryInterface|null

Reimplemented in Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ mwAliases()

Wikimedia\Parsoid\Config\SiteConfig::mwAliases ( )

List all magic words by canonical name.

Returns
string[][] Keys are canonical names, values are arrays of aliases.

◆ namespaceCase()

Wikimedia\Parsoid\Config\SiteConfig::namespaceCase ( int  $ns)
abstract

Return namespace case setting.

Parameters
int$ns
Returns
string 'first-letter' or 'case-sensitive'

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ namespaceHasSubpages()

Wikimedia\Parsoid\Config\SiteConfig::namespaceHasSubpages ( int  $ns)
abstract

Test if a namespace has subpages.

Note
This replaces namespacesWithSubpages
Parameters
int$ns
Returns
bool

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ namespaceId()

Wikimedia\Parsoid\Config\SiteConfig::namespaceId ( string  $name)
abstract

Map a namespace name to its index.

Note
This replaces canonicalNamespaces
Parameters
string$name
Returns
int|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ namespaceIsTalk()

Wikimedia\Parsoid\Config\SiteConfig::namespaceIsTalk ( int  $ns)

Test if a namespace is a talk namespace.

Note
This replaces title.getNamespace().isATalkNamespace()
Parameters
int$ns
Returns
bool

◆ namespaceName()

Wikimedia\Parsoid\Config\SiteConfig::namespaceName ( int  $ns)
abstract

Map a namespace index to its preferred name.

Note
This replaces namespaceNames
Parameters
int$ns
Returns
string|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ nativeGalleryEnabled()

Wikimedia\Parsoid\Config\SiteConfig::nativeGalleryEnabled ( )

"Native gallery" serialization.

When true we always serialize using the HTML generated by our native gallery extension. When false we emit the original wikitext in an extsrc attribute, and only serialize from HTML when extsrc is dropped (ie, when the gallery is edited), since T214648/T214649 cause a lot of normalization.

This is enabled in true development but still false in production.

Returns
bool

◆ processExtensionModule()

Wikimedia\Parsoid\Config\SiteConfig::processExtensionModule ( ExtensionModule  $ext)
protected

Register a Parsoid-compatible extension.

Parameters
ExtensionModule$ext

◆ quoteTitleRe()

static Wikimedia\Parsoid\Config\SiteConfig::quoteTitleRe ( string  $s,
string  $delimiter = '/' 
)
staticprotected

Quote a title regex.

Assumes '/' as the delimiter, and replaces spaces or underscores with [ _] so either will be matched.

Parameters
string$s
string$delimiterDefaults to '/'
Returns
string

◆ redirectRegexp()

Wikimedia\Parsoid\Config\SiteConfig::redirectRegexp ( )
abstract

A regexp matching the localized 'REDIRECT' marker for this wiki.

The regexp should be delimited, but should not have boundary anchors or capture groups.

Returns
string

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ registerExtensionModule()

Wikimedia\Parsoid\Config\SiteConfig::registerExtensionModule (   $configOrSpec)
final

Register a Parsoid extension module.

Parameters
string|array{name:string}|array{factory:callable}|array{class:class-string<ExtensionModule>}$configOrSpec Either an object factory specification for an ExtensionModule object, or else the configuration array which ExtensionModule::getConfig() would return. (The latter is preferred, but our internal extensions use the former.)
Returns
int An integer identifier that can be passed to ::unregisterExtensionModule to remove this extension (
Parameters
array$config

◆ relativeLinkPrefix()

Wikimedia\Parsoid\Config\SiteConfig::relativeLinkPrefix ( )

Prefix for relative links.

Prefix to prepend to a page title to link to that page. Intended to be relative to the URI returned by baseURI().

If possible, keep the default "./" so clients need not know this value to extract titles from link hrefs.

Returns
string

Reimplemented in Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ responsiveReferences()

Wikimedia\Parsoid\Config\SiteConfig::responsiveReferences ( )
abstract

Responsive references configuration.

Returns
array With two keys:
  • enabled: (bool) Whether it's enabled
  • threshold: (int) Threshold

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ rtl()

Wikimedia\Parsoid\Config\SiteConfig::rtl ( )
abstract

Whether the wiki language is right-to-left.

Returns
bool

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ script()

Wikimedia\Parsoid\Config\SiteConfig::script ( )
abstract

◆ scriptpath()

Wikimedia\Parsoid\Config\SiteConfig::scriptpath ( )
abstract

FIXME: This is only used to compute the modules path below and maybe shouldn't be exposed.

The base wiki path

Returns
string

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ scrubBidiChars()

Wikimedia\Parsoid\Config\SiteConfig::scrubBidiChars ( )

If enabled, bidi chars adjacent to category links will be stripped in the html -> wt serialization pass.

Returns
bool

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ server()

Wikimedia\Parsoid\Config\SiteConfig::server ( )
abstract

◆ solTransparentWikitextNoWsRegexp()

Wikimedia\Parsoid\Config\SiteConfig::solTransparentWikitextNoWsRegexp ( bool  $addIncludes = false)

A regex matching a line containing just comments and sol transparent links and behavior switches.

Parameters
bool$addIncludes
Returns
string

◆ solTransparentWikitextRegexp()

Wikimedia\Parsoid\Config\SiteConfig::solTransparentWikitextRegexp ( )

A regex matching a line containing just whitespace, comments, and sol transparent links and behavior switches.

Returns
string

◆ specialPageLocalName()

Wikimedia\Parsoid\Config\SiteConfig::specialPageLocalName ( string  $alias)
abstract

Get the default local name for a special page.

Parameters
string$aliasSpecial page alias
Returns
string|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ tidyWhitespaceBugMaxLength()

Wikimedia\Parsoid\Config\SiteConfig::tidyWhitespaceBugMaxLength ( )

Maximum run length for Tidy whitespace bug.

Returns
int Length in Unicode codepoints

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ timezoneOffset()

Wikimedia\Parsoid\Config\SiteConfig::timezoneOffset ( )
abstract

The wiki's time zone offset.

Returns
int Minutes east of UTC

Reimplemented in Wikimedia\Parsoid\ParserTests\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ ucfirst()

Wikimedia\Parsoid\Config\SiteConfig::ucfirst ( string  $str)

Uppercasing method for titles.

Parameters
string$str
Returns
string

◆ unregisterExtensionModule()

Wikimedia\Parsoid\Config\SiteConfig::unregisterExtensionModule ( int  $extId)
final

Unregister a Parsoid extension module.

This is typically used only for testing purposes in order to reset a shared SiteConfig to its original configuration.

Parameters
int$extIdThe value returned by the call to ::registerExtensionModule()

◆ variants()

Wikimedia\Parsoid\Config\SiteConfig::variants ( )
abstract

Language variant information.

Returns
array Keys are variant codes (e.g. "zh-cn"), values are arrays with two fields:
  • base: (string) Base language code (e.g. "zh")
  • fallbacks: (string[]) Fallback variants

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

◆ widthOption()

Wikimedia\Parsoid\Config\SiteConfig::widthOption ( )
abstract

Default thumbnail width.

Returns
int

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\Config\Api\SiteConfig.

Member Data Documentation

◆ $html2wtLimits

Wikimedia\Parsoid\Config\SiteConfig::$html2wtLimits
protected
Initial value:
= [
'htmlSize' => 10000000,
]

@phan-var array<string,int>

◆ $wt2htmlLimits

Wikimedia\Parsoid\Config\SiteConfig::$wt2htmlLimits
protected
Initial value:
= [
'wikitextSize' => 2048 * 1024,
'listItem' => 30000,
'tableCell' => 30000,
'transclusion' => 10000,
'image' => 1000,
'token' => 1000000,
]

@phan-var array<string,int>


The documentation for this class was generated from the following file: