<div dir="ltr">Hi all, apologies for the cross-posting!<div><br></div><div><span style="font-size:12.800000190734863px">How to read this post?</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">----------------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">* For those without time to read lengthy technical emails,</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  read the TL;DR section.</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">* For those who don't care about all the details but want to</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  help with this project, you can read sections 1 and 2 about Tidy,</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  and then skip to section 7.</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">* For those who like all their details, read the post in its entirety,</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  and follow the links.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Please ask follow up questions on wiki *on the FAQ’s talk page* [0]. If you</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">find a bug, please report it *on Phabricator or on the page mentioned</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">above*.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">TL;DR</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">-----</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">The Parsing team wants to replace Tidy with a RemexHTML-based solution on</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">the Wikimedia cluster by June 2018. This will require editors to fix pages</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">and templates to address wikitext patterns that behave differently with</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">RemexHTML.  Please see 'What editors will need to do' section on the Tidy</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">replacement FAQ [1].</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">1. What is Tidy?</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">----------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Tidy [2] is a library currently used by MediaWiki to fix some HTML errors</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">found in wiki pages.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Badly formed markup is common on wiki pages when editors use HTML tags in</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">templates and on the page itself. (Ex: unclosed HTML tags, such as a <small></span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">without a </small>, are common). In some cases, MediaWiki can generate</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">erroneous HTML by itself. If we didn't fix these before sending it to</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">browsers, some would display things in a broken way to readers.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">But Tidy also does other "cleanup" on its own that is not required for</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">correctness. Ex: it removes empty elements and adds whitespace between HTML</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">tags, which can sometimes change rendering.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">2. Why replace it?</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">------------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Since Tidy is based on HTML4 semantics and the Web has moved to HTML5, it</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">also makes some incorrect changes to HTML to 'fix' things that used to not</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">work; for example, Tidy will unexpectedly move a bullet list out of a table</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">caption even though that's allowed. HTML4 Tidy is no longer maintained or</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">packaged. There have also been a number of bug reports filed against Tidy</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">[3]. Since Parsoid is based on HTML5 semantics, there are differences in</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">rendering between Parsoid's rendering of a page and current read view that</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">is based on Tidy.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">3. Project status</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">-----------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Given all these considerations, the Parsing team started work to replace</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Tidy [4] around mid-2015. Tim Starling started this work and after a survey</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">of existing options, decided to write a wrapper over a Java-based HTML5</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">parser.  At the time we started the project, we thought we could probably</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">have Tidy replaced by mid-2016. Alas!</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">4. What is replacing Tidy?</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">--------------------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Tidy will be replaced by a RemexHTML-based solution that uses the</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">RemexHTML[5] library along with some Tidy-compatibility shims to ensure</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">better parity with the current rendering. RemexHTML is a PHP library that</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Tim wrote with C.Scott’s input that implements the HTML5 parsing spec.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">5. Testing and followup</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">-----------------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">We knew that some pages will be affected and need fixing due to this</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">change.  In order to more precisely identify what that would be, we wanted</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">to do some thorough testing. So, we built some new tools [6][7] and</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">overhauled and upgraded other test infrastructure [8][9] to let us evaluate</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">the impacts of replacing Tidy (among other such things in the future) which</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">can be a subject of a post all on its own.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">You can find the details of our testing on the wiki [1][10], but we found</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">that a large number of pages had rendering differences. We analyzed the</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">results and categorized the source of differences. Based on that, to ease</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">the process of replacement, we added a bunch of compatibility shims to</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">mimic what Tidy does. I am skipping the details in this post. Even after</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">that, newer testing showed that this nevertheless still leaves us with a</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">few patterns that need fixing that we cannot / don't want to work around</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">automatically.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">6. Tools to assist editors: Linter & ParserMigration</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">------------------------------</span><wbr style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">----------------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">In October 2016, at the parsing team offsite, Kunal ([[User:Legoktm (WMF)]])</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">dusted off the stalled wikitext linting project [11] and (with the help from</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">a bunch of people on the Parsoid, db/security/code review areas) built the</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Linter extension that surfaces wikitext errors that Parsoid knows about to</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">let editors fix them.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Earlier this year, we decided to use Linter in service of Tidy replacement.</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Based on our earlier testing results, we have added a set of high-priority</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">linter categories that identifies specific wikitext markup patterns on wiki</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">pages that need to be fixed [12].</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Separately, Tim built the ParserMigration extension to let editors evaluate</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">their fixes to pages [13]. You can enable this in your editing preferences</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">or replace '&action=edit' in your url bar with</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">'&action=parsermigration-edit'</span><wbr style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">7. What editors have to do</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">--------------------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">The part that you have all been waiting for!</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Please see 'What editors will need to do' section on the Tidy replacement</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">FAQ [1]. We have added simplified instructions, so that even community</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">members who do not consider themselves "techies" can still learn about ways</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">to fix pages.  We'll keep that section up to date based on feedback and</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">questions.  But since it is a wiki, please also edit and tweak as required</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">to make the text useful for yourselves! This is a first call for fixes and</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">it is about the problems defined as "high priority". We'll issue other</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">calls in the future for any other necessary Tidy fixups.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">Caveats:</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">* As noted on that page, the linter categories don't cover all the possible</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  sources of rendering differences. For example, there is still T157418 [14]</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  left to address. For those who have an opinion about this, please chime in</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  on that task. We are still evaluating the best solution for this without</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  adding more cruft to wikitext behavior or kicking the cleanup can down the</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  road.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">* As the issues in the identified linter categories are fixed, we might be</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">  better able to isolate other issues that need addressing.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">8. So, when will Tidy actually be replaced?</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">------------------------------</span><wbr style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">-------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">We really would like to get Tidy removed from the cluster latest by June</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">2018 (or sooner if possible), and your assistance and prompt attention to</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">these markup issues would be very helpful. We will do this in a phased</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">manner on different wikis rather than all at once on all wikis.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">We really want to do this as smoothly as possible without disrupting the</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">work of editors or affecting the rendering of the large corpus of pages on</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">the various wikis. As you might have gathered from the text above, we have</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">built and leveraged a wide variety of tools to assist with this.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">9. Monitoring progress</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">----------------------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">In order to monitor progress, we plan to do a weekly (or some such periodic</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">frequency) test run that compares the rendering of pages with Tidy and with</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">RemexHTML on a large sample of pages (in the 50K range) from a large subset</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">of Wikimedia wikis (~50 or so).  This will give us a pulse of how fixups are</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">going, and when we might be able to flip the switch on different wikis.</span><br style="font-size:12.800000190734863px"><br style="font-size:12.800000190734863px"><div>Best,</div><div>Elitre (WMF) on behalf of the Parsing Team (<a href="https://www.mediawiki.org/wiki/Parsing">https://www.mediawiki.org/wiki/Parsing</a> )</div><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">References</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">----------</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">0. </span><a href="https://www.mediawiki.org/wiki/Talk:Parsing/Replacing_Tidy/FAQ" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://www.mediawiki.org/wiki<wbr>/Talk:Parsing/Replacing_Tidy/<wbr>FAQ</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">1.</span><br style="font-size:12.800000190734863px"><a href="https://www.mediawiki.org/wiki/Parsing/Replacing_Tidy/FAQ#What_will_editors_need_to_do.3F" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://www.mediawiki.org/wiki<wbr>/Parsing/Replacing_Tidy/FAQ#<wbr>What_will_editors_need_to_do.<wbr>3F</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">2. </span><a href="https://en.wikipedia.org/wiki/HTML_Tidy" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://en.wikipedia.org/wiki/<wbr>HTML_Tidy</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">3. </span><a href="https://phabricator.wikimedia.org/tag/tidy/" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://phabricator.wikimedia.<wbr>org/tag/tidy/</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">4. </span><a href="https://phabricator.wikimedia.org/T89331" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://phabricator.wikimedia.<wbr>org/T89331</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">5. </span><a href="https://github.com/wikimedia/mediawiki-libs-RemexHtml" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://github.com/wikimedia/m<wbr>ediawiki-libs-RemexHtml</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">6. </span><a href="https://phabricator.wikimedia.org/T120345" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://phabricator.wikimedia.<wbr>org/T120345</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">7. </span><a href="https://github.com/wikimedia/integration-uprightdiff" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://github.com/wikimedia/i<wbr>ntegration-uprightdiff</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">8. </span><a href="https://github.com/wikimedia/integration-visualdiff" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://github.com/wikimedia/i<wbr>ntegration-visualdiff</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">9. </span><a href="https://github.com/wikimedia/mediawiki-services-parsoid-testreduce" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://github.com/wikimedia/m<wbr>ediawiki-services-parsoid-test<wbr>reduce</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">10. </span><a href="https://www.mediawiki.org/wiki/Parsing/Replacing_Tidy" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://www.mediawiki.org/wiki<wbr>/Parsing/Replacing_Tidy</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">11. </span><a href="https://phabricator.wikimedia.org/T48705" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://phabricator.wikimedia.<wbr>org/T48705</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">12. </span><a href="https://www.mediawiki.org/wiki/Help:Extension:Linter#Goal:_Replacing_Tidy" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://www.mediawiki.org/wiki<wbr>/Help:Extension:Linter#Goal:_<wbr>Replacing_Tidy</a><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">13. </span><a href="https://www.mediawiki.org/wiki/Help:Extension:Linter#Verifying_fixes_for_these_lint_categories" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://www.mediawiki.org/wiki<wbr>/Help:Extension:Linter#Verifyi<wbr>ng_fixes_for_these_lint_<wbr>categories</a><span style="font-size:12.800000190734863px"> </span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">14. </span><a href="https://phabricator.wikimedia.org/T157418" rel="noreferrer" target="_blank" style="font-size:12.800000190734863px">https://phabricator.wikimedia.<wbr>org/T157418</a><br></div><div><br></div><div><br></div></div>