Open cfjedimaster opened 4 years ago
It seems to be correctly decoding entities but not the <
and >
.
According to https://www.rubydoc.info/gems/jekyll/Jekyll%2FFilters%3Axml_escape the output is this:
xml_escape('foo "bar" <baz>')
# => "foo "bar" <baz>"
For anyone else being bitten by this, I've created a temporary branch that you can install from GitHub, with this in your package.json:
"devDependencies": {
"@11ty/eleventy": "^1.0.0",
"eleventy-xml-plugin": "github:sentience/eleventy-xml-plugin#dist"
}
The library is all wrong, it use decode from html-entities instead of encode. So it unescape. Just ignore the library that is useless and use html-entities directly:
const { encode } = require('html-entities');
module.exports = function(eleventyConfig) {
// ... other config
eleventyConfig.addFilter("xml_escape", function(str) {
return encode(str, {level: 'xml'});
});
};
The library is only 4 lines of code that use obsolete version of html-entities anyway.
Sorry for the vague title, but that's the best I can say. I installed the plugin and then tried to use it, but it doesn't seem to do anything. So for example:
When output, the tags in the hard coded string are not escaped as I'd expect.