claudetech / node-static-i18n

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

Attribute names are unconditionally lower-cased #41

Open skywhale opened 3 years ago

skywhale commented 3 years ago

This breaks some of the attributes like viewBox, which is case-sensitive.

Input:

<svg width="21" height="15" viewBox="0 0 21 15" />

output:

<svg width="21" height="15" viewbox="0 0 21 15"/>
danhper commented 3 years ago

Hi, I think that might be because of how cheerio handles that. More of a workaround but would using the xml mode help?

skywhale commented 3 years ago

Thank you. I confirmed that using xml mode preserves cases. It's not ideal, though, as it makes other non-HTML transformations like making <script> tags self-closing.

danhper commented 3 years ago

I agree it is not ideal but unfortunately, I do not think there is a simple fix because of the underlying library used: https://github.com/cheeriojs/cheerio/issues/1096 If you think of a solution I would be happy to take a further look.

skywhale commented 3 years ago

Yeah I don't have a good solution either. Please feel free to close the issue.

We have a simple regex script that runs after static-i18n to work around the issue and it's okay for us now. Thank you for looking into it :)

danhper commented 3 years ago

Thank you for the update (and sorry for the delay). I'll leave this open in case somebody comes up with something!