Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::normalize()
- 9 core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::normalize()
Normalizes an HTML snippet.
This function is essentially \DOMDocument::normalizeDocument(), but operates on an HTML string instead of a \DOMDocument.
Parameters
string $html: The HTML string to normalize.
Return value
string The normalized HTML string.
5 calls to Html::normalize()
- BigPipeStrategy::placeholderIsAttributeSafe in core/
modules/ big_pipe/ src/ Render/ Placeholder/ BigPipeStrategy.php - Determines whether the given placeholder is attribute-safe or not.
- FieldFilteredMarkup::create in core/
lib/ Drupal/ Core/ Field/ FieldFilteredMarkup.php - Overrides \Drupal\Component\Render\MarkupTrait::create().
- MailFormatHelper::htmlToText in core/
lib/ Drupal/ Core/ Mail/ MailFormatHelper.php - Transforms an HTML string into plain text, preserving its structure.
- text_summary in core/
modules/ text/ text.module - Generates a trimmed, formatted version of a text field value.
- XssTest::testFilterNormalizedHtml5 in core/
tests/ Drupal/ Tests/ Component/ Utility/ XssTest.php - Checks that escaped HTML embedded in an attribute is not filtered.
File
- core/
lib/ Drupal/ Component/ Utility/ Html.php, line 256
Class
- Html
- Provides DOMDocument helpers for parsing and serializing HTML strings.
Namespace
Drupal\Component\UtilityCode
public static function normalize($html) {
$document = static::load($html);
return static::serialize($document);
}