GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing www.mediawiki.org — Parsoid - MediaWiki
For the historic version of Parsoid written in JavaScript (Node.js) until 2020, see Parsoid/JS .
Parsoid is a PHP library that is used for converting back and forth between wikitext and HTML. It has been under development since 2012, originally written in JavaScript and built to support the VisualEditor . It has been bundled with MediaWiki since version 1.35. In MediaWiki 1.47, Parsoid is planned to become MediaWiki's default parser, replacing the current native parser , in a project known as parser unification . Technical detailsParsoid is an application which can translate back and forth between MediaWiki's wikitext syntax and an equivalent HTML/RDFa document model with enhanced support for automated processing and rich editing. It has been under development by a team at the Wikimedia Foundation since 2012. It is currently used extensively by VisualEditor , Content translation and other applications. Parsoid is intended to provide flawless back-and-forth conversion, i.e. to avoid information loss and also prevent "dirty diffs". On Wikimedia wikis, for several applications, Parsoid is currently proxied behind RESTBase , which stores the HTML translated by Parsoid. It is expected that RESTBase will eventually be replaced with a cache more tightly integrated with MediaWiki. For more on the overall project, see this blog post from March 2013. To read about the HTML model being used, see MediaWiki DOM spec. Parsoid was originally structured as a web service and written in JavaScript, making use of GitHub Repository: https://github.com/wikimedia/parsoid Usage
InstallationThis extension comes with MediaWiki 1.35 and later, so you do not need to download it. The remaining configuration instructions must still be followed.
Parsoid has been included in MediaWiki since version 1.35. No configuration is necessary to enable it. Parsoid exports an internal REST API which was historically used by RESTBase and not accessible outside the WMF internal cluster. This is no longer required for Visual Editor or core read views, and the internal API is being deprecated and is planned for removal in MW 1.43. Parsoid is nominally a composer library used by mediawiki core.
If you still require the internal API for some reason, you can explicitly load Parsoid "as an extension" by adding the following to wfLoadExtension( 'Parsoid', "$IP/vendor/wikimedia/parsoid/extension.json" ); Any remaining third-party users of the internal Parsoid API are strongly encouraged to migrate to the core REST HTML page endpoint which provides equivalent functionality. DevelopmentDevelopment happens in the Parsoid Git repository. Code review happens in Gerrit. See Gerrit/Getting started to set up an account for yourself. If you use the MediaWiki-Vagrant development environment using a virtual machine, you can simply add the role The instructions below are for MediaWiki 1.35 or later. Check Parsoid/JS if you are running the old version of Parsoid written in JavaScript, and used for MW 1.34 and earlier. Linking a developer checkout of ParsoidIn a standard MediaWiki installation, Parsoid is included from MediaWiki as a composer library, For development purposes you usually want to use a git checkout of Parsoid, and not the version bundled in MediaWiki core as a composer library. The following lines added to LocalSettings.php allow use of a git checkout of Parsoid (optionally), load the Parsoid REST API with wfLoadExtension (rather than using the version bundled in VisualEditor) and manually do the Parsoid configuration which is usually done by VisualEditor: $parsoidInstallDir = 'vendor/wikimedia/parsoid'; # bundled copy #$parsoidInstallDir = '/my/path/to/git/checkout/of/Parsoid'; // For developers: ensure Parsoid is executed from $parsoidInstallDir, // (not the version included in mediawiki-core by default) // Must occur *before* wfLoadExtension() if ( $parsoidInstallDir !== 'vendor/wikimedia/parsoid' ) { function wfInterceptParsoidLoading( $className ) { // Only intercept Parsoid namespace classes if ( preg_match( '/(MW|Wikimedia\\\\)Parsoid\\\\/', $className ) ) { $fileName = Autoloader::find( $className ); if ( $fileName !== null ) { require $fileName; } } } spl_autoload_register( 'wfInterceptParsoidLoading', true, true ); // AutoLoader::registerNamespaces was added in MW 1.39 AutoLoader::registerNamespaces( [ // Keep this in sync with the "autoload" clause in // $parsoidInstallDir/composer.json 'Wikimedia\\Parsoid\\' => "$parsoidInstallDir/src/", ] ); } wfLoadExtension( 'Parsoid', "$parsoidInstallDir/extension.json" ); unset( $parsoidInstallDir ); Unit tests in
mediawiki-core do not use the standard autoloader (or LocalSettings.php) and so will not pick up your local Parsoid; set MEDIAWIKI_HAS_INTEGRATION_TESTS=1 in your environment to force the use of LocalSettings.php and the autoloader when running core unit tests against your local Parsoid checkout.The If you're serving MediaWiki with Nginx, you'll need to also add something like this in your server block (Assuming your MediaWiki setup has its files residing in location /w/rest.php/ { try_files $uri $uri/ /w/rest.php?$query_string; } If you are running Mediawiki using Docker, and linking your local Parsoid repository to Mediawiki, you need to map additional volume to the docker container in docker-compose.override.yml file in media wiki project. To do so, the simplest way is to create docker-compose.override.yml in mediawiki project and put code bellow inside (with path modification). If you already have docker-compose.override.yml file, modify it accordingly. services: mediawiki: volumes: - ./:/var/www/html/w:cached - /my/path/to/git/checkout/of/Parsoid:/my/path/to/git/checkout/of/Parsoid To test proper configuration, visit Running the testsTo run all parser tests and mocha tests: $ composer test The parser tests have quite a few options now which can be listed using If you have the environment variable $ composer phan-integrated Converting simple wikitextYou can convert simple wikitext snippets from the command line using the $ echo '[[Foo]]' | php bin/parse.php The parse script has a lot of options.
Debugging Parsoid (for developers)See Parsoid/Debugging for debugging tips. Continuous IntegrationParsoid is always available as a library since it is a composer dependency of MediaWiki core. But two pieces are not enabled:
The test runner Quibble would enable it if it detects
The ServiceWiring should be enabled in MediaWiki starting with 1.38. The REST API would theorically never get merged in MediaWiki: a) it has never been exposed to the public in production, it is an internal API used by RESTBase which is going away; b) it never has been security audited and c) it is redundant with the enterprise MediaWiki API. The solution will be for VisualEditor to invoke Parsoid directly via the VisualEditor Action API which would save a round trip through the REST API. Loading the extension is thus a hack which enables using interfaces subject to change and which we don't really want people to use yet. For most purposes, parsoid should thus not be added as a CI dependency, the only exception as of October 2021 is the Disambiguator MediaWiki extension. Loading parsoid as an extension let us run MediaWiki integration test jobs against An extension may be able to write tests with Parsoid even when the repository has not been cloned.
Since it is a composer dependency of MediaWiki core the For CI, Parsoid is tested against the tip of MediaWiki, whereas MediaWiki is tested with the Composer dependency. In case of a breaking change, the Parsoid change get merged first (which breaks its CI but not MediaWiki one) and MediaWiki get adjusted when Parsoid is updated. It is thus a one way change. Release buildFor MediaWiki release builds, we have an integration of Parsoid ServiceWiring into VisualEditor in order to have VisualEditor work without further configuration (beside a Technical documents
Links for Parsoid developers
Links for Parsoid deployers (to the Wikimedia cluster)
HistoryThe original application was written in JavaScript (using Node.js) and started running on the Wikimedia cluster in December 2012. In 2019, Parsoid was ported to PHP, and the PHP version replaced the JS version on the Wikimedia cluster in December 2019. Parsoid is being integrated into core MediaWiki, with the goal of eventually replacing MediaWiki's current native parser. In early 2024, Parsoid began to be used on some production wikis of the Wikimedia Foundation as the default parser for read views. You can see them in the production config list. Parsoid (the PHP version) has been natively bundled with MediaWiki since version 1.35, released in September 2020. For non-Wikimedia installations, Parsoid/JS was supported until the end-of-life of MediaWiki 1.31 (LTS) in September 2021. FAQ
See also
External links
ContactIf you need help or have questions/feedback, you can contact us in #mediawiki-parsoid connect or the wikitext-l mailing list.
If all that fails, you can also contact us by email at
Retrieved from "https://www.mediawiki.org/w/index.php?title=Parsoid&oldid=8696709" Hidden categories:
| |||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |