govspeak 1.0.1 → 1.1.0
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.
- data/lib/govspeak.rb +1 -0
- data/lib/govspeak/html_sanitizer.rb +19 -0
- data/lib/govspeak/html_validator.rb +1 -15
- data/lib/govspeak/version.rb +1 -1
- metadata +5 -4
data/lib/govspeak.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'sanitize'
|
2
|
+
|
3
|
+
class Govspeak::HtmlSanitizer
|
4
|
+
def initialize(dirty_html)
|
5
|
+
@dirty_html = dirty_html
|
6
|
+
end
|
7
|
+
|
8
|
+
def sanitize
|
9
|
+
Sanitize.clean(@dirty_html, sanitize_config)
|
10
|
+
end
|
11
|
+
|
12
|
+
def sanitize_config
|
13
|
+
config = Sanitize::Config::RELAXED.dup
|
14
|
+
config[:attributes][:all].push("id", "class")
|
15
|
+
config[:attributes]["a"].push("rel")
|
16
|
+
config[:elements].push("div", "hr")
|
17
|
+
config
|
18
|
+
end
|
19
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'sanitize'
|
2
|
-
|
3
1
|
class Govspeak::HtmlValidator
|
4
2
|
attr_reader :string
|
5
3
|
|
@@ -13,7 +11,7 @@ class Govspeak::HtmlValidator
|
|
13
11
|
|
14
12
|
def valid?
|
15
13
|
dirty_html = govspeak_to_html
|
16
|
-
clean_html =
|
14
|
+
clean_html = Govspeak::HtmlSanitizer.new(dirty_html).sanitize
|
17
15
|
normalise_html(dirty_html) == normalise_html(clean_html)
|
18
16
|
end
|
19
17
|
|
@@ -25,16 +23,4 @@ class Govspeak::HtmlValidator
|
|
25
23
|
def govspeak_to_html
|
26
24
|
Govspeak::Document.new(string).to_html
|
27
25
|
end
|
28
|
-
|
29
|
-
def sanitize_html(dirty_html)
|
30
|
-
Sanitize.clean(dirty_html, sanitize_config)
|
31
|
-
end
|
32
|
-
|
33
|
-
def sanitize_config
|
34
|
-
config = Sanitize::Config::RELAXED.dup
|
35
|
-
config[:attributes][:all].push("id", "class")
|
36
|
-
config[:attributes]["a"].push("rel")
|
37
|
-
config[:elements].push("div", "hr")
|
38
|
-
config
|
39
|
-
end
|
40
26
|
end
|
data/lib/govspeak/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: govspeak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Griffiths
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-14 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: kramdown
|
@@ -104,6 +104,7 @@ extra_rdoc_files: []
|
|
104
104
|
|
105
105
|
files:
|
106
106
|
- lib/govspeak/version.rb
|
107
|
+
- lib/govspeak/html_sanitizer.rb
|
107
108
|
- lib/govspeak/header_extractor.rb
|
108
109
|
- lib/govspeak/html_validator.rb
|
109
110
|
- lib/govspeak.rb
|
@@ -128,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
129
|
requirements:
|
129
130
|
- - ">="
|
130
131
|
- !ruby/object:Gem::Version
|
131
|
-
hash:
|
132
|
+
hash: 2687403366774857492
|
132
133
|
segments:
|
133
134
|
- 0
|
134
135
|
version: "0"
|
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
138
|
requirements:
|
138
139
|
- - ">="
|
139
140
|
- !ruby/object:Gem::Version
|
140
|
-
hash:
|
141
|
+
hash: 2687403366774857492
|
141
142
|
segments:
|
142
143
|
- 0
|
143
144
|
version: "0"
|