metanorma-iso 2.5.0 → 2.5.2
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 +4 -4
- data/lib/isodoc/iso/base_convert.rb +1 -1
- data/lib/isodoc/iso/init.rb +6 -8
- data/lib/isodoc/iso/iso.amendment.xsl +34 -15
- data/lib/isodoc/iso/iso.international-standard.xsl +34 -15
- data/lib/isodoc/iso/pdf_convert.rb +1 -1
- data/lib/isodoc/iso/presentation_xml_convert.rb +27 -20
- data/lib/isodoc/iso/sections.rb +2 -2
- data/lib/isodoc/iso/word_convert.rb +2 -4
- data/lib/isodoc/iso/word_dis_convert.rb +6 -3
- data/lib/isodoc/iso/xref.rb +22 -35
- data/lib/metanorma/iso/boilerplate-fr.adoc +1 -1
- data/lib/metanorma/iso/cleanup.rb +9 -11
- data/lib/metanorma/iso/front.rb +7 -91
- data/lib/metanorma/iso/front_contributor.rb +144 -0
- data/lib/metanorma/iso/isodoc.rng +4 -1
- data/lib/metanorma/iso/validate.rb +12 -14
- data/lib/metanorma/iso/validate_requirements.rb +5 -5
- data/lib/metanorma/iso/validate_section.rb +7 -4
- data/lib/metanorma/iso/validate_style.rb +6 -6
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66e717f4c41d2cda0aa92bc42985e6f12d420e9bcdb2b0410fe085bca689a549
|
|
4
|
+
data.tar.gz: 33d5e0b9f67c9c76afcbd0feff13a81e21919c3cb48dc56524bfa34203725ae1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5249f0f6147e52c1ef81b7c32a3a431a74478a7727e8bde1842e411f20d1e56311fb41755828f93dc626e94ea14b5d661a5e4fbd6a17c41619131fe1a4d60eb
|
|
7
|
+
data.tar.gz: a97203b198a7e9baa2e28f5597f53c9cd60ab79cc0de989f5e3dcc7671d5199e9047abdf0eb0b02401d05d48317dbae45781475642275b4c15fa8a6aaf0f446d
|
data/lib/isodoc/iso/init.rb
CHANGED
|
@@ -20,9 +20,8 @@ module IsoDoc
|
|
|
20
20
|
i18nyaml: i18nyaml || @i18nyaml)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def amd(docxml)
|
|
24
|
-
|
|
25
|
-
%w(amendment technical-corrigendum).include? doctype
|
|
23
|
+
def amd?(docxml)
|
|
24
|
+
%w(amendment technical-corrigendum).include? @doctype
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
def clausedelim
|
|
@@ -44,16 +43,15 @@ module IsoDoc
|
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
def std_docid_semantic1(id)
|
|
47
|
-
ids = id.split(/
|
|
48
|
-
|
|
49
|
-
.include?(ids[0].sub(/\/.*$/, "")) or
|
|
50
|
-
return id
|
|
46
|
+
ids = id.split(/(\p{Zs})/)
|
|
47
|
+
agency?(ids[0].sub(/\/.*$/, "")) or return id
|
|
51
48
|
ids.map! do |i|
|
|
52
49
|
if %w(GUIDE TR TS DIR).include?(i)
|
|
53
50
|
"<span class='stddocNumber'>#{i}</span>"
|
|
51
|
+
elsif /\p{Zs}/.match?(i) then i
|
|
54
52
|
else std_docid_semantic_full(i)
|
|
55
53
|
end
|
|
56
|
-
end.join
|
|
54
|
+
end.join
|
|
57
55
|
end
|
|
58
56
|
|
|
59
57
|
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:
|
|
2677
|
+
<xsl:variable name="font_family" select="."/>
|
|
2678
2678
|
|
|
2679
|
-
<xsl:
|
|
2680
|
-
<xsl:
|
|
2681
|
-
|
|
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
|
-
|
|
5370
|
+
<fo:block xsl:use-attribute-sets="table-note-style">
|
|
5356
5371
|
|
|
5357
|
-
|
|
5372
|
+
<xsl:call-template name="refine_table-note-style"/>
|
|
5358
5373
|
|
|
5359
|
-
|
|
5360
|
-
|
|
5374
|
+
<!-- Table's note/example name (NOTE, for example) -->
|
|
5375
|
+
<fo:inline xsl:use-attribute-sets="table-note-name-style">
|
|
5361
5376
|
|
|
5362
|
-
|
|
5377
|
+
<xsl:call-template name="refine_table-note-name-style"/>
|
|
5363
5378
|
|
|
5364
|
-
|
|
5379
|
+
<xsl:apply-templates select="*[local-name() = 'name']"/>
|
|
5365
5380
|
|
|
5366
|
-
|
|
5381
|
+
</fo:inline>
|
|
5367
5382
|
|
|
5368
|
-
|
|
5369
|
-
|
|
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:
|
|
2677
|
+
<xsl:variable name="font_family" select="."/>
|
|
2678
2678
|
|
|
2679
|
-
<xsl:
|
|
2680
|
-
<xsl:
|
|
2681
|
-
|
|
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
|
-
|
|
5370
|
+
<fo:block xsl:use-attribute-sets="table-note-style">
|
|
5356
5371
|
|
|
5357
|
-
|
|
5372
|
+
<xsl:call-template name="refine_table-note-style"/>
|
|
5358
5373
|
|
|
5359
|
-
|
|
5360
|
-
|
|
5374
|
+
<!-- Table's note/example name (NOTE, for example) -->
|
|
5375
|
+
<fo:inline xsl:use-attribute-sets="table-note-name-style">
|
|
5361
5376
|
|
|
5362
|
-
|
|
5377
|
+
<xsl:call-template name="refine_table-note-name-style"/>
|
|
5363
5378
|
|
|
5364
|
-
|
|
5379
|
+
<xsl:apply-templates select="*[local-name() = 'name']"/>
|
|
5365
5380
|
|
|
5366
|
-
|
|
5381
|
+
</fo:inline>
|
|
5367
5382
|
|
|
5368
|
-
|
|
5369
|
-
|
|
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))
|
|
@@ -156,8 +158,7 @@ module IsoDoc
|
|
|
156
158
|
end
|
|
157
159
|
|
|
158
160
|
def toc_title(docxml)
|
|
159
|
-
|
|
160
|
-
%w(amendment technical-corrigendum).include?(doctype) and return
|
|
161
|
+
%w(amendment technical-corrigendum).include?(@doctype) and return
|
|
161
162
|
super
|
|
162
163
|
end
|
|
163
164
|
|
|
@@ -194,6 +195,12 @@ module IsoDoc
|
|
|
194
195
|
ret
|
|
195
196
|
end
|
|
196
197
|
|
|
198
|
+
def move_norm_ref_to_sections(docxml)
|
|
199
|
+
if amd?(docxml)
|
|
200
|
+
else super
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
197
204
|
include Init
|
|
198
205
|
end
|
|
199
206
|
end
|
data/lib/isodoc/iso/sections.rb
CHANGED
|
@@ -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)
|
|
@@ -185,8 +185,7 @@ module IsoDoc
|
|
|
185
185
|
end
|
|
186
186
|
|
|
187
187
|
def figure_name_parse(node, div, name)
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
name.nil? and return
|
|
190
189
|
div.p **figure_name_attrs(node) do |p|
|
|
191
190
|
name.children.each { |n| parse(n, p) }
|
|
192
191
|
end
|
|
@@ -205,8 +204,7 @@ module IsoDoc
|
|
|
205
204
|
end
|
|
206
205
|
|
|
207
206
|
def annex_name(_annex, name, div)
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
name.nil? and return
|
|
210
208
|
name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
|
|
211
209
|
div.h1 class: "Annex" do |t|
|
|
212
210
|
annex_name1(name, t)
|
|
@@ -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
|
-
|
|
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
|
data/lib/isodoc/iso/xref.rb
CHANGED
|
@@ -8,22 +8,33 @@ module IsoDoc
|
|
|
8
8
|
class Xref < IsoDoc::Xref
|
|
9
9
|
attr_accessor :anchors_previous, :anchors
|
|
10
10
|
|
|
11
|
-
def
|
|
12
|
-
if @klass.amd(
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
|
|
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
|
|
34
|
+
def initial_anchor_names(doc)
|
|
35
|
+
super
|
|
21
36
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
|
22
|
-
|
|
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
|
© 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(
|
|
113
|
+
def boilerplate_file(_xmldoc)
|
|
114
114
|
file = case @lang
|
|
115
|
-
when "fr" then "boilerplate-fr.
|
|
116
|
-
when "ru" then "boilerplate-ru.
|
|
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
|
-
|
|
146
|
-
|
|
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(
|
|
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(
|
|
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.
|
|
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
|
-
|
|
241
|
-
|
|
239
|
+
g["type"] and next
|
|
242
240
|
g["type"] = DEFAULT_EDGROUP_TYPE[v.to_sym]
|
|
243
241
|
end
|
|
244
242
|
end
|
data/lib/metanorma/iso/front.rb
CHANGED
|
@@ -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
|
|
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
|
|
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.
|
|
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"/>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require "metanorma-standoc"
|
|
2
|
-
require_relative "
|
|
3
|
-
require_relative "
|
|
4
|
-
require_relative "
|
|
5
|
-
require_relative "
|
|
6
|
-
require_relative "
|
|
7
|
-
require_relative "
|
|
2
|
+
require_relative "validate_style"
|
|
3
|
+
require_relative "validate_requirements"
|
|
4
|
+
require_relative "validate_section"
|
|
5
|
+
require_relative "validate_title"
|
|
6
|
+
require_relative "validate_image"
|
|
7
|
+
require_relative "validate_list"
|
|
8
8
|
require "nokogiri"
|
|
9
9
|
require "jing"
|
|
10
10
|
require "iev"
|
|
@@ -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)\
|
|
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)\
|
|
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,
|
|
@@ -116,13 +116,12 @@ module Metanorma
|
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
def doctype_validate(
|
|
120
|
-
doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
|
|
119
|
+
def doctype_validate(_xmldoc)
|
|
121
120
|
%w(international-standard technical-specification technical-report
|
|
122
121
|
publicly-available-specification international-workshop-agreement
|
|
123
|
-
guide amendment technical-corrigendum).include? doctype or
|
|
122
|
+
guide amendment technical-corrigendum).include? @doctype or
|
|
124
123
|
@log.add("Document Attributes", nil,
|
|
125
|
-
"#{doctype} is not a recognised document type")
|
|
124
|
+
"#{@doctype} is not a recognised document type")
|
|
126
125
|
end
|
|
127
126
|
|
|
128
127
|
def script_validate(xmldoc)
|
|
@@ -173,8 +172,7 @@ module Metanorma
|
|
|
173
172
|
|
|
174
173
|
def validate(doc)
|
|
175
174
|
content_validate(doc)
|
|
176
|
-
|
|
177
|
-
schema = case doctype
|
|
175
|
+
schema = case @doctype
|
|
178
176
|
when "amendment", "technical-corrigendum" # @amd
|
|
179
177
|
"isostandard-amd.rng"
|
|
180
178
|
else
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
114
|
+
.gsub("_", "\\s"), Regexp::IGNORECASE)
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def ambig_words_check(text)
|
|
@@ -4,8 +4,7 @@ module Metanorma
|
|
|
4
4
|
module ISO
|
|
5
5
|
class Converter < Standoc::Converter
|
|
6
6
|
def section_validate(doc)
|
|
7
|
-
|
|
8
|
-
unless %w(amendment technical-corrigendum).include? doctype
|
|
7
|
+
unless %w(amendment technical-corrigendum).include? @doctype
|
|
9
8
|
foreword_validate(doc.root)
|
|
10
9
|
normref_validate(doc.root)
|
|
11
10
|
symbols_validate(doc.root)
|
|
@@ -181,7 +180,7 @@ module Metanorma
|
|
|
181
180
|
end
|
|
182
181
|
|
|
183
182
|
def tech_report_style(root)
|
|
184
|
-
|
|
183
|
+
@doctype == "technical-report" or return
|
|
185
184
|
root.xpath("//sections/clause[not(@type = 'scope')] | //annex")
|
|
186
185
|
.each do |s|
|
|
187
186
|
r = requirement_check(extract_text(s)) and
|
|
@@ -193,10 +192,14 @@ module Metanorma
|
|
|
193
192
|
NORM_BIBITEMS =
|
|
194
193
|
"//references[@normative = 'true']/bibitem".freeze
|
|
195
194
|
|
|
195
|
+
ISO_PUBLISHER_XPATH = <<~XPATH.freeze
|
|
196
|
+
./contributor[role/@type = 'publisher']/organization[abbreviation = 'ISO' or abbreviation = 'IEC' or name = 'International Organization for Standardization' or name = 'International Electrotechnical Commission']
|
|
197
|
+
XPATH
|
|
198
|
+
|
|
196
199
|
# ISO/IEC DIR 2, 10.2
|
|
197
200
|
def norm_bibitem_style(root)
|
|
198
201
|
root.xpath(NORM_BIBITEMS).each do |b|
|
|
199
|
-
if b.at(
|
|
202
|
+
if b.at(ISO_PUBLISHER_XPATH).nil?
|
|
200
203
|
@log.add("Style", b, "#{NORM_ISO_WARN}: #{b.text}")
|
|
201
204
|
end
|
|
202
205
|
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(/(?:^|\
|
|
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(/(
|
|
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,]*\
|
|
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,]*\
|
|
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(/\
|
|
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
|
data/metanorma-iso.gemspec
CHANGED
|
@@ -32,9 +32,9 @@ 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.
|
|
35
|
+
spec.add_dependency "metanorma-standoc", "~> 2.6.0"
|
|
36
36
|
spec.add_dependency "mnconvert", "~> 1.14"
|
|
37
|
-
spec.add_dependency "pubid-iso", "~> 0.
|
|
37
|
+
spec.add_dependency "pubid-iso", "~> 0.6.0"
|
|
38
38
|
spec.add_dependency "ruby-jing"
|
|
39
39
|
spec.add_dependency "tokenizer", "~> 0.3.0"
|
|
40
40
|
spec.add_dependency "twitter_cldr"
|
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.
|
|
4
|
+
version: 2.5.2
|
|
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-
|
|
11
|
+
date: 2023-09-11 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.
|
|
19
|
+
version: 2.6.0
|
|
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.
|
|
26
|
+
version: 2.6.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: mnconvert
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.
|
|
47
|
+
version: 0.6.0
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.
|
|
54
|
+
version: 0.6.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: ruby-jing
|
|
57
57
|
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
|