metanorma-iso 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b68e0ac152a02770b1ca677908a34d243a66ba8da955a98aac66391a6e1a73ae
4
- data.tar.gz: 4122f534ef647b210a829dc1645240b79bc240a0059dec141ca3eec0f1c64efc
3
+ metadata.gz: 1ab1010b198fb64456b71a06834ab3c1207417c16c765f6c5905cd18ff5a0dc8
4
+ data.tar.gz: c92bdd8228ce983eed939cb2b38b60b7ec631d37b64ea390e26e870700f7065b
5
5
  SHA512:
6
- metadata.gz: bb2d619b3e439f33ac96fd63691a288730daed7aa3ed8d478898caca5f755d3aea436469499afd81aa318519be87f5f12e5d8b632d17f40cff1b67e2c20851ad
7
- data.tar.gz: 2e37056accf0f22aa7a13702ff79c928c359c0188126a10e165e8c448a9a7f110acf743b29fed45b5b972c54d77f7a8a7610a6da889f8ef9ca43d3b77bbfa501
6
+ metadata.gz: de58d8b4fa0e039e153cd5a9d9637adaedf45e674cb59c113e2feb4eaa1444ca7d98badd5ac080687ec66ee19305e8b8677ea855c24b1df91ddae0c12464180a
7
+ data.tar.gz: 48d297855239fec0dd80dbb6db404bf4b8c2a79ba49051d275f56f3dff579bda479f30ba71ba1931170088c7e3c0014878b92af7d91177151f625cdf359e7ef9
@@ -6,7 +6,7 @@ module IsoDoc
6
6
  module Iso
7
7
  module BaseConvert
8
8
  def convert1(docxml, filename, dir)
9
- if amd(docxml)
9
+ if amd?(docxml)
10
10
  @oldsuppressheadingnumbers = @suppressheadingnumbers
11
11
  @suppressheadingnumbers = true
12
12
  end
@@ -20,7 +20,7 @@ module IsoDoc
20
20
  i18nyaml: i18nyaml || @i18nyaml)
21
21
  end
22
22
 
23
- def amd(docxml)
23
+ def amd?(docxml)
24
24
  doctype = docxml.at(ns("//bibdata/ext/doctype"))&.text
25
25
  %w(amendment technical-corrigendum).include? doctype
26
26
  end
@@ -44,16 +44,15 @@ module IsoDoc
44
44
  end
45
45
 
46
46
  def std_docid_semantic1(id)
47
- ids = id.split(/ /)
48
- %w(ISO IEC ITU IETF NIST OGC IEEE BIPM BSI IANA UN W3C IEV)
49
- .include?(ids[0].sub(/\/.*$/, "")) or
50
- return id
47
+ ids = id.split(/(\p{Zs})/)
48
+ agency?(ids[0].sub(/\/.*$/, "")) or return id
51
49
  ids.map! do |i|
52
50
  if %w(GUIDE TR TS DIR).include?(i)
53
51
  "<span class='stddocNumber'>#{i}</span>"
52
+ elsif /\p{Zs}/.match?(i) then i
54
53
  else std_docid_semantic_full(i)
55
54
  end
56
- end.join(" ")
55
+ end.join
57
56
  end
58
57
 
59
58
  def std_docid_semantic_full(ident)
@@ -2674,11 +2674,26 @@
2674
2674
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
2675
2675
  </xsl:if>
2676
2676
 
2677
- <xsl:value-of select="."/>
2677
+ <xsl:variable name="font_family" select="."/>
2678
2678
 
2679
- <xsl:if test="$additional_fonts != ''">
2680
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2681
- </xsl:if>
2679
+ <xsl:choose>
2680
+ <xsl:when test="$additional_fonts = ''">
2681
+ <xsl:value-of select="$font_family"/>
2682
+ </xsl:when>
2683
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
2684
+ <xsl:choose>
2685
+ <xsl:when test="contains($font_family, ',')">
2686
+ <xsl:value-of select="substring-before($font_family, ',')"/>
2687
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2688
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
2689
+ </xsl:when>
2690
+ <xsl:otherwise>
2691
+ <xsl:value-of select="$font_family"/>
2692
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2693
+ </xsl:otherwise>
2694
+ </xsl:choose>
2695
+ </xsl:otherwise>
2696
+ </xsl:choose>
2682
2697
  </xsl:attribute>
2683
2698
  </xsl:when>
2684
2699
  <xsl:otherwise>
@@ -5352,21 +5367,21 @@
5352
5367
 
5353
5368
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
5354
5369
 
5355
- <fo:block xsl:use-attribute-sets="table-note-style">
5370
+ <fo:block xsl:use-attribute-sets="table-note-style">
5356
5371
 
5357
- <xsl:call-template name="refine_table-note-style"/>
5372
+ <xsl:call-template name="refine_table-note-style"/>
5358
5373
 
5359
- <!-- Table's note/example name (NOTE, for example) -->
5360
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
5374
+ <!-- Table's note/example name (NOTE, for example) -->
5375
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
5361
5376
 
5362
- <xsl:call-template name="refine_table-note-name-style"/>
5377
+ <xsl:call-template name="refine_table-note-name-style"/>
5363
5378
 
5364
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5379
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
5365
5380
 
5366
- </fo:inline>
5381
+ </fo:inline>
5367
5382
 
5368
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5369
- </fo:block>
5383
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5384
+ </fo:block>
5370
5385
 
5371
5386
  </xsl:template> <!-- table/note -->
5372
5387
 
@@ -8588,8 +8603,12 @@
8588
8603
  <xsl:variable name="isAdded" select="../@added"/>
8589
8604
  <xsl:variable name="isDeleted" select="../@deleted"/>
8590
8605
  <xsl:choose>
8591
- <xsl:when test="ancestor::*[local-name() = 'title']">
8606
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
8592
8607
  <fo:inline padding-left="1mm" padding-right="1mm">
8608
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
8609
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
8610
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
8611
+ </xsl:if>
8593
8612
  <xsl:variable name="src">
8594
8613
  <xsl:call-template name="image_src"/>
8595
8614
  </xsl:variable>
@@ -8622,7 +8641,7 @@
8622
8641
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
8623
8642
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
8624
8643
 
8625
- <xsl:if test="@width != '' and @width != 'auto'">
8644
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
8626
8645
  <xsl:attribute name="width">
8627
8646
  <xsl:value-of select="@width"/>
8628
8647
  </xsl:attribute>
@@ -2674,11 +2674,26 @@
2674
2674
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
2675
2675
  </xsl:if>
2676
2676
 
2677
- <xsl:value-of select="."/>
2677
+ <xsl:variable name="font_family" select="."/>
2678
2678
 
2679
- <xsl:if test="$additional_fonts != ''">
2680
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2681
- </xsl:if>
2679
+ <xsl:choose>
2680
+ <xsl:when test="$additional_fonts = ''">
2681
+ <xsl:value-of select="$font_family"/>
2682
+ </xsl:when>
2683
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
2684
+ <xsl:choose>
2685
+ <xsl:when test="contains($font_family, ',')">
2686
+ <xsl:value-of select="substring-before($font_family, ',')"/>
2687
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2688
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
2689
+ </xsl:when>
2690
+ <xsl:otherwise>
2691
+ <xsl:value-of select="$font_family"/>
2692
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2693
+ </xsl:otherwise>
2694
+ </xsl:choose>
2695
+ </xsl:otherwise>
2696
+ </xsl:choose>
2682
2697
  </xsl:attribute>
2683
2698
  </xsl:when>
2684
2699
  <xsl:otherwise>
@@ -5352,21 +5367,21 @@
5352
5367
 
5353
5368
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
5354
5369
 
5355
- <fo:block xsl:use-attribute-sets="table-note-style">
5370
+ <fo:block xsl:use-attribute-sets="table-note-style">
5356
5371
 
5357
- <xsl:call-template name="refine_table-note-style"/>
5372
+ <xsl:call-template name="refine_table-note-style"/>
5358
5373
 
5359
- <!-- Table's note/example name (NOTE, for example) -->
5360
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
5374
+ <!-- Table's note/example name (NOTE, for example) -->
5375
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
5361
5376
 
5362
- <xsl:call-template name="refine_table-note-name-style"/>
5377
+ <xsl:call-template name="refine_table-note-name-style"/>
5363
5378
 
5364
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5379
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
5365
5380
 
5366
- </fo:inline>
5381
+ </fo:inline>
5367
5382
 
5368
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5369
- </fo:block>
5383
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5384
+ </fo:block>
5370
5385
 
5371
5386
  </xsl:template> <!-- table/note -->
5372
5387
 
@@ -8588,8 +8603,12 @@
8588
8603
  <xsl:variable name="isAdded" select="../@added"/>
8589
8604
  <xsl:variable name="isDeleted" select="../@deleted"/>
8590
8605
  <xsl:choose>
8591
- <xsl:when test="ancestor::*[local-name() = 'title']">
8606
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
8592
8607
  <fo:inline padding-left="1mm" padding-right="1mm">
8608
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
8609
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
8610
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
8611
+ </xsl:if>
8593
8612
  <xsl:variable name="src">
8594
8613
  <xsl:call-template name="image_src"/>
8595
8614
  </xsl:variable>
@@ -8622,7 +8641,7 @@
8622
8641
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
8623
8642
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
8624
8643
 
8625
- <xsl:if test="@width != '' and @width != 'auto'">
8644
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
8626
8645
  <xsl:attribute name="width">
8627
8646
  <xsl:value-of select="@width"/>
8628
8647
  </xsl:attribute>
@@ -11,7 +11,7 @@ module IsoDoc
11
11
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
12
12
  def convert1(docxml, filename, dir)
13
13
  @iso_class = instance_of?(IsoDoc::Iso::PresentationXMLConvert)
14
- if amd(docxml)
14
+ if amd?(docxml)
15
15
  @oldsuppressheadingnumbers = @suppressheadingnumbers
16
16
  @suppressheadingnumbers = true
17
17
  end
@@ -38,12 +38,12 @@ module IsoDoc
38
38
  end
39
39
 
40
40
  def annex(isoxml)
41
- amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
41
+ amd?(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
42
42
  super
43
43
  isoxml.xpath(ns("//annex//clause | //annex//appendix")).each do |f|
44
44
  clause1(f)
45
45
  end
46
- amd(isoxml) and @suppressheadingnumbers = true
46
+ amd?(isoxml) and @suppressheadingnumbers = true
47
47
  end
48
48
 
49
49
  def figure1(node)
@@ -87,23 +87,25 @@ module IsoDoc
87
87
  end
88
88
  end
89
89
 
90
- # we're assuming terms and clauses in the right place for display,
91
- # to cope with multiple terms sections
92
- def display_order(docxml)
93
- i = 0
94
- i = display_order_xpath(docxml, "//preface/*", i)
95
- i = display_order_at(docxml, "//clause[@type = 'scope']", i)
96
- i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
97
- i = display_order_xpath(docxml,
98
- "//sections/clause[not(@type = 'scope')][not(.//references)] | " \
99
- "//sections/terms | //sections/definitions", i)
100
- i = display_order_xpath(docxml, "//annex", i)
101
- i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
102
- display_order_xpath(docxml, "//indexsect", i)
103
- end
104
-
105
90
  def admonition1(elem)
106
91
  super
92
+ admonition_inline_name(elem)
93
+ admonition_outside_clauses(elem)
94
+ end
95
+
96
+ def admonition_outside_clauses(elem)
97
+ elem.parent.name == "sections" or return
98
+ wrap_in_bold(elem)
99
+ end
100
+
101
+ def wrap_in_bold(cell)
102
+ cell.text? && cell.text.strip.empty? and return
103
+ cell.text? and cell.swap("<strong>#{cell.to_xml}</strong>")
104
+ %w(strong fn).include?(cell.name) and return
105
+ cell.children.each { |p| wrap_in_bold(p) }
106
+ end
107
+
108
+ def admonition_inline_name(elem)
107
109
  n = elem.at(ns("./name")) or return
108
110
  if (p = n.next_element) && p&.name == "p"
109
111
  p.children.first.previous = admonition_name(to_xml(n.remove.children))
@@ -194,6 +196,12 @@ module IsoDoc
194
196
  ret
195
197
  end
196
198
 
199
+ def move_norm_ref_to_sections(docxml)
200
+ if amd?(docxml)
201
+ else super
202
+ end
203
+ end
204
+
197
205
  include Init
198
206
  end
199
207
  end
@@ -2,10 +2,10 @@ module IsoDoc
2
2
  module Iso
3
3
  module BaseConvert
4
4
  def annex(node, out)
5
- amd(node.document) and
5
+ amd?(node.document) and
6
6
  @suppressheadingnumbers = @oldsuppressheadingnumbers
7
7
  super
8
- amd(node.document) and @suppressheadingnumbers = true
8
+ amd?(node.document) and @suppressheadingnumbers = true
9
9
  end
10
10
 
11
11
  def foreword(clause, out)
@@ -103,15 +103,18 @@ module IsoDoc
103
103
  end
104
104
 
105
105
  def span_parse(node, out)
106
+ st = node["style"]
106
107
  case node["class"]
107
108
  when "nonboldtitle"
108
- out.span(style: "font-weight:normal") do |s|
109
+ out.span **attr_code(style: "#{st};font-weight:normal") do |s|
109
110
  node.children.each { |n| parse(n, s) }
110
111
  end
111
112
  when "boldtitle"
112
- node.children.each { |n| parse(n, out) }
113
+ out.span **attr_code(style: st) do |s|
114
+ node.children.each { |n| parse(n, s) }
115
+ end
113
116
  else
114
- out.span class: node["class"] do |x|
117
+ out.span **attr_code(class: node["class"], style: st) do |x|
115
118
  node.children.each { |n| parse(n, x) }
116
119
  end
117
120
  end
@@ -8,22 +8,33 @@ module IsoDoc
8
8
  class Xref < IsoDoc::Xref
9
9
  attr_accessor :anchors_previous, :anchors
10
10
 
11
- def initial_anchor_names(doc)
12
- if @klass.amd(doc) then initial_anchor_names_amd(doc)
13
- else initial_anchor_names1(doc)
11
+ def clause_order_main(docxml)
12
+ if @klass.amd?(docxml)
13
+ [{ path: "//sections/clause", multi: true }]
14
+ else
15
+ [{ path: "//clause[@type = 'scope']" },
16
+ { path: @klass.norm_ref_xpath },
17
+ { path:
18
+ "#{@klass.middle_clause(docxml)} | //sections/terms | " \
19
+ "//sections/clause[descendant::terms or descendant::definitions] " \
20
+ "| //sections/definitions", multi: true }]
14
21
  end
15
- if @parse_settings.empty? || @parse_settings[:clauses]
16
- introduction_names(doc.at(ns("//introduction")))
22
+ end
23
+
24
+ def clause_order_back(docxml)
25
+ if @klass.amd?(docxml)
26
+ [{ path: @klass.norm_ref_xpath },
27
+ { path: @klass.bibliography_xpath },
28
+ { path: "//indexsect", multi: true },
29
+ { path: "//colophon/*", multi: true }]
30
+ else super
17
31
  end
18
32
  end
19
33
 
20
- def initial_anchor_names_amd(doc)
34
+ def initial_anchor_names(doc)
35
+ super
21
36
  if @parse_settings.empty? || @parse_settings[:clauses]
22
- ["//preface/*", "//sections/clause"].each do |xpath|
23
- doc.xpath(ns(xpath)).each do |c|
24
- c.element? and preface_names(c)
25
- end
26
- end
37
+ introduction_names(doc.at(ns("//introduction")))
27
38
  end
28
39
  end
29
40
 
@@ -33,23 +44,6 @@ module IsoDoc
33
44
  sequential_asset_names(doc.xpath(ns("//preface/*")))
34
45
  end
35
46
 
36
- def initial_anchor_names1(doc)
37
- if @parse_settings.empty? || @parse_settings[:clauses]
38
- doc.xpath(ns("//preface/*")).each do |c|
39
- c.element? and preface_names(c)
40
- end
41
- # potentially overridden in middle_section_asset_names()
42
- sequential_asset_names(doc.xpath(ns("//preface/*")))
43
- n = Counter.new
44
- n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
45
- n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
46
- doc.xpath(ns("//sections/clause[not(@type = 'scope')][not(.//references)] | " \
47
- "//sections/terms | //sections/definitions")).each do |c|
48
- n = section_names(c, n, 1)
49
- end
50
- end
51
- end
52
-
53
47
  def hierarchical_formula_names(clause, num)
54
48
  c = IsoDoc::XrefGen::Counter.new
55
49
  clause.xpath(ns(".//formula")).each do |t|
@@ -131,13 +125,6 @@ module IsoDoc
131
125
  .sub(/ \(All Parts\)/i, "") }
132
126
  end
133
127
 
134
- def back_anchor_names(docxml)
135
- super
136
- if @parse_settings.empty? || @parse_settings[:clauses]
137
- docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
138
- end
139
- end
140
-
141
128
  def list_anchor_names(sections)
142
129
  sections.each do |s|
143
130
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
@@ -1,5 +1,5 @@
1
1
  == copyright-statement
2
- === {% if stage_int >= 40 %}DOCUMENT PROTÉGÉ PAR COPYRIGHT{%else%}{blank}
2
+ === {% if stage_int >= 40 %}DOCUMENT PROTÉGÉ PAR COPYRIGHT{%else%}{blank}{%endif%}
3
3
 
4
4
  [[boilerplate-year]]
5
5
  &#xa9; span:std_publisher:[{{ agency }}] span:std_docNumber[{{ docyear }}]
@@ -110,10 +110,10 @@ module Metanorma
110
110
  xml.xpath("//*[@inline-header]").each { |h| h.delete("inline-header") }
111
111
  end
112
112
 
113
- def boilerplate_file(xmldoc)
113
+ def boilerplate_file(_xmldoc)
114
114
  file = case @lang
115
- when "fr" then "boilerplate-fr.xml"
116
- when "ru" then "boilerplate-ru.xml"
115
+ when "fr" then "boilerplate-fr.adoc"
116
+ when "ru" then "boilerplate-ru.adoc"
117
117
  else "boilerplate.adoc"
118
118
  end
119
119
  File.join(@libdir, file)
@@ -142,11 +142,10 @@ module Metanorma
142
142
  def unpublished_note(xmldoc)
143
143
  xmldoc.xpath("//bibitem[not(./ancestor::bibitem)]" \
144
144
  "[not(note[@type = 'Unpublished-Status'])]").each do |b|
145
- next if pub_class(b) > 2
146
- next unless (s = b.at("./status/stage")) && (s.text.to_i < 60)
147
-
145
+ pub_class(b) > 2 and next
146
+ ((s = b.at("./status/stage")) && (s.text.to_i < 60)) or next
148
147
  id = b.at("docidentifier").text
149
- insert_unpub_note(b, @i18n.under_preparation.sub(/%/, id))
148
+ insert_unpub_note(b, @i18n.under_preparation.sub("%", id))
150
149
  end
151
150
  end
152
151
 
@@ -155,7 +154,7 @@ module Metanorma
155
154
  .each do |b|
156
155
  withdrawn_ref?(b) or next
157
156
  if id = replacement_standard(b)
158
- insert_unpub_note(b, @i18n.cancelled_and_replaced.sub(/%/, id))
157
+ insert_unpub_note(b, @i18n.cancelled_and_replaced.sub("%", id))
159
158
  else insert_unpub_note(b, @i18n.withdrawn)
160
159
  end
161
160
  end
@@ -227,7 +226,7 @@ module Metanorma
227
226
  xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']/" \
228
227
  "organization").each_with_object([]) do |p, m|
229
228
  x = p.at("./abbreviation") || p.at("./name") or next
230
- m << x.text
229
+ m << x.children.to_xml
231
230
  end
232
231
  end
233
232
 
@@ -237,8 +236,7 @@ module Metanorma
237
236
  def editorial_group_types(xmldoc)
238
237
  %w(technical-committee subcommittee workgroup).each do |v|
239
238
  xmldoc.xpath("//bibdata//#{v} | //bibdata//approval-#{v}").each do |g|
240
- next if g["type"]
241
-
239
+ g["type"] and next
242
240
  g["type"] = DEFAULT_EDGROUP_TYPE[v.to_sym]
243
241
  end
244
242
  end
@@ -5,6 +5,7 @@ require "json"
5
5
  require "pathname"
6
6
  require "open-uri"
7
7
  require_relative "front_id"
8
+ require_relative "front_contributor"
8
9
 
9
10
  module Metanorma
10
11
  module ISO
@@ -17,13 +18,16 @@ module Metanorma
17
18
  xml.updates_document_type a
18
19
  end
19
20
 
21
+ STAGE_ERROR = [Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
22
+ Pubid::Core::Errors::TypeStageParseError,
23
+ Pubid::Core::Errors::StageInvalidError].freeze
24
+
20
25
  def metadata_stage(node, xml)
21
26
  id = iso_id_default(iso_id_params(node))
22
27
  id.stage and
23
28
  xml.stagename metadata_stagename(id)&.strip,
24
29
  **attr_code(abbreviation: id.typed_stage_abbrev&.strip)
25
- rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
26
- Pubid::Core::Errors::TypeStageParseError
30
+ rescue *STAGE_ERROR
27
31
  end
28
32
 
29
33
  def metadata_stagename(id)
@@ -44,53 +48,6 @@ module Metanorma
44
48
  a = node.attr("horizontal") and xml.horizontal a
45
49
  end
46
50
 
47
- def org_abbrev
48
- { "International Organization for Standardization" => "ISO",
49
- "International Electrotechnical Commission" => "IEC" }
50
- end
51
-
52
- def metadata_author(node, xml)
53
- publishers = node.attr("publisher") || "ISO"
54
- csv_split(publishers).each do |p|
55
- xml.contributor do |c|
56
- c.role type: "author"
57
- c.organization do |a|
58
- organization(a, p, false, node, !node.attr("publisher"))
59
- end
60
- end
61
- end
62
- end
63
-
64
- def metadata_publisher(node, xml)
65
- publishers = node.attr("publisher") || "ISO"
66
- csv_split(publishers).each do |p|
67
- xml.contributor do |c|
68
- c.role type: "publisher"
69
- c.organization do |a|
70
- organization(a, p, true, node, !node.attr("publisher"))
71
- end
72
- end
73
- end
74
- end
75
-
76
- def metadata_copyright(node, xml)
77
- publishers = node.attr("copyright-holder") || node.attr("publisher") ||
78
- "ISO"
79
- csv_split(publishers).each do |p|
80
- xml.copyright do |c|
81
- c.from (node.attr("copyright-year") || Date.today.year)
82
- c.owner do |owner|
83
- owner.organization do |o|
84
- organization(
85
- o, p, true, node,
86
- !(node.attr("copyright-holder") || node.attr("publisher"))
87
- )
88
- end
89
- end
90
- end
91
- end
92
- end
93
-
94
51
  def metadata_status(node, xml)
95
52
  stage = get_stage(node)
96
53
  substage = get_substage(node)
@@ -100,8 +57,7 @@ module Metanorma
100
57
  s.substage substage
101
58
  i = node.attr("iteration") and s.iteration i
102
59
  end
103
- rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
104
- Pubid::Core::Errors::TypeStageParseError
60
+ rescue *STAGE_ERROR
105
61
  report_illegal_stage(stage, substage)
106
62
  end
107
63
 
@@ -111,46 +67,6 @@ module Metanorma
111
67
  warn err
112
68
  end
113
69
 
114
- def metadata_committee(node, xml)
115
- metadata_editorial_committee(node, xml)
116
- metadata_approval_committee(node, xml)
117
- end
118
-
119
- def metadata_editorial_committee(node, xml)
120
- xml.editorialgroup do |a|
121
- %w(technical-committee subcommittee workgroup).each do |v|
122
- node.attr("#{v}-number") and committee_component(v, node, a)
123
- end
124
- node.attr("secretariat") and a.secretariat(node.attr("secretariat"))
125
- end
126
- end
127
-
128
- def metadata_approval_committee(node, xml)
129
- types = metadata_approval_committee_types(node)
130
- xml.approvalgroup do |a|
131
- metadata_approval_agency(a, node.attr("approval-agency")
132
- &.split(%r{[/,;]}))
133
- types.each do |v|
134
- node.attr("#{v}-number") and committee_component(v, node, a)
135
- end
136
- end
137
- end
138
-
139
- def metadata_approval_committee_types(node)
140
- types = %w(technical-committee subcommittee workgroup)
141
- node.attr("approval-technical-committee-number") and
142
- types = %w(approval-technical-committee approval-subcommittee
143
- approval-workgroup)
144
- types
145
- end
146
-
147
- def metadata_approval_agency(xml, list)
148
- list = ["ISO"] if list.nil? || list.empty?
149
- list.each do |v|
150
- xml.agency v
151
- end
152
- end
153
-
154
70
  def title_intro(node, xml, lang, at)
155
71
  return unless node.attr("title-intro-#{lang}")
156
72
 
@@ -0,0 +1,144 @@
1
+ module Metanorma
2
+ module ISO
3
+ class Converter < Standoc::Converter
4
+ def home_agency
5
+ "ISO"
6
+ end
7
+
8
+ def org_abbrev
9
+ { "International Organization for Standardization" => "ISO",
10
+ "International Electrotechnical Commission" => "IEC" }
11
+ end
12
+
13
+ def metadata_author(node, xml)
14
+ publishers = node.attr("publisher") || home_agency
15
+ metadata_contrib_sdo(node, xml, publishers,
16
+ { role: "author",
17
+ default_org: !node.attr("publisher") })
18
+ committee_contributors(node, xml, false, home_agency)
19
+ end
20
+
21
+ def metadata_contrib_sdo(node, xml, publishers, opt)
22
+ publishers.nil? and return
23
+ csv_split(publishers).each do |p|
24
+ xml.contributor do |c|
25
+ c.role type: opt[:role] do |r|
26
+ opt[:desc] and r << opt[:desc]
27
+ end
28
+ c.organization do |a|
29
+ (opt[:committee] and
30
+ contrib_committee_build(a, opt[:agency],
31
+ { name: p, id: opt[:ident] })) or
32
+ organization(a, p, opt[:role] == "publisher", node,
33
+ opt[:default_org])
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def committee_contributors(node, xml, approval, agency)
40
+ types = metadata_approval_committee_types(approval ? node : nil)
41
+ types.each do |v|
42
+ n = node.attr("#{v}-number") or next
43
+ t = committee_abbrev(node.attr("#{v}-type"), n, v)
44
+ metadata_contrib_sdo(
45
+ node, xml, node.attr(v),
46
+ { role: approval ? "authorizer" : "author", ident: t,
47
+ default_org: false, committee: true, agency: agency,
48
+ desc: v.sub(/^approval-/, "").gsub("-", " ").capitalize }
49
+ )
50
+ end
51
+ approval and
52
+ metadata_contrib_sdo(node, xml, agency,
53
+ { role: "authorizer", default_org: false,
54
+ desc: "Agency", committee: false })
55
+ end
56
+
57
+ def contrib_committee_build(xml, agency, committee)
58
+ n = org_abbrev.invert[agency] and agency = n
59
+ xml.name agency
60
+ xml.subdivision committee[:name]
61
+ committee[:abbr] and xml.abbreviation committee[:abbr]
62
+ committee[:id] and xml.identifier committee[:id]
63
+ end
64
+
65
+ COMMITTEE_ABBREVS =
66
+ { "technical-committee" => "TC", "subcommittee" => "SC",
67
+ "workgroup" => "WG" }.freeze
68
+
69
+ def committee_abbrev(type, number, level)
70
+ type ||= COMMITTEE_ABBREVS[level.sub(/^approval-/, "")]
71
+ type == "Other" and type = ""
72
+ "#{type} #{number}".strip
73
+ end
74
+
75
+ def metadata_publisher(node, xml)
76
+ publishers = node.attr("publisher") || home_agency
77
+ metadata_contrib_sdo(node, xml, publishers,
78
+ { role: "publisher",
79
+ default_org: !node.attr("publisher") })
80
+ # approvals
81
+ committee_contributors(node, xml, true,
82
+ node.attr("approval-agency") || home_agency)
83
+ end
84
+
85
+ def metadata_copyright(node, xml)
86
+ publishers = node.attr("copyright-holder") || node.attr("publisher") ||
87
+ home_agency
88
+ csv_split(publishers).each do |p|
89
+ xml.copyright do |c|
90
+ c.from (node.attr("copyright-year") || Date.today.year)
91
+ c.owner do |owner|
92
+ owner.organization do |o|
93
+ organization(
94
+ o, p, true, node,
95
+ !(node.attr("copyright-holder") || node.attr("publisher"))
96
+ )
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ def metadata_committee(node, xml)
104
+ metadata_editorial_committee(node, xml)
105
+ metadata_approval_committee(node, xml)
106
+ end
107
+
108
+ def metadata_editorial_committee(node, xml)
109
+ xml.editorialgroup do |a|
110
+ %w(technical-committee subcommittee workgroup).each do |v|
111
+ node.attr("#{v}-number") and committee_component(v, node, a)
112
+ end
113
+ node.attr("secretariat") and a.secretariat(node.attr("secretariat"))
114
+ end
115
+ end
116
+
117
+ def metadata_approval_committee(node, xml)
118
+ types = metadata_approval_committee_types(node)
119
+ xml.approvalgroup do |a|
120
+ metadata_approval_agency(a, node.attr("approval-agency")
121
+ &.split(%r{[/,;]}))
122
+ types.each do |v|
123
+ node.attr("#{v}-number") and committee_component(v, node, a)
124
+ end
125
+ end
126
+ end
127
+
128
+ def metadata_approval_committee_types(node)
129
+ types = %w(technical-committee subcommittee workgroup)
130
+ !node.nil? && node.attr("approval-technical-committee-number") and
131
+ types = %w(approval-technical-committee approval-subcommittee
132
+ approval-workgroup)
133
+ types
134
+ end
135
+
136
+ def metadata_approval_agency(xml, list)
137
+ list = [home_agency] if list.nil? || list.empty?
138
+ list.each do |v|
139
+ xml.agency v
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.3 -->
20
+ <!-- VERSION v1.2.4 -->
21
21
  <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">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -2068,6 +2068,9 @@
