From c1cdd9c57be6986b39d95308c8987c12f0c38274 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 23 Oct 2024 00:18:48 +1100 Subject: [PATCH] subclass ClauseCounter, to allow it to be overridden in flavours: https://github.com/metanorma/metanorma-jis/issues/228 --- lib/isodoc/xref.rb | 1 + lib/isodoc/xref/xref_counter_types.rb | 11 +++++++++++ lib/isodoc/xref/xref_gen.rb | 3 +-- lib/isodoc/xref/xref_sect_gen.rb | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 lib/isodoc/xref/xref_counter_types.rb diff --git a/lib/isodoc/xref.rb b/lib/isodoc/xref.rb index b2ddae68..41a2e893 100644 --- a/lib/isodoc/xref.rb +++ b/lib/isodoc/xref.rb @@ -1,5 +1,6 @@ require_relative "xref/xref_anchor" require_relative "xref/xref_counter" +require_relative "xref/xref_counter_types" require_relative "xref/xref_gen_seq" require_relative "xref/xref_gen" require_relative "xref/xref_sect_gen" diff --git a/lib/isodoc/xref/xref_counter_types.rb b/lib/isodoc/xref/xref_counter_types.rb new file mode 100644 index 00000000..6afa085f --- /dev/null +++ b/lib/isodoc/xref/xref_counter_types.rb @@ -0,0 +1,11 @@ +require_relative "xref_counter" + +module IsoDoc + module XrefGen + class ClauseCounter < Counter + def initialize(num = 0, opts = { numerals: :arabic }) + super + end + end + end +end diff --git a/lib/isodoc/xref/xref_gen.rb b/lib/isodoc/xref/xref_gen.rb index cfeb3d00..d6c13912 100644 --- a/lib/isodoc/xref/xref_gen.rb +++ b/lib/isodoc/xref/xref_gen.rb @@ -33,8 +33,7 @@ def termnote_label(note) end def increment_label(elems, node, counter, increment: true) - return "" if elems.size == 1 && !node["number"] - + elems.size == 1 && !node["number"] and return "" counter.increment(node) if increment " #{counter.print}" end diff --git a/lib/isodoc/xref/xref_sect_gen.rb b/lib/isodoc/xref/xref_sect_gen.rb index c9babe95..90d2540b 100644 --- a/lib/isodoc/xref/xref_sect_gen.rb +++ b/lib/isodoc/xref/xref_sect_gen.rb @@ -56,7 +56,7 @@ def preface_anchor_names(xml) end def main_anchor_names(xml) - n = Counter.new + n = ClauseCounter.new clause_order_main(xml).each do |a| xml.xpath(ns(a[:path])).each do |c| section_names(c, n, 1)