### Install Parsoid Node.js Dependencies Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/setup.md After cloning the repository, execute this command from the main Parsoid directory to install all required Node.js packages and dependencies using npm. ```Shell $ npm install ``` -------------------------------- ### Install Parsoid Dependencies and Run Tests Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/README.md Instructions to navigate to the project root, install Node.js dependencies, and execute the test suite for the Parsoid project. ```Shell cd .. npm test ``` -------------------------------- ### Run Parsoid API Server Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/setup.md This command starts the Parsoid API server, which is primarily used by VisualEditor for backend operations. Users can customize settings by copying and modifying `config.example.yaml`. ```Shell $ node bin/server ``` -------------------------------- ### MediaWiki Parser Configuration Example Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/sectionWrappingParserTests.txt An example of a JSON configuration setting, likely related to how sections are handled during parsing, indicating that sections should be wrapped. ```JSON { "wrapSections": true } ``` -------------------------------- ### Test Case 2: Basic Content Rendering with Generic HTML Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/phpunit/Parsoid/ParserTests/data/basicTests.txt This second test case illustrates the rendering of 'Hello 2' content, showing both the original wikitext input and its corresponding generic HTML output. It serves as a straightforward example of content transformation from wikitext to standard HTML. ```wikitext Hello 2 ``` ```html

Hello 2

``` -------------------------------- ### Clone Parsoid Git Repository Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/setup.md This command clones the Parsoid source code repository from Gerrit, making the project files available locally for setup and development. ```Shell $ git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid ``` -------------------------------- ### Launch Parsoid HTTP API Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md Starts Parsoid's HTTP API server, allowing developers to verify appropriate responses directly in a web browser. This is useful for interactive testing of the API's behavior. ```Bash npm start ``` -------------------------------- ### Wikitext Test Setup: Template and Article Definition Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/separatorTests.txt This section defines a simple template `Template:1x` that expands its first parameter, and an `article` block that uses this template. This setup is foundational for subsequent tests demonstrating separator handling. ```Wikitext Template:1x !! text {{{1}}} ``` -------------------------------- ### Convert Inline Dummyanno Tags Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test verifies the conversion of inline 'dummyanno' tags in wikitext to HTML, ensuring the correct placement of start and end meta tags for the annotation. ```wikitext Some text with some annotated content inline. ``` ```html/parsoid

Some text with some annotated content inline.

``` -------------------------------- ### Example: Get Parsoid Daemon Version using cURL Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/apiuse.md Demonstrates how to use the `curl` command-line tool to query the `/_version` endpoint and retrieve the Parsoid daemon's version information. The expected response is a JSON object containing `name`, `version`, and `sha`. ```Shell curl http://localhost:8000/_version ``` -------------------------------- ### Running Parsoid API Server for Testing Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md Instructions for testing the Parsoid API server by running `npm start` and verifying its response by loading a specific page, such as French Wikipedia's page on Obama, to ensure accurate and semantically consistent output. ```Shell npm start ``` -------------------------------- ### Handling Multiple Spaces at Start-of-Line Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/indentPre.txt Examines how multiple leading spaces at the start of a line in wikitext are interpreted, distinguishing between preformatted text, HTML tags, and table syntax. ```Wikitext

foo

\n foo\n\t{|\n|foo\n|} ``` ```HTML

foo

\n
   foo\n
