html_spellchecker 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/html_spellchecker.rb +7 -2
- metadata +4 -4
data/lib/html_spellchecker.rb
CHANGED
@@ -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/ ?
|
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
|
-
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
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-
|
18
|
+
date: 2011-04-04 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|