raakt 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/raakt.rb CHANGED
@@ -48,7 +48,7 @@ module Raakt
48
48
  :difficult_word => "Vocabulary: %s"
49
49
  }
50
50
 
51
- VERSION = "0.5.4"
51
+ VERSION = "0.5.5"
52
52
 
53
53
  class ErrorMessage
54
54
 
@@ -238,15 +238,14 @@ module Raakt
238
238
  def check_document_structure
239
239
  messages = []
240
240
  currentitem = 0
241
- docheadings = headings
242
241
 
243
- for heading in docheadings
242
+ for heading in headings
244
243
  if currentitem == 0
245
244
  if level(heading.name) != 1
246
245
  messages << ErrorMessage.new(:first_h_not_h1, "h" + heading.name[1,1])
247
246
  end
248
247
  else
249
- if level(heading.name) - level(docheadings[currentitem - 1].name) > 1
248
+ if level(heading.name) - level(headings[currentitem - 1].name) > 1
250
249
  messages << ErrorMessage.new(:wrong_h_structure)
251
250
  break
252
251
  end
@@ -460,14 +459,16 @@ module Raakt
460
459
  return messages
461
460
  end
462
461
 
462
+
463
+
464
+
463
465
  # Utility methods
464
-
465
466
  def headings
466
- headings = []
467
- 1.upto(6) do |i|
468
- headings.push((@doc/"h#{i}")) if (@doc/"h#{i}").length > 0
469
- end
470
- headings.flatten
467
+ items = []
468
+ @doc.traverse_element("h1", "h2", "h3", "h4", "h5", "h6") { |heading|
469
+ items << heading
470
+ }
471
+ return items
471
472
  end
472
473
 
473
474
 
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <title>Headingsdoc 10</title>
5
+ </head>
6
+ <body>
7
+ <h2> 2 Sub heading directly</h2>
8
+ <p>Text</p>
9
+ <h3> 3 This is next</h3>
10
+ <h4> 4 subheading</h4>
11
+
12
+ <h1>1 First h1 heading</h1>
13
+ <p>This is a minimal <a href="http://www.w3.org/TR/xhtml1/">XHTML 1.0</a>
14
+ document.</p>
15
+ <h2> 2 a sub heading</h2>
16
+ <table><tr><td>Test table</td></tr></table>
17
+ <H1>1 Third h1 heading</H1>
18
+ </body>
19
+ </html>
data/tests/raakt_test.rb CHANGED
@@ -168,6 +168,10 @@ class RaaktTest < Test::Unit::TestCase
168
168
  @raakt.doc = data_headingsdoc6
169
169
  assert_equal 0, @raakt.check_document_structure.length
170
170
 
171
+ @raakt.doc = data_headingsdoc10
172
+ assert_equal 1, @raakt.check_document_structure.length
173
+ assert_equal :first_h_not_h1, @raakt.check_document_structure[0].eid
174
+
171
175
  @raakt.doc = data_empty
172
176
  assert_equal 0, @raakt.check_document_structure.length
173
177
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raakt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Krantz
@@ -9,7 +9,7 @@ autorequire: raakt
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-19 00:00:00 +01:00
12
+ date: 2009-01-22 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -61,6 +61,7 @@ files:
61
61
  - tests/full_berg.htm
62
62
  - tests/full_google.htm
63
63
  - tests/headingsdoc1.htm
64
+ - tests/headingsdoc10.htm
64
65
  - tests/headingsdoc2.htm
65
66
  - tests/headingsdoc3.htm
66
67
  - tests/headingsdoc4.htm