Provides wikitext handling and tree parsing

4.0.1 2022-09-09 10:00 UTC

This package is auto-updated.

Last update: 2022-09-09 10:02:22 UTC


WikiText for MediaWiki

This code is meant to be executed within the MediaWiki application context. No standalone usage is intended.

Use in a MediaWiki extension

Add "mwstake/mediawiki-component-wikitext": "~3" to the require section of your composer.json file.

Since 2.0 explicit initialization is required. This can be archived by

  • either adding "callback": "mwsInitComponents" to your extension.json/skin.json
  • or calling mwsInitComponents(); within you extensions/skins custom callback method

See also mwstake/mediawiki-componentloader.

Available Services

  • WikitextParserFactory
  • WikitextNodeProcessorRegistryFactory

Using the MenuParser

/* @var MediaWiki\Storage\RevisionRecord */
$revision = $this->getRevision();

/* @var MWStake\MediaWiki\Component\Wikitext\ParserFactory */
$parserFactory = MediaWiki\MediaWikiServices::getInstance()->get( 'WikitextParserFactory' );

/* @var MWStake\MediaWiki\Component\Wikitext\Parser\MenuParser */
$menuParser = $parserFactory->newMenuParser( $revision );

/* @var MWStake\MediaWiki\Component\Wikitext\INode[] */
$nodes = $parser->parse();