metanorma-iso 1.7.3 → 1.8.3
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/.gitignore +2 -0
- data/.rubocop.yml +7 -1
- data/lib/asciidoctor/iso/base.rb +14 -11
- data/lib/asciidoctor/iso/biblio.rng +5 -6
- data/lib/asciidoctor/iso/cleanup.rb +40 -24
- data/lib/asciidoctor/iso/front.rb +29 -17
- data/lib/asciidoctor/iso/front_id.rb +81 -60
- data/lib/asciidoctor/iso/isodoc.rng +305 -4
- data/lib/asciidoctor/iso/isostandard.rng +1 -0
- data/lib/asciidoctor/iso/section.rb +2 -1
- data/lib/asciidoctor/iso/validate.rb +22 -110
- data/lib/asciidoctor/iso/validate_image.rb +97 -0
- data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
- data/lib/asciidoctor/iso/validate_section.rb +55 -29
- data/lib/asciidoctor/iso/validate_style.rb +36 -24
- data/lib/asciidoctor/iso/validate_title.rb +23 -17
- data/lib/isodoc/iso/base_convert.rb +8 -2
- data/lib/isodoc/iso/html/style-human.css +7 -0
- data/lib/isodoc/iso/html/style-iso.css +7 -0
- data/lib/isodoc/iso/html_convert.rb +0 -1
- data/lib/isodoc/iso/index.rb +2 -1
- data/lib/isodoc/iso/iso.amendment.xsl +659 -194
- data/lib/isodoc/iso/iso.international-standard.xsl +659 -194
- data/lib/isodoc/iso/metadata.rb +1 -0
- data/lib/isodoc/iso/presentation_xml_convert.rb +44 -33
- data/lib/isodoc/iso/sts_convert.rb +10 -13
- data/lib/isodoc/iso/word_convert.rb +0 -1
- data/lib/isodoc/iso/xref.rb +43 -26
- data/lib/metanorma/iso/processor.rb +1 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +8 -8
- data/spec/asciidoctor/amd_spec.rb +5 -5
- data/spec/asciidoctor/base_spec.rb +428 -307
- data/spec/asciidoctor/blocks_spec.rb +96 -34
- data/spec/asciidoctor/cleanup_spec.rb +383 -25
- data/spec/asciidoctor/section_spec.rb +0 -14
- data/spec/asciidoctor/validate_spec.rb +235 -83
- data/spec/isodoc/postproc_spec.rb +481 -438
- data/spec/spec_helper.rb +16 -13
- metadata +50 -50
- data/lib/isodoc/iso/html/scripts.html +0 -178
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb8038b020aca28d9a8ac7faa9fd0c11157fb9bc380d291edcb05fb91f675683
|
4
|
+
data.tar.gz: af9152228cacb007d0e19bce254d89e4d524596c615aa8031b9348519996e6c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6de552f032b9f1a767a3dd9b8aecc4a3d73ef66bdb2bfcffa5b045a3e2c3557ddcd9b85af78134db5cdb21618f6d209abba095f5a24b0a9b04c6bbbc8e024bbb
|
7
|
+
data.tar.gz: f560fd265b804ab36ba2e304fc85c0d0353f99dbefe7af5bea3841306c70f78ca72b7827a4f0148483244bebd6c5ef976cb2a93e58843f92446b125001a7762e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# This project follows the Ribose OSS style guide.
|
2
2
|
# https://github.com/riboseinc/oss-guides
|
3
3
|
# All project-specific additions and overrides should be specified in this file.
|
4
|
-
|
5
4
|
inherit_from:
|
6
5
|
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
6
|
+
|
7
|
+
# local repo-specific modifications
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
DisplayCopNames: false
|
11
|
+
StyleGuideCopsOnly: false
|
12
|
+
TargetRubyVersion: 2.4
|
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -17,8 +17,8 @@ module Asciidoctor
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def html_converter_alt(node)
|
20
|
-
IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node)
|
21
|
-
merge(alt: true))
|
20
|
+
IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node)
|
21
|
+
.merge(alt: true))
|
22
22
|
end
|
23
23
|
|
24
24
|
def doc_converter(node)
|
@@ -27,11 +27,13 @@ module Asciidoctor
|
|
27
27
|
|
28
28
|
def pdf_converter(node)
|
29
29
|
return nil if node.attr("no-pdf")
|
30
|
+
|
30
31
|
IsoDoc::Iso::PdfConvert.new(doc_extract_attributes(node))
|
31
32
|
end
|
32
33
|
|
33
34
|
def sts_converter(node)
|
34
35
|
return nil if node.attr("no-pdf")
|
36
|
+
|
35
37
|
IsoDoc::Iso::StsConvert.new(html_extract_attributes(node))
|
36
38
|
end
|
37
39
|
|
@@ -42,25 +44,26 @@ module Asciidoctor
|
|
42
44
|
def init(node)
|
43
45
|
super
|
44
46
|
@amd = %w(amendment technical-corrigendum).include? doctype(node)
|
47
|
+
@vocab = node.attr("docsubtype") == "vocabulary"
|
45
48
|
end
|
46
49
|
|
47
50
|
def ol_attrs(node)
|
48
|
-
attr_code(keep_attrs(node)
|
49
|
-
merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
|
51
|
+
attr_code(keep_attrs(node)
|
52
|
+
.merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
|
50
53
|
end
|
51
54
|
|
52
55
|
def outputs(node, ret)
|
53
|
-
File.open(@filename
|
54
|
-
presentation_xml_converter(node).convert(@filename
|
55
|
-
html_converter_alt(node).convert(@filename
|
56
|
+
File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
|
57
|
+
presentation_xml_converter(node).convert("#{@filename}.xml")
|
58
|
+
html_converter_alt(node).convert("#{@filename}.presentation.xml",
|
56
59
|
nil, false, "#{@filename}_alt.html")
|
57
|
-
html_converter(node).convert(@filename
|
60
|
+
html_converter(node).convert("#{@filename}.presentation.xml",
|
58
61
|
nil, false, "#{@filename}.html")
|
59
|
-
doc_converter(node).convert(@filename
|
62
|
+
doc_converter(node).convert("#{@filename}.presentation.xml",
|
60
63
|
nil, false, "#{@filename}.doc")
|
61
|
-
pdf_converter(node)&.convert(@filename
|
64
|
+
pdf_converter(node)&.convert("#{@filename}.presentation.xml",
|
62
65
|
nil, false, "#{@filename}.pdf")
|
63
|
-
#sts_converter(node)&.convert(@filename + ".xml")
|
66
|
+
# sts_converter(node)&.convert(@filename + ".xml")
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
@@ -124,7 +124,7 @@
|
|
124
124
|
<value>application/tei+xml</value>
|
125
125
|
<value>text/x-asciidoc</value>
|
126
126
|
<value>text/markdown</value>
|
127
|
-
<value>application/x-
|
127
|
+
<value>application/x-metanorma+xml</value>
|
128
128
|
<text/>
|
129
129
|
</choice>
|
130
130
|
</attribute>
|
@@ -452,6 +452,7 @@
|
|
452
452
|
<attribute name="type">
|
453
453
|
<choice>
|
454
454
|
<value>isni</value>
|
455
|
+
<value>orcid</value>
|
455
456
|
<value>uri</value>
|
456
457
|
</choice>
|
457
458
|
</attribute>
|
@@ -461,10 +462,7 @@
|
|
461
462
|
<define name="org-identifier">
|
462
463
|
<element name="identifier">
|
463
464
|
<attribute name="type">
|
464
|
-
<
|
465
|
-
<value>orcid</value>
|
466
|
-
<value>uri</value>
|
467
|
-
</choice>
|
465
|
+
<data type="string" datatypeLibrary=""/>
|
468
466
|
</attribute>
|
469
467
|
<text/>
|
470
468
|
</element>
|
@@ -789,6 +787,7 @@
|
|
789
787
|
<value>adapted</value>
|
790
788
|
<value>vote-started</value>
|
791
789
|
<value>vote-ended</value>
|
790
|
+
<value>announced</value>
|
792
791
|
</choice>
|
793
792
|
</define>
|
794
793
|
<define name="bdate">
|
@@ -1106,7 +1105,7 @@
|
|
1106
1105
|
<value>complementOf</value>
|
1107
1106
|
<value>obsoletes</value>
|
1108
1107
|
<value>obsoletedBy</value>
|
1109
|
-
<value>
|
1108
|
+
<value>cites</value>
|
1110
1109
|
<value>isCitedIn</value>
|
1111
1110
|
</choice>
|
1112
1111
|
</define>
|
@@ -22,20 +22,19 @@ module Asciidoctor
|
|
22
22
|
def other_footnote_renumber(xmldoc)
|
23
23
|
seen = {}
|
24
24
|
i = 0
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
xmldoc.xpath(POST_NORMREF_FOOTNOTES).each do |fn|
|
32
|
-
i, seen = other_footnote_renumber1(fn, i, seen)
|
25
|
+
[PRE_NORMREF_FOOTNOTES, NORMREF_FOOTNOTES,
|
26
|
+
POST_NORMREF_FOOTNOTES].each do |xpath|
|
27
|
+
xmldoc.xpath(xpath).each do |fn|
|
28
|
+
i, seen = other_footnote_renumber1(fn, i, seen)
|
29
|
+
end
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
36
33
|
def id_prefix(prefix, id)
|
37
|
-
|
38
|
-
|
34
|
+
# we're just inheriting the prefixes from parent doc
|
35
|
+
return id.text if @amd
|
36
|
+
|
37
|
+
prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text
|
39
38
|
end
|
40
39
|
|
41
40
|
def get_id_prefix(xmldoc)
|
@@ -66,8 +65,12 @@ module Asciidoctor
|
|
66
65
|
super
|
67
66
|
end
|
68
67
|
|
69
|
-
TERM_CLAUSE = "//sections//terms"
|
68
|
+
TERM_CLAUSE = "//sections//terms | "\
|
69
|
+
"//sections//clause[descendant::terms][not(descendant::definitions)]"
|
70
|
+
.freeze
|
71
|
+
|
70
72
|
PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
|
73
|
+
|
71
74
|
OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
|
72
75
|
"@type = 'ISBN'".freeze
|
73
76
|
|
@@ -79,6 +82,7 @@ module Asciidoctor
|
|
79
82
|
return 2 if bib.at("#{PUBLISHER}[name = 'International "\
|
80
83
|
"Electrotechnical Commission']")
|
81
84
|
return 3 if bib.at("./docidentifier[@type][not(#{OTHERIDS})]")
|
85
|
+
|
82
86
|
4
|
83
87
|
end
|
84
88
|
|
@@ -101,25 +105,26 @@ module Asciidoctor
|
|
101
105
|
num = bib&.at("./docnumber")&.text
|
102
106
|
id = bib&.at("./docidentifier[not(#{OTHERIDS})]")
|
103
107
|
metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text
|
104
|
-
abbrid = metaid unless /^\[\d+\]$/.match(metaid)
|
108
|
+
abbrid = metaid unless /^\[\d+\]$/.match?(metaid)
|
105
109
|
/\d-(?<partid>\d+)/ =~ id&.text
|
106
|
-
type = id[
|
110
|
+
type = id["type"] if id
|
107
111
|
title = bib&.at("./title[@type = 'main']")&.text ||
|
108
112
|
bib&.at("./title")&.text || bib&.at("./formattedref")&.text
|
109
113
|
"#{pubclass} :: #{type} :: "\
|
110
|
-
"#{num.nil? ? abbrid : sprintf(
|
114
|
+
"#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: "\
|
111
115
|
"#{partid} :: #{id&.text} :: #{title}"
|
112
116
|
end
|
113
117
|
|
114
|
-
def sections_cleanup(
|
118
|
+
def sections_cleanup(xml)
|
115
119
|
super
|
116
120
|
return unless @amd
|
117
|
-
|
118
|
-
|
121
|
+
|
122
|
+
xml.xpath("//*[@inline-header]").each do |h|
|
123
|
+
h.delete("inline-header")
|
119
124
|
end
|
120
125
|
end
|
121
126
|
|
122
|
-
def boilerplate_file(
|
127
|
+
def boilerplate_file(_xmldoc)
|
123
128
|
file = @lang == "fr" ? "boilerplate-fr.xml" : "boilerplate.xml"
|
124
129
|
File.join(@libdir, file)
|
125
130
|
end
|
@@ -146,16 +151,27 @@ module Asciidoctor
|
|
146
151
|
end
|
147
152
|
|
148
153
|
def unpublished_note(xmldoc)
|
149
|
-
xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
|
154
|
+
xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
|
155
|
+
.each do |b|
|
150
156
|
next if pub_class(b) > 2
|
151
|
-
next unless s = b.at("./status/stage")
|
157
|
+
next unless (s = b.at("./status/stage")) && (s.text.to_i < 60)
|
158
|
+
|
152
159
|
id = b.at("docidentifier").text
|
153
|
-
b.at("./language | ./script | ./abstract | ./status")
|
154
|
-
|
155
|
-
|
156
|
-
NOTE
|
160
|
+
b.at("./language | ./script | ./abstract | ./status")
|
161
|
+
.previous = %(<note type="Unpublished-Status">
|
162
|
+
<p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>)
|
157
163
|
end
|
158
164
|
end
|
165
|
+
|
166
|
+
def termdef_boilerplate_insert(xmldoc, isodoc, once = false)
|
167
|
+
once = true
|
168
|
+
super
|
169
|
+
end
|
170
|
+
|
171
|
+
def term_defs_boilerplate_cont(src, term, isodoc)
|
172
|
+
@vocab and src.empty? and return
|
173
|
+
super
|
174
|
+
end
|
159
175
|
end
|
160
176
|
end
|
161
177
|
end
|
@@ -33,7 +33,9 @@ module Asciidoctor
|
|
33
33
|
csv_split(publishers).each do |p|
|
34
34
|
xml.contributor do |c|
|
35
35
|
c.role **{ type: "author" }
|
36
|
-
c.organization
|
36
|
+
c.organization do |a|
|
37
|
+
organization(a, p, false, node, !node.attr("publisher"))
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -43,20 +45,25 @@ module Asciidoctor
|
|
43
45
|
csv_split(publishers).each do |p|
|
44
46
|
xml.contributor do |c|
|
45
47
|
c.role **{ type: "publisher" }
|
46
|
-
c.organization
|
48
|
+
c.organization do |a|
|
49
|
+
organization(a, p, true, node, !node.attr("publisher"))
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
51
55
|
def metadata_copyright(node, xml)
|
52
|
-
publishers = node.attr("copyright-holder") || node.attr("publisher") ||
|
56
|
+
publishers = node.attr("copyright-holder") || node.attr("publisher") ||
|
57
|
+
"ISO"
|
53
58
|
csv_split(publishers).each do |p|
|
54
59
|
xml.copyright do |c|
|
55
60
|
c.from (node.attr("copyright-year") || Date.today.year)
|
56
61
|
c.owner do |owner|
|
57
62
|
owner.organization do |o|
|
58
|
-
organization(
|
59
|
-
|
63
|
+
organization(
|
64
|
+
o, p, true, node,
|
65
|
+
!(node.attr("copyright-holder") || node.attr("publisher"))
|
66
|
+
)
|
60
67
|
end
|
61
68
|
end
|
62
69
|
end
|
@@ -67,7 +74,7 @@ module Asciidoctor
|
|
67
74
|
stage = get_stage(node)
|
68
75
|
substage = get_substage(node)
|
69
76
|
xml.status do |s|
|
70
|
-
s.stage stage, **attr_code(abbreviation:
|
77
|
+
s.stage stage, **attr_code(abbreviation: cover_stage_abbr(node))
|
71
78
|
s.substage substage
|
72
79
|
node.attr("iteration") && (s.iteration node.attr("iteration"))
|
73
80
|
end
|
@@ -82,34 +89,39 @@ module Asciidoctor
|
|
82
89
|
end
|
83
90
|
end
|
84
91
|
|
85
|
-
def title_intro(node,
|
92
|
+
def title_intro(node, xml, lang, at)
|
86
93
|
return unless node.attr("title-intro-#{lang}")
|
87
|
-
|
94
|
+
|
95
|
+
xml.title(**attr_code(at.merge(type: "title-intro"))) do |t1|
|
88
96
|
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-intro-#{lang}"))
|
89
97
|
end
|
90
98
|
end
|
91
99
|
|
92
|
-
def title_main(node,
|
93
|
-
|
100
|
+
def title_main(node, xml, lang, at)
|
101
|
+
xml.title **attr_code(at.merge(type: "title-main")) do |t1|
|
94
102
|
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-main-#{lang}"))
|
95
103
|
end
|
96
104
|
end
|
97
105
|
|
98
|
-
def title_part(node,
|
106
|
+
def title_part(node, xml, lang, at)
|
99
107
|
return unless node.attr("title-part-#{lang}")
|
100
|
-
|
108
|
+
|
109
|
+
xml.title(**attr_code(at.merge(type: "title-part"))) do |t1|
|
101
110
|
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-part-#{lang}"))
|
102
111
|
end
|
103
112
|
end
|
104
113
|
|
105
|
-
def title_amd(node,
|
114
|
+
def title_amd(node, xml, lang, at)
|
106
115
|
return unless node.attr("title-amendment-#{lang}")
|
107
|
-
|
108
|
-
|
116
|
+
|
117
|
+
xml.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
|
118
|
+
t1 << Metanorma::Utils::asciidoc_sub(
|
119
|
+
node.attr("title-amendment-#{lang}")
|
120
|
+
)
|
109
121
|
end
|
110
122
|
end
|
111
123
|
|
112
|
-
def title_full(node,
|
124
|
+
def title_full(node, xml, lang, at)
|
113
125
|
title = node.attr("title-main-#{lang}")
|
114
126
|
intro = node.attr("title-intro-#{lang}")
|
115
127
|
part = node.attr("title-part-#{lang}")
|
@@ -117,7 +129,7 @@ module Asciidoctor
|
|
117
129
|
title = "#{intro} -- #{title}" if intro
|
118
130
|
title = "#{title} -- #{part}" if part
|
119
131
|
title = "#{title} -- #{amd}" if amd && @amd
|
120
|
-
|
132
|
+
xml.title **attr_code(at.merge(type: "main")) do |t1|
|
121
133
|
t1 << Metanorma::Utils::asciidoc_sub(title)
|
122
134
|
end
|
123
135
|
end
|
@@ -11,7 +11,7 @@ module Asciidoctor
|
|
11
11
|
class Converter < Standoc::Converter
|
12
12
|
STAGE_ABBRS = {
|
13
13
|
"00": "PWI",
|
14
|
-
"10": "
|
14
|
+
"10": "NP",
|
15
15
|
"20": "WD",
|
16
16
|
"30": "CD",
|
17
17
|
"40": "DIS",
|
@@ -35,27 +35,26 @@ module Asciidoctor
|
|
35
35
|
|
36
36
|
def stage_abbr(stage, substage, doctype)
|
37
37
|
return nil if stage.to_i > 60
|
38
|
+
|
38
39
|
ret = STAGE_ABBRS[stage.to_sym]
|
39
40
|
ret = "PRF" if stage == "60" && substage == "00"
|
40
|
-
if
|
41
|
-
|
42
|
-
|
43
|
-
ret = "
|
44
|
-
ret = "
|
45
|
-
|
46
|
-
%w(amendment technical-corrigendum).include?(doctype)
|
47
|
-
ret = "D" if stage == "50" and
|
48
|
-
%w(technical-report technical-specification).include?(doctype)
|
41
|
+
ret = "AWI" if stage == "10" && substage == "99"
|
42
|
+
if %w(amendment technical-corrigendum technical-report
|
43
|
+
technical-specification).include?(doctype)
|
44
|
+
ret = "D" if stage == "40" && doctype == "amendment"
|
45
|
+
ret = "FD" if stage == "50" && %w(amendment technical-corrigendum)
|
46
|
+
.include?(doctype)
|
49
47
|
end
|
50
48
|
ret
|
51
49
|
end
|
52
50
|
|
53
51
|
def stage_name(stage, substage, doctype, iteration = nil)
|
54
52
|
return "Proof" if stage == "60" && substage == "00"
|
53
|
+
|
55
54
|
ret = STAGE_NAMES[stage.to_sym]
|
56
55
|
if iteration && %w(20 30).include?(stage)
|
57
|
-
prefix
|
58
|
-
to_rbnf_s("SpelloutRules", "spellout-ordinal")
|
56
|
+
prefix = iteration.to_i.localize(@lang.to_sym)
|
57
|
+
.to_rbnf_s("SpelloutRules", "spellout-ordinal")
|
59
58
|
ret = "#{prefix.capitalize} #{ret.downcase}"
|
60
59
|
end
|
61
60
|
ret
|
@@ -70,40 +69,39 @@ module Asciidoctor
|
|
70
69
|
end
|
71
70
|
|
72
71
|
def iso_id(node, xml)
|
73
|
-
|
74
|
-
|
72
|
+
!@amd && node.attr("docnumber") || @amd && node.attr("updates") or
|
73
|
+
return
|
74
|
+
|
75
75
|
dn = iso_id1(node)
|
76
76
|
dn1 = id_stage_prefix(dn, node, false)
|
77
77
|
dn2 = id_stage_prefix(dn, node, true)
|
78
78
|
xml.docidentifier dn1, **attr_code(type: "ISO")
|
79
|
-
xml.docidentifier
|
80
|
-
|
81
|
-
xml.docidentifier
|
82
|
-
|
79
|
+
xml.docidentifier(id_langsuffix(dn1, node),
|
80
|
+
**attr_code(type: "iso-with-lang"))
|
81
|
+
xml.docidentifier(id_langsuffix(dn2, node),
|
82
|
+
**attr_code(type: "iso-reference"))
|
83
83
|
end
|
84
84
|
|
85
85
|
def iso_id1(node)
|
86
86
|
if @amd
|
87
87
|
dn = node.attr("updates")
|
88
|
-
|
88
|
+
add_amd_parts(dn, node)
|
89
89
|
else
|
90
90
|
part, subpart = node&.attr("partnumber")&.split(/-/)
|
91
|
-
|
91
|
+
add_id_parts(node.attr("docnumber"), part, subpart)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
def add_amd_parts(
|
96
|
-
a = node.attr("amendment-number")
|
97
|
-
c = node.attr("corrigendum-number")
|
95
|
+
def add_amd_parts(docnum, node)
|
98
96
|
case doctype(node)
|
99
97
|
when "amendment"
|
100
|
-
"#{
|
98
|
+
"#{docnum}/Amd #{node.attr('amendment-number')}"
|
101
99
|
when "technical-corrigendum"
|
102
|
-
"#{
|
100
|
+
"#{docnum}/Cor.#{node.attr('corrigendum-number')}"
|
103
101
|
end
|
104
102
|
end
|
105
103
|
|
106
|
-
def id_langsuffix(
|
104
|
+
def id_langsuffix(docnum, node)
|
107
105
|
lang = node.attr("language") || "en"
|
108
106
|
suffix = case lang
|
109
107
|
when "en" then "(E)"
|
@@ -111,82 +109,105 @@ module Asciidoctor
|
|
111
109
|
else
|
112
110
|
"(X)"
|
113
111
|
end
|
114
|
-
"#{
|
112
|
+
"#{docnum}#{suffix}"
|
115
113
|
end
|
116
114
|
|
117
115
|
def structured_id(node, xml)
|
118
116
|
return unless node.attr("docnumber")
|
117
|
+
|
119
118
|
part, subpart = node&.attr("partnumber")&.split(/-/)
|
120
119
|
xml.structuredidentifier do |i|
|
121
|
-
i.project_number
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
120
|
+
i.project_number(node.attr("docnumber"), **attr_code(
|
121
|
+
part: part, subpart: subpart,
|
122
|
+
amendment: node.attr("amendment-number"),
|
123
|
+
corrigendum: node.attr("corrigendum-number"),
|
124
|
+
origyr: node.attr("created-date")
|
125
|
+
))
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
def add_id_parts(
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
def add_id_parts(docnum, part, subpart)
|
130
|
+
docnum += "-#{part}" if part
|
131
|
+
docnum += "-#{subpart}" if subpart
|
132
|
+
docnum
|
133
|
+
end
|
134
|
+
|
135
|
+
def id_stage_abbr(stage, substage, node, bare = false)
|
136
|
+
ret = if bare
|
137
|
+
IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
|
138
|
+
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
139
|
+
substage, nil, nil, doctype(node))
|
140
|
+
else
|
141
|
+
IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
|
142
|
+
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
143
|
+
substage, node.attr("iteration"),
|
144
|
+
node.attr("draft"), doctype(node))
|
145
|
+
end
|
146
|
+
if %w(amendment technical-corrigendum technical-report
|
147
|
+
technical-specification).include?(doctype(node))
|
148
|
+
ret = "#{ret} " unless %w(D FD).include?(ret)
|
149
|
+
end
|
150
|
+
ret
|
133
151
|
end
|
134
152
|
|
135
|
-
def
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
technical-corrigendum).include?(doctype(node))
|
142
|
-
ret = ret + " " unless %w(40 50).include?(stage)
|
153
|
+
def cover_stage_abbr(node)
|
154
|
+
stage = get_stage(node)
|
155
|
+
abbr = id_stage_abbr(get_stage(node), get_substage(node), node, true)
|
156
|
+
typeabbr = get_typeabbr(node, true)
|
157
|
+
if stage.to_i > 50 || stage.to_i == 60 && get_substage(node).to_i < 60
|
158
|
+
typeabbr = ""
|
143
159
|
end
|
144
|
-
|
160
|
+
"#{abbr}#{typeabbr}".strip
|
145
161
|
end
|
146
162
|
|
147
|
-
def id_stage_prefix(
|
163
|
+
def id_stage_prefix(docnum, node, force_year)
|
148
164
|
stage = get_stage(node)
|
149
165
|
typeabbr = get_typeabbr(node)
|
150
166
|
if stage && (stage.to_i < 60)
|
151
|
-
|
152
|
-
elsif typeabbr
|
167
|
+
docnum = unpub_stage_prefix(docnum, stage, typeabbr, node)
|
168
|
+
elsif typeabbr == "DIR " then docnum = "#{typeabbr}#{docnum}"
|
169
|
+
elsif typeabbr && !@amd then docnum = "/#{typeabbr}#{docnum}"
|
153
170
|
end
|
154
171
|
(force_year || !(stage && (stage.to_i < 60))) and
|
155
|
-
|
156
|
-
|
172
|
+
docnum = id_add_year(docnum, node)
|
173
|
+
docnum
|
157
174
|
end
|
158
175
|
|
159
|
-
def unpub_stage_prefix(
|
176
|
+
def unpub_stage_prefix(docnum, stage, typeabbr, node)
|
160
177
|
abbr = id_stage_abbr(stage, get_substage(node), node)
|
161
178
|
%w(40 50).include?(stage) && i = node.attr("iteration") and
|
162
179
|
itersuffix = ".#{i}"
|
163
|
-
return
|
164
|
-
return "/#{abbr}#{typeabbr} #{
|
165
|
-
|
180
|
+
return docnum if abbr.nil? || abbr.empty? # prefixes added in cleanup
|
181
|
+
return "/#{abbr}#{typeabbr} #{docnum}#{itersuffix}" unless @amd
|
182
|
+
|
183
|
+
a = docnum.split(%r{/})
|
166
184
|
a[-1] = "#{abbr}#{a[-1]}#{itersuffix}"
|
167
185
|
a.join("/")
|
168
186
|
end
|
169
187
|
|
170
|
-
def id_add_year(
|
188
|
+
def id_add_year(docnum, node)
|
171
189
|
year = node.attr("copyright-year")
|
172
190
|
@amd and year ||= node.attr("updated-date")&.sub(/-.*$/, "")
|
173
|
-
|
174
|
-
|
191
|
+
docnum += ":#{year}" if year
|
192
|
+
docnum
|
175
193
|
end
|
176
194
|
|
177
195
|
def get_stage(node)
|
178
|
-
|
196
|
+
node.attr("status") || node.attr("docstage") || "60"
|
179
197
|
end
|
180
198
|
|
181
199
|
def get_substage(node)
|
182
200
|
stage = get_stage(node)
|
183
|
-
node.attr("docsubstage") || (
|
201
|
+
node.attr("docsubstage") || (stage == "60" ? "60" : "00")
|
184
202
|
end
|
185
203
|
|
186
|
-
def get_typeabbr(node)
|
204
|
+
def get_typeabbr(node, amd = false)
|
187
205
|
case doctype(node)
|
206
|
+
when "directive" then "DIR "
|
188
207
|
when "technical-report" then "TR "
|
189
208
|
when "technical-specification" then "TS "
|
209
|
+
when "amendment" then (amd ? "Amd " : "")
|
210
|
+
when "technical-corrigendum" then (amd ? "Cor " : "")
|
190
211
|
else
|
191
212
|
nil
|
192
213
|
end
|