metanorma-iso 1.10.1 → 1.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ubuntu.yml +1 -1
- data/Gemfile +1 -1
- data/lib/asciidoctor/iso/base.rb +1 -1
- data/lib/asciidoctor/iso/basicdoc.rng +1 -11
- data/lib/asciidoctor/iso/biblio.rng +0 -2
- data/lib/asciidoctor/iso/front.rb +17 -4
- data/lib/asciidoctor/iso/front_id.rb +20 -17
- data/lib/asciidoctor/iso/isodoc.rng +61 -19
- data/lib/asciidoctor/iso/isostandard-amd.rng +1 -1
- data/lib/asciidoctor/iso/isostandard.rng +15 -3
- data/lib/asciidoctor/iso/reqt.rng +1 -1
- data/lib/asciidoctor/iso/section.rb +1 -1
- data/lib/asciidoctor/iso/validate.rb +1 -1
- data/lib/asciidoctor/iso/validate_image.rb +1 -1
- data/lib/asciidoctor/iso/validate_section.rb +1 -1
- data/lib/isodoc/iso/base_convert.rb +14 -31
- data/lib/isodoc/iso/html/isodoc.css +0 -1
- data/lib/isodoc/iso/html/isodoc.scss +0 -1
- data/lib/isodoc/iso/html/style-human.css +40 -9
- data/lib/isodoc/iso/html/style-human.scss +36 -9
- data/lib/isodoc/iso/html/style-iso.css +35 -6
- data/lib/isodoc/iso/html/style-iso.scss +31 -6
- data/lib/isodoc/iso/html/wordstyle.css +10 -8
- data/lib/isodoc/iso/html/wordstyle.scss +10 -8
- data/lib/isodoc/iso/html_convert.rb +81 -22
- data/lib/isodoc/iso/index.rb +53 -45
- data/lib/isodoc/iso/iso.amendment.xsl +333 -113
- data/lib/isodoc/iso/iso.international-standard.xsl +333 -113
- data/lib/isodoc/iso/isosts_convert.rb +6 -2
- data/lib/isodoc/iso/metadata.rb +27 -22
- data/lib/isodoc/iso/presentation_xml_convert.rb +60 -25
- data/lib/isodoc/iso/sts_convert.rb +3 -2
- data/lib/isodoc/iso/word_convert.rb +0 -2
- data/lib/metanorma/iso/processor.rb +2 -2
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +3 -3
- data/spec/asciidoctor/base_spec.rb +397 -545
- data/spec/asciidoctor/blocks_spec.rb +4 -4
- data/spec/asciidoctor/cleanup_spec.rb +15 -12
- data/spec/asciidoctor/refs_spec.rb +87 -84
- data/spec/isodoc/amd_spec.rb +261 -250
- data/spec/isodoc/i18n_spec.rb +7 -7
- data/spec/isodoc/inline_spec.rb +242 -216
- data/spec/isodoc/iso_spec.rb +3 -1
- data/spec/isodoc/postproc_spec.rb +111 -28
- data/spec/isodoc/section_spec.rb +3 -3
- data/spec/isodoc/terms_spec.rb +34 -41
- data/spec/isodoc/xref_spec.rb +3 -3
- data/spec/metanorma/processor_spec.rb +110 -14
- data/spec/vcr_cassettes/docrels.yml +37 -427
- metadata +8 -8
@@ -22,8 +22,12 @@ module IsoDoc
|
|
22
22
|
f.path
|
23
23
|
end
|
24
24
|
FileUtils.rm_rf dir
|
25
|
-
MnConvert.convert(input_fname,
|
26
|
-
|
25
|
+
MnConvert.convert(input_fname,
|
26
|
+
{
|
27
|
+
input_format: MnConvert::InputFormat::MN,
|
28
|
+
output_file: output_fname || "#{fname}.#{@suffix}",
|
29
|
+
output_format: :iso,
|
30
|
+
})
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -21,9 +21,8 @@ module IsoDoc
|
|
21
21
|
stage = "DTS" if stage == "DIS"
|
22
22
|
stage = "FDTS" if stage == "FDIS"
|
23
23
|
end
|
24
|
-
|
24
|
+
%w(PWI NWIP WD CD).include?(stage) && iter and
|
25
25
|
stage += iter
|
26
|
-
end
|
27
26
|
stage = "Pre#{stage}" if /^0\./.match?(draft)
|
28
27
|
stage
|
29
28
|
end
|
@@ -31,20 +30,25 @@ module IsoDoc
|
|
31
30
|
def docstatus(isoxml, _out)
|
32
31
|
docstatus = isoxml.at(ns("//bibdata/status/stage"))
|
33
32
|
set(:unpublished, false)
|
34
|
-
if docstatus
|
35
|
-
set(:stage, docstatus.text)
|
36
|
-
set(:stage_int, docstatus.text.to_i)
|
37
|
-
set(:unpublished, unpublished(docstatus.text))
|
38
|
-
set(:statusabbr, status_abbrev(docstatus["abbreviation"] || "??",
|
39
|
-
isoxml&.at(ns("//bibdata/status/substage"))&.text,
|
40
|
-
isoxml&.at(ns("//bibdata/status/iteration"))&.text,
|
41
|
-
isoxml&.at(ns("//bibdata/version/draft"))&.text,
|
42
|
-
isoxml&.at(ns("//bibdata/ext/doctype"))&.text))
|
43
|
-
unpublished(docstatus.text) and
|
44
|
-
set(:stageabbr, docstatus["abbreviation"])
|
45
|
-
end
|
46
33
|
revdate = isoxml.at(ns("//bibdata/version/revision-date"))
|
47
34
|
set(:revdate, revdate&.text)
|
35
|
+
if docstatus
|
36
|
+
docstatus1(isoxml, docstatus)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def docstatus1(isoxml, docstatus)
|
41
|
+
set(:stage, docstatus.text)
|
42
|
+
set(:stage_int, docstatus.text.to_i)
|
43
|
+
set(:unpublished, unpublished(docstatus.text))
|
44
|
+
set(:statusabbr,
|
45
|
+
status_abbrev(docstatus["abbreviation"] || "??",
|
46
|
+
isoxml&.at(ns("//bibdata/status/substage"))&.text,
|
47
|
+
isoxml&.at(ns("//bibdata/status/iteration"))&.text,
|
48
|
+
isoxml&.at(ns("//bibdata/version/draft"))&.text,
|
49
|
+
isoxml&.at(ns("//bibdata/ext/doctype"))&.text))
|
50
|
+
unpublished(docstatus.text) and
|
51
|
+
set(:stageabbr, docstatus["abbreviation"])
|
48
52
|
end
|
49
53
|
|
50
54
|
def unpublished(status)
|
@@ -73,8 +77,7 @@ module IsoDoc
|
|
73
77
|
|
74
78
|
def amd_label(lang)
|
75
79
|
case lang
|
76
|
-
when "en" then "AMENDMENT"
|
77
|
-
when "fr" then "AMENDMENT"
|
80
|
+
when "en", "fr" then "AMENDMENT"
|
78
81
|
end
|
79
82
|
end
|
80
83
|
|
@@ -183,10 +186,10 @@ module IsoDoc
|
|
183
186
|
end
|
184
187
|
|
185
188
|
def tc(xml)
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
189
|
+
tc_type = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/"\
|
190
|
+
"@type"))&.text || "TC"
|
191
|
+
if tc_num = xml.at(ns("//bibdata/ext/editorialgroup/"\
|
192
|
+
"technical-committee/@number"))
|
190
193
|
tcid = "#{tc_type} #{tc_num.text}"
|
191
194
|
set(:tc, tcid)
|
192
195
|
set(:editorialgroup, get[:editorialgroup] << tcid)
|
@@ -195,7 +198,8 @@ module IsoDoc
|
|
195
198
|
|
196
199
|
def sc(xml)
|
197
200
|
sc_num = xml.at(ns("//bibdata/ext/editorialgroup/subcommittee/@number"))
|
198
|
-
sc_type = xml.at(ns("//bibdata/ext/editorialgroup/subcommittee
|
201
|
+
sc_type = xml.at(ns("//bibdata/ext/editorialgroup/subcommittee/"\
|
202
|
+
"@type"))&.text || "SC"
|
199
203
|
if sc_num
|
200
204
|
scid = "#{sc_type} #{sc_num.text}"
|
201
205
|
set(:sc, scid)
|
@@ -205,7 +209,8 @@ module IsoDoc
|
|
205
209
|
|
206
210
|
def wg(xml)
|
207
211
|
wg_num = xml.at(ns("//bibdata/ext/editorialgroup/workgroup/@number"))
|
208
|
-
wg_type = xml.at(ns("//bibdata/ext/editorialgroup/workgroup
|
212
|
+
wg_type = xml.at(ns("//bibdata/ext/editorialgroup/workgroup/"\
|
213
|
+
"@type"))&.text || "WG"
|
209
214
|
if wg_num
|
210
215
|
wgid = "#{wg_type} #{wg_num.text}"
|
211
216
|
set(:wg, wgid)
|
@@ -57,7 +57,7 @@ module IsoDoc
|
|
57
57
|
ret += " 第#{from.text}" if from
|
58
58
|
ret += "–#{upto.text}" if upto
|
59
59
|
loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize)
|
60
|
-
ret += " #{loc}" unless subsection && type == "clause" ||
|
60
|
+
ret += " #{loc}" unless (subsection && type == "clause") ||
|
61
61
|
type == "list" || target.match(/^IEV$|^IEC 60050-/) ||
|
62
62
|
node["droploc"] == "true"
|
63
63
|
ret += ")" if type == "list"
|
@@ -73,8 +73,8 @@ module IsoDoc
|
|
73
73
|
return l10n(eref_localities1_zh(target, type, from, upto, node,
|
74
74
|
delim))
|
75
75
|
ret = eref_delim(delim, type)
|
76
|
-
ret += eref_locality_populate(type, node) unless subsection &&
|
77
|
-
type == "clause" || type == "list" ||
|
76
|
+
ret += eref_locality_populate(type, node) unless (subsection &&
|
77
|
+
type == "clause") || type == "list" ||
|
78
78
|
target.match(/^IEV$|^IEC 60050-/)
|
79
79
|
ret += " #{from.text}" if from
|
80
80
|
ret += "–#{upto.text}" if upto
|
@@ -113,28 +113,29 @@ module IsoDoc
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def concept(docxml)
|
116
|
-
docxml
|
117
|
-
concept_term(f, m)
|
118
|
-
end
|
116
|
+
concept_term(docxml)
|
119
117
|
docxml.xpath(ns("//concept")).each do |node|
|
120
|
-
concept_render(node, ital:
|
121
|
-
|
122
|
-
linkref: node["linkref"] || "true",
|
123
|
-
linkmention: node["linkmention"] || "false")
|
118
|
+
concept_render(node, ital: "false", ref: "false",
|
119
|
+
linkref: "true", linkmention: "false")
|
124
120
|
end
|
125
121
|
end
|
126
122
|
|
127
|
-
def concept_term(
|
123
|
+
def concept_term(docxml)
|
124
|
+
docxml.xpath(ns("//term")).each do |f|
|
125
|
+
m = {}
|
126
|
+
f.xpath(ns(".//concept")).each do |c|
|
127
|
+
concept_term1(c, m)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def concept_term1(node, seen)
|
128
133
|
term = node&.at(ns("./refterm"))&.to_xml
|
129
134
|
if term && seen[term]
|
130
|
-
concept_render(node, ital:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
else concept_render(node, ital: node["ital"] || "true",
|
135
|
-
ref: node["ref"] || "true",
|
136
|
-
linkref: node["linkref"] || "true",
|
137
|
-
linkmention: node["linkmention"] || "false")
|
135
|
+
concept_render(node, ital: "false", ref: "false",
|
136
|
+
linkref: "true", linkmention: "false")
|
137
|
+
else concept_render(node, ital: "true", ref: "true",
|
138
|
+
linkref: "true", linkmention: "false")
|
138
139
|
end
|
139
140
|
seen[term] = true if term
|
140
141
|
seen
|
@@ -163,17 +164,51 @@ module IsoDoc
|
|
163
164
|
i = display_order_xpath(docxml, "//preface/*", i)
|
164
165
|
i = display_order_at(docxml, "//clause[@type = 'scope']", i)
|
165
166
|
i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
# i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
|
170
|
-
i = display_order_xpath(docxml, "//sections/clause[not(@type = 'scope')] | "\
|
171
|
-
"//sections/terms | //sections/definitions", i)
|
167
|
+
i = display_order_xpath(docxml,
|
168
|
+
"//sections/clause[not(@type = 'scope')] | "\
|
169
|
+
"//sections/terms | //sections/definitions", i)
|
172
170
|
i = display_order_xpath(docxml, "//annex", i)
|
173
171
|
i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
|
174
172
|
display_order_xpath(docxml, "//indexsect", i)
|
175
173
|
end
|
176
174
|
|
175
|
+
def termdefinition1(elem)
|
176
|
+
prefix_domain_to_definition(elem)
|
177
|
+
super
|
178
|
+
end
|
179
|
+
|
180
|
+
def prefix_domain_to_definition(elem)
|
181
|
+
((d = elem.at(ns("./domain"))) &&
|
182
|
+
(v = elem.at(ns("./definition/verbal-definition"))) &&
|
183
|
+
v.elements.first.name == "p") or return
|
184
|
+
v.elements.first.children.first.previous =
|
185
|
+
"<#{d.remove.children.to_xml}> "
|
186
|
+
end
|
187
|
+
|
188
|
+
def insertall_after_here(node, insert, name)
|
189
|
+
node.children.each do |n|
|
190
|
+
next unless n.name == name
|
191
|
+
|
192
|
+
insert.next = n.remove
|
193
|
+
insert = n
|
194
|
+
end
|
195
|
+
insert
|
196
|
+
end
|
197
|
+
|
198
|
+
def termexamples_before_termnotes(node)
|
199
|
+
return unless insert = node.at(ns("./definition"))
|
200
|
+
|
201
|
+
insert = insertall_after_here(node, insert, "termexample")
|
202
|
+
insertall_after_here(node, insert, "termnote")
|
203
|
+
end
|
204
|
+
|
205
|
+
def terms(docxml)
|
206
|
+
docxml.xpath(ns("//term[termnote][termexample]")).each do |node|
|
207
|
+
termexamples_before_termnotes(node)
|
208
|
+
end
|
209
|
+
super
|
210
|
+
end
|
211
|
+
|
177
212
|
include Init
|
178
213
|
end
|
179
214
|
end
|
@@ -19,8 +19,9 @@ module IsoDoc
|
|
19
19
|
f.path
|
20
20
|
end
|
21
21
|
FileUtils.rm_rf dir
|
22
|
-
MnConvert.convert(in_fname,
|
23
|
-
MnConvert::InputFormat::MN
|
22
|
+
MnConvert.convert(in_fname,
|
23
|
+
{ input_format: MnConvert::InputFormat::MN,
|
24
|
+
output_file: out_fname || "#{filename}.#{@suffix}" })
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -4,7 +4,7 @@ module Metanorma
|
|
4
4
|
module Iso
|
5
5
|
class Processor < Metanorma::Processor
|
6
6
|
|
7
|
-
def initialize
|
7
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
8
8
|
@short = :iso
|
9
9
|
@input_format = :asciidoc
|
10
10
|
@asciidoctor_backend = :iso
|
@@ -17,7 +17,7 @@ module Metanorma
|
|
17
17
|
doc: "doc",
|
18
18
|
pdf: "pdf",
|
19
19
|
sts: "sts.xml",
|
20
|
-
isosts: "iso.sts.xml"
|
20
|
+
isosts: "iso.sts.xml",
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
data/metanorma-iso.gemspec
CHANGED
@@ -30,16 +30,16 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
31
31
|
|
32
32
|
spec.add_dependency "metanorma-standoc", "~> 1.11.0"
|
33
|
-
spec.add_dependency "mnconvert", "~>
|
33
|
+
spec.add_dependency "mnconvert", "~> 2.0"
|
34
34
|
spec.add_dependency "ruby-jing"
|
35
35
|
spec.add_dependency "tokenizer", "~> 0.3.0"
|
36
36
|
spec.add_dependency "twitter_cldr"
|
37
37
|
|
38
|
-
spec.add_development_dependency "
|
38
|
+
spec.add_development_dependency "debug"
|
39
39
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
40
40
|
spec.add_development_dependency "guard", "~> 2.14"
|
41
41
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
42
|
-
spec.add_development_dependency "iev", "~> 0.
|
42
|
+
spec.add_development_dependency "iev", "~> 0.3.0"
|
43
43
|
spec.add_development_dependency "rake", "~> 13.0"
|
44
44
|
spec.add_development_dependency "rspec", "~> 3.6"
|
45
45
|
spec.add_development_dependency "rubocop", "~> 1.5.2"
|