Class: Uniword::Validation::Rules::TablesRule

Inherits:
Base
  • Object
show all
Defined in:
lib/uniword/validation/rules/tables_rule.rb

Overview

Validates table structure.

DOC-060: Table grid columns match cell tc count DOC-061: Merge cells have valid gridSpan/vMerge

Constant Summary collapse

W_NS =
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"

Instance Method Summary collapse

Methods inherited from Base

#context_type, #description, #validity_rule

Instance Method Details

#applicable?(context) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/uniword/validation/rules/tables_rule.rb', line 17

def applicable?(context)
  context.part_exists?("word/document.xml")
end

#categoryObject



14
# File 'lib/uniword/validation/rules/tables_rule.rb', line 14

def category = :tables

#check(context) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/uniword/validation/rules/tables_rule.rb', line 21

def check(context)
  issues = []
  doc = context.document_xml
  return issues unless doc

  doc.root.xpath(".//w:tbl",
                 "w" => W_NS).each_with_index do |table, idx|
    check_table(table, idx, issues)
  end

  issues
end

#codeObject



13
# File 'lib/uniword/validation/rules/tables_rule.rb', line 13

def code = "DOC-060"

#severityObject



15
# File 'lib/uniword/validation/rules/tables_rule.rb', line 15

def severity = "warning"