Class: Uniword::Validation::Rules::EmptyParagraphsRule

Inherits:
ModelRule
  • Object
show all
Defined in:
lib/uniword/validation/rules/empty_paragraphs_rule.rb

Overview

DOC-203: paragraphs should not be empty.

Empty paragraphs are usually leftover scaffolding; reported as warnings only.

Instance Method Summary collapse

Methods inherited from ModelRule

#context_type

Methods inherited from Base

#applicable?, #context_type, #description, #validity_rule

Instance Method Details

#categoryObject



12
# File 'lib/uniword/validation/rules/empty_paragraphs_rule.rb', line 12

def category = :structure

#check(context) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/uniword/validation/rules/empty_paragraphs_rule.rb', line 15

def check(context)
  paragraphs = context.document.paragraphs
  paragraphs.each_with_index.filter_map do |para, idx|
    next unless para.runs.nil? || para.runs.empty?

    issue("Empty paragraph at index #{idx}",
          part: "word/document.xml")
  end
end

#codeObject



11
# File 'lib/uniword/validation/rules/empty_paragraphs_rule.rb', line 11

def code = "DOC-203"

#severityObject



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

def severity = "warning"