\n\n\n
foo\n
``` -------------------------------- ### GNU GPL Interactive Program Startup Notice Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/COPYING.txt A sample short notice to be displayed by interactive programs when they start. This message informs users about the program's warranty status and directs them to commands for more details on redistribution conditions under the GNU GPL. ```plaintext Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Parsoid Test Configuration for Annotation Fostering Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt Configuration options for the Parsoid test, specifying the modes for conversion (wikitext to HTML, selective serialization, wikitext to wikitext) and enabling annotations. ```JSON parsoid={ "modes": ["wt2html", "selser","wt2wt"] } annotations=1 ``` -------------------------------- ### Install Dumpgrepper Utility Globally Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/README.md Command to install the `dumpgrepper` utility globally using npm. This utility is designed for efficiently searching large XML dumps with JavaScript regular expressions. ```Shell npm install -g dumpgrepper ``` -------------------------------- ### Serializing Indent Pre at Start-of-Line Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/indentPre.txt Tests the serialization of preformatted text blocks that start at the beginning of a line in wikitext, and their corresponding HTML output. ```Wikitext hi ``` ```Parsoid HTML
hi
``` ```PHP HTML
hi\n
``` -------------------------------- ### Converting a Simple Wikitext Table to HTML Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt This example illustrates the basic conversion of a two-row, two-column MediaWiki wikitext table into its standard HTML representation, showing how rows and cells are structured. ```wikitext {| |1||2 |- |3||4 |} ``` ```html
1 2
3 4
``` -------------------------------- ### Submitting Code Changes with Git and Gerrit Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md A sequence of Git commands (`git add`, `git commit`, `git review`) used to stage, commit, and submit code changes to the Parsoid project for review via Gerrit, assuming `git-review` is installed and configured. ```Shell $ git add # any files you changed $ git commit # enter a commit summary $ git review # send it for review ``` -------------------------------- ### Wikitext Template '1x' Content Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This snippet shows the Wikitext content for a MediaWiki template named '1x'. When this template is used (transcluded) on a page, it will display the value passed as its first unnamed parameter. ```Wikitext {{{1}}} ``` -------------------------------- ### Test Case 1: Basic Content Rendering Across Formats Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/phpunit/Parsoid/ParserTests/data/basicTests.txt This test case demonstrates the rendering of simple 'Hello' content across different output formats. It includes the original wikitext input, its corresponding HTML generated by a PHP process, and HTML specifically generated by Parsoid, highlighting potential differences in output. ```wikitext Hello ``` ```html/php

Hello legacy

``` ```html/parsoid

Hello parsoid

``` -------------------------------- ### Wikitext Redirect Syntax Not at Start of Line Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/redirects.txt Confirms that `#redirect` syntax is only recognized as a page redirect if it appears at the very beginning of the wikitext content. If preceded by other text, it's rendered as a regular list item, not a redirect. ```Wikitext some text #redirect [[Main Page]] ``` ```HTML

some text

  1. redirect Main Page
``` -------------------------------- ### Indentation: Missing first level Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/definitionLists.txt Tests indentation starting from the second level, verifying that the parser correctly creates the necessary parent `
` structures. ```Wikitext ::i2 :::i3 ``` ```HTML
i2
i3
``` -------------------------------- ### Basic dummyanno Annotation Parsing Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt Illustrates the fundamental parsing of a `dummyanno` tag, showing how it generates a `meta` tag for the annotation and how subsequent text is rendered in a paragraph. The `data-parsoid` and `data-mw` attributes contain range and offset information. ```Wikitext Let's have some text. plop Let's have some text. ``` ```HTML

plop

Let's have some text.

``` -------------------------------- ### Parsoid Test Configuration and Article Setup Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/interwikiLinks.txt Defines initial options for Parsoid parser tests and sets up standard articles ('Main Page', 'Foo', 'Template:Foo') that are assumed to exist for the subsequent tests. The 'parsoid-compatible' option is relevant when running parser tests in integrated mode with Parsoid. ```Configuration parsoid-compatible=wt2html,wt2wt version=2 ``` ```Wikitext (Article Definition) Main Page !! text blah blah ``` ```Wikitext (Article Definition) Foo !!text FOO ``` ```Wikitext (Article Definition) Template:Foo !!text FOO ``` -------------------------------- ### Generic Wikitext to HTML Conversion Test Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/phpunit/Parsoid/ParserTests/data/testsWithKnownFailures.txt This snippet provides a second example of wikitext to HTML conversion, using 'Hello 2' as input. It illustrates a general HTML output, useful for verifying basic rendering functionality and consistency across different conversion scenarios. ```wikitext Hello 2 ``` ```html

Hello 2

``` -------------------------------- ### Timing Metrics for HTML to Wikitext Conversion in Parsoid Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/metrics.md Documents performance metrics for converting edited HTML back to wikitext, including initialization, selser setup, preprocessing, DOM diff computation, and total serialization time. ```APIDOC Metric: html2wt.init Description: Covers time to parse edited HTML and original HTML, including pagebundles. Location: Rest/Handler/ParsoidHandler.php Metric: html2wt.setup Description: Covers time to set up selser (selective serialization). Location: Wikitext/ContentHandler.php Metric: html2wt.preprocess Description: Covers time to run any extension preprocessors (currently none as of March 2022). Location: Wikitext/ContentHandler.php Metric: html2wt.selser.domDiff Description: Covers time to compute DOM diff between original and edited DOMs. Location: Html2Wt/SelectiveSerializer.php Metric: html2wt.selser.serialize Description: Covers total time to convert HTML to wikitext after selser setup, including html2wt.selser.domDiff. Location: Html2Wt/SelectiveSerializer.php Metric: html2wt.total Description: Covers the total request time within Parsoid, including all html2wt components. Location: Rest/Handler/ParsoidHandler.php ``` -------------------------------- ### Demonstrate f3_uc Parser Function for Uppercase Conversion Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/pFragmentHandlerTests.txt This snippet shows the basic usage of the `#f3_uc` parser function to convert input text to uppercase. It includes examples with simple strings and nested parser functions. ```MediaWiki Wikitext {{#f3_uc:lower UPPER}} {{#f3_uc:{{1x|foo}}}} ``` ```HTML

LOWER UPPER

FOO

``` -------------------------------- ### Parsoid Wikitext to HTML Conversion Test: Hello Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/phpunit/Parsoid/ParserTests/data/testNoEndTag.txt This test case demonstrates the conversion of the wikitext 'test 1' into its corresponding HTML output '

test 1

'. It serves as a basic example of Parsoid's rendering capabilities for simple text. ```wikitext test 1 ``` ```html

test 1

``` -------------------------------- ### Indent-Pre started by table-line syntax Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/indentPre.txt This test explores how a preformatted block is initiated when a line of text is followed by lines that resemble table-line syntax but are indented, showing the different interpretations by PHP and Parsoid HTML renderers. ```wikitext a | b | c ``` ```html/php

a

| b
| c
``` ```html/parsoid

a

| b
| c
``` -------------------------------- ### Extend dummyanno Range to Nested Italic Tag Start Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt Demonstrates how a `dummyanno` tag starting at the beginning of a paragraph and ending inside an italicized section (``) extends its range to cover the entire italicized content, rather than the whole paragraph. Parsoid options include `wt2html`, `selser`, and `wt2wt` modes with annotations enabled. ```Wikitext This should ''fail miserably'' ... let's fix it ``` ```HTML

This should fail miserably ... let's fix it

``` -------------------------------- ### Get Full Page Name: {{FULLPAGENAME}} Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/magicWords.txt Demonstrates the {{FULLPAGENAME}} magic word, which returns the full name of the current page, including its namespace. This example uses a page title with special characters to show its unencoded output. ```Wikitext {{FULLPAGENAME}} ``` ```HTML/PHP

User:Ævar Arnfjörð Bjarmason

``` ```HTML/Parsoid

User:Ævar Arnfjörð Bjarmason

