metanorma-iso 1.9.2 → 1.9.6
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/asciidoctor/iso/basicdoc.rng +21 -4
- data/lib/asciidoctor/iso/cleanup.rb +3 -4
- data/lib/asciidoctor/iso/front.rb +9 -1
- data/lib/asciidoctor/iso/front_id.rb +7 -2
- data/lib/asciidoctor/iso/isodoc.rng +241 -61
- data/lib/asciidoctor/iso/isostandard.rng +10 -23
- data/lib/asciidoctor/iso/reqt.rng +23 -2
- data/lib/asciidoctor/iso/section.rb +7 -1
- data/lib/asciidoctor/iso/validate_section.rb +18 -20
- data/lib/asciidoctor/iso/validate_style.rb +17 -9
- data/lib/isodoc/iso/html/isodoc.css +1 -2
- data/lib/isodoc/iso/html/isodoc.scss +1 -1
- data/lib/isodoc/iso/html/wordstyle.css +16 -4
- data/lib/isodoc/iso/html/wordstyle.scss +16 -4
- data/lib/isodoc/iso/index.rb +48 -24
- data/lib/isodoc/iso/iso.amendment.xsl +407 -123
- data/lib/isodoc/iso/iso.international-standard.xsl +407 -123
- data/lib/isodoc/iso/metadata.rb +28 -16
- data/lib/isodoc/iso/presentation_xml_convert.rb +30 -22
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +3 -1
- data/spec/asciidoctor/base_spec.rb +351 -177
- data/spec/asciidoctor/blank_spec.rb +38 -0
- data/spec/asciidoctor/blocks_spec.rb +39 -0
- data/spec/asciidoctor/refs_spec.rb +1 -1
- data/spec/isodoc/inline_spec.rb +306 -245
- data/spec/isodoc/terms_spec.rb +30 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/vcr_cassettes/docrels.yml +393 -0
- metadata +32 -2
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -2,7 +2,7 @@ require "isodoc"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
module Iso
|
5
|
-
class
|
5
|
+
class Metadata < IsoDoc::Metadata
|
6
6
|
def initialize(lang, script, i18n)
|
7
7
|
super
|
8
8
|
set(:tc, "XXXX")
|
@@ -14,17 +14,17 @@ module IsoDoc
|
|
14
14
|
set(:obsoletes_part, nil)
|
15
15
|
end
|
16
16
|
|
17
|
-
def status_abbrev(stage,
|
17
|
+
def status_abbrev(stage, _substage, iter, draft, doctype)
|
18
18
|
return "" unless stage
|
19
19
|
|
20
20
|
if %w(technical-report technical-specification).include?(doctype)
|
21
21
|
stage = "DTS" if stage == "DIS"
|
22
22
|
stage = "FDTS" if stage == "FDIS"
|
23
23
|
end
|
24
|
-
if %w(PWI NWIP WD CD).include?(stage)
|
25
|
-
stage += iter
|
24
|
+
if %w(PWI NWIP WD CD).include?(stage) && iter
|
25
|
+
stage += iter
|
26
26
|
end
|
27
|
-
stage = "Pre"
|
27
|
+
stage = "Pre#{stage}" if /^0\./.match?(draft)
|
28
28
|
stage
|
29
29
|
end
|
30
30
|
|
@@ -48,14 +48,14 @@ module IsoDoc
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def unpublished(status)
|
51
|
-
status.to_i
|
51
|
+
status.to_i.positive? && status.to_i < 60
|
52
52
|
end
|
53
53
|
|
54
54
|
def docid(isoxml, _out)
|
55
55
|
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ISO']"))
|
56
56
|
set(:docnumber, dn&.text)
|
57
57
|
tcdn = isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
|
58
|
-
set(:tc_docnumber, tcdn.map
|
58
|
+
set(:tc_docnumber, tcdn.map(&:text))
|
59
59
|
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))
|
60
60
|
set(:docnumber_lang, dn&.text)
|
61
61
|
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-reference']"))
|
@@ -87,6 +87,7 @@ module IsoDoc
|
|
87
87
|
|
88
88
|
def part_title(part, partnum, subpartnum, lang)
|
89
89
|
return "" unless part
|
90
|
+
|
90
91
|
suffix = @c.encode(part.text, :hexadecimal)
|
91
92
|
partnum = "#{partnum}–#{subpartnum}" if partnum && subpartnum
|
92
93
|
suffix = "#{part_label(lang)} #{partnum}: " + suffix if partnum
|
@@ -125,10 +126,14 @@ module IsoDoc
|
|
125
126
|
end
|
126
127
|
|
127
128
|
def title_parts(isoxml, lang)
|
128
|
-
[isoxml.at(ns("//bibdata//title[@type='title-intro' and
|
129
|
-
|
130
|
-
isoxml.at(ns("//bibdata//title[@type='title-
|
131
|
-
|
129
|
+
[isoxml.at(ns("//bibdata//title[@type='title-intro' and "\
|
130
|
+
"@language='#{lang}']")),
|
131
|
+
isoxml.at(ns("//bibdata//title[@type='title-main' and "\
|
132
|
+
"@language='#{lang}']")),
|
133
|
+
isoxml.at(ns("//bibdata//title[@type='title-part' and "\
|
134
|
+
"@language='#{lang}']")),
|
135
|
+
isoxml.at(ns("//bibdata//title[@type='title-amd' and "\
|
136
|
+
"@language='#{lang}']"))]
|
132
137
|
end
|
133
138
|
|
134
139
|
def title(isoxml, _out)
|
@@ -139,7 +144,10 @@ module IsoDoc
|
|
139
144
|
set(:doctitlemain, @c.encode(main ? main.text : "", :hexadecimal))
|
140
145
|
main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
|
141
146
|
set(:doctitle, main)
|
142
|
-
|
147
|
+
if intro
|
148
|
+
set(:doctitleintro,
|
149
|
+
@c.encode(intro ? intro.text : "", :hexadecimal))
|
150
|
+
end
|
143
151
|
set(:doctitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
|
144
152
|
set(:doctitlepart, @c.encode(part.text, :hexadecimal)) if part
|
145
153
|
set(:doctitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
|
@@ -155,7 +163,10 @@ module IsoDoc
|
|
155
163
|
set(:docsubtitlemain, @c.encode(main ? main.text : "", :hexadecimal))
|
156
164
|
main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
|
157
165
|
set(:docsubtitle, main)
|
158
|
-
|
166
|
+
if intro
|
167
|
+
set(:docsubtitleintro,
|
168
|
+
@c.encode(intro ? intro.text : "", :hexadecimal))
|
169
|
+
end
|
159
170
|
set(:docsubtitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
|
160
171
|
set(:docsubtitlepart, @c.encode(part.text, :hexadecimal)) if part
|
161
172
|
set(:docsubtitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
|
@@ -173,8 +184,8 @@ module IsoDoc
|
|
173
184
|
|
174
185
|
def tc(xml)
|
175
186
|
tc_num = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@number"))
|
176
|
-
tc_type = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@type"))
|
177
|
-
text || "TC"
|
187
|
+
tc_type = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@type"))
|
188
|
+
&.text || "TC"
|
178
189
|
if tc_num
|
179
190
|
tcid = "#{tc_type} #{tc_num.text}"
|
180
191
|
set(:tc, tcid)
|
@@ -212,7 +223,8 @@ module IsoDoc
|
|
212
223
|
ics = []
|
213
224
|
isoxml.xpath(ns("//bibdata/ext/ics/code")).each { |i| ics << i.text }
|
214
225
|
set(:ics, ics.empty? ? nil : ics.join(", "))
|
215
|
-
a = isoxml.at(ns("//bibdata/ext/horizontal")) and set(:horizontal,
|
226
|
+
a = isoxml.at(ns("//bibdata/ext/horizontal")) and set(:horizontal,
|
227
|
+
a.text)
|
216
228
|
end
|
217
229
|
end
|
218
230
|
end
|
@@ -45,13 +45,15 @@ module IsoDoc
|
|
45
45
|
prefix_name(node, " — ", lbl, "name")
|
46
46
|
end
|
47
47
|
|
48
|
+
def eref_delim(delim, type)
|
49
|
+
if delim == ";" then ";"
|
50
|
+
else type == "list" ? "" : delim
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
48
54
|
def eref_localities1_zh(target, type, from, upto, node, delim)
|
49
55
|
subsection = from&.text&.match(/\./)
|
50
|
-
ret =
|
51
|
-
";"
|
52
|
-
else
|
53
|
-
type == "list" ? "" : delim
|
54
|
-
end
|
56
|
+
ret = eref_delim(delim, type)
|
55
57
|
ret += " 第#{from.text}" if from
|
56
58
|
ret += "–#{upto.text}" if upto
|
57
59
|
loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize)
|
@@ -68,11 +70,9 @@ module IsoDoc
|
|
68
70
|
subsection = from&.text&.match(/\./)
|
69
71
|
type = type.downcase
|
70
72
|
lang == "zh" and
|
71
|
-
return l10n(eref_localities1_zh(target, type, from, upto, node,
|
72
|
-
|
73
|
-
|
74
|
-
type == "list" ? "" : delim
|
75
|
-
end
|
73
|
+
return l10n(eref_localities1_zh(target, type, from, upto, node,
|
74
|
+
delim))
|
75
|
+
ret = eref_delim(delim, type)
|
76
76
|
ret += eref_locality_populate(type, node) unless subsection &&
|
77
77
|
type == "clause" || type == "list" ||
|
78
78
|
target.match(/^IEV$|^IEC 60050-/)
|
@@ -113,31 +113,39 @@ module IsoDoc
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def concept(docxml)
|
116
|
-
docxml.xpath(ns("//
|
116
|
+
docxml.xpath(ns("//term//concept")).each_with_object({}) do |f, m|
|
117
117
|
concept_term(f, m)
|
118
118
|
end
|
119
119
|
docxml.xpath(ns("//concept")).each do |node|
|
120
|
-
concept_render(node, node["ital"] || "false",
|
120
|
+
concept_render(node, ital: node["ital"] || "false",
|
121
|
+
ref: node["ref"] || "false",
|
122
|
+
linkref: node["linkref"] || "true",
|
123
|
+
linkmention: node["linkmention"] || "false")
|
121
124
|
end
|
122
125
|
end
|
123
126
|
|
124
127
|
def concept_term(node, seen)
|
125
128
|
term = node&.at(ns("./refterm"))&.to_xml
|
126
129
|
if term && seen[term]
|
127
|
-
concept_render(node, node["ital"] || "false",
|
128
|
-
|
130
|
+
concept_render(node, ital: node["ital"] || "false",
|
131
|
+
ref: node["ref"] || "false",
|
132
|
+
linkref: node["linkref"] || "true",
|
133
|
+
linkmention: node["linkmention"] || "false")
|
134
|
+
else concept_render(node, ital: node["ital"] || "true",
|
135
|
+
ref: node["ref"] || "true",
|
136
|
+
linkref: node["linkref"] || "true",
|
137
|
+
linkmention: node["linkmention"] || "false")
|
129
138
|
end
|
130
139
|
seen[term] = true if term
|
131
140
|
seen
|
132
141
|
end
|
133
142
|
|
134
|
-
def
|
135
|
-
if
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
r.replace("(#{r.to_xml})")
|
143
|
+
def concept1_ref_content(ref)
|
144
|
+
if ref.name == "termref"
|
145
|
+
ref.replace(@i18n.term_defined_in.sub(/%/,
|
146
|
+
ref.to_xml))
|
147
|
+
else
|
148
|
+
ref.replace("(#{ref.to_xml})")
|
141
149
|
end
|
142
150
|
end
|
143
151
|
|
@@ -160,7 +168,7 @@ module IsoDoc
|
|
160
168
|
# i = display_order_at(docxml, "//sections/definitions", i)
|
161
169
|
# i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
|
162
170
|
i = display_order_xpath(docxml, "//sections/clause[not(@type = 'scope')] | "\
|
163
|
-
|
171
|
+
"//sections/terms | //sections/definitions", i)
|
164
172
|
i = display_order_xpath(docxml, "//annex", i)
|
165
173
|
i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
|
166
174
|
display_order_xpath(docxml, "//indexsect", i)
|
data/metanorma-iso.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ["open.source@ribose.com"]
|
12
12
|
|
13
13
|
spec.summary = "metanorma-iso lets you write ISO standards "\
|
14
|
-
|
14
|
+
"in AsciiDoc."
|
15
15
|
spec.description = <<~DESCRIPTION
|
16
16
|
metanorma-iso lets you write ISO standards in AsciiDoc syntax.
|
17
17
|
|
@@ -47,4 +47,6 @@ Gem::Specification.new do |spec|
|
|
47
47
|
spec.add_development_dependency "sassc", "2.4.0"
|
48
48
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
49
49
|
spec.add_development_dependency "timecop", "~> 0.9"
|
50
|
+
spec.add_development_dependency "vcr", "~> 5.0.0"
|
51
|
+
spec.add_development_dependency "webmock"
|
50
52
|
end
|