2068
2068
  </define>
2069
2069
  <define name="termdefinition">
2070
2070
  <element name="definition">
2071
+ <optional>
2072
+ <attribute name="type"/>
2073
+ </optional>
2071
2074
  <choice>
2072
2075
  <ref name="verbaldefinition"/>
2073
2076
  <ref name="nonverbalrep"/>
@@ -34,7 +34,7 @@ module Metanorma
34
34
  root.xpath("//xref").each do |t|
35
35
  preceding = t.at("./preceding-sibling::text()[last()]")
36
36
  next unless !preceding.nil? &&
37
- /\b(see| refer to)\s*\Z/mi.match(preceding)
37
+ /\b(see| refer to)\p{Zs}*\Z/mi.match(preceding)
38
38
 
39
39
  (target = root.at("//*[@id = '#{t['target']}']")) || next
40
40
  target.at("./ancestor-or-self::*[@obligation = 'normative']") &&
@@ -49,7 +49,7 @@ module Metanorma
49
49
  @lang == "en" or return
50
50
  root.xpath("//eref").each do |t|
51
51
  prec = t.at("./preceding-sibling::text()[last()]")
52
- next unless !prec.nil? && /\b(see|refer to)\s*\Z/mi.match(prec)
52
+ next unless !prec.nil? && /\b(see|refer to)\p{Zs}*\Z/mi.match(prec)
53
53
 
54
54
  unless target = root.at("//*[@id = '#{t['bibitemid']}']")
55
55
  @log.add("Bibliography", t,
@@ -20,7 +20,7 @@ module Metanorma
20
20
 
21
21
  def requirement_re
22
22
  Regexp.new(self.class::REQUIREMENT_RE_STR.gsub(/\s/, "")
23
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
23
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
24
24
  end
25
25
 
26
26
  def requirement_check(text)
@@ -41,7 +41,7 @@ module Metanorma
41
41
 
42
42
  def recommendation_re
43
43
  Regexp.new(self.class::RECOMMENDATION_RE_STR.gsub(/\s/, "")
44
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
44
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
45
45
  end
46
46
 
47
47
  def recommendation_check(text)
@@ -64,7 +64,7 @@ module Metanorma
64
64
  def permission_re
65
65
  @lang == "en" or return
66
66
  Regexp.new(self.class::PERMISSION_RE_STR.gsub(/\s/, "")
67
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
67
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
68
68
  end
69
69
 
70
70
  def permission_check(text)
@@ -87,7 +87,7 @@ module Metanorma
87
87
  def possibility_re
88
88
  @lang == "en" or return
89
89
  Regexp.new(self.class::POSSIBILITY_RE_STR.gsub(/\s/, "")
90
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
90
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
91
91
  end
92
92
 
93
93
  def possibility_check(text)
@@ -111,7 +111,7 @@ module Metanorma
111
111
  def ambig_words_re
112
112
  @lang == "en" or return
113
113
  Regexp.new(self.class::AMBIG_WORDS_RE_STR.gsub(/\s/, "")
114
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
114
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
115
115
  end
116
116
 
117
117
  def ambig_words_check(text)
@@ -4,7 +4,7 @@ module Metanorma
4
4
  module ISO
5
5
  class Converter < Standoc::Converter
6
6
  def section_validate(doc)
7
- doctype = doc&.at("//bibdata/ext/doctype")&.text
7
+ doctype = doc.at("//bibdata/ext/doctype")&.text
8
8
  unless %w(amendment technical-corrigendum).include? doctype
9
9
  foreword_validate(doc.root)
10
10
  normref_validate(doc.root)
@@ -193,10 +193,14 @@ module Metanorma
193
193
  NORM_BIBITEMS =
194
194
  "//references[@normative = 'true']/bibitem".freeze
195
195
 
196
+ ISO_PUBLISHER_XPATH = <<~XPATH.freeze
197
+ ./contributor[role/@type = 'publisher']/organization[abbreviation = 'ISO' or abbreviation = 'IEC' or name = 'International Organization for Standardization' or name = 'International Electrotechnical Commission']
198
+ XPATH
199
+
196
200
  # ISO/IEC DIR 2, 10.2
197
201
  def norm_bibitem_style(root)
198
202
  root.xpath(NORM_BIBITEMS).each do |b|
199
- if b.at(Standoc::Converter::ISO_PUBLISHER_XPATH).nil?
203
+ if b.at(ISO_PUBLISHER_XPATH).nil?
200
204
  @log.add("Style", b, "#{NORM_ISO_WARN}: #{b.text}")
201
205
  end
202
206
  end
@@ -127,7 +127,7 @@ module Metanorma
127
127
  "possible decimal point", node, text)
128
128
  @lang == "en" and style_regex(/\b(?<num>billions?)\b/i,
129
129
  "ambiguous number", node, text)
130
- style_regex(/(?:^|\s)(?<num>-[0-9][0-9,.]*)/i,
130
+ style_regex(/(?:^|\P{Zs})(?<num>-[0-9][0-9,.]*)/i,
131
131
  "hyphen instead of minus sign U+2212", node, text)
132
132
  end
133
133
 
@@ -158,8 +158,8 @@ module Metanorma
158
158
  # ISO/IEC DIR 2, 8.4
159
159
  # ISO/IEC DIR 2, 9.3
160
160
  def style_abbrev(node, text)
161
- style_regex(/(\A|\s)(?!e\.g\.|i\.e\.)
162
- (?<num>[a-z]{1,2}\.([a-z]{1,2}|\.))\b/ix,
161
+ style_regex(/(?:\A|\p{Zs})(?!e\.g\.|i\.e\.)
162
+ (?<num>[a-z]{1,2}\.(?:[a-z]{1,2}|\.))\b/ix,
163
163
  "no dots in abbreviations", node, text)
164
164
  style_regex(/\b(?<num>ppm)\b/i,
165
165
  "language-specific abbreviation", node, text)
@@ -172,7 +172,7 @@ module Metanorma
172
172
 
173
173
  # ISO/IEC DIR 2, 9.3
174
174
  def style_units(node, text)
175
- style_regex(/\b(?<num>[0-9][0-9,]*\s+[\u00b0\u2032\u2033])/,
175
+ style_regex(/\b(?<num>[0-9][0-9,]*\p{Zs}+[\u00b0\u2032\u2033])/,
176
176
  "space between number and degrees/minutes/seconds",
177
177
  node, text)
178
178
  style_regex(/\b(?<num>[0-9][0-9,]*#{SI_UNIT})\b/o,
@@ -188,7 +188,7 @@ module Metanorma
188
188
  # ISO/IEC DIR 2, 9.3
189
189
  def style_non_std_units(node, text)
190
190
  NONSTD_UNITS.each do |k, v|
191
- style_regex(/\b(?<num>[0-9][0-9,]*\s+#{k})\b/,
191
+ style_regex(/\b(?<num>[0-9][0-9,]*\p{Zs}+#{k})\b/,
192
192
  "non-standard unit (should be #{v})", node, text)
193
193
  end
194
194
  end
@@ -198,7 +198,7 @@ module Metanorma
198
198
  def style_punct(node, text)
199
199
  @lang == "en" and style_regex(/\b(?<num>and\/?or)\b/i,
200
200
  "Use 'either x or y, or both'", node, text)
201
- style_regex(/\s(?<num>&)\s/i,
201
+ style_regex(/\p{Zs}(?<num>&)\p{Zs}/i,
202
202
  "Avoid ampersand in ordinary text'", node, text)
203
203
  eref_style_punct(node)
204
204
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.5.0".freeze
3
+ VERSION = "2.5.1".freeze
4
4
  end
5
5
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
33
33
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
34
34
 
35
- spec.add_dependency "metanorma-standoc", "~> 2.5.0"
35
+ spec.add_dependency "metanorma-standoc", "~> 2.5.1"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
37
  spec.add_dependency "pubid-iso", "~> 0.5.0"
38
38
  spec.add_dependency "ruby-jing"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-07 00:00:00.000000000 Z
11
+ date: 2023-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.5.0
19
+ version: 2.5.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.5.0
26
+ version: 2.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -375,6 +375,7 @@ files:
375
375
  - lib/metanorma/iso/cleanup.rb
376
376
  - lib/metanorma/iso/converter.rb
377
377
  - lib/metanorma/iso/front.rb
378
+ - lib/metanorma/iso/front_contributor.rb
378
379
  - lib/metanorma/iso/front_id.rb
379
380
  - lib/metanorma/iso/isodoc.rng
380
381
  - lib/metanorma/iso/isostandard-amd.rng