HTML5 Balancer
authorC. Scott Ananian <cscott@cscott.net>
Tue, 15 Mar 2016 19:13:43 +0000 (15:13 -0400)
committerTim Starling <tstarling@wikimedia.org>
Tue, 12 Jul 2016 04:18:04 +0000 (14:18 +1000)
commita7e2b5b2842b95bd3b63af89a3687a92d144aa68
treef63b4acaa2688be34da58493585f94e25d1b2728
parent6cdae8051370b7e6641eaaeb438b889ddb510281
HTML5 Balancer

This adds an implementation of the HTML5 Tree Builder algorithm to PHP,
along with test cases from the tree builder derived from the
html5lib-tests package on github.  The test cases were preprocessed
into JSON for the `domino` HTML5 parser, and we're using the JSON
form of the tests.

The implementation follows both the language of the HTML5 specification
and the implementation in `domino` very closely, easing updates if the
specification changes.

This code is used in follow-on commits to support an HTML5-based
"tidy" for mediawiki and the `{{#balance}}` parser function, which
ensures that a template expands to properly-balanced HTML, with all
tags closed and nothing left on the HTML active formatting elements
list.

See: https://github.com/fgnass/domino
Change-Id: I6f4d20a43510dd819776bb333b639315b19d150d
autoload.php
includes/Sanitizer.php
includes/libs/ReverseArrayIterator.php [new file with mode: 0644]
includes/tidy/Balancer.php [new file with mode: 0644]
tests/phpunit/includes/tidy/BalancerTest.php [new file with mode: 0644]
tests/phpunit/includes/tidy/html5lib-tests.json [new file with mode: 0644]