lib/isodoc/iso/xref.rb in metanorma-iso-2.5.0 vs lib/isodoc/iso/xref.rb in metanorma-iso-2.5.1

- old
+ new

@@ -6,52 +6,46 @@ end class Xref < IsoDoc::Xref attr_accessor :anchors_previous, :anchors - def initial_anchor_names(doc) - if @klass.amd(doc) then initial_anchor_names_amd(doc) - else initial_anchor_names1(doc) + def clause_order_main(docxml) + if @klass.amd?(docxml) + [{ path: "//sections/clause", multi: true }] + else + [{ path: "//clause[@type = 'scope']" }, + { path: @klass.norm_ref_xpath }, + { path: + "#{@klass.middle_clause(docxml)} | //sections/terms | " \ + "//sections/clause[descendant::terms or descendant::definitions] " \ + "| //sections/definitions", multi: true }] end - if @parse_settings.empty? || @parse_settings[:clauses] - introduction_names(doc.at(ns("//introduction"))) + end + + def clause_order_back(docxml) + if @klass.amd?(docxml) + [{ path: @klass.norm_ref_xpath }, + { path: @klass.bibliography_xpath }, + { path: "//indexsect", multi: true }, + { path: "//colophon/*", multi: true }] + else super end end - def initial_anchor_names_amd(doc) + def initial_anchor_names(doc) + super if @parse_settings.empty? || @parse_settings[:clauses] - ["//preface/*", "//sections/clause"].each do |xpath| - doc.xpath(ns(xpath)).each do |c| - c.element? and preface_names(c) - end - end + introduction_names(doc.at(ns("//introduction"))) end end def asset_anchor_names(doc) super @parse_settings.empty? or return sequential_asset_names(doc.xpath(ns("//preface/*"))) end - def initial_anchor_names1(doc) - if @parse_settings.empty? || @parse_settings[:clauses] - doc.xpath(ns("//preface/*")).each do |c| - c.element? and preface_names(c) - end - # potentially overridden in middle_section_asset_names() - sequential_asset_names(doc.xpath(ns("//preface/*"))) - n = Counter.new - n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1) - n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1) - doc.xpath(ns("//sections/clause[not(@type = 'scope')][not(.//references)] | " \ - "//sections/terms | //sections/definitions")).each do |c| - n = section_names(c, n, 1) - end - end - end - def hierarchical_formula_names(clause, num) c = IsoDoc::XrefGen::Counter.new clause.xpath(ns(".//formula")).each do |t| next if blank?(t["id"]) @@ -127,16 +121,9 @@ def reference_names(ref) super @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref] .sub(/ \(All Parts\)/i, "") } - end - - def back_anchor_names(docxml) - super - if @parse_settings.empty? || @parse_settings[:clauses] - docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) } - end end def list_anchor_names(sections) sections.each do |s| notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -