Skip to content

Commit

Permalink
debug single-child annex and unnumbered clause cross-references
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Dec 18, 2024
1 parent c5e483a commit 796eb47
Show file tree
Hide file tree
Showing 3 changed files with 685 additions and 509 deletions.
31 changes: 4 additions & 27 deletions lib/isodoc/bipm/xref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ def main_anchor_names(xml)
"./term[#{UNNUM}] | ./terms[#{UNNUM}] | " \
"./definitions[#{UNNUM}]".freeze

# KILL
def section_name_anchors(clause, num, lvl)
lbl = @jcgm ? "clause_jcgm" : "clause"
@anchors[clause["id"]] =
{ label: num.print, xref: l10n("#{@labels[lbl]} #{num.print}"),
level: lvl, type: "clause", elem: @labels[lbl] }
end

def section_name_anchors(clause, num, level)
lbl = @jcgm ? "clause_jcgm" : "clause"
xref = labelled_autonum(@labels[lbl], num)
Expand All @@ -77,21 +69,6 @@ def section_name_anchors(clause, num, level)
elem: @labels[lbl] }
end

# KILL
def section_names(clause, num, lvl)
clause.nil? and return num
num.increment(clause)
@anchors[clause["id"]] = section_name_anchors(clause, num, lvl)
i = Counter.new(0, prefix: num.print)
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
section_names1(c, i.increment(c).print, lvl + 1)
end
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
unnumbered_section_names1(c, lvl + 1)
end
num
end

def section_names(clause, num, lvl)
unnumbered_section_name?(clause) and return num
num.increment(clause)
Expand Down Expand Up @@ -135,7 +112,7 @@ def section_names1(clause, parentnum, num, level)
section_names1(c, lbl, i.increment(c).print, level + 1)
end
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
unnumbered_section_names1(c, lvl + 1)
unnumbered_section_names1(c, level + 1)
end
end

Expand Down Expand Up @@ -180,7 +157,7 @@ def annex_names(clause, num)
@anchors[clause["id"]] = annex_name_anchors(clause, lbl)
if @klass.single_term_clause?(clause)
annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
lbl, 1)
nil, "#{prefix}#{num}", 1)
else
i = Counter.new(0)
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
Expand All @@ -202,8 +179,8 @@ def unnumbered_annex_names(clause)
lbl = semx(clause, lbl, "title")
@anchors[clause["id"]] = unnumbered_annex_anchors(lbl)
if @klass.single_term_clause?(clause)
annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
num.to_s, 1)
unnumbered_annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
1)
else
clause.xpath(ns(SUBCLAUSES))
.each { |c| unnumbered_annex_names1(c, 2) }
Expand Down
Loading

0 comments on commit 796eb47

Please sign in to comment.