Skip to content

Commit

Permalink
Fix void elements that libxml2 does not know (#142)
Browse files Browse the repository at this point in the history
* Fix void elements that libxml2 does not know

* Combine two `str_replace()` into one
  • Loading branch information
krokodok authored Oct 1, 2024
1 parent ed8ab22 commit d1bc811
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ function enable_lightbox_for_images( string $content ): string {
$link->setAttribute( 'data-group', $image_id );
}

// Strip the XML tag and placeholders as it's only used for the internal encoding.
// Strip XML tag, internal encoding placeholders and stray end tags of void elements unknown to libxml2.
$document_html = trim(
str_replace(
[
'<?xml encoding="utf-8"?>',
'<preserveselfclosingtags>',
'</preserveselfclosingtags>',
'</embed>',
'</source>',
'</track>',
'</wbr>',
],
'',
(string) $document->saveHTML()
Expand Down

0 comments on commit d1bc811

Please sign in to comment.