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.
@@ -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
- if page.h1s.to_a.empty? && !page.h2s.to_a.empty?
114
- e << "H2 tag found but no H1 found on page"
115
- end
116
- if page.h2s.to_a.empty? && !page.h3s.to_a.empty?
117
- e << "H3 tag found but no H2 found on page"
118
- end
119
- if page.h3s.to_a.empty? && !page.h4s.to_a.empty?
120
- e << "H4 tag found but no H3 found on page"
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
@@ -1,3 +1,3 @@
1
1
  module AdaMatcher
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Brown