metanorma-iso 2.0.7 → 2.1.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/asciidoctor/iso/base.rb +0 -1
- data/lib/asciidoctor/iso/cleanup.rb +0 -1
- data/lib/asciidoctor/iso/converter.rb +0 -1
- data/lib/asciidoctor/iso/deprecated.rb +4 -2
- data/lib/asciidoctor/iso/front.rb +0 -1
- data/lib/asciidoctor/iso/front_id.rb +0 -1
- data/lib/asciidoctor/iso/section.rb +0 -1
- data/lib/asciidoctor/iso/validate.rb +0 -1
- data/lib/asciidoctor/iso/validate_image.rb +0 -1
- data/lib/asciidoctor/iso/validate_requirements.rb +0 -1
- data/lib/asciidoctor/iso/validate_section.rb +0 -1
- data/lib/asciidoctor/iso/validate_style.rb +0 -1
- data/lib/asciidoctor/iso/validate_title.rb +0 -1
- data/lib/html2doc/lists.rb +37 -0
- data/lib/isodoc/iso/html/html_iso_titlepage.html +7 -2
- data/lib/isodoc/iso/html/isodoc-dis.css +196 -156
- data/lib/isodoc/iso/html/isodoc-dis.scss +193 -156
- data/lib/isodoc/iso/html/word_iso_intro-dis.html +7 -0
- data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +3 -2
- data/lib/isodoc/iso/html/word_iso_titlepage.html +8 -2
- data/lib/isodoc/iso/html/wordstyle-dis.css +204 -34
- data/lib/isodoc/iso/html/wordstyle-dis.scss +198 -34
- data/lib/isodoc/iso/i18n-en.yaml +2 -1
- data/lib/isodoc/iso/i18n-fr.yaml +1 -0
- data/lib/isodoc/iso/i18n-ru.yaml +1 -0
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc/iso/index.rb +1 -1
- data/lib/isodoc/iso/init.rb +17 -1
- data/lib/isodoc/iso/iso.amendment.xsl +726 -299
- data/lib/isodoc/iso/iso.international-standard.xsl +726 -299
- data/lib/isodoc/iso/metadata.rb +75 -63
- data/lib/isodoc/iso/presentation_inline.rb +90 -0
- data/lib/isodoc/iso/presentation_xml_convert.rb +39 -100
- data/lib/isodoc/iso/presentation_xref.rb +126 -0
- data/lib/isodoc/iso/word_cleanup.rb +16 -2
- data/lib/isodoc/iso/word_convert.rb +27 -10
- data/lib/isodoc/iso/word_dis_convert.rb +174 -0
- data/lib/isodoc/iso/xref.rb +50 -30
- data/lib/metanorma/iso/biblio.rng +62 -10
- data/lib/metanorma/iso/boilerplate-fr.xml +1 -1
- data/lib/metanorma/iso/boilerplate-ru.xml +1 -3
- data/lib/metanorma/iso/boilerplate.xml +1 -3
- data/lib/metanorma/iso/cleanup.rb +7 -6
- data/lib/metanorma/iso/front_id.rb +28 -11
- data/lib/metanorma/iso/isodoc.rng +56 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/metanorma-iso.rb +1 -0
- data/lib/relaton/render/config.yml +4 -0
- data/lib/relaton/render/general.rb +13 -0
- data/metanorma-iso.gemspec +1 -1
- data/spec/isodoc/amd_spec.rb +15 -14
- data/spec/isodoc/blocks_spec.rb +286 -179
- data/spec/isodoc/i18n_spec.rb +296 -133
- data/spec/isodoc/inline_spec.rb +35 -42
- data/spec/isodoc/iso_spec.rb +43 -27
- data/spec/isodoc/postproc_spec.rb +25 -0
- data/spec/isodoc/ref_spec.rb +66 -69
- data/spec/isodoc/section_spec.rb +78 -76
- data/spec/isodoc/table_spec.rb +2 -2
- data/spec/isodoc/terms_spec.rb +2 -2
- data/spec/isodoc/word_dis_spec.rb +760 -0
- data/spec/isodoc/xref_spec.rb +51 -51
- data/spec/metanorma/amd_spec.rb +39 -16
- data/spec/metanorma/base_spec.rb +17 -9
- data/spec/metanorma/blocks_spec.rb +4 -4
- data/spec/metanorma/cleanup_spec.rb +11 -11
- data/spec/metanorma/section_spec.rb +3 -3
- data/spec/spec_helper.rb +5 -2
- data/spec/vcr_cassettes/withdrawn_iso.yml +26 -26
- metadata +11 -5
- data/spec/vcr_cassettes/docrels.yml +0 -385
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -21,8 +21,7 @@ module IsoDoc
|
|
21
21
|
stage = "DTS" if stage == "DIS"
|
22
22
|
stage = "FDTS" if stage == "FDIS"
|
23
23
|
end
|
24
|
-
%w(PWI NWIP WD CD).include?(stage) && iter and
|
25
|
-
stage += iter
|
24
|
+
%w(PWI NWIP WD CD).include?(stage) && iter and stage += iter
|
26
25
|
stage = "Pre#{stage}" if /^0\./.match?(draft)
|
27
26
|
stage
|
28
27
|
end
|
@@ -32,9 +31,7 @@ module IsoDoc
|
|
32
31
|
set(:unpublished, false)
|
33
32
|
revdate = isoxml.at(ns("//bibdata/version/revision-date"))
|
34
33
|
set(:revdate, revdate&.text)
|
35
|
-
|
36
|
-
docstatus1(isoxml, docstatus)
|
37
|
-
end
|
34
|
+
docstatus and docstatus1(isoxml, docstatus)
|
38
35
|
end
|
39
36
|
|
40
37
|
def docstatus1(isoxml, docstatus)
|
@@ -56,10 +53,14 @@ module IsoDoc
|
|
56
53
|
end
|
57
54
|
|
58
55
|
def docid(isoxml, _out)
|
59
|
-
set(:
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
set(:tc_docnumber, isoxml
|
57
|
+
.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']")).map(&:text))
|
58
|
+
{ docnumber: "ISO", docnumber_lang: "iso-with-lang",
|
59
|
+
docnumber_reference: "iso-reference",
|
60
|
+
docnumber_undated: "iso-undated" }.each do |k, v|
|
61
|
+
set(k,
|
62
|
+
isoxml&.at(ns("//bibdata/docidentifier[@type = '#{v}']"))&.text)
|
63
|
+
end
|
63
64
|
end
|
64
65
|
|
65
66
|
# we don't leave this to i18n.rb, because we have both English and
|
@@ -87,55 +88,63 @@ module IsoDoc
|
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
|
-
def part_title(part,
|
91
|
+
def part_title(part, titlenums, lang)
|
91
92
|
return "" unless part
|
92
93
|
|
93
94
|
suffix = @c.encode(part.text, :hexadecimal)
|
94
|
-
|
95
|
-
|
95
|
+
p = titlenums[:part]
|
96
|
+
titlenums[:part] && titlenums[:subpart] and
|
97
|
+
p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
|
98
|
+
titlenums[:part] and
|
99
|
+
suffix = "#{part_label(lang)} #{p}: " + suffix
|
96
100
|
suffix
|
97
101
|
end
|
98
102
|
|
99
|
-
def part_prefix(
|
100
|
-
|
101
|
-
|
103
|
+
def part_prefix(titlenums, lang)
|
104
|
+
p = titlenums[:part]
|
105
|
+
titlenums[:part] && titlenums[:subpart] and
|
106
|
+
p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
|
107
|
+
"#{part_label(lang)} #{p}"
|
102
108
|
end
|
103
109
|
|
104
|
-
def amd_prefix(
|
105
|
-
"#{amd_label(lang)} #{
|
110
|
+
def amd_prefix(titlenums, lang)
|
111
|
+
"#{amd_label(lang)} #{titlenums[:amd]}"
|
106
112
|
end
|
107
113
|
|
108
|
-
def corr_prefix(
|
109
|
-
"#{corr_label(lang)} #{
|
114
|
+
def corr_prefix(titlenums, lang)
|
115
|
+
"#{corr_label(lang)} #{titlenums[:corr]}"
|
110
116
|
end
|
111
117
|
|
112
|
-
def compose_title(
|
113
|
-
main =
|
114
|
-
|
115
|
-
main =
|
116
|
-
|
117
|
-
|
118
|
+
def compose_title(tparts, tnums, lang)
|
119
|
+
main = ""
|
120
|
+
tparts[:main].nil? or
|
121
|
+
main = @c.encode(tparts[:main].text, :hexadecimal)
|
122
|
+
tparts[:intro] &&
|
123
|
+
main = "#{@c.encode(tparts[:intro].text,
|
124
|
+
:hexadecimal)} — #{main}"
|
125
|
+
if tparts[:part]
|
126
|
+
suffix = part_title(tparts[:part], tnums, lang)
|
118
127
|
main = "#{main} — #{suffix}"
|
119
128
|
end
|
120
129
|
main
|
121
130
|
end
|
122
131
|
|
123
132
|
def title_nums(isoxml)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
133
|
+
{ part: isoxml.at(ns("//bibdata//project-number/@part")),
|
134
|
+
subpart: isoxml.at(ns("//bibdata//project-number/@subpart")),
|
135
|
+
amd: isoxml.at(ns("//bibdata//project-number/@amendment")),
|
136
|
+
corr: isoxml.at(ns("//bibdata//project-number/@corrigendum")) }
|
128
137
|
end
|
129
138
|
|
130
139
|
def title_parts(isoxml, lang)
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
140
|
+
{ intro: isoxml.at(ns("//bibdata//title[@type='title-intro' and "\
|
141
|
+
"@language='#{lang}']")),
|
142
|
+
main: isoxml.at(ns("//bibdata//title[@type='title-main' and "\
|
143
|
+
"@language='#{lang}']")),
|
144
|
+
part: isoxml.at(ns("//bibdata//title[@type='title-part' and "\
|
145
|
+
"@language='#{lang}']")),
|
146
|
+
amd: isoxml.at(ns("//bibdata//title[@type='title-amd' and "\
|
147
|
+
"@language='#{lang}']")) }
|
139
148
|
end
|
140
149
|
|
141
150
|
def title(isoxml, _out)
|
@@ -144,40 +153,43 @@ module IsoDoc
|
|
144
153
|
when "ru" then "ru"
|
145
154
|
else "en"
|
146
155
|
end
|
147
|
-
intro, main, part, amd = title_parts(isoxml, lang)
|
148
|
-
|
156
|
+
# intro, main, part, amd = title_parts(isoxml, lang)
|
157
|
+
tp = title_parts(isoxml, lang)
|
158
|
+
tn = title_nums(isoxml)
|
149
159
|
|
150
|
-
set(:doctitlemain,
|
151
|
-
|
160
|
+
set(:doctitlemain,
|
161
|
+
@c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
|
162
|
+
main = compose_title(tp, tn, lang)
|
152
163
|
set(:doctitle, main)
|
153
|
-
|
164
|
+
tp[:intro] and
|
154
165
|
set(:doctitleintro,
|
155
|
-
@c.encode(intro ? intro.text : "", :hexadecimal))
|
156
|
-
|
157
|
-
set(:
|
158
|
-
set(:
|
159
|
-
set(:
|
160
|
-
set(:
|
161
|
-
set(:doctitlecorrlabel, corr_prefix(corrnumber, lang)) if corrnumber
|
166
|
+
@c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
|
167
|
+
set(:doctitlepartlabel, part_prefix(tn, lang))
|
168
|
+
set(:doctitlepart, @c.encode(tp[:part].text, :hexadecimal)) if tp[:part]
|
169
|
+
set(:doctitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
|
170
|
+
set(:doctitleamd, @c.encode(tp[:amd].text, :hexadecimal)) if tp[:amd]
|
171
|
+
set(:doctitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
|
162
172
|
end
|
163
173
|
|
164
174
|
def subtitle(isoxml, _out)
|
165
175
|
lang = @lang == "en" ? "fr" : "en"
|
166
|
-
|
167
|
-
|
176
|
+
tp = title_parts(isoxml, lang)
|
177
|
+
tn = title_nums(isoxml)
|
168
178
|
|
169
|
-
set(:docsubtitlemain,
|
170
|
-
|
179
|
+
set(:docsubtitlemain,
|
180
|
+
@c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
|
181
|
+
main = compose_title(tp, tn, lang)
|
171
182
|
set(:docsubtitle, main)
|
172
|
-
|
183
|
+
tp[:intro] and
|
173
184
|
set(:docsubtitleintro,
|
174
|
-
@c.encode(intro ? intro.text : "", :hexadecimal))
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
set(:
|
180
|
-
set(:
|
185
|
+
@c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
|
186
|
+
set(:docsubtitlepartlabel, part_prefix(tn, lang))
|
187
|
+
tp[:part] and
|
188
|
+
set(:docsubtitlepart,
|
189
|
+
@c.encode(tp[:part].text, :hexadecimal))
|
190
|
+
set(:docsubtitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
|
191
|
+
set(:docsubtitleamd, @c.encode(tp[:amd].text, :hexadecimal)) if tp[:amd]
|
192
|
+
set(:docsubtitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
|
181
193
|
end
|
182
194
|
|
183
195
|
def author(xml, _out)
|
@@ -231,8 +243,8 @@ module IsoDoc
|
|
231
243
|
ics = []
|
232
244
|
isoxml.xpath(ns("//bibdata/ext/ics/code")).each { |i| ics << i.text }
|
233
245
|
set(:ics, ics.empty? ? nil : ics.join(", "))
|
234
|
-
a = isoxml.at(ns("//bibdata/ext/horizontal")) and
|
235
|
-
|
246
|
+
a = isoxml.at(ns("//bibdata/ext/horizontal")) and
|
247
|
+
set(:horizontal, a.text)
|
236
248
|
end
|
237
249
|
end
|
238
250
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Iso
|
3
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
4
|
+
def xref_init(lang, script, klass, labels, options)
|
5
|
+
@xrefs = Xref.new(lang, script, klass, labels, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def eref_delim(delim, type)
|
9
|
+
if delim == ";" then ";"
|
10
|
+
else type == "list" ? " " : delim
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def can_conflate_eref_rendering?(refs)
|
15
|
+
super or return false
|
16
|
+
|
17
|
+
first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
|
18
|
+
refs.first.at(ns("./locality/referenceFrom"))&.text)
|
19
|
+
refs.all? do |r|
|
20
|
+
subclause?(nil, r.at(ns("./locality/@type"))&.text,
|
21
|
+
r.at(ns("./locality/referenceFrom"))&.text) == first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def locality_delimiter(loc)
|
26
|
+
loc&.next_element&.attribute("type")&.text == "list" and return " "
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def eref_localities_conflated(refs, target, node)
|
31
|
+
droploc = node["droploc"]
|
32
|
+
node["droploc"] = true
|
33
|
+
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
|
34
|
+
node))
|
35
|
+
node["droploc"] = droploc
|
36
|
+
eref_localities1(target,
|
37
|
+
prefix_clause(target, refs.first.at(ns("./locality"))),
|
38
|
+
l10n(ret[1..-1].join), nil, node, @lang)
|
39
|
+
end
|
40
|
+
|
41
|
+
def prefix_clause(target, loc)
|
42
|
+
loc["type"] == "clause" or return loc["type"]
|
43
|
+
|
44
|
+
if subclause?(target, loc["type"],
|
45
|
+
loc&.at(ns("./referenceFrom"))&.text)
|
46
|
+
""
|
47
|
+
else
|
48
|
+
"clause"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def subclause?(target, type, from)
|
53
|
+
(from&.match?(/\./) && type == "clause") ||
|
54
|
+
type == "list" || target&.match(/^IEV$|^IEC 60050-/)
|
55
|
+
end
|
56
|
+
|
57
|
+
def eref_localities1_zh(target, type, from, upto, node)
|
58
|
+
ret = " 第#{from}" if from
|
59
|
+
ret += "–#{upto}" if upto
|
60
|
+
if node["droploc"] != "true" && !subclause?(target, type, from)
|
61
|
+
ret += eref_locality_populate(type, node)
|
62
|
+
end
|
63
|
+
ret += ")" if type == "list"
|
64
|
+
ret
|
65
|
+
end
|
66
|
+
|
67
|
+
def eref_localities1(target, type, from, upto, node, lang = "en")
|
68
|
+
return nil if type == "anchor"
|
69
|
+
|
70
|
+
type = type.downcase
|
71
|
+
lang == "zh" and
|
72
|
+
return l10n(eref_localities1_zh(target, type, from, upto, node))
|
73
|
+
ret = if node["droploc"] != "true" && !subclause?(target, type,
|
74
|
+
from)
|
75
|
+
eref_locality_populate(type, node)
|
76
|
+
else ""
|
77
|
+
end
|
78
|
+
ret += " #{from}" if from
|
79
|
+
ret += "–#{upto}" if upto
|
80
|
+
ret += ")" if type == "list"
|
81
|
+
l10n(ret)
|
82
|
+
end
|
83
|
+
|
84
|
+
def prefix_container(container, linkend, target)
|
85
|
+
delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
|
86
|
+
l10n(@xrefs.anchor(container, :xref) + delim + linkend)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
require_relative "init"
|
2
2
|
require "isodoc"
|
3
3
|
require_relative "index"
|
4
|
+
require_relative "presentation_inline"
|
5
|
+
require_relative "presentation_xref"
|
6
|
+
require_relative "../../relaton/render/general"
|
4
7
|
|
5
8
|
module IsoDoc
|
6
9
|
module Iso
|
7
10
|
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
8
11
|
def convert1(docxml, filename, dir)
|
12
|
+
@iso_class = instance_of?(IsoDoc::Iso::PresentationXMLConvert)
|
9
13
|
if amd(docxml)
|
10
14
|
@oldsuppressheadingnumbers = @suppressheadingnumbers
|
11
15
|
@suppressheadingnumbers = true
|
@@ -22,13 +26,7 @@ module IsoDoc
|
|
22
26
|
amd(isoxml) and @suppressheadingnumbers = true
|
23
27
|
end
|
24
28
|
|
25
|
-
def xref_init(lang, script, klass, labels, options)
|
26
|
-
@xrefs = Xref.new(lang, script, klass, labels, options)
|
27
|
-
end
|
28
|
-
|
29
29
|
def figure1(node)
|
30
|
-
return if labelled_ancestor(node) && node.ancestors("figure").empty?
|
31
|
-
|
32
30
|
lbl = @xrefs.anchor(node["id"], :label, false) or return
|
33
31
|
figname = node.parent.name == "figure" ? "" : "#{@i18n.figure} "
|
34
32
|
connective = node.parent.name == "figure" ? " " : " — "
|
@@ -37,93 +35,12 @@ module IsoDoc
|
|
37
35
|
|
38
36
|
def example1(node)
|
39
37
|
n = @xrefs.get[node["id"]]
|
40
|
-
lbl = if n.nil? || n[:label]
|
41
|
-
|
42
|
-
else
|
43
|
-
l10n("#{@i18n.example} #{n[:label]}")
|
38
|
+
lbl = if n.nil? || blank?(n[:label]) then @i18n.example
|
39
|
+
else l10n("#{@i18n.example} #{n[:label]}")
|
44
40
|
end
|
45
41
|
prefix_name(node, " — ", lbl, "name")
|
46
42
|
end
|
47
43
|
|
48
|
-
def eref_delim(delim, type)
|
49
|
-
if delim == ";" then ";"
|
50
|
-
else type == "list" ? " " : delim
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def can_conflate_eref_rendering?(refs)
|
55
|
-
super or return false
|
56
|
-
|
57
|
-
first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
|
58
|
-
refs.first.at(ns("./locality/referenceFrom"))&.text)
|
59
|
-
refs.all? do |r|
|
60
|
-
subclause?(nil, r.at(ns("./locality/@type"))&.text,
|
61
|
-
r.at(ns("./locality/referenceFrom"))&.text) == first
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def locality_delimiter(loc)
|
66
|
-
loc&.next_element&.attribute("type")&.text == "list" and return " "
|
67
|
-
super
|
68
|
-
end
|
69
|
-
|
70
|
-
def eref_localities_conflated(refs, target, node)
|
71
|
-
droploc = node["droploc"]
|
72
|
-
node["droploc"] = true
|
73
|
-
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
|
74
|
-
node))
|
75
|
-
node["droploc"] = droploc
|
76
|
-
eref_localities1(target,
|
77
|
-
prefix_clause(target, refs.first.at(ns("./locality"))),
|
78
|
-
l10n(ret[1..-1].join), nil, node, @lang)
|
79
|
-
end
|
80
|
-
|
81
|
-
def prefix_clause(target, loc)
|
82
|
-
loc["type"] == "clause" or return loc["type"]
|
83
|
-
|
84
|
-
if subclause?(target, loc["type"], loc&.at(ns("./referenceFrom"))&.text)
|
85
|
-
""
|
86
|
-
else
|
87
|
-
"clause"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def subclause?(target, type, from)
|
92
|
-
(from&.match?(/\./) && type == "clause") ||
|
93
|
-
type == "list" || target&.match(/^IEV$|^IEC 60050-/)
|
94
|
-
end
|
95
|
-
|
96
|
-
def eref_localities1_zh(target, type, from, upto, node)
|
97
|
-
ret = " 第#{from}" if from
|
98
|
-
ret += "–#{upto}" if upto
|
99
|
-
if node["droploc"] != "true" && !subclause?(target, type, from)
|
100
|
-
ret += eref_locality_populate(type, node)
|
101
|
-
end
|
102
|
-
ret += ")" if type == "list"
|
103
|
-
ret
|
104
|
-
end
|
105
|
-
|
106
|
-
def eref_localities1(target, type, from, upto, node, lang = "en")
|
107
|
-
return nil if type == "anchor"
|
108
|
-
|
109
|
-
type = type.downcase
|
110
|
-
lang == "zh" and
|
111
|
-
return l10n(eref_localities1_zh(target, type, from, upto, node))
|
112
|
-
ret = if node["droploc"] != "true" && !subclause?(target, type, from)
|
113
|
-
eref_locality_populate(type, node)
|
114
|
-
else ""
|
115
|
-
end
|
116
|
-
ret += " #{from}" if from
|
117
|
-
ret += "–#{upto}" if upto
|
118
|
-
ret += ")" if type == "list"
|
119
|
-
l10n(ret)
|
120
|
-
end
|
121
|
-
|
122
|
-
def prefix_container(container, linkend, target)
|
123
|
-
delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
|
124
|
-
l10n(@xrefs.anchor(container, :xref) + delim + linkend)
|
125
|
-
end
|
126
|
-
|
127
44
|
def example_span_label(_node, div, name)
|
128
45
|
return if name.nil?
|
129
46
|
|
@@ -143,8 +60,7 @@ module IsoDoc
|
|
143
60
|
def clause(docxml)
|
144
61
|
docxml.xpath(ns("//clause[not(ancestor::annex)] | "\
|
145
62
|
"//terms | //definitions | //references | "\
|
146
|
-
"//preface/introduction[clause]"))
|
147
|
-
.each do |f|
|
63
|
+
"//preface/introduction[clause]")).each do |f|
|
148
64
|
clause1(f)
|
149
65
|
end
|
150
66
|
end
|
@@ -160,9 +76,7 @@ module IsoDoc
|
|
160
76
|
def concept_term(docxml)
|
161
77
|
docxml.xpath(ns("//term")).each do |f|
|
162
78
|
m = {}
|
163
|
-
f.xpath(ns(".//concept")).each
|
164
|
-
concept_term1(c, m)
|
165
|
-
end
|
79
|
+
f.xpath(ns(".//concept")).each { |c| concept_term1(c, m) }
|
166
80
|
end
|
167
81
|
end
|
168
82
|
|
@@ -179,12 +93,11 @@ module IsoDoc
|
|
179
93
|
end
|
180
94
|
|
181
95
|
def concept1_ref_content(ref)
|
182
|
-
if ref.name == "termref"
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
96
|
+
repl = if ref.name == "termref"
|
97
|
+
@i18n.term_defined_in.sub(/%/, ref.to_xml)
|
98
|
+
else "(#{ref.to_xml})"
|
99
|
+
end
|
100
|
+
ref.replace(repl)
|
188
101
|
end
|
189
102
|
|
190
103
|
def concept1(node)
|
@@ -246,6 +159,32 @@ module IsoDoc
|
|
246
159
|
super
|
247
160
|
end
|
248
161
|
|
162
|
+
def admonition1(elem)
|
163
|
+
super
|
164
|
+
return unless n = elem.at(ns("./name"))
|
165
|
+
|
166
|
+
p = n.next_element
|
167
|
+
return unless p.name == "p"
|
168
|
+
|
169
|
+
p.children.first.previous = admonition_name(n.remove.children.to_xml)
|
170
|
+
end
|
171
|
+
|
172
|
+
def admonition_name(xml)
|
173
|
+
"#{xml} — "
|
174
|
+
end
|
175
|
+
|
176
|
+
def bibrenderer
|
177
|
+
::Relaton::Render::Iso::General.new(language: @lang, i18nhash: @i18n.get)
|
178
|
+
end
|
179
|
+
|
180
|
+
def bibrender(xml)
|
181
|
+
unless xml.at(ns("./formattedref"))
|
182
|
+
xml.children =
|
183
|
+
"#{bibrenderer.render(xml.to_xml)}"\
|
184
|
+
"#{xml.xpath(ns('./docidentifier | ./uri | ./note')).to_xml}"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
249
188
|
include Init
|
250
189
|
end
|
251
190
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Iso
|
3
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
4
|
+
def xref_init(lang, script, klass, labels, options)
|
5
|
+
@xrefs = Xref.new(lang, script, klass, labels, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def eref_delim(delim, type)
|
9
|
+
if delim == ";" then ";"
|
10
|
+
else type == "list" ? " " : delim
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def can_conflate_eref_rendering?(refs)
|
15
|
+
super or return false
|
16
|
+
|
17
|
+
first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
|
18
|
+
refs.first.at(ns("./locality/referenceFrom"))&.text)
|
19
|
+
refs.all? do |r|
|
20
|
+
subclause?(nil, r.at(ns("./locality/@type"))&.text,
|
21
|
+
r.at(ns("./locality/referenceFrom"))&.text) == first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def locality_delimiter(loc)
|
26
|
+
loc&.next_element&.attribute("type")&.text == "list" and return " "
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def eref_localities_conflated(refs, target, node)
|
31
|
+
droploc = node["droploc"]
|
32
|
+
node["droploc"] = true
|
33
|
+
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
|
34
|
+
node))
|
35
|
+
node["droploc"] = droploc
|
36
|
+
eref_localities1(target,
|
37
|
+
prefix_clause(target, refs.first.at(ns("./locality"))),
|
38
|
+
l10n(ret[1..-1].join), nil, node, @lang)
|
39
|
+
end
|
40
|
+
|
41
|
+
def prefix_clause(target, loc)
|
42
|
+
loc["type"] == "clause" or return loc["type"]
|
43
|
+
|
44
|
+
if subclause?(target, loc["type"],
|
45
|
+
loc&.at(ns("./referenceFrom"))&.text)
|
46
|
+
""
|
47
|
+
else "clause"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def subclause?(target, type, from)
|
52
|
+
(from&.match?(/\./) && type == "clause") ||
|
53
|
+
type == "list" ||
|
54
|
+
target&.gsub(/<[^>]+>/, "")&.match(/^IEV$|^IEC 60050-/)
|
55
|
+
end
|
56
|
+
|
57
|
+
LOCALITY2SPAN = {
|
58
|
+
annex: "citeapp",
|
59
|
+
dunno: "citebase",
|
60
|
+
dunno2: "citebib",
|
61
|
+
dunno3: "citebox",
|
62
|
+
dunno4: "citeen",
|
63
|
+
dunno5: "citeeq",
|
64
|
+
figure: "citefig",
|
65
|
+
dunno6: "citefn",
|
66
|
+
clause: "citesec",
|
67
|
+
dunno7: "citesection",
|
68
|
+
table: "citetbl",
|
69
|
+
dunno8: "citetfn",
|
70
|
+
}.freeze
|
71
|
+
|
72
|
+
def locality_span_wrap(ret, type)
|
73
|
+
type or return ret
|
74
|
+
m = /^(\s*)(.+?)(\s*)$/.match(ret) or return ret
|
75
|
+
ret = [m[1], m[2], m[3]]
|
76
|
+
spanclass = LOCALITY2SPAN[type.to_sym] and
|
77
|
+
ret[1] = "<span class='#{spanclass}'>#{ret[1]}</span>"
|
78
|
+
ret.join
|
79
|
+
end
|
80
|
+
|
81
|
+
def eref_localities1_zh(target, type, from, upto, node)
|
82
|
+
ret = " 第#{from}" if from
|
83
|
+
ret += "–#{upto}" if upto
|
84
|
+
node["droploc"] != "true" && !subclause?(target, type, from) and
|
85
|
+
ret += eref_locality_populate(type, node)
|
86
|
+
ret += ")" if type == "list"
|
87
|
+
locality_span_wrap(ret, type)
|
88
|
+
end
|
89
|
+
|
90
|
+
def eref_localities1(target, type, from, upto, node, lang = "en")
|
91
|
+
return nil if type == "anchor"
|
92
|
+
|
93
|
+
type = type.downcase
|
94
|
+
lang == "zh" and
|
95
|
+
return l10n(eref_localities1_zh(target, type, from, upto, node))
|
96
|
+
ret = ""
|
97
|
+
node["droploc"] != "true" && !subclause?(target, type, from) and
|
98
|
+
ret = eref_locality_populate(type, node)
|
99
|
+
ret += " #{from}" if from
|
100
|
+
ret += "–#{upto}" if upto
|
101
|
+
ret += ")" if type == "list"
|
102
|
+
ret = l10n(ret)
|
103
|
+
locality_span_wrap(ret, type)
|
104
|
+
end
|
105
|
+
|
106
|
+
def prefix_container(container, linkend, target)
|
107
|
+
delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
|
108
|
+
l10n(@xrefs.anchor(container, :xref) + delim + linkend)
|
109
|
+
end
|
110
|
+
|
111
|
+
def expand_citeas(text)
|
112
|
+
std_docid_semantic(super)
|
113
|
+
end
|
114
|
+
|
115
|
+
def anchor_value(id)
|
116
|
+
locality_span_wrap(super, @xrefs.anchor(id, :subtype) ||
|
117
|
+
@xrefs.anchor(id, :type))
|
118
|
+
end
|
119
|
+
|
120
|
+
def anchor_linkend1(node)
|
121
|
+
locality_span_wrap(super, @xrefs.anchor(node["target"], :subtype) ||
|
122
|
+
@xrefs.anchor(node["target"], :type))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -65,7 +65,7 @@ module IsoDoc
|
|
65
65
|
insert = docxml.at("//div[@id = 'boilerplate-license-destination']")
|
66
66
|
auth = docxml&.at("//div[@class = 'boilerplate-license']")&.remove
|
67
67
|
auth&.xpath(".//p[not(@class)]")&.each { |p| p["class"] = "zzWarning" }
|
68
|
-
auth and insert.children = auth
|
68
|
+
auth and insert and insert.children = auth
|
69
69
|
insert = docxml.at("//div[@id = 'boilerplate-copyright-destination']")
|
70
70
|
auth = docxml&.at("//div[@class = 'boilerplate-copyright']")&.remove
|
71
71
|
auth&.xpath(".//p[not(@class)]")&.each do |p|
|
@@ -80,7 +80,8 @@ module IsoDoc
|
|
80
80
|
auth&.xpath(".//p[@id = 'boilerplate-place']")&.each do |p|
|
81
81
|
p["class"] = "zzCopyright1"
|
82
82
|
end
|
83
|
-
auth and insert.children = auth
|
83
|
+
auth and insert and insert.children = auth
|
84
|
+
coverpage_note_cleanup(docxml)
|
84
85
|
end
|
85
86
|
|
86
87
|
def word_cleanup(docxml)
|
@@ -89,6 +90,19 @@ module IsoDoc
|
|
89
90
|
style_cleanup(docxml)
|
90
91
|
docxml
|
91
92
|
end
|
93
|
+
|
94
|
+
# supply missing annex title
|
95
|
+
def make_WordToC(docxml, level)
|
96
|
+
toc = ""
|
97
|
+
xpath = (1..level).each.map { |i| "//h#{i}" }.join (" | ")
|
98
|
+
docxml.xpath(xpath).each do |h|
|
99
|
+
x = ""
|
100
|
+
x = @anchor[h.parent["id"]][:xref] if h["class"] == "ANNEX"
|
101
|
+
toc += word_toc_entry(h.name[1].to_i, x + header_strip(h))
|
102
|
+
end
|
103
|
+
toc.sub(/(<p class="MsoToc1">)/,
|
104
|
+
%{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
|
105
|
+
end
|
92
106
|
end
|
93
107
|
end
|
94
108
|
end
|