Specs/wikitext/1.0.0

MediaWiki's Wikitext flavor is primarily defined by its implementations in MediaWiki itself and Parsoid. These entry points should be helpful:
 * Wikitext - an August 2016 attempt to centralize the definition of MediaWiki Wikitext
 * The Wikitext Help page on Wikipedia.org provides a high-level overview.
 * parserTests.txt defines over 1000 input / output pairs, which are executed in CI tests for both the PHP parser and Parsoid

Changes to whitespace behavior as of RFC T157418
Leading and trailing whitespace is trimmed in table cells, table headings, table captions, list items (ordered, unordered, definition), section headers that are generated by native wikitext markup. Whitespace in HTML tags is left untouched.

Examples:

Historical context
Till June 2018, HTML4-Tidy was being used to clean up the HTML generated by the PHP parser. Among other things, Tidy also did a whitespace cleanup of HTML. So, it removed leading and trailing whitespace from all HTML tags. So, wikis effectively came to rely upon this behavior as if it was part of the wikitext spec itself.

With the introduction of RemexHtml to replace Tidy, this changed because RemexHtml doesn't trim whitespace since whitespace is meaningful for rendering in HTML5 because of CSS properties like. However, since wikis relied on this whitespace trimming behavior (ironically because if untrimmed, the white-space would be rendered because of CSS properties that affected it), we chose to formally make this whitespace trimming behavior part of the official wikitext spec. But, we deliberately chose to not touch native HTML tags because it would lead to unintuitive and gratuitous differences from the HTML5 spec and HTML used elsewhere on the web.