Class: Nokogiri::XML::Text
- Inherits:
-
Object
- Object
- Nokogiri::XML::Text
- Defined in:
- lib/html_spellchecker.rb
Constant Summary collapse
- WORDS_REGEXP =
RUBY_VERSION =~ /^1\.8/ ? /(&\w+;)|([\w']+)/ : /(&\p{Word}{2,3};)|([\p{Word}']+)/
- ENTITIES =
[">", "<", "&"]
Instance Method Summary collapse
Instance Method Details
#spellcheck(dict) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/html_spellchecker.rb', line 58 def spellcheck(dict) to_xhtml(:encoding => 'UTF-8').gsub(WORDS_REGEXP) do |word| if ENTITIES.include?(word) || dict.check?(word) word else "<span class=\"misspelled\">#{word}</span>" end end end |