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

Add option to tolerate capitalization mistakes #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amomchilov
Copy link

Add an option (defaults to off) which allows decoding to be done in a way that's flexible to capitalization mistakes.

If the correct capitalization exists, it'll be used. Otherwise if this option is on, we will attempt to decode the entity as if it were all lower case.

e.g.

HTMLEntities.new.decode('&#oelig;') # => 'œ'
HTMLEntities.new.decode('&#OElig;') # => 'Œ'
HTMLEntities.new.decode('&#OELIG;') # => '&#OELIG;',  this isn't a valid HTML entity, so it's ignored.

HTMLEntities.new.decode('&#oelig;', tolerate_capitalization_mistakes: true) # => 'œ'
HTMLEntities.new.decode('&#OElig;', tolerate_capitalization_mistakes: true) # => 'Œ'
HTMLEntities.new.decode('&#OELIG;', tolerate_capitalization_mistakes: true) # => 'œ', this is best-effort

Fixes #35

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

Successfully merging this pull request may close these issues.

Add support for case-insentitive decoding
1 participant