(Created after getting no responses to this Stack Overflow question.)
This is a version of Rails's highlight that is transliteration aware.
For example, highlighting 'duss' in 'Düsseldorf' will actually match something:
irb(main):001:0> require 'translighterate'
=> true
irb(main):002:0> Translighterate.highlight("Düsseldorf", "duss")
=> "<mark>Düss</mark>eldorf"as opposed to this behavior with Rails's highlight:
irb(main):002:0> require 'action_view'
=> true
irb(main):004:0> include ActionView::Helpers::TextHelper
=> Object
irb(main):005:0> highlight("Düsseldorf", "duss")
=> "Düsseldorf"Installation
Add this line to your application's Gemfile:
gem 'translighterate'And then execute:
$ bundle
Or install it yourself as:
$ gem install translighterate
Usage
We have one class Translighterate with one method highlight.
irb(main):001:0> require 'translighterate'
=> true
irb(main):002:0> Translighterate.highlight("Düsseldorf", "duss")
=> "<mark>Düss</mark>eldorf"Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Testing
bin/rspec to run the tests.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jfly/translighterate.
License
The gem is available as open source under the terms of the MIT License.