ada_matcher 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ada_matcher.rb +17 -8
- data/lib/ada_matcher/version.rb +1 -1
- metadata +2 -2
data/lib/ada_matcher.rb
CHANGED
@@ -108,16 +108,25 @@ module AdaMatcher
|
|
108
108
|
e # return error message array
|
109
109
|
end
|
110
110
|
|
111
|
+
# Currently, no method exists to collect all Heading tags (H1 - H6).
|
112
|
+
# We scan all tags on the page and evaluate their order for proper
|
113
|
+
# hierarchical sequencing.
|
111
114
|
def htag_hierarchy(page)
|
112
115
|
e = Array.new
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
116
|
+
page_tags = page.elements.to_a.collect {|e| e.tag_name}
|
117
|
+
|
118
|
+
last_htag_num = 0
|
119
|
+
for i in 0..(page_tags.size - 1)
|
120
|
+
if hMatch = /^h([1-6])$/.match(page_tags[i])
|
121
|
+
headingIdx = hMatch[1].to_i
|
122
|
+
if (last_htag_num > 0) && (headingIdx > (last_htag_num + 1))
|
123
|
+
e << "H#{headingIdx} tag found, but prior Heading tag was H#{last_htag_num}."
|
124
|
+
elsif headingIdx > (last_htag_num + 1)
|
125
|
+
e << "H#{headingIdx} tag found, but no prior higher level Heading tag was found."
|
126
|
+
else
|
127
|
+
last_htag_num = headingIdx
|
128
|
+
end
|
129
|
+
end
|
121
130
|
end
|
122
131
|
|
123
132
|
e # return error message array
|
data/lib/ada_matcher/version.rb
CHANGED