Skip to content

Wants to spellcheck an HTML string properly? This gem is for you.

License

Notifications You must be signed in to change notification settings

oyeanuj/HTML-Spellchecker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML Spellchecker

Wants to spellcheck an HTML string properly? This gem is for you. It's powered by Nokogiri and ffi-hunspell!

How to use it

It's very simple. Install it with rubygems:

gem install html_spellchecker

Or, if you use bundler, add it to your Gemfile:

gem "html_spellchecker", :version => "~>0.1"

Then you can use it in your code:

require "html_spellchecker"
HTML_Spellchecker.english.spellcheck("<p>This is xzqwy.</p>")
# => "<p>This is <mark class="misspelled">xzqwy</mark>.</p>"

The HTML_Spellchecker class can be initialized by giving 2 paths: the affinity and dictionnary for hunspell. There are helpers to create a new instance for english and french dictionnaries.

Then, you can use spellcheck method: you give it an HTML string and it returns you with the same string with misspelled words enclosed in <mark> tags (with the misspelled class).

HTML_Spellchecker can avoid to check the spelling of special tags like <code>, by keeping a list of the tags to spellcheck in HTML_Spellchecker.spellcheckable_tags.

Issues or Suggestions

Found an issue or have a suggestion? Please report it on Github's issue tracker.

If you wants to make a pull request, please check the specs before:

rspec spec

Credits

Thanks Andreas Haller for the hunspell-ffi gem.

Copyright (c) 2011 Bruno Michel bmichel@menfin.info, released under the MIT license

About

Wants to spellcheck an HTML string properly? This gem is for you.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%