html_spellchecker 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/html_spellchecker.rb +7 -2
  2. metadata +4 -4
@@ -52,11 +52,16 @@ class Nokogiri::XML::Node
52
52
  end
53
53
 
54
54
  class Nokogiri::XML::Text
55
- WORDS_REGEXP = RUBY_VERSION =~ /^1\.8/ ? /\w+/ : /\p{Word}+/
55
+ WORDS_REGEXP = RUBY_VERSION =~ /^1\.8/ ? /(&\w+;)|([\w']+)/ : /(&\p{Word}{2,3};)|([\p{Word}']+)/
56
+ ENTITIES = [">", "<", "&"]
56
57
 
57
58
  def spellcheck(dict)
58
59
  to_xhtml(:encoding => 'UTF-8').gsub(WORDS_REGEXP) do |word|
59
- dict.check(word) ? word : "<span class=\"misspelled\">#{word}</span>"
60
+ if ENTITIES.include?(word) || dict.check(word)
61
+ word
62
+ else
63
+ "<span class=\"misspelled\">#{word}</span>"
64
+ end
60
65
  end
61
66
  end
62
67
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_spellchecker
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bruno Michel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-03 00:00:00 +02:00
18
+ date: 2011-04-04 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency