Skip to content

Commit

Permalink
configure separator on xref counter: metanorma/metanorma-jis#228
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Oct 24, 2024
1 parent ba317bb commit a009bbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/isodoc/xref/xref_counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def initialize(num = 0, opts = { numerals: :arabic })
@style = opts[:numerals]
@skip_i = opts[:skip_i]
@prefix = opts[:prefix]
@separator = opts[:separator] || "."
@base = ""
if num.is_a? String
if /^\d+$/.match?(num)
Expand Down Expand Up @@ -166,7 +167,9 @@ def print
@prefix_override and return @prefix_override
num = @number_override || @num
out = style_number(num)
"#{@prefix}#{@base}#{out}#{@letter_override || @letter}"
prefix = @prefix
prefix &&= "#{prefix}#{@separator}"
"#{prefix}#{@base}#{out}#{@letter_override || @letter}"
end

def ol_type(list, depth)
Expand Down
8 changes: 4 additions & 4 deletions lib/isodoc/xref/xref_sect_gen.rb
Original file line number Diff line number Diff line change
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(clause_counter(0, prefix: "#{num.print}.")) do |c, i|
.each_with_object(clause_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 = clause_counter(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 Expand Up @@ -203,7 +203,7 @@ def annex_names(clause, num)
num.to_s, 1)
else
clause.xpath(ns(SUBCLAUSES))
.each_with_object(clause_counter(0, prefix: "#{num}.")) do |c, i|
.each_with_object(clause_counter(0, prefix: num)) do |c, i|
annex_names1(c, i.increment(c).print, 2)
end
end
Expand All @@ -212,7 +212,7 @@ def annex_names(clause, num)

def annex_names1(clause, num, level)
annex_name_anchors(clause, num, level)
i = clause_counter(0, prefix: "#{num}.")
i = clause_counter(0, prefix: num)
clause.xpath(ns(SUBCLAUSES)).each do |c|
annex_names1(c, i.increment(c).print, level + 1)
end
Expand Down

0 comments on commit a009bbc

Please sign in to comment.