Class: Uniword::Validation::Rules::FootnotesRule
- Defined in:
- lib/uniword/validation/rules/footnotes_rule.rb
Overview
Validates footnotes and endnotes consistency.
DOC-020: footnotePr/endnotePr implies footnotes.xml/endnotes.xml exists DOC-021: footnoteReference/endnoteReference IDs exist in parts DOC-022: Separator entries present when footnotePr defined
Constant Summary collapse
- W_NS =
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #severity ⇒ Object
Methods inherited from Base
#context_type, #description, #validity_rule
Instance Method Details
#applicable?(context) ⇒ Boolean
18 19 20 |
# File 'lib/uniword/validation/rules/footnotes_rule.rb', line 18 def applicable?(context) context.part_exists?("word/settings.xml") end |
#category ⇒ Object
15 |
# File 'lib/uniword/validation/rules/footnotes_rule.rb', line 15 def category = :footnotes |
#check(context) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/uniword/validation/rules/footnotes_rule.rb', line 22 def check(context) issues = [] settings = context.settings_xml return issues unless settings has_footnote_pr = settings.root.xpath(".//w:footnotePr", "w" => W_NS).any? has_endnote_pr = settings.root.xpath(".//w:endnotePr", "w" => W_NS).any? # DOC-020: Check parts exist when properties are declared if has_footnote_pr && !context.part_exists?("word/footnotes.xml") issues << issue( "settings.xml declares footnotePr but word/footnotes.xml is missing", part: "word/settings.xml", suggestion: "Add a minimal footnotes.xml with separator entries " \ "(id=-1, id=0), or remove footnotePr from settings.xml " \ "if no footnotes are used.", ) end if has_endnote_pr && !context.part_exists?("word/endnotes.xml") issues << issue( "settings.xml declares endnotePr but word/endnotes.xml is missing", part: "word/settings.xml", suggestion: "Add a minimal endnotes.xml with separator entries " \ "(id=-1, id=0), or remove endnotePr from settings.xml " \ "if no endnotes are used.", ) end # DOC-022: Check separator entries check_separators(context, has_footnote_pr, has_endnote_pr, issues) # DOC-021: Check reference IDs check_footnote_references(context, issues) issues end |
#code ⇒ Object
14 |
# File 'lib/uniword/validation/rules/footnotes_rule.rb', line 14 def code = "DOC-020" |
#severity ⇒ Object
16 |
# File 'lib/uniword/validation/rules/footnotes_rule.rb', line 16 def severity = "error" |