Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question #212

Open
Lofesa opened this issue Mar 23, 2022 · 8 comments
Open

Question #212

Lofesa opened this issue Mar 23, 2022 · 8 comments

Comments

@Lofesa
Copy link

Lofesa commented Mar 23, 2022

Hi
I come here to ask a, maybe, dumb question.
I used a WP plugin that uses this library to make changes to the html. This html contain inlined svg like:

< svg xmlns= "https://www.w3.org/2000/svg" some stuff here ></svg>

After get parsed this becomes:

< svg some stuff here /></svg>

Is there any way to preserve the xmlns attribute and don´t set the autoclosig / ?

Thx in advance.

@stof
Copy link
Contributor

stof commented Jan 11, 2023

Are you using $dom->saveHTML() or $html5->saveHTML($dom); to generate the output ? Using DOMDocument::saveHTML is known to produce a wrong output because the DOMDocument implementation in PHP is not aware of HTML5 rules.

@Lofesa
Copy link
Author

Lofesa commented Jan 12, 2023

The plugin uses html5->saveHTML($dom);

@stof
Copy link
Contributor

stof commented Jan 12, 2023

Can you provide an actual reproducer ?

@Lofesa
Copy link
Author

Lofesa commented Jan 12, 2023

Yes this url https://intersindicalrm.org/la-intersindical-se-extiende-al-servicio-murciano-de-salud/
These icons in the image have the xmlns attribute but get stripped
Captura de pantalla 2023-01-12 133330

@stof
Copy link
Contributor

stof commented Jan 12, 2023

When I take this URL, the SVG icons don't have the xmlns attribute.

@Lofesa
Copy link
Author

Lofesa commented Jan 12, 2023

Yes, because are striped

For example, the arrow up svg, the original is

$output = '<svg viewBox="0 0 330 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M305.863 314.916c0 2.266-1.133 4.815-2.832 6.514l-14.157 14.163c-1.699 1.7-3.964 2.832-6.513 2.832-2.265 0-4.813-1.133-6.512-2.832L164.572 224.276 53.295 335.593c-1.699 1.7-4.247 2.832-6.512 2.832-2.265 0-4.814-1.133-6.513-2.832L26.113 321.43c-1.699-1.7-2.831-4.248-2.831-6.514s1.132-4.816 2.831-6.515L158.06 176.408c1.699-1.7 4.247-2.833 6.512-2.833 2.265 0 4.814 1.133 6.513 2.833L303.03 308.4c1.7 1.7 2.832 4.249 2.832 6.515z" fill-rule="nonzero" /></svg>';

@stof
Copy link
Contributor

stof commented Jan 12, 2023

If you give me a URL which shows the HTML being the output of the library, that's not a reproducing case.

@stof
Copy link
Contributor

stof commented Jan 12, 2023

The xmlns is not rendered in the output of the library because it is useless when using a svg tag inside HTML: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants