metanorma-iso 2.3.5 → 2.4.0
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/html2doc/lists.rb +9 -7
- data/lib/isodoc/iso/base_convert.rb +42 -24
- data/lib/isodoc/iso/html/style-human.css +8 -0
- data/lib/isodoc/iso/html/style-human.scss +6 -0
- data/lib/isodoc/iso/html/style-iso.css +8 -0
- data/lib/isodoc/iso/html/style-iso.scss +7 -0
- data/lib/isodoc/iso/html/wordstyle-dis.css +16 -0
- data/lib/isodoc/iso/html/wordstyle-dis.scss +14 -0
- data/lib/isodoc/iso/html/wordstyle.css +16 -0
- data/lib/isodoc/iso/html/wordstyle.scss +14 -0
- data/lib/isodoc/iso/html_convert.rb +13 -0
- data/lib/isodoc/iso/iso.amendment.xsl +417 -146
- data/lib/isodoc/iso/iso.international-standard.xsl +417 -146
- data/lib/isodoc/iso/presentation_xml_convert.rb +21 -0
- data/lib/isodoc/iso/sections.rb +6 -6
- data/lib/isodoc/iso/word_cleanup.rb +12 -2
- data/lib/isodoc/iso/word_convert.rb +44 -9
- data/lib/isodoc/iso/xref.rb +22 -4
- data/lib/metanorma/iso/base.rb +5 -0
- data/lib/metanorma/iso/biblio.rng +11 -1
- data/lib/metanorma/iso/cleanup.rb +8 -20
- data/lib/metanorma/iso/front_id.rb +8 -4
- data/lib/metanorma/iso/isodoc.rng +56 -296
- data/lib/metanorma/iso/isostandard.rng +1 -8
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +1 -1
- metadata +4 -4
@@ -215,6 +215,27 @@ module IsoDoc
|
|
215
215
|
node.remove
|
216
216
|
end
|
217
217
|
|
218
|
+
def note1(elem)
|
219
|
+
elem["type"] == "units" and return
|
220
|
+
super
|
221
|
+
end
|
222
|
+
|
223
|
+
def formula_where(dlist)
|
224
|
+
dlist.nil? and return
|
225
|
+
return super unless dlist.xpath(ns("./dt")).size == 1 &&
|
226
|
+
dlist.at(ns("./dd"))&.elements&.size == 1 &&
|
227
|
+
dlist.at(ns("./dd/p"))
|
228
|
+
|
229
|
+
formula_where_one(dlist)
|
230
|
+
end
|
231
|
+
|
232
|
+
def formula_where_one(dlist)
|
233
|
+
dt = to_xml(dlist.at(ns("./dt")).children)
|
234
|
+
dd = to_xml(dlist.at(ns("./dd/p")).children)
|
235
|
+
dlist.previous = "<p>#{@i18n.where_one} #{dt} #{dd}</p>"
|
236
|
+
dlist.remove
|
237
|
+
end
|
238
|
+
|
218
239
|
include Init
|
219
240
|
end
|
220
241
|
end
|
data/lib/isodoc/iso/sections.rb
CHANGED
@@ -7,24 +7,24 @@ module IsoDoc
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def middle_title_main(out)
|
10
|
-
out.p(
|
10
|
+
out.p(class: "zzSTDTitle1") do |p|
|
11
11
|
p << @meta.get[:doctitleintro]
|
12
12
|
p << " — " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
|
13
13
|
p << @meta.get[:doctitlemain]
|
14
14
|
p << " — " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
|
15
15
|
end
|
16
|
-
a = @meta.get[:doctitlepart] and out.p(
|
16
|
+
a = @meta.get[:doctitlepart] and out.p(class: "zzSTDTitle2") do |p|
|
17
17
|
b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
|
18
18
|
p << "<br/><b>#{a}</b>"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def middle_title_amd(out)
|
23
|
-
a = @meta.get[:doctitleamdlabel] and out.p(
|
23
|
+
a = @meta.get[:doctitleamdlabel] and out.p(class: "zzSTDTitle2") do |p|
|
24
24
|
p << a
|
25
25
|
a = @meta.get[:doctitleamd] and p << ": #{a}"
|
26
26
|
end
|
27
|
-
a = @meta.get[:doctitlecorrlabel] and out.p(
|
27
|
+
a = @meta.get[:doctitlecorrlabel] and out.p(class: "zzSTDTitle2") do |p|
|
28
28
|
p << a
|
29
29
|
end
|
30
30
|
end
|
@@ -39,8 +39,8 @@ module IsoDoc
|
|
39
39
|
f = isoxml.at(ns("//introduction")) || return
|
40
40
|
title_attr = { class: "IntroTitle" }
|
41
41
|
page_break(out)
|
42
|
-
out.div
|
43
|
-
clause_name(
|
42
|
+
out.div class: "Section3", id: f["id"] do |div|
|
43
|
+
clause_name(f, f.at(ns("./title")), div, title_attr)
|
44
44
|
f.elements.each do |e|
|
45
45
|
parse(e, div) unless e.name == "title"
|
46
46
|
end
|
@@ -5,7 +5,7 @@ module IsoDoc
|
|
5
5
|
super
|
6
6
|
xml.xpath("//div[@class = 'figure']//table[@class = 'dl']").each do |t|
|
7
7
|
t["class"] = "figdl"
|
8
|
-
d = t.add_previous_sibling("<div class='figdl' "\
|
8
|
+
d = t.add_previous_sibling("<div class='figdl' " \
|
9
9
|
"style='page-break-after:avoid;'/>")
|
10
10
|
t.parent = d.first
|
11
11
|
end
|
@@ -38,6 +38,16 @@ module IsoDoc
|
|
38
38
|
word_annex_cleanup_h1(docxml)
|
39
39
|
figure_style(docxml)
|
40
40
|
new_styles(docxml)
|
41
|
+
index_cleanup(docxml)
|
42
|
+
end
|
43
|
+
|
44
|
+
def index_cleanup(docxml)
|
45
|
+
docxml.xpath("//div[@class = 'index']").each do |i|
|
46
|
+
i.xpath(".//p | .//li").each do |p|
|
47
|
+
p["style"] ||= ""
|
48
|
+
p["style"] += "margin-bottom:0px;"
|
49
|
+
end
|
50
|
+
end
|
41
51
|
end
|
42
52
|
|
43
53
|
def figure_style(docxml)
|
@@ -48,7 +58,7 @@ module IsoDoc
|
|
48
58
|
end
|
49
59
|
|
50
60
|
def quote_style(docxml)
|
51
|
-
docxml.xpath("//div[@class = 'Quote' or @class = 'Note' or "\
|
61
|
+
docxml.xpath("//div[@class = 'Quote' or @class = 'Note' or " \
|
52
62
|
"@class = 'Example' or @class = 'Admonition']").each do |d|
|
53
63
|
quote_style1(d)
|
54
64
|
end
|
@@ -10,10 +10,6 @@ module IsoDoc
|
|
10
10
|
def initialize(options)
|
11
11
|
@libdir = File.dirname(__FILE__)
|
12
12
|
super
|
13
|
-
@wordToClevels = options[:doctoclevels].to_i
|
14
|
-
@wordToClevels = 3 if @wordToClevels.zero?
|
15
|
-
@htmlToClevels = options[:htmltoclevels].to_i
|
16
|
-
@htmlToClevels = 3 if @htmlToClevels.zero?
|
17
13
|
init_dis(options)
|
18
14
|
end
|
19
15
|
|
@@ -74,17 +70,41 @@ module IsoDoc
|
|
74
70
|
make_body1(body, docxml)
|
75
71
|
make_body2(body, docxml)
|
76
72
|
make_body3(body, docxml)
|
73
|
+
indexsect(docxml, body)
|
77
74
|
colophon(body, docxml)
|
78
75
|
end
|
79
76
|
end
|
80
77
|
|
78
|
+
def br(out, pagebreak)
|
79
|
+
out.br clear: "all", style: "page-break-before:#{pagebreak};" \
|
80
|
+
"mso-break-type:section-break"
|
81
|
+
end
|
82
|
+
|
81
83
|
def colophon(body, _docxml)
|
82
84
|
stage = @meta.get[:stage_int]
|
83
85
|
return if !stage.nil? && stage < 60
|
84
86
|
|
85
|
-
body
|
86
|
-
|
87
|
-
|
87
|
+
br(body, "left")
|
88
|
+
body.div class: "colophon" do |div|
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def indexsect(isoxml, out)
|
93
|
+
isoxml.xpath(ns("//indexsect")).each do |i|
|
94
|
+
indexsect_title(i, out)
|
95
|
+
br(out, "auto")
|
96
|
+
out.div class: "index" do |div|
|
97
|
+
i.children.each do |e|
|
98
|
+
parse(e, div) unless e.name == "title"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def indexsect_title(clause, out)
|
105
|
+
br(out, "always")
|
106
|
+
out.div class: "WordSection3" do |div|
|
107
|
+
clause_name(clause, clause.at(ns("./title")), div, nil)
|
88
108
|
end
|
89
109
|
end
|
90
110
|
|
@@ -181,7 +201,7 @@ module IsoDoc
|
|
181
201
|
return if name.nil?
|
182
202
|
|
183
203
|
name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
|
184
|
-
div.h1
|
204
|
+
div.h1 class: "Annex" do |t|
|
185
205
|
annex_name1(name, t)
|
186
206
|
clause_parse_subtitle(name, t)
|
187
207
|
end
|
@@ -190,7 +210,7 @@ module IsoDoc
|
|
190
210
|
def annex_name1(name, out)
|
191
211
|
name.children.each do |c2|
|
192
212
|
if c2.name == "span" && c2["class"] == "obligation"
|
193
|
-
out.span
|
213
|
+
out.span style: "font-weight:normal;" do |s|
|
194
214
|
c2.children.each { |c3| parse(c3, s) }
|
195
215
|
end
|
196
216
|
else parse(c2, out)
|
@@ -204,6 +224,21 @@ module IsoDoc
|
|
204
224
|
ret
|
205
225
|
end
|
206
226
|
|
227
|
+
def table_parse(node, out)
|
228
|
+
@in_table = true
|
229
|
+
table_title_parse(node, out)
|
230
|
+
measurement_units(node, out)
|
231
|
+
out.div align: "center", class: "table_container" do |div|
|
232
|
+
div.table **table_attrs(node) do |t|
|
233
|
+
table_parse_core(node, t)
|
234
|
+
(dl = node.at(ns("./dl"))) && parse(dl, div)
|
235
|
+
node.xpath(ns("./note[not(@type = 'units')]"))
|
236
|
+
.each { |n| parse(n, div) }
|
237
|
+
end
|
238
|
+
end
|
239
|
+
@in_table = false
|
240
|
+
end
|
241
|
+
|
207
242
|
include BaseConvert
|
208
243
|
include Init
|
209
244
|
end
|
data/lib/isodoc/iso/xref.rb
CHANGED
@@ -65,19 +65,24 @@ module IsoDoc
|
|
65
65
|
|
66
66
|
def figure_anchor(elem, sublabel, label, klass)
|
67
67
|
@anchors[elem["id"]] = anchor_struct(
|
68
|
-
|
68
|
+
"#{label}#{sublabel}",
|
69
69
|
nil, @labels[klass] || klass.capitalize, klass, elem["unnumbered"]
|
70
70
|
)
|
71
|
-
sublabel && elem["unnumbered"] != "true" and
|
71
|
+
!sublabel.empty? && elem["unnumbered"] != "true" and
|
72
72
|
@anchors[elem["id"]][:label] = sublabel
|
73
73
|
end
|
74
74
|
|
75
|
+
def subfigure_label(subfignum)
|
76
|
+
subfignum.zero? and return ""
|
77
|
+
" #{(subfignum + 96).chr})"
|
78
|
+
end
|
79
|
+
|
75
80
|
def sequential_figure_names(clause)
|
76
81
|
j = 0
|
77
82
|
clause.xpath(ns(FIGURE_NO_CLASS)).noblank
|
78
83
|
.each_with_object(IsoDoc::XrefGen::Counter.new) do |t, c|
|
79
84
|
j = subfigure_increment(j, c, t)
|
80
|
-
sublabel =
|
85
|
+
sublabel = subfigure_label(j)
|
81
86
|
figure_anchor(t, sublabel, c.print, "figure")
|
82
87
|
end
|
83
88
|
sequential_figure_class_names(clause)
|
@@ -101,7 +106,7 @@ module IsoDoc
|
|
101
106
|
clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
|
102
107
|
j = subfigure_increment(j, c, t)
|
103
108
|
label = "#{num}#{hiersep}#{c.print}"
|
104
|
-
sublabel =
|
109
|
+
sublabel = subfigure_label(j)
|
105
110
|
figure_anchor(t, sublabel, label, "figure")
|
106
111
|
end
|
107
112
|
hierarchical_figure_class_names(clause, num)
|
@@ -196,6 +201,19 @@ module IsoDoc
|
|
196
201
|
super
|
197
202
|
modspec_table_xrefs(clause) if @anchors_previous
|
198
203
|
end
|
204
|
+
|
205
|
+
def uncountable_note?(note)
|
206
|
+
@anchors[note["id"]] || blank?(note["id"]) || note["type"] == "units"
|
207
|
+
end
|
208
|
+
|
209
|
+
def note_anchor_names1(notes, counter)
|
210
|
+
countable = notes.reject { |n| uncountable_note?(n) }
|
211
|
+
countable.each do |n|
|
212
|
+
@anchors[n["id"]] =
|
213
|
+
anchor_struct(increment_label(countable, n, counter), n,
|
214
|
+
@labels["note_xref"], "note", false)
|
215
|
+
end
|
216
|
+
end
|
199
217
|
end
|
200
218
|
end
|
201
219
|
end
|
data/lib/metanorma/iso/base.rb
CHANGED
@@ -56,9 +56,14 @@ module Metanorma
|
|
56
56
|
@vocab = node.attr("docsubtype") == "vocabulary"
|
57
57
|
end
|
58
58
|
|
59
|
+
def toc_default
|
60
|
+
{ word_levels: 3, html_levels: 2 }
|
61
|
+
end
|
62
|
+
|
59
63
|
def ol_attrs(node)
|
60
64
|
attr_code(keep_attrs(node)
|
61
65
|
.merge(id: ::Metanorma::Utils::anchor_or_uuid(node),
|
66
|
+
"explicit-type": olist_style(node.attributes[1]),
|
62
67
|
start: node.attr("start")))
|
63
68
|
end
|
64
69
|
|
@@ -216,6 +216,9 @@
|
|
216
216
|
<optional>
|
217
217
|
<ref name="fullname"/>
|
218
218
|
</optional>
|
219
|
+
<zeroOrMore>
|
220
|
+
<ref name="credential"/>
|
221
|
+
</zeroOrMore>
|
219
222
|
<zeroOrMore>
|
220
223
|
<ref name="affiliation"/>
|
221
224
|
</zeroOrMore>
|
@@ -232,6 +235,11 @@
|
|
232
235
|
<ref name="FullNameType"/>
|
233
236
|
</element>
|
234
237
|
</define>
|
238
|
+
<define name="credential">
|
239
|
+
<element name="credential">
|
240
|
+
<text/>
|
241
|
+
</element>
|
242
|
+
</define>
|
235
243
|
<define name="FullNameType">
|
236
244
|
<choice>
|
237
245
|
<group>
|
@@ -305,7 +313,9 @@
|
|
305
313
|
<zeroOrMore>
|
306
314
|
<ref name="affiliationdescription"/>
|
307
315
|
</zeroOrMore>
|
308
|
-
<
|
316
|
+
<optional>
|
317
|
+
<ref name="organization"/>
|
318
|
+
</optional>
|
309
319
|
</element>
|
310
320
|
</define>
|
311
321
|
<define name="affiliationname">
|
@@ -8,11 +8,13 @@ module Metanorma
|
|
8
8
|
"//clause[@type = 'scope']//fn".freeze
|
9
9
|
|
10
10
|
NORMREF_FOOTNOTES =
|
11
|
-
"//references[@normative = 'true']//fn"
|
11
|
+
"//references[@normative = 'true']//fn | " \
|
12
|
+
"//clause[.//references[@normative = 'true']]//fn".freeze
|
12
13
|
|
13
14
|
POST_NORMREF_FOOTNOTES =
|
14
15
|
"//sections//clause[not(@type = 'scope')]//fn | " \
|
15
|
-
"//annex//fn | //references[@normative = 'false']//fn"
|
16
|
+
"//annex//fn | //references[@normative = 'false']//fn | " \
|
17
|
+
"//clause[.//references[@normative = 'false']]//fn".freeze
|
16
18
|
|
17
19
|
def other_footnote_renumber(xmldoc)
|
18
20
|
seen = {}
|
@@ -27,8 +29,7 @@ module Metanorma
|
|
27
29
|
|
28
30
|
def id_prefix(prefix, id)
|
29
31
|
# we're just inheriting the prefixes from parent doc
|
30
|
-
return id.text
|
31
|
-
|
32
|
+
@amd and return id.text
|
32
33
|
prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text
|
33
34
|
end
|
34
35
|
|
@@ -44,18 +45,8 @@ module Metanorma
|
|
44
45
|
# ISO as a prefix goes first
|
45
46
|
def docidentifier_cleanup(xmldoc)
|
46
47
|
prefix = get_id_prefix(xmldoc)
|
47
|
-
=begin
|
48
|
-
id = xmldoc.at("//bibdata/docidentifier[@type = 'ISO']") or return
|
49
|
-
id.content = id_prefix(prefix, id)
|
50
|
-
=end
|
51
48
|
id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
|
52
49
|
id.content = id_prefix(prefix, id)
|
53
|
-
=begin
|
54
|
-
%w(iso-with-lang iso-reference iso-undated).each do |t|
|
55
|
-
id = xmldoc.at("//bibdata/docidentifier[@type = '#{t}']") and
|
56
|
-
id.content = id_prefix(prefix, id)
|
57
|
-
end
|
58
|
-
=end
|
59
50
|
end
|
60
51
|
|
61
52
|
def format_ref(ref, type)
|
@@ -115,8 +106,7 @@ module Metanorma
|
|
115
106
|
|
116
107
|
def sections_cleanup(xml)
|
117
108
|
super
|
118
|
-
|
119
|
-
|
109
|
+
@amd or return
|
120
110
|
xml.xpath("//*[@inline-header]").each { |h| h.delete("inline-header") }
|
121
111
|
end
|
122
112
|
|
@@ -163,8 +153,7 @@ module Metanorma
|
|
163
153
|
def withdrawn_note(xmldoc)
|
164
154
|
xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
|
165
155
|
.each do |b|
|
166
|
-
|
167
|
-
|
156
|
+
withdrawn_ref?(b) or next
|
168
157
|
if id = replacement_standard(b)
|
169
158
|
insert_unpub_note(b, @i18n.cancelled_and_replaced.sub(/%/, id))
|
170
159
|
else insert_unpub_note(b, @i18n.withdrawn)
|
@@ -173,8 +162,7 @@ module Metanorma
|
|
173
162
|
end
|
174
163
|
|
175
164
|
def withdrawn_ref?(biblio)
|
176
|
-
|
177
|
-
|
165
|
+
pub_class(biblio) > 2 and return false
|
178
166
|
(s = biblio.at("./status/stage")) && (s.text.to_i == 95) &&
|
179
167
|
(t = biblio.at("./status/substage")) && (t.text.to_i == 99)
|
180
168
|
end
|
@@ -46,11 +46,14 @@ module Metanorma
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def metadata_id(node, xml)
|
49
|
-
|
49
|
+
if id = node.attr("docidentifier")
|
50
|
+
xml.docidentifier id, **attr_code(type: "ISO")
|
51
|
+
else iso_id(node, xml)
|
52
|
+
end
|
50
53
|
node.attr("tc-docnumber")&.split(/,\s*/)&.each do |n|
|
51
54
|
xml.docidentifier(n, **attr_code(type: "iso-tc"))
|
52
55
|
end
|
53
|
-
xml.docnumber node
|
56
|
+
xml.docnumber node.attr("docnumber")
|
54
57
|
end
|
55
58
|
|
56
59
|
# @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type]
|
@@ -62,6 +65,7 @@ module Metanorma
|
|
62
65
|
when "directive" then :dir
|
63
66
|
when "technical-report" then :tr
|
64
67
|
when "technical-specification" then :ts
|
68
|
+
when "publicly-available-specification" then :pas
|
65
69
|
when "guide" then :guide
|
66
70
|
end
|
67
71
|
end
|
@@ -138,7 +142,7 @@ module Metanorma
|
|
138
142
|
xml.docidentifier iso_id_default(params).to_s(with_prf: with_prf),
|
139
143
|
**attr_code(type: "ISO")
|
140
144
|
xml.docidentifier iso_id_reference(params)
|
141
|
-
.to_s(format: :
|
145
|
+
.to_s(format: :ref_num_short, with_prf: with_prf),
|
142
146
|
**attr_code(type: "iso-reference")
|
143
147
|
xml.docidentifier iso_id_reference(params).urn, **attr_code(type: "URN")
|
144
148
|
return if @amd
|
@@ -146,7 +150,7 @@ module Metanorma
|
|
146
150
|
xml.docidentifier iso_id_undated(params).to_s(with_prf: with_prf),
|
147
151
|
**attr_code(type: "iso-undated")
|
148
152
|
xml.docidentifier iso_id_with_lang(params)
|
149
|
-
.to_s(format: :
|
153
|
+
.to_s(format: :ref_num_long, with_prf: with_prf),
|
150
154
|
**attr_code(type: "iso-with-lang")
|
151
155
|
rescue StandardError => e
|
152
156
|
clean_abort("Document identifier: #{e}", xml)
|