htmlentities
htmlentities copied to clipboard
Add option to tolerate capitalization mistakes
trafficstars
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