``` -------------------------------- ### Selser: Insert lists before dummyanno tags, ensuring correct newlines Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test checks the Selser's ability to insert a new list *before* `dummyanno` tags, ensuring that the wikitext output includes the appropriate number of newlines for list formatting. ```JSON { "modes": ["selser"], "changes": [ ["meta", "before", "
  • plop
"] ] } ``` ```Wikitext ==title== some paragraph hello some other paragraph ``` ```Wikitext ==title== some paragraph * plop hello * plop some other paragraph ``` -------------------------------- ### Selser: Insert lists after dummyanno tags, ensuring correct newlines Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test verifies how the Selser handles the insertion of a new list *after* `dummyanno` tags, specifically checking for the correct newlines to maintain proper wikitext list formatting. ```JSON { "modes": ["selser"], "changes": [ ["meta", "after", "
  • plop
"] ] } ``` ```Wikitext ==title== some paragraph hello some other paragraph ``` ```Wikitext ==title== some paragraph * plop hello * plop some other paragraph ``` -------------------------------- ### Handle Template Inside Dummyanno Tag Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test confirms that the presence of a template ('{{1x|...}}') inside a 'dummyanno' tag does not interfere with the annotation's conversion to HTML, ensuring proper nesting and 'rangeId' generation. ```wikitext {{1x| == Title == }} Let's have some text. ``` ```html/parsoid

Title

Let's have some text.

``` -------------------------------- ### External Links: No Preceding Word Characters Allowed (T67278) Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/extLinks.txt This test case illustrates the rule that free external links are only recognized if they are preceded by non-word characters or start a new line. It shows examples where a URL is not linked if immediately preceded by letters or numbers, but is linked if preceded by punctuation. ```wikitext NOPEhttp://example.com N0http://example.com ok:http://example.com ok-http://example.com ``` -------------------------------- ### Parsoid Wikitext to HTML Conversion Test: Hello 2 Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/phpunit/Parsoid/ParserTests/data/testNoEndTag.txt This test case illustrates the conversion of the wikitext 'test 2' into its corresponding HTML output '

test 2

'. It provides another simple example of how Parsoid processes wikitext into HTML. ```wikitext test 2 ``` ```html

test 2

``` -------------------------------- ### Selser: Insert content before and after dummyanno tags, preserving paragraphs Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test confirms that the Selser can insert new paragraph content both before and after `dummyanno` tags, maintaining proper paragraph structure and annotation integrity in the edited wikitext. ```JSON { "modes": ["selser"], "changes": [ ["meta", "before", "

plop

"], ["meta", "after", "

plop2

"] ] } ``` ```Wikitext hello ``` ```Wikitext plop plop2 hello plop plop2 ``` -------------------------------- ### Selser: Insert headings before dummyanno tags, ensuring correct newlines Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test verifies the Selser's behavior when inserting a new heading *before* `dummyanno` tags, focusing on the correct generation of newlines for proper wikitext structure. ```JSON { "modes": ["selser","wt2wt"], "changes": [ ["meta", "before", "

plop

"] ] } ``` ```Wikitext ==title== some paragraph hello some other paragraph ``` ```Wikitext ==title== some paragraph == plop == hello == plop == some other paragraph ``` -------------------------------- ### Run Parsoid Roundtrip Tests Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md Initiates roundtrip tests on two representative pages to ensure that wikitext can be converted to HTML and back without loss of information. This helps verify the integrity of the parsing and serialization process. ```Bash npm run roundtrip ``` -------------------------------- ### Extend dummyanno Range to Nested Italic Tag End Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt Illustrates how a `dummyanno` tag starting within an italicized section (``) and ending at the paragraph's conclusion extends its range to encompass the entire italicized content, not the whole paragraph. Parsoid options include `wt2html`, `selser`, and `wt2wt` modes with annotations enabled. ```Wikitext This should ''fail miserably'' ... let's fix it ``` ```HTML

This should fail miserably ... let's fix it

``` -------------------------------- ### Selser: Insert content before dummyanno tags, preserving paragraphs Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test verifies the Selser's ability to insert new paragraph content *before* `dummyanno` tags, ensuring the original annotation and surrounding paragraphs are correctly handled in the edited wikitext. ```JSON { "modes": ["selser"], "changes": [ ["meta", "before", "

plop

"] ] } ``` ```Wikitext hello ``` ```Wikitext plop hello plop ``` -------------------------------- ### Selser: Insert content after dummyanno tags, preserving paragraphs Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test checks if the Selser correctly inserts new paragraph content *after* `dummyanno` tags, maintaining the integrity of the annotation and surrounding paragraphs in the edited wikitext. ```JSON { "modes": ["selser"], "changes": [ ["meta", "after", "

plop2

"] ] } ``` ```Wikitext hello ``` ```Wikitext plop2 hello plop2 ``` -------------------------------- ### Handle Poorly Nested Annotation Range with Code Tag (T325575) Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt Demonstrates Parsoid's ability to correctly parse and convert wikitext with poorly nested annotation ranges, specifically when a `` tag is involved. The test ensures that Parsoid automatically inserts start and end tags to create a valid HTML structure while preserving the content and annotation metadata. ```wikitext hello ``` ```html/parsoid

hello

``` -------------------------------- ### Run Parsoid Unit and Parser Tests Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md Executes the main test suite for Parsoid, which includes parserTests.js, unit tests with Mocha, and various code style checkers. This is a comprehensive test to verify changes. ```Bash npm test ``` -------------------------------- ### Wikitext to HTML Conversion: Definition List with Bracketed URL Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/definitionLists.txt Shows the conversion of a wikitext definition list term containing a bracketed external URL with custom text (`[http://www.example.com/ Example]`) into an HTML link (``). This verifies the parsing of explicit external links. ```Wikitext ;[http://www.example.com/ Example]:Something about it ``` ```HTML
Example
Something about it
``` -------------------------------- ### Display Parser Test Options Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md Shows all available command-line options for the parser test suite. This is helpful for understanding and customizing test execution, including different parsing modes like `--wt2html` or `--html2wt`. ```Bash node bin/parserTests --help ``` -------------------------------- ### Wikitext Template Expanded Content Wrapping (1c) Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/indentPre.txt Illustrates that preformatting wrapping is based on the *expanded* content of a template. A line starting with a space in the expanded content becomes preformatted, while subsequent lines without a leading space become paragraphs. ```wikitext {{1x|a b}} ``` ```html
a

b

``` -------------------------------- ### Selser: T295330 - DSR computation with dummyanno and category Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test case, related to task T295330, ensures that the DSR (Document Structure Representation) computation correctly handles `dummyanno` annotations and categories, allowing for proper Selser operations. It demonstrates the HTML output generated by Parsoid. ```JSON { "annotations": 1 } ``` ```Wikitext '''The quick brown fox jumps over the lazy dog.''' [[Category:Foo]] ``` ```HTML

The quick brown fox jumps over the lazy dog.

``` -------------------------------- ### Selser: Insert headings after dummyanno tags, ensuring correct newlines Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test examines how the Selser handles the insertion of a new heading *after* `dummyanno` tags, specifically checking for the correct number of newlines to maintain proper wikitext formatting. ```JSON { "modes": ["selser"], "changes": [ ["meta", "after", "

plop

"] ] } ``` ```Wikitext ==title== some paragraph hello some other paragraph ``` ```Wikitext ==title== some paragraph == plop == hello == plop == some other paragraph ``` -------------------------------- ### Indent-Pre and Table-Line Syntax (Preformatted block) Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/indentPre.txt This test demonstrates how lines starting with a space, followed by what looks like table-line syntax (| b, | c), are interpreted as part of a preformatted block in PHP HTML output, rather than table content. ```wikitext a | b | c ``` ```html/php
a
| b
| c
``` -------------------------------- ### MediaWiki Wikitext Input for Template Continuity Test Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt The MediaWiki wikitext input demonstrating a template `{{1x|...}}` containing text, a table, and a `dummyanno` annotation. This wikitext is designed to test how annotations interact with transcluded table content. ```Wikitext {{1x|Some text!

first fostered

}}

last fostered

table
stuff
``` -------------------------------- ### ISBN Magic Link Rendering Example Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/magicLinks.txt An example of an ISBN magic link rendered by Parsoid, showing the `data-parsoid` attribute for structural information and `mw:Entity` for preserving spaces. ```html

ISBN 978-0-1234-56 789

``` -------------------------------- ### Test Parsoid Parse Tool with Wikitext Input Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md Demonstrates how to use the `parse.js` tool to test parser and serializer features by piping a sample wikitext string as input. This command exercises a reasonable number of features, though not as comprehensively as the full parser test suite. ```Bash echo "''Non'''-trivial'' wikitext''' [[with links]] {{echo|and templates}} | node bin/parse --wt2wt ``` -------------------------------- ### Execute Parsoid Parser Tests Directly Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md Runs the parser tests (parserTests.js) directly using Node.js. This command can be noisy, but provides detailed output on test failures. Options like `--quiet` can reduce verbosity. ```Bash node bin/parserTests ``` -------------------------------- ### Example Free External Link with Percent-Encoded Ampersand Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/extLinks.txt An initial example demonstrating the HTML output for a free external link where the URL contains a percent-encoded ampersand (%26). This shows the basic rendering of such a link by Parsoid. ```html/parsoid

http://www.example.com/?title=AT%26T

``` -------------------------------- ### Table with Empty Line After Start Tag Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt Illustrates Parsoid's parsing of tables that include an empty line directly after the table start tag ({|) but before the first row definition. This tests whitespace handling at the table's beginning. ```wikitext {| |- |foo |} ``` ```html/*
foo
``` -------------------------------- ### MediaWiki Template: tbl-start Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt Defines a MediaWiki template 'tbl-start' that outputs the Wikitext syntax for initiating a table. ```Wikitext {| ``` -------------------------------- ### GNU GPL License Notice for Source Files Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/COPYING.txt A template for the license notice that should be attached to the beginning of each source file of a program released under the GNU General Public License. It specifies copyright details, redistribution rights, and disclaims all warranties. ```plaintext Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ``` -------------------------------- ### T265737: 1. Relax section start requirements to reduce unnecessary conflicts between template and section boundaries Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/sectionWrappingParserTests.txt This test examines how section wrapping interacts with templates, specifically when a section starts immediately after a template. It compares the HTML output from the PHP parser and Parsoid, with 'wrapSections' enabled. ```Wikitext = x = {{Foobar1}} y ``` ```HTML/PHP

x

[edit]

bar

[edit]

baz y

``` ```HTML/Parsoid

x

bar

baz y

``` -------------------------------- ### Example Wikitext for Table Conversion Template Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/design.md This wikitext example demonstrates a 'convert' template used within a table, which can cause issues when the construct is split across top-level content and templates. This specific pattern affects pages like enwiki:List_of_largest_container_ships and requires generalization of the 'TableFixups.php' code. ```Wikitext {|\n|{{convert| 400|m|ft|disp=table|sortable=on}}\n|} ``` -------------------------------- ### Convert Whole Content Wrapped by Dummyanno Tags Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/annotationParserTests.txt This test checks how Parsoid converts wikitext with a 'dummyanno' tag wrapping an entire section (including a heading and a paragraph) into HTML, ensuring correct meta tag placement and 'rangeId' generation. ```wikitext ==Title== Let's have some text. ``` ```html/parsoid

Title

Let's have some text.

``` -------------------------------- ### Table Test: Stray Table End Tags on Start Line Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt Examines how Parsoid and PHP handle tables with stray `|}` (table end) tags on the same line as the table start tag (`{|`), and with or without additional attributes like `id`. This test covers multiple variations of this syntax. ```Wikitext {|style="color: red;"|} {|style ``` -------------------------------- ### RFC 2373 IPv6 Address Type URL Examples Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/extLinks.txt Illustrates different types of IPv6 addresses (unicast, multicast, loopback, unspecified, and IPv4-compatible) when used as literals in URLs, based on RFC 2373, section 2.2. These examples highlight the specific syntax for each address type. ```URL Syntax http://[1080::8:800:200C:417A]/unicast ``` ```URL Syntax http://[FF01::101]/multicast ``` ```URL Syntax http://[::1]/loopback ``` ```URL Syntax http://[::]/unspecified ``` ```URL Syntax http://[::13.1.68.3]/ipv4compat ``` ```URL Syntax http://[::FFFF:129.144.52.38]/ipv4compat ``` -------------------------------- ### Handling Ready Asynchronous Content with f6_async_return Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/pFragmentHandlerTests.txt This test demonstrates the `f6_async_return` parser function when the content is immediately available ('ready' case). It shows how the function processes the 'ready' state and outputs the specified content without any fallback. ```wikitext Content is ready: {{#f6_async_return:ready|Ready!}} ``` ```html

Content is ready: Ready!

``` -------------------------------- ### T265737: 2. Relax section start requirements to reduce unnecessary conflicts between template and section boundaries Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/sectionWrappingParserTests.txt This test further explores section wrapping and template interactions, specifically when a section starts after a template that includes comments and page properties. It compares the HTML output from the PHP parser and Parsoid, with 'wrapSections' enabled. ```Wikitext = x = {{Foobar2}} y ``` ```HTML/PHP

x

[edit]


bar

[edit]

baz y

``` ```HTML/Parsoid

x

bar

baz y

``` -------------------------------- ### Configure Git Remote for Gerrit Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/devsetup.md This command adds a Gerrit remote to your local Git repository, enabling you to submit patches to the Parsoid project. Replace with your actual Gerrit username. ```Bash git remote add gerrit ssh://@gerrit.wikimedia.org:29418/mediawiki/services/parsoid ``` -------------------------------- ### Convert Wikitext to HTML using Parsoid Parse Tool Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/setup.md This command demonstrates using the `parse.js` script to convert a simple wikitext string into HTML. The tool supports various conversion options like `--wt2wt`, `--html2wt`, and `--html2html`, and `--normalize=parsoid` for cleaner output. ```Shell $ echo "some harmless [[wikitext]]" | node tests/parse ``` -------------------------------- ### RFC 2732 IPv6 Address URL Syntax Examples Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/extLinks.txt Demonstrates various forms of IPv6 literal addresses within URLs, including full, compressed, and IPv4-mapped addresses, as defined in RFC 2732, section 2. These examples show how to correctly format IPv6 addresses when used as hostnames in URLs. ```URL Syntax http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html ``` ```URL Syntax http://[1080:0:0:0:8:800:200C:417A]/index.html ``` ```URL Syntax http://[3ffe:2a00:100:7031::1] ``` ```URL Syntax http://[1080::8:800:200C:417A]/foo ``` ```URL Syntax http://[::192.9.5.5]/ipng ``` ```URL Syntax http://[::FFFF:129.144.52.38]:80/index.html ``` ```URL Syntax http://[2010:836B:4179::836B:4179] ``` -------------------------------- ### MediaWiki Template: 1x Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt Defines a simple MediaWiki template '1x' that takes one unnamed parameter and outputs its value. ```Wikitext {{{1}}} ``` -------------------------------- ### GNU GPL Copyright Disclaimer Sample Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/COPYING.txt A template for a copyright disclaimer that an employer or school might sign to relinquish their copyright interest in a program written by an employee or student, thereby allowing the program to be released under the GNU GPL. ```plaintext Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice ``` -------------------------------- ### Handling Not Ready Asynchronous Content with f6_async_return Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/pFragmentHandlerTests.txt This snippet illustrates the `f6_async_return` parser function's behavior when content is not immediately ready ('not ready' case). It demonstrates both the default fallback mechanism and the use of a custom fallback message provided as an argument. ```wikitext Default fallback content: {{#f6_async_return:not ready}} Specified fallback content: {{#f6_async_return:not ready|My own fallback}} ``` ```html

Default fallback content:

Specified fallback content: My own fallback

``` -------------------------------- ### Get Talk Namespace Name: {{TALKSPACE}} in Main Namespace Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/magicWords.txt Illustrates the behavior of {{TALKSPACE}} when the current page is in the main (article) namespace. In this scenario, it returns 'Talk', which is the default talk namespace. ```Wikitext {{TALKSPACE}} ``` ```HTML/PHP

Talk

``` ```HTML/Parsoid

Talk

``` -------------------------------- ### Display ParserTests Command-Line Options Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/README.md Command to view the available command-line options and help information for the `parserTests.js` utility. ```Shell node bin/parserTests.js --help ``` -------------------------------- ### Simple Key-Value Return with f7_kv Parser Function Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/pFragmentHandlerTests.txt This test case verifies the basic functionality of the `f7_kv` parser function. It demonstrates its ability to process and return key-value pair arguments in a straightforward manner, showing the direct output of the function. ```wikitext {{#f7_kv:foo=bar|bat=baz}} ``` ```html

(arguments)

``` -------------------------------- ### Run Parsoid Parser Tests Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/README.md Command to execute the `parserTests.js` script, which requires MediaWiki's `parserTests.txt` file. This script is used for running parser-specific tests. ```Shell node bin/parserTests.js ``` -------------------------------- ### MediaWiki Test Environment Configuration Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/pFragmentHandlerTests.txt Sets up the necessary MediaWiki environment for Parsoid tests, including global options, a simple template, and two articles (one with a redirect) to be used as test data. ```MediaWiki Options parsoid-compatible=wt2html version=2 ``` ```MediaWiki Template Template:1x !! text {{{1}}} ``` ```MediaWiki Article Foo !! text Define [[Foo]] to avoid a red link ``` ```MediaWiki Redirect FOO !! text #REDIRECT [[Foo]] ``` -------------------------------- ### Converting Multi-line Wikitext Table Captions to HTML Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt This example demonstrates how multi-line captions in MediaWiki wikitext tables are rendered in HTML, preserving the line breaks within the caption element. ```wikitext {| |+line 1 of caption line 2 of caption |data |} ``` ```html
line 1 of caption line 2 of caption
data
``` -------------------------------- ### Render Simple Thumbnailed Video Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/timedMediaHandlerParserTests.txt Illustrates the rendering of a video with the `|thumb` option in wikitext, showing how it generates a `
` element with a smaller video player and a thumbnail image. ```Wikitext [[File:Video.ogv|thumb]] ``` ```HTML/PHP
``` ```HTML/Parsoid
``` -------------------------------- ### Parsoid HTML Attributes for Page Reading Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/data.md HTML attributes are used for information essential for reading the page, including client-side JavaScript uses like styling. Examples include `typeof` and `about` for template identification. ```APIDOC HTML Attributes: typeof: string Purpose: Identifies the type of an HTML element, often used for template identification. Usage:
...
about: string Purpose: Links an HTML element to a resource, often used in conjunction with typeof for template identification. Usage:
...
``` -------------------------------- ### Parse Row-syntax Table Cells Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt Tests the parsing of table cells where the row starts with a table cell, specifically demonstrating how newlines and '||' delimiters are handled within a single row. ```Wikitext {| |a b||c |} ``` ```HTML
a

b||c

``` -------------------------------- ### Get Talk Namespace Name: {{TALKSPACE}} in User Talk Namespace Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/magicWords.txt Demonstrates {{TALKSPACE}} when the current page is already in a talk namespace (e.g., 'User talk:'). It correctly returns the name of that same talk namespace. ```Wikitext {{TALKSPACE}} ``` ```HTML/PHP

User talk

``` ```HTML/Parsoid

User talk

``` -------------------------------- ### Timing Metrics for Language Conversion in Parsoid Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/docs/metrics.md Documents performance metrics for the language converter, including initialization times (general and variant-specific) and total conversion times. ```APIDOC Metric: langconv.init Description: Covers initialization time for the language converter. Location: LanguageConverter.php Metric: langconv.$HTMLVARIANT.init Description: Covers initialization time, split by HTML variants. Location: LanguageConverter.php Metric: langconv.total Description: Covers time to convert to the requested HTML variant. Location: LanguageConverter.php Metric: langconv.$HTMLVARIANT.total Description: Covers time to convert to the requested HTML variant, split by variants. Location: LanguageConverter.php Metric: langconv.totalWithInit Description: Includes both langconv.init and langconv.total. Location: LanguageConverter.php ``` -------------------------------- ### Parsoid HTML Output for Section Parsing Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/sectionWrappingParserTests.txt Displays the HTML structure generated by Parsoid for the wikitext examples. This output includes Parsoid-specific metadata attributes like `data-parsoid` and `data-mw-section-id`, which are used for round-tripping and semantic preservation. ```HTML

PHP section=1

Not a section

PHP section=3

``` -------------------------------- ### Applying __NOGALLERY__ Magic Word and Flag Setting Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/magicWords.txt This example illustrates how the __NOGALLERY__ magic word in wikitext is processed by Parsoid, resulting in an HTML property and the setting of the 'mw-NoGallery' flag in the page's metadata. ```Wikitext __NOGALLERY__ ``` ```HTML ``` ```APIDOC flags=mw-NoGallery ``` -------------------------------- ### Wikitext to HTML Conversion: Simple Definition List Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/definitionLists.txt Demonstrates the conversion of a basic wikitext definition list (`:name :Definition`) into its corresponding HTML `
` structure, showing standard parsing behavior. ```Wikitext ;name :Definition ``` ```HTML
name
Definition
``` -------------------------------- ### Parsoid Wikitext to HTML Transformation Test Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/phpunit/Parsoid/ParserTests/data/twoVersionsDecl.txt This is a test test. Demonstrates the transformation of 'Hello' wikitext into HTML by both legacy PHP and Parsoid parsers, verifying consistent output. ```Wikitext Hello ``` ```HTML/PHP

Hello legacy

``` ```HTML/Parsoid

Hello parsoid

``` -------------------------------- ### Basic Wikitext to HTML Conversion Test (Parsoid) Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/phpunit/Parsoid/ParserTests/data/testsWithKnownFailures.txt This test case demonstrates the conversion of a simple 'Hello' wikitext input into HTML. It shows the output from both a legacy PHP rendering engine and the Parsoid service, highlighting potential differences in HTML structure and rendering. ```wikitext Hello ``` ```html/php

Hello legacy

``` ```html/parsoid

Hello parsoid

``` -------------------------------- ### Get Encoded Talk Namespace Name: {{TALKSPACEE}} Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/magicWords.txt Shows the {{TALKSPACEE}} magic word, which returns the URL-encoded name of the talk namespace corresponding to the current page's namespace. For a 'User:' page, it returns 'User_talk'. ```Wikitext {{TALKSPACEE}} ``` ```HTML/PHP

User_talk

``` ```HTML/Parsoid

User_talk

``` -------------------------------- ### Wikitext Preformatting with Inline Content Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/indentPre.txt Demonstrates how preformatted text interacts with inline formatting. The example shows that inline formatting like italics (`''b''`) is correctly preserved and rendered within the `
` block.

```wikitext
 a
 ''b''
```

```html
a
b
``` -------------------------------- ### MediaWiki Article: Main Page Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/tables.txt Defines the standard 'Main Page' article content assumed to exist for testing purposes. ```Wikitext blah blah ``` -------------------------------- ### CSS for Resetting MediaWiki Reference Back-link Counter Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tools/cite_css/generated.parsoid.cite.css.output.txt Defines the CSS rule to reset the 'mw-ref-linkback' counter for elements that serve as containers for reference back-links. This ensures that the numbering or lettering for back-links starts correctly. ```CSS span[ rel="mw:referencedBy" ] { counter-reset: mw-ref-linkback 0; } ``` -------------------------------- ### Resetting MediaWiki Reference Linkback Counter Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tools/cite_css/generated.parsoid.cite.css.output.txt This CSS rule initializes the 'mw-ref-linkback' counter to 0 for elements that serve as containers for referenced content. This ensures that reference numbering starts correctly within each context. ```CSS span[ rel="mw:referencedBy" ] { counter-reset: mw-ref-linkback 0; } ``` -------------------------------- ### Parsoid Test Configuration Options Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/definitionLists.txt Defines the parsoid-compatible modes and version for integrated parser tests, specifying how wikitext should be converted to HTML and back, and the version of the test suite. ```Configuration parsoid-compatible=wt2html,wt2wt version=2 ``` -------------------------------- ### Render Simple Video Element Source: https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/tests/parser/timedMediaHandlerParserTests.txt Demonstrates how a basic `[[File:Video.ogv]]` wikitext link is rendered into HTML by both MediaWiki's PHP parser and Parsoid, producing a standard HTML5 `