-
Notifications
You must be signed in to change notification settings - Fork 29
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
named HTML entities in inline-SVG cause errors #197
Comments
Reproduction: {
"dependencies": {
"htmlnano": "2.0.2",
"svgo": "2.8.0"
}
} const htmlnano = require("htmlnano");
const posthtml = require("posthtml");
const INPUT = `<!doctype html>
<svg viewBox="0 0 100 100">
<text x="20" y="20" style="fill: black;">✗</text>
</svg>`;
const htmlNanoConfig = {
minifyJs: false,
minifyCss: false,
minifySvg: {},
};
posthtml([htmlnano(htmlNanoConfig)])
.process(INPUT)
.then(
function (result) {
console.log(result.html);
},
function (err) {
console.error(err);
}
); |
HTML entities contain invalid characters which cause the svgo to fail to parse them. |
SukkaW
added a commit
to SukkaW/htmlnano
that referenced
this issue
May 25, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a copy of an issue I filed with parcel. There I was told to bring it up here as well as it seems to be rooted in htmlnano. I did not (yet) further investigate and produce a MWE with just htmlnano, but I guess the example HTML should already be rather straight forward.
🐛 bug report
When running parcel on an HTML document with an embedded SVG that uses named HTML entities like below, the build fails with an error.
Replacing the HTML entity with its numeric variation (
✗
) seems to work just fine.🤔 Expected Behavior
No error. Simply return an (almost) unchanged HTML file.
😯 Current Behavior
💁 Possible Solution
Named entities are not defined in standalone SVG according to this SO answer. However, they work in inline SVG (open the above file directly in your browser).
So it seems this inline SVG is treated as standalone SVG at some point during the pipeline.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: