How to read this post?----------------------* For those without time to read lengthy technical emails, read the TL;DR section.* For those who don't care about all the details but want to help with this project, you can read sections 1 and 2 about Tidy, and then skip to section 7.* For those who like all their details, read the post in its entirety, and follow the links.Please ask follow up questions on wiki *on the FAQ’s talk page* [0]. If youfind a bug, please report it *on Phabricator or on the page mentionedabove*.TL;DR-----The Parsing team wants to replace Tidy with a RemexHTML-based solution onthe Wikimedia cluster by June 2018. This will require editors to fix pagesand templates to address wikitext patterns that behave differently withRemexHTML. Please see 'What editors will need to do' section on the Tidyreplacement FAQ [1].1. What is Tidy?----------------Tidy [2] is a library currently used by MediaWiki to fix some HTML errorsfound in wiki pages.Badly formed markup is common on wiki pages when editors use HTML tags intemplates and on the page itself. (Ex: unclosed HTML tags, such as a <small>without a </small>, are common). In some cases, MediaWiki can generateerroneous HTML by itself. If we didn't fix these before sending it tobrowsers, some would display things in a broken way to readers.But Tidy also does other "cleanup" on its own that is not required forcorrectness. Ex: it removes empty elements and adds whitespace between HTMLtags, which can sometimes change rendering.2. Why replace it?------------------Since Tidy is based on HTML4 semantics and the Web has moved to HTML5, italso makes some incorrect changes to HTML to 'fix' things that used to notwork; for example, Tidy will unexpectedly move a bullet list out of a tablecaption even though that's allowed. HTML4 Tidy is no longer maintained orpackaged. There have also been a number of bug reports filed against Tidy[3]. Since Parsoid is based on HTML5 semantics, there are differences inrendering between Parsoid's rendering of a page and current read view thatis based on Tidy.3. Project status-----------------Given all these considerations, the Parsing team started work to replaceTidy [4] around mid-2015. Tim Starling started this work and after a surveyof existing options, decided to write a wrapper over a Java-based HTML5parser. At the time we started the project, we thought we could probablyhave Tidy replaced by mid-2016. Alas!4. What is replacing Tidy?--------------------------Tidy will be replaced by a RemexHTML-based solution that uses theRemexHTML[5] library along with some Tidy-compatibility shims to ensurebetter parity with the current rendering. RemexHTML is a PHP library thatTim wrote with C.Scott’s input that implements the HTML5 parsing spec.5. Testing and followup-----------------------We knew that some pages will be affected and need fixing due to thischange. In order to more precisely identify what that would be, we wantedto do some thorough testing. So, we built some new tools [6][7] andoverhauled and upgraded other test infrastructure [8][9] to let us evaluatethe impacts of replacing Tidy (among other such things in the future) whichcan be a subject of a post all on its own.You can find the details of our testing on the wiki [1][10], but we foundthat a large number of pages had rendering differences. We analyzed theresults and categorized the source of differences. Based on that, to easethe process of replacement, we added a bunch of compatibility shims tomimic what Tidy does. I am skipping the details in this post. Even afterthat, newer testing showed that this nevertheless still leaves us with afew patterns that need fixing that we cannot / don't want to work aroundautomatically.6. Tools to assist editors: Linter & ParserMigration----------------------------------------------------In October 2016, at the parsing team offsite, Kunal ([[User:Legoktm (WMF)]])dusted off the stalled wikitext linting project [11] and (with the help froma bunch of people on the Parsoid, db/security/code review areas) built theLinter extension that surfaces wikitext errors that Parsoid knows about tolet editors fix them.Earlier this year, we decided to use Linter in service of Tidy replacement.Based on our earlier testing results, we have added a set of high-prioritylinter categories that identifies specific wikitext markup patterns on wikipages that need to be fixed [12].Separately, Tim built the ParserMigration extension to let editors evaluatetheir fixes to pages [13]. You can enable this in your editing preferencesor replace '&action=edit' in your url bar with'&action=parsermigration-edit'.7. What editors have to do--------------------------The part that you have all been waiting for!Please see 'What editors will need to do' section on the Tidy replacementFAQ [1]. We have added simplified instructions, so that even communitymembers who do not consider themselves "techies" can still learn about waysto fix pages. We'll keep that section up to date based on feedback andquestions. But since it is a wiki, please also edit and tweak as requiredto make the text useful for yourselves! This is a first call for fixes andit is about the problems defined as "high priority". We'll issue othercalls in the future for any other necessary Tidy fixups.Caveats:* As noted on that page, the linter categories don't cover all the possible sources of rendering differences. For example, there is still T157418 [14] left to address. For those who have an opinion about this, please chime in on that task. We are still evaluating the best solution for this without adding more cruft to wikitext behavior or kicking the cleanup can down the road.* As the issues in the identified linter categories are fixed, we might be better able to isolate other issues that need addressing.8. So, when will Tidy actually be replaced?-------------------------------------------We really would like to get Tidy removed from the cluster latest by June2018 (or sooner if possible), and your assistance and prompt attention tothese markup issues would be very helpful. We will do this in a phasedmanner on different wikis rather than all at once on all wikis.We really want to do this as smoothly as possible without disrupting thework of editors or affecting the rendering of the large corpus of pages onthe various wikis. As you might have gathered from the text above, we havebuilt and leveraged a wide variety of tools to assist with this.9. Monitoring progress----------------------In order to monitor progress, we plan to do a weekly (or some such periodicfrequency) test run that compares the rendering of pages with Tidy and withRemexHTML on a large sample of pages (in the 50K range) from a large subsetof Wikimedia wikis (~50 or so). This will give us a pulse of how fixups aregoing, and when we might be able to flip the switch on different wikis.Best,
Elitre (WMF) on behalf of the Parsing Team
References----------0. https://www.mediawiki.org/wiki/Talk:Parsing/Replacing_Tidy/FAQ1.https://www.mediawiki.org/wiki/Parsing/Replacing_Tidy/FAQ#What_will_editors_need_to_do.3F2. https://en.wikipedia.org/wiki/HTML_Tidy3. https://phabricator.wikimedia.org/tag/tidy/4. https://phabricator.wikimedia.org/T893315. https://github.com/wikimedia/mediawiki-libs-RemexHtml6. https://phabricator.wikimedia.org/T1203457. https://github.com/wikimedia/integration-uprightdiff8. https://github.com/wikimedia/integration-visualdiff9. https://github.com/wikimedia/mediawiki-services-parsoid-testreduce10. https://www.mediawiki.org/wiki/Parsing/Replacing_Tidy11. https://phabricator.wikimedia.org/T4870512. https://www.mediawiki.org/wiki/Help:Extension:Linter#Goal:_Replacing_Tidy13. https://www.mediawiki.org/wiki/Help:Extension:Linter#Verifying_fixes_for_these_lint_categories 14. https://phabricator.wikimedia.org/T157418