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

prevent non-ascii chars conversion to html entities #93

Open
adipasquale opened this issue Dec 21, 2022 · 1 comment
Open

prevent non-ascii chars conversion to html entities #93

adipasquale opened this issue Dec 21, 2022 · 1 comment

Comments

@adipasquale
Copy link

adipasquale commented Dec 21, 2022

Hello! Thanks for a super convenient tool

I'm wondering if we could add an option to preserve non-ascii characters as-is. Currently, the tool transforms them to HTML entities. For example é becomes é. I would rather have it stay as é.

I tried looking into the source code on how to implement this change but I am a bit lost. I looked at the functions about html entities but they are about decoding rather than encoding. I also tried bypassing the CGI.escapeHTML to no avail. Would you have a direction to point me in?

Thank you!

@adipasquale
Copy link
Author

I currently have a super hacky bash script to help me with this:

# scripts/html2haml.sh
ls $1 | sed 'p;s/.erb$/.haml/' | xargs -n2 bundle exec html2haml --ruby19-attributes -E utf-8:utf-8
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/é/é/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/è/è/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/ /\ /g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/«/«/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/»/»/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/à/à/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/’/ʼ/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/fi/fi/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/œ/œ/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/î/î/g'
ls $1 | sed 's/.erb$/.haml/' | xargs sed -i '' 's/\À/À/g'

(please don't judge my absolute lack of shell scripting skills)

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

1 participant