Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch-number override of section numbering: https://github.com/metan… #351

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "features/branch-number"

20 changes: 8 additions & 12 deletions lib/isodoc/bipm/xref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ 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
i = Counter.new(0, prefix: "#{num.print}.")
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
i.increment(c)
section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
section_names1(c, i.increment(c).print, lvl + 1)
end
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
unnumbered_section_names1(c, lvl + 1)
Expand All @@ -110,10 +109,9 @@ def section_name1_anchors(clause, num, level)

def section_names1(clause, num, level)
@anchors[clause["id"]] = section_name1_anchors(clause, num, level)
i = Counter.new
i = Counter.new(0, prefix: "#{num}.")
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
i.increment(c)
section_names1(c, "#{num}.#{i.print}", level + 1)
section_names1(c, i.increment(c).print, level + 1)
end
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
unnumbered_section_names1(c, lvl + 1)
Expand Down Expand Up @@ -158,11 +156,10 @@ def annex_names(clause, num)
annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
num.to_s, 1)
else
i = Counter.new
prefix = @jcgm ? "" : "A"
i = Counter.new(0, prefix: "#{prefix}#{num}.")
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
i.increment(c)
annex_names1(c, "#{prefix}#{num}.#{i.print}", 2)
annex_names1(c, i.increment(c).print, 2)
end
clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
.each { |c| unnumbered_annex_names1(c, 2) }
Expand Down Expand Up @@ -196,10 +193,9 @@ def annex_names1_anchors(num, level)

def annex_names1(clause, num, level)
@anchors[clause["id"]] = annex_names1_anchors(num, level)
i = Counter.new
i = Counter.new(0, prefix: "#{num}.")
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
i.increment(c)
annex_names1(c, "#{num}.#{i.print}", level + 1)
annex_names1(c, i.increment(c).print, level + 1)
end
clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
.each { |c| unnumbered_annex_names1(c, level + 1) }
Expand Down
1 change: 1 addition & 0 deletions lib/metanorma/bipm/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@
<value>obsoleted</value>
<value>confirmed</value>
<value>updated</value>
<value>corrected</value>
<value>issued</value>
<value>transmitted</value>
<value>copied</value>
Expand Down
16 changes: 15 additions & 1 deletion lib/metanorma/bipm/isodoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
these elements; we just want one namespace for any child grammars
of this.
-->
<!-- VERSION v1.2.6 -->
<!-- VERSION v1.2.7 -->
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<include href="reqt.rng"/>
<include href="basicdoc.rng">
Expand Down Expand Up @@ -1054,6 +1054,17 @@
<ref name="date_inline"/>
</choice>
</define>
<define name="PureTextElement" combine="choice">
<ref name="passthrough_inline"/>
</define>
<define name="passthrough_inline">
<element name="passthrough">
<optional>
<attribute name="formats"/>
</optional>
<text/>
</element>
</define>
<define name="add">
<element name="add">
<choice>
Expand Down Expand Up @@ -1092,6 +1103,9 @@
<optional>
<attribute name="style"/>
</optional>
<optional>
<attribute name="custom-charset"/>
</optional>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
Expand Down
3 changes: 3 additions & 0 deletions spec/isodoc/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
:circulateddate=>"XXX",
:confirmeddate=>"XXX",
:copieddate=>"XXX",
:correcteddate=>"XXX",
:createddate=>"XXX",
:docnumber=>"1000",
:docsubtitle=>"Chef Title",
Expand Down Expand Up @@ -284,6 +285,7 @@
:circulateddate=>"XXX",
:confirmeddate=>"XXX",
:copieddate=>"XXX",
:correcteddate=>"XXX",
:createddate=>"XXX",
:docnumber=>"1000",
:docsubtitle=>"Main Title",
Expand Down Expand Up @@ -347,6 +349,7 @@
:circulateddate=>"XXX",
:confirmeddate=>"XXX",
:copieddate=>"XXX",
:correcteddate=>"XXX",
:createddate=>"XXX",
:draft=>"3.4",
:draftinfo=>" (draft 3.4, 2000-01-01)",
Expand Down
30 changes: 15 additions & 15 deletions spec/vcr_cassettes/bipm-fr.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 40 additions & 40 deletions spec/vcr_cassettes/bipm.yml

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions spec/vcr_cassettes/standoc.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading