From 1139a51e9c6608dc235938d9d234ed185c5d5706 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 23 Aug 2024 14:53:59 +0000 Subject: [PATCH] HTML API: Parse DOCTYPE tokens and set HTML parser mode accordingly. This patch adds until-now missing code to parse the structure of HTML DOCTYPE declarations. The DOCTYPE is mostly unused but can dictate the document compatability mode, which governs whether CSS class names match in a ASCII-case-insensitive way or not, and whether TABLE elements close an open P element. The DOCTYPE information is made available through a new method on the Tag Processor, `get_doctype_info()`. Developed in https://github.com/wordpress/wordpress-develop/pull/7195 Discussed in https://core.trac.wordpress.org/ticket/61576 Props dmsnell, jonsurrell. See #61576. git-svn-id: https://develop.svn.wordpress.org/trunk@58925 602fd350-edb4-49c9-b593-d223f7449a82 --- phpcs.xml.dist | 1 + .../html-api/class-wp-html-doctype-info.php | 616 ++++++++++++++++++ .../html-api/class-wp-html-processor.php | 12 +- .../html-api/class-wp-html-tag-processor.php | 23 +- src/wp-settings.php | 1 + .../tests/html-api/wpHtmlDoctypeInfo.php | 118 ++++ .../html-api/wpHtmlProcessorHtml5lib.php | 24 +- .../tests/html-api/wpHtmlTagProcessor.php | 16 + 8 files changed, 792 insertions(+), 19 deletions(-) create mode 100644 src/wp-includes/html-api/class-wp-html-doctype-info.php create mode 100644 tests/phpunit/tests/html-api/wpHtmlDoctypeInfo.php diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ece1c82386..636580a404 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -262,6 +262,7 @@ in the parsing, and distance the code from its standard. --> /wp-includes/html-api/class-wp-html-processor\.php + /wp-includes/html-api/class-wp-html-doctype-info\.php