Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
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.
 
 unregisterExtensionModule (int $extId)
 Unregister a Parsoid extension module.
 
 getExtensionModules ()
 Return the set of Parsoid extension modules associated with this SiteConfig.
 
 __construct ()
 Base constructor.
 
 fakeTimestamp ()
 Fake timestamp, for unit tests.
 
 getObjectFactory ()
 Return an object factory to use when instantiating extensions.
 
 tagNeedsNowikiStrippedInTagPF (string $lowerTagName)
 
 getContentModelHandler (string $contentmodel)
 Return a ContentModelHandler for the specified $contentmodel, if one is registered.
 
 getAnnotationStrippers ()
 Returns all the annotationStrippers that are defined as annotation configuration.
 
 isExtensionTag (string $name)
 Determine whether a given name, which must have already been converted to lower case, is a valid extension tag name.
 
 isAnnotationTag (string $tagName)
 
 getAnnotationTags ()
 Get an array of defined annotation tags in lower case.
 
 getExtensionTagNameMap ()
 Get an array of defined extension tags, with the lower case name in the key, and the value being arbitrary.
 
 getExtTagConfig (string $tagName)
 
 getExtTagImpl (string $tagName)
 
 getExtDOMProcessors ()
 Return an array mapping extension name to an array of object factory specs for Ext\DOMProcessor objects.
 
 getWt2HtmlLimits ()
 
 getHtml2WtLimits ()
 
 getNoFollowConfig ()
 
 getExternalLinkTarget ()
 
Global config
 getLogger ()
 General log channel.
 
 setLogger (?LoggerInterface $logger)
 Set the log channel, for debugging.
 
 galleryOptions ()
 Default gallery options for this wiki.
 
 addHTMLTemplateParameters ()
 When processing template parameters, parse them to HTML and add it to the template parameters data.
 
 metrics ()
 Statistics aggregator, for counting and timing.
 
 scrubBidiChars ()
 If enabled, bidi chars adjacent to category links will be stripped in the html -> wt serialization pass.
 

Static Public Member Functions

static createLogger (?string $filePath=null)
 

Protected Member Functions

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

Protected Attributes

 $mwAliases
 
 $functionSynonyms
 
 $interwikiMapNoNamespaces
 
 $linkTrailRegex = false
 
 $logger = null
 
 $iwMatcherBatchSize = 4096
 
 $addHTMLTemplateParameters = false
 
 $scrubBidiChars = false
 
 $linterEnabled = false
 
 $extConfig = null
 
 $wt2htmlLimits
 
 $html2wtLimits
 

Wiki config

 allowedExternalImagePrefixes ()
 Allowed external image URL prefixes.
 
 baseURI ()
 Site base URI.
 
 relativeLinkPrefix ()
 Prefix for relative links.
 
 bswPagePropRegexp ()
 Regex matching all double-underscore magic words.
 
 canonicalNamespaceId (string $name)
 Map a canonical namespace name to its index.
 
 namespaceId (string $name)
 Map a namespace name to its index.
 
 namespaceName (int $ns)
 Map a namespace index to its preferred name (with spaces, not underscores).
 
 namespaceHasSubpages (int $ns)
 Test if a namespace has subpages.
 
 namespaceCase (int $ns)
 Return namespace case setting.
 
 namespaceIsTalk (int $ns)
 Test if a namespace is a talk namespace.
 
 ucfirst (string $str)
 Uppercasing method for titles.
 
 specialPageLocalName (string $alias)
 Get the default local name for a special page.
 
 interwikiMagic ()
 Treat language links as magic connectors, not inline links.
 
 interwikiMap ()
 Interwiki link data.
 
 interwikiMapNoNamespaces ()
 Interwiki link data, after removing items that conflict with namespace names.
 
 interwikiMatcher (string $href)
 Match interwiki URLs.
 
 iwp ()
 Wiki identifier, for cache keys.
 
 legalTitleChars ()
 Legal title characters.
 
 linkPrefixRegex ()
 Link prefix regular expression.
 
 linkTrailRegex ()
 Link trail regular expression.
 
 langBcp47 ()
 Wiki language code.
 
 mainPageLinkTarget ()
 Main page title, as LinkTarget.
 
 getMWConfigValue (string $key)
 Lookup config.
 
 rtl ()
 Whether the wiki language is right-to-left.
 
 langConverterEnabledBcp47 (Bcp47Code $lang)
 Whether language converter is enabled for the specified language.
 
 script ()
 The URL path to index.php.
 
 scriptpath ()
 FIXME: This is only used to compute the modules path below and maybe shouldn't be exposed.
 
 server ()
 The base URL of the server.
 
 exportMetadataToHeadBcp47 (Document $document, ContentMetadataCollector $metadata, string $defaultTitle, Bcp47Code $lang)
 Export content metadata via meta tags (and via a stylesheet for now to aid some clients).
 
 redirectRegexp ()
 A regexp matching the localized 'REDIRECT' marker for this wiki.
 
 categoryRegexp ()
 A regexp matching the localized 'Category' prefix for this wiki.
 
 bswRegexp ()
 A regexp matching localized behavior switches for this wiki.
 
 solTransparentWikitextRegexp ()
 A regex matching a line containing just whitespace, comments, and sol transparent links and behavior switches.
 
 solTransparentWikitextNoWsRegexp (bool $addIncludes=false)
 A regex matching a line containing just comments and sol transparent links and behavior switches.
 
 timezoneOffset ()
 The wiki's time zone offset.
 
 variantsFor (Bcp47Code $lang)
 Language variant information for the given language (or null if unknown).
 
 widthOption ()
 Default thumbnail width.
 
 mwAliases ()
 List all magic words by canonical name.
 
 getMagicWordForFunctionHook (string $str)
 Return canonical magic word for a function hook.
 
 getMagicWordForVariable (string $str)
 Return canonical magic word for a variable.
 
 getMagicWordForMediaOption (string $word)
 Return canonical magic word for a media option.
 
 getMagicWordForBehaviorSwitch (string $word)
 Return canonical magic word for a behavior switch.
 
 isBehaviorSwitch (string $word)
 Check if a string is a recognized behavior switch.
 
 getMagicWordWT (string $word, string $suggest)
 Convert the internal canonical magic word name to the wikitext alias.
 
 getMagicWordMatcher (string $id)
 Get a regexp matching a localized magic word, given its id.
 
 getMediaPrefixParameterizedAliasMatcher ()
 Get a matcher function for fetching values out of interpolated magic words which are media prefix options.
 
 getMaxTemplateDepth ()
 Get the maximum template depth.
 
 getExtResourceURLPatternMatcher ()
 Matcher for ISBN/RFC/PMID URL patterns, returning the type and number.
 
 linterEnabled ()
 
 getLinterSiteConfig ()
 Return the desired linter configuration.
 
 makeExtResourceURL (array $match, string $href, string $content)
 Serialize ISBN/RFC/PMID URL patterns.
 
 getProtocolsRegex (bool $excludeProtRel=false)
 Get a regex fragment matching URL protocols, quoted for an exclamation mark delimiter.
 
 hasValidProtocol (string $potentialLink)
 Matcher for valid protocols, must be anchored at start of string.
 
 findValidProtocol (string $potentialLink)
 Matcher for valid protocols, may occur at any point within string.
 
 linkTrail ()
 Return raw link trail regexp from config.
 
 exportMetadataHelper (Document $document, string $modulesLoadURI, array $modules, array $moduleStyles, array $jsConfigVars, string $htmlTitle, $lang)
 Helper function to create <head> elements from metadata.
 
 getVariableIDs ()
 
 getMagicWords ()
 
 haveComputedFunctionSynonyms ()
 Does the SiteConfig provide precomputed function synonyms? If no, the SiteConfig is expected to provide an implementation for updateFunctionSynonym.
 
 getFunctionSynonyms ()
 Get a list of precomputed function synonyms.
 
 updateFunctionSynonym (string $func, string $magicword, bool $caseSensitive)
 
 getParameterizedAliasMatcher (array $words)
 Get a matcher function for fetching values out of interpolated magic words, ie those with $1 in their aliases.
 
 getSpecialNSAliases ()
 Return name spaces aliases for the NS_SPECIAL namespace.
 
 getSpecialPageAliases (string $specialPage)
 Return Special Page aliases for a special page name.
 
 getProtocols ()
 Get the list of valid protocols.
 
static quoteTitleRe (string $s, string $delimiter='/')
 Quote a title regex.
 

Detailed Description

Site-level configuration interface for Parsoid.

This includes both global configuration and wiki-level configuration.

Constructor & Destructor Documentation

◆ __construct()

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

Base constructor.

This constructor is public because it is used to create mock objects in our test suite.

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\Config\Api\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\ParserTests\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\Config\Api\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\ParserTests\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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ createLogger()

static Wikimedia\Parsoid\Config\SiteConfig::createLogger ( ?string $filePath = null)
static
Parameters
?string$filePathFile to log to (if null, logs to console)
Returns
Logger

◆ exportMetadataHelper()

Wikimedia\Parsoid\Config\SiteConfig::exportMetadataHelper ( Document $document,
string $modulesLoadURI,
array $modules,
array $moduleStyles,
array $jsConfigVars,
string $htmlTitle,
$lang )
protected

Helper function to create <head> elements from metadata.

Parameters
Document$document
string$modulesLoadURI
string[]$modules
string[]$moduleStyles
array<string,mixed>$jsConfigVars
string$htmlTitleThe display title, as escaped HTML
string | Bcp47Code$langa MediaWiki-internal language code string, or a Bcp47Code object (latter is preferred)

◆ exportMetadataToHeadBcp47()

Wikimedia\Parsoid\Config\SiteConfig::exportMetadataToHeadBcp47 ( Document $document,
ContentMetadataCollector $metadata,
string $defaultTitle,
Bcp47Code $lang )
abstract

Export content metadata via meta tags (and via a stylesheet for now to aid some clients).

Parameters
Document$document
ContentMetadataCollector$metadata
string$defaultTitleThe default title to display, as an unescaped string
Bcp47Code$langa BCP-47 language code

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

◆ 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\Mocks\MockSiteConfig, and Wikimedia\Parsoid\ParserTests\SiteConfig.

◆ 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.

◆ getAnnotationStrippers()

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

Returns all the annotationStrippers that are defined as annotation configuration.

Returns
array<AnnotationStripper>

◆ 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)

Return a ContentModelHandler for the specified $contentmodel, if one is registered.

If null is returned, will use the default wikitext content model handler.

Parameters
string$contentmodel
Returns
ContentModelHandler|null

◆ 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

◆ getExternalLinkTarget()

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

◆ 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.

◆ getHtml2WtLimits()

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

◆ getLinterSiteConfig()

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

Return the desired linter configuration.

These are heuristic values which have hardcoded defaults but could be overridden on a per-wiki basis.

Returns
array{enabled?:string[],disabled?:string[],maxTableColumnHeuristic?:int,maxTableRowsToCheck?:int}

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ getLogger()

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

General log channel.

Returns
LoggerInterface

◆ getMagicWordForBehaviorSwitch()

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

Return canonical magic word for a behavior switch.

Parameters
string$word
Returns
string|null

◆ getMagicWordForFunctionHook()

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

Return canonical magic word for a function hook.

Parameters
string$str
Returns
string|null

◆ getMagicWordForMediaOption()

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

Return canonical magic word for a media option.

Parameters
string$word
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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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

◆ getMWConfigValue()

Wikimedia\Parsoid\Config\SiteConfig::getMWConfigValue ( string $key)
abstract

Lookup config.

Parameters
string$key
Returns
mixed|null config value for $key, if present or null, if not.

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

◆ getNoFollowConfig()

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

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ getObjectFactory()

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

Return an object factory to use when instantiating extensions.

(This is assumed to be plumbed up to an appropriate service container.)

Returns
ObjectFactory The object factory to use for extensions
Parameters
string$id
Returns
never
Parameters
string$id
Returns
false

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ getProtocols()

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

Get the list of valid protocols.

Returns
array

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

◆ getProtocolsRegex()

Wikimedia\Parsoid\Config\SiteConfig::getProtocolsRegex ( bool $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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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

◆ haveComputedFunctionSynonyms()

Wikimedia\Parsoid\Config\SiteConfig::haveComputedFunctionSynonyms ( )
protected

Does the SiteConfig provide precomputed function synonyms? If no, the SiteConfig is expected to provide an implementation for updateFunctionSynonym.

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

◆ interwikiMagic()

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

Treat language links as magic connectors, not inline links.

Returns
bool

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

◆ interwikiMap()

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

Interwiki link data.

Returns
array<string,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\Config\Api\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\ParserTests\SiteConfig.

◆ interwikiMapNoNamespaces()

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

Interwiki link data, after removing items that conflict with namespace names.

(In case of such conflict, namespace wins, interwiki is ignored.)

Returns
array<string,array> See interwikiMap()

◆ 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

◆ isBehaviorSwitch()

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

Check if a string is a recognized behavior switch.

Parameters
string$word
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

◆ iwp()

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

Wiki identifier, for cache keys.

Should match a key in mwApiMap()?

Returns
string

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

◆ langBcp47()

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

Wiki language code.

Returns
Bcp47Code BCP-47 language code

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

◆ langConverterEnabledBcp47()

Wikimedia\Parsoid\Config\SiteConfig::langConverterEnabledBcp47 ( Bcp47Code $lang)
abstract

Whether language converter is enabled for the specified language.

Parameters
Bcp47Code$lang
Returns
bool

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

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ linkPrefixRegex()

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

Link prefix regular expression.

Returns
string|null

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

◆ linkTrail()

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

Return raw link trail regexp from config.

Returns
string

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

◆ linkTrailRegex()

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

Link trail regular expression.

Returns
string|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ linterEnabled()

Wikimedia\Parsoid\Config\SiteConfig::linterEnabled ( )
Returns
bool

◆ mainPageLinkTarget()

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

Main page title, as LinkTarget.

Returns
LinkTarget

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

◆ 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, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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 (with spaces, not underscores).

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

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

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ 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.

◆ rtl()

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

Whether the wiki language is right-to-left.

Returns
bool

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

◆ 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\Config\Api\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\ParserTests\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

◆ setLogger()

Wikimedia\Parsoid\Config\SiteConfig::setLogger ( ?LoggerInterface $logger)

Set the log channel, for debugging.

Parameters
?LoggerInterface$logger

◆ 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\Config\Api\SiteConfig, and Wikimedia\Parsoid\Mocks\MockSiteConfig.

◆ tagNeedsNowikiStrippedInTagPF()

Wikimedia\Parsoid\Config\SiteConfig::tagNeedsNowikiStrippedInTagPF ( string $lowerTagName)
Parameters
string$lowerTagName
Returns
bool

◆ timezoneOffset()

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

The wiki's time zone offset.

Returns
int Minutes east of UTC

Reimplemented in Wikimedia\Parsoid\Config\Api\SiteConfig, Wikimedia\Parsoid\Mocks\MockSiteConfig, and Wikimedia\Parsoid\ParserTests\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()

◆ updateFunctionSynonym()

Wikimedia\Parsoid\Config\SiteConfig::updateFunctionSynonym ( string $func,
string $magicword,
bool $caseSensitive )
protected

◆ variantsFor()

Wikimedia\Parsoid\Config\SiteConfig::variantsFor ( Bcp47Code $lang)
abstract

Language variant information for the given language (or null if unknown).

Parameters
Bcp47Code$langThe language for which you want variant information
Returns
?array{base:Bcp47Code,fallbacks:Bcp47Code[]} an array with two fields:
  • base: (Bcp47Code) Base BCP-47 language code (e.g. "zh")
  • fallbacks: (Bcp47Code[]) Fallback variants, as BCP-47 codes

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

◆ widthOption()

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

Member Data Documentation

◆ $html2wtLimits

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

◆ $wt2htmlLimits

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

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