claudetech / node-static-i18n

HTML static pages i18n tool
https://www.npmjs.com/package/static-i18n
MIT License
102 stars 21 forks source link

Little problem with HTML `<` #39

Closed adrienluitot closed 4 years ago

adrienluitot commented 4 years ago

If we allow html in the translation and we have something like this in the JSON: "key": "<span>5 < 8</span>, that's obvious" It will display something strange in HTML like : <span> 5 < 8< span>, that's obvious</span> The / disappear and the browser auto close the element.

To fix this we can use &lt; instead of <.

danhper commented 4 years ago

You're right, I think the library used under the hood (https://github.com/cheeriojs/cheerio) does not support it. I also don't think it's worth fixing, as in general most HTML validators would also be against using raw < or " in HTML anyway. As you already figured, using &lt; is the way to go.