Skip to content

Commit

Permalink
clause counter method: metanorma/metanorma-jis#228
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Oct 22, 2024
1 parent a9d0398 commit c28d58a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/isodoc/xref/xref_counter_types.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require_relative "xref_counter"

module IsoDoc
module XrefGen
class ClauseCounter < Counter
class Xref
def class_counter(num = 0, opts = { numerals: :arabic })
::IsoDoc::XrefGen::Counter.new(num, opts)
end
end
end
6 changes: 3 additions & 3 deletions lib/isodoc/xref/xref_sect_gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def preface_anchor_names(xml)
end

def main_anchor_names(xml)
n = self.ClauseCounter.new
n = class_counter
clause_order_main(xml).each do |a|
xml.xpath(ns(a[:path])).each do |c|
section_names(c, n, 1)
Expand Down Expand Up @@ -144,7 +144,7 @@ def section_names(clause, num, lvl)
num.increment(clause)
section_name_anchors(clause, num.print, lvl)
clause.xpath(ns(SUBCLAUSES))
.each_with_object(self.ClauseCounter.new(0, prefix: "#{num.print}.")) do |c, i|
.each_with_object(class_counter(0, prefix: "#{num.print}.")) do |c, i|
section_names1(c, i.increment(c).print, lvl + 1)
end
num
Expand All @@ -153,7 +153,7 @@ def section_names(clause, num, lvl)
def section_names1(clause, num, level)
unnumbered_section_name?(clause) and return num
section_name_anchors(clause, num, level)
i = self.ClauseCounter.new(0, prefix: "#{num}.")
i = clause_counter(0, prefix: "#{num}.")
clause.xpath(ns(SUBCLAUSES)).each do |c|
section_names1(c, i.increment(c).print, level + 1)
end
Expand Down

0 comments on commit c28d58a

Please sign in to comment.