lib/asciidoctor/iso/validate_section.rb in asciidoctor-iso-0.7.2 vs lib/asciidoctor/iso/validate_section.rb in asciidoctor-iso-0.7.3
- old
+ new
@@ -30,11 +30,11 @@
NON_DL_SYMBOLS_WARNING = "ISO style: Symbols and Abbreviated Terms can "\
"only contain a definition list".freeze
def symbols_validate(root)
- f = root.xpath("//symbols-abbrevs")
+ f = root.xpath("//definitions")
f.empty? && return
(f.size == 1) || warn(ONE_SYMBOLS_WARNING)
f.first.elements.each do |e|
unless e.name == "dl"
warn(NON_DL_SYMBOLS_WARNING)
@@ -72,22 +72,27 @@
{
msg: "Normative References must be followed by "\
"Terms and Definitions",
val: [
{ tag: "terms", title: "Terms and Definitions" },
+ { tag: "clause", title: "Terms and Definitions" },
{
tag: "terms",
title: "Terms, Definitions, Symbols and Abbreviated Terms",
},
+ {
+ tag: "clause",
+ title: "Terms, Definitions, Symbols and Abbreviated Terms",
+ },
],
},
].freeze
SECTIONS_XPATH =
- " //foreword | //introduction | //sections/terms | "\
- "//symbols-abbrevs | "\
- "//sections/clause | ./references | ./annex".freeze
+ "//foreword | //introduction | //sections/terms | .//annex | "\
+ "//definitions | //sections/clause | //references[not(parent::clause)] | "\
+ "//clause[descendant::references][not(parent::clause)]".freeze
def sections_sequence_validate(root)
f = root.xpath(SECTIONS_XPATH)
names = f.map { |s| { tag: s.name, title: s&.at("./title")&.text } }
names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val]) || return
@@ -96,10 +101,10 @@
if n == { tag: "introduction", title: "Introduction" }
names = seqcheck(names, SEQ[2][:msg], SEQ[2][:val]) || return
end
names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val]) || return
n = names.shift
- if n == { tag: "symbols-abbrevs", title: nil }
+ if n == { tag: "definitions", title: nil }
n = names.shift || return
end
unless n
warn "ISO style: Document must contain at least one clause"
return