Investigate switching to Masterminds HTML5-PHP parser as opposed to built-in PHP DOM extension #3293
Labels
Enhancement
New feature or improvement of an existing one
Groomed
Needs More Info
Follow-up required in order to be actionable.
P2
Low priority
WS:Core
Work stream for Plugin core
The AMP plugin uses PHP's built-in DOM extension which are powered by libxml. There are various idiosyncrasies with libxml which force us to do various workarounds in
AMP_DOM_Utils
, namely:data-amp-bind-*
syntax using regular expression replacements, since PHP DOM doesn't understand the brackets. (The replacements should still be done, but preferably not via regex!)We may be able to remove these workarounds and improve our parsing routines by switching to the Masterminds HTML5-PHP parser. This was actually chosen for the Drupal AMP module's underlying AMP PHP Library (which is no longer maintained, cf. #2315). This HTML5 parser did not exist at the time the AMP plugin was first created, do it made sense to use PHP's DOM extension. But now a better choice may be the Masterminds library. This would also reduce a dependency.
Something that makes me wary, however, is whether the Masterminds library would be slower than the PHP extension. This is something to be investigated.
The text was updated successfully, but these errors were encountered: