[TASK] Normalize the DOCTYPE declaration #866
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ensure that the DOCTYPE declaration consists of uppercase
DOCTYPE
andlowercase root element name (
html
).This is done when the
DOMDocument
is created from an HTML source. Once theDOMDocument
has been created, theDOMDocumentType
cannot be changed, so thedocument type declaration must be manipulated (if necessary) in the HTML
beforehand. (Since only HTML documents are supported, the declaration is only
normalized when the root element name is HTML, in whatever case - the precise
specification for any element name involves lists of various Unicode character
ranges which it would be superfluous to allow for and try to match. PHP's
DOMDocument
/libxml
itself will output theDOCTYPE
keyword in uppercase inany case.)
This normalization is consistent with the relevant part of the
polyglot markup specification.
While polyglot markup is primarily intended for serialization of HTML as XML
(we don't actually support outputting as XHTML), is also recommended for maximum
interoperability and robustness when rendering HTML.
This also makes the output consistent with that of
Masterminds/html5-php
andwould eliminate the need to change associated tests specifically for #831.
Closes #858.