metanorma-ieee 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/ieee/html/header_amd.html +105 -0
- data/lib/isodoc/ieee/html/html_ieee_titlepage.html +13 -22
- data/lib/isodoc/ieee/html/ieee.css +23 -18
- data/lib/isodoc/ieee/html/ieee.scss +24 -18
- data/lib/isodoc/ieee/html/word_ieee_titlepage.html +12 -1
- data/lib/isodoc/ieee/html_convert.rb +37 -1
- data/lib/isodoc/ieee/i18n-en.yaml +1 -0
- data/lib/isodoc/ieee/ieee.amendment.xsl +4151 -3293
- data/lib/isodoc/ieee/ieee.standard.xsl +4151 -3293
- data/lib/isodoc/ieee/metadata.rb +23 -60
- data/lib/isodoc/ieee/pdf_convert.rb +2 -2
- data/lib/isodoc/ieee/presentation_ref.rb +81 -0
- data/lib/isodoc/ieee/presentation_terms.rb +90 -30
- data/lib/isodoc/ieee/presentation_xml_convert.rb +114 -63
- data/lib/isodoc/ieee/word_authority.rb +19 -3
- data/lib/isodoc/ieee/word_convert.rb +12 -0
- data/lib/metanorma/ieee/boilerplate.xml +68 -19
- data/lib/metanorma/ieee/cleanup.rb +135 -34
- data/lib/metanorma/ieee/cleanup_ref.rb +11 -2
- data/lib/metanorma/ieee/converter.rb +8 -0
- data/lib/metanorma/ieee/front.rb +53 -53
- data/lib/metanorma/ieee/ieee.rng +97 -6
- data/lib/metanorma/ieee/isodoc.rng +16 -1
- data/lib/metanorma/ieee/reqt.rng +1 -1
- data/lib/metanorma/ieee/term_lookup_cleanup.rb +11 -0
- data/lib/metanorma/ieee/validate.rb +58 -53
- data/lib/metanorma/ieee/validate_style.rb +53 -0
- data/lib/metanorma/ieee/version.rb +1 -1
- data/lib/relaton/render/config.yml +1 -1
- data/metanorma-itu.gemspec +1 -1
- metadata +7 -4
data/lib/isodoc/ieee/metadata.rb
CHANGED
@@ -6,11 +6,13 @@ module IsoDoc
|
|
6
6
|
class Metadata < IsoDoc::Metadata
|
7
7
|
def initialize(lang, script, i18n, fonts_options = {})
|
8
8
|
super
|
9
|
-
@metadata[:
|
9
|
+
@metadata[:issueddate] = "<Date Approved>"
|
10
10
|
end
|
11
11
|
|
12
12
|
def bibdate(isoxml, _out)
|
13
|
-
|
13
|
+
isoxml.xpath(ns("//bibdata/date[@format = 'ddMMMyyyy']")).each do |d|
|
14
|
+
set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d))
|
15
|
+
end
|
14
16
|
draft = isoxml.at(ns("//bibdata/date[@type = 'issued']")) ||
|
15
17
|
isoxml.at(ns("//bibdata/date[@type = 'circulated']")) ||
|
16
18
|
isoxml.at(ns("//bibdata/date[@type = 'created']")) ||
|
@@ -25,8 +27,10 @@ module IsoDoc
|
|
25
27
|
b = isoxml.at(ns("//bibdata/ext/doctype"))&.text or return
|
26
28
|
set(:doctype, b.split(/[- ]/).map(&:capitalize).join(" "))
|
27
29
|
set(:doctype_abbrev, @labels["doctype_abbrev"][b])
|
28
|
-
s = isoxml.at(ns("//bibdata/ext/
|
30
|
+
s = isoxml.at(ns("//bibdata/ext/subdoctype"))&.text and
|
29
31
|
set(:docsubtype, s.split(/[- ]/).map(&:capitalize).join(" "))
|
32
|
+
s = isoxml.at(ns("//bibdata/ext/trial-use"))&.text and s == "true" and
|
33
|
+
set(:trial_use, true)
|
30
34
|
end
|
31
35
|
|
32
36
|
def author(xml, _out)
|
@@ -35,7 +39,6 @@ module IsoDoc
|
|
35
39
|
tc(xml)
|
36
40
|
wg(xml)
|
37
41
|
bg(xml)
|
38
|
-
std_group(xml)
|
39
42
|
end
|
40
43
|
|
41
44
|
def society(xml)
|
@@ -50,59 +53,17 @@ module IsoDoc
|
|
50
53
|
set(:technical_committee, tc)
|
51
54
|
end
|
52
55
|
|
53
|
-
def editor_names(xml, role)
|
54
|
-
xml.xpath(ns("//bibdata/contributor[role/@type = 'editor']"\
|
55
|
-
"[role = '#{role}']/person/name/completename"))
|
56
|
-
&.each&.map(&:text)
|
57
|
-
end
|
58
|
-
|
59
|
-
def editor_name(xml, role)
|
60
|
-
editor_names(xml, role)&.first
|
61
|
-
end
|
62
|
-
|
63
56
|
def wg(xml)
|
64
57
|
wg = xml.at(ns("//bibdata/ext/editorialgroup/"\
|
65
58
|
"working-group")) or return nil
|
66
59
|
set(:working_group, wg.text)
|
67
|
-
m = {}
|
68
|
-
["Chair", "Vice-Chair", "Secretary"].each do |r|
|
69
|
-
a = editor_name(xml, "Working Group #{r}") and
|
70
|
-
m[r.downcase.gsub(/ /, "-")] = a
|
71
|
-
end
|
72
|
-
wg_members(xml, m)
|
73
|
-
end
|
74
|
-
|
75
|
-
def wg_members(xml, members)
|
76
|
-
a = editor_names(xml, "Working Group Member") and members["members"] = a
|
77
|
-
members["members"].empty? and (1..9).each do |i|
|
78
|
-
members["members"] << "Participant#{i}"
|
79
|
-
end
|
80
|
-
set(:wg_members, members)
|
81
60
|
end
|
82
61
|
|
83
62
|
def bg(xml)
|
84
63
|
bg = xml.at(ns("//bibdata/ext/editorialgroup/"\
|
85
64
|
"balloting-group")) or return nil
|
86
65
|
set(:balloting_group, bg.text)
|
87
|
-
|
88
|
-
m["members"] = editor_names(xml, "Balloting Group Member")
|
89
|
-
m["members"].empty? and (1..9).each do |i|
|
90
|
-
m["members"] << "Balloter#{i}"
|
91
|
-
end
|
92
|
-
set(:balloting_group_members, m["members"])
|
93
|
-
end
|
94
|
-
|
95
|
-
def std_group(xml)
|
96
|
-
m = {}
|
97
|
-
["Chair", "Vice-Chair", "Past Chair", "Secretary"].each do |r|
|
98
|
-
m[r.downcase.gsub(/ /, "-")] =
|
99
|
-
editor_name(xml, "Standards Board #{r}") || "<Name>"
|
100
|
-
end
|
101
|
-
m["members"] = editor_names(xml, "Standards Board Member")
|
102
|
-
m["members"].empty? and (1..9).each do |i|
|
103
|
-
m["members"] << "SBMember#{i}"
|
104
|
-
end
|
105
|
-
set(:std_board, m)
|
66
|
+
set(:balloting_group_type, bg["type"])
|
106
67
|
end
|
107
68
|
|
108
69
|
def otherid(isoxml, _out)
|
@@ -120,6 +81,10 @@ module IsoDoc
|
|
120
81
|
set(:stdid_pdf, dn&.text || "STDXXXXX")
|
121
82
|
dn = isoxml.at(ns("//#{id}[@scope = 'print']"))
|
122
83
|
set(:stdid_print, dn&.text || "STDPDXXXXX")
|
84
|
+
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/amendment")) and
|
85
|
+
set(:amd, dn.text)
|
86
|
+
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/corrigendum")) and
|
87
|
+
set(:corr, dn.text)
|
123
88
|
end
|
124
89
|
|
125
90
|
def title(isoxml, _out)
|
@@ -128,6 +93,8 @@ module IsoDoc
|
|
128
93
|
doctype(isoxml, _out)
|
129
94
|
set(:full_doctitle, fulltitle(@metadata[:doctype], draft))
|
130
95
|
set(:abbrev_doctitle, fulltitle(@metadata[:doctype_abbrev], draft))
|
96
|
+
prov = isoxml&.at(ns("//bibdata/title[@type='provenance']")) and
|
97
|
+
set(:provenance_doctitle, prov.children.to_xml)
|
131
98
|
end
|
132
99
|
|
133
100
|
def fulltitle(type, draft)
|
@@ -136,21 +103,17 @@ module IsoDoc
|
|
136
103
|
title
|
137
104
|
end
|
138
105
|
|
139
|
-
def
|
140
|
-
|
141
|
-
relations_get(isoxml, "updates")
|
142
|
-
relations_get(isoxml, "merges")
|
143
|
-
end
|
144
|
-
|
145
|
-
def relations_get(isoxml, type)
|
146
|
-
std = isoxml.xpath(ns("//bibdata/relation[@type = '#{type}']"))
|
147
|
-
return if std.empty?
|
106
|
+
def ddMMMyyyy(isodate)
|
107
|
+
return nil if isodate.nil?
|
148
108
|
|
149
|
-
|
150
|
-
|
151
|
-
|
109
|
+
arr = isodate.split("-")
|
110
|
+
if arr.size == 1 && (/^\d+$/.match isodate)
|
111
|
+
Date.new(*arr.map(&:to_i)).strftime("%Y")
|
112
|
+
elsif arr.size == 2
|
113
|
+
Date.new(*arr.map(&:to_i)).strftime("%b %Y")
|
114
|
+
else
|
115
|
+
Date.parse(isodate).strftime("%d %b %Y")
|
152
116
|
end
|
153
|
-
set(type.to_sym, ret)
|
154
117
|
end
|
155
118
|
end
|
156
119
|
end
|
@@ -12,8 +12,8 @@ module IsoDoc
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def pdf_stylesheet(docxml)
|
15
|
-
doctype = docxml&.at(ns("//bibdata/ext/
|
16
|
-
if
|
15
|
+
doctype = docxml&.at(ns("//bibdata/ext/subdoctype"))&.text
|
16
|
+
if %w(amendment corrigendum erratum).include?(doctype)
|
17
17
|
"ieee.amendment.xsl"
|
18
18
|
else
|
19
19
|
"ieee.standard.xsl"
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module IEEE
|
3
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
4
|
+
# Style manual 19
|
5
|
+
def anchor_linkend(node, linkend)
|
6
|
+
@bibanchors ||= biblio_ids_titles(node.document)
|
7
|
+
if node["citeas"] && i = @bibanchors[node["bibitemid"]]
|
8
|
+
biblio_anchor_linkend(node, i)
|
9
|
+
else super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def biblio_anchor_linkend(node, bib)
|
14
|
+
if %w(techreport standard).include?(bib[:type])
|
15
|
+
node["citeas"] + " #{bib[:ord]}"
|
16
|
+
else
|
17
|
+
"#{bib[:author]} " + node["citeas"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def biblio_ids_titles(xmldoc)
|
22
|
+
xmldoc.xpath(ns("//references[@normative = 'false']/bibitem"))
|
23
|
+
.each_with_object({}) do |b, m|
|
24
|
+
m[b["id"]] =
|
25
|
+
{ docid: pref_ref_code(b), type: b["type"],
|
26
|
+
title: (b.at(ns("./title")) ||
|
27
|
+
b.at(ns("./formattedref")))&.text,
|
28
|
+
author: @author[b["id"]] || (b.at(ns("./title")) ||
|
29
|
+
b.at(ns("./formattedref")))&.text,
|
30
|
+
ord: b.at(ns("./docidentifier[@type = 'metanorma' or "\
|
31
|
+
"@type = 'metanorma-ordinal']")).text }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def bibrenderer
|
36
|
+
::Relaton::Render::IEEE::General.new(language: @lang,
|
37
|
+
i18nhash: @i18n.get)
|
38
|
+
end
|
39
|
+
|
40
|
+
def citestyle
|
41
|
+
"author-date"
|
42
|
+
end
|
43
|
+
|
44
|
+
def references_render(docxml)
|
45
|
+
@author = {}
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def bibrender_relaton(xml, renderings)
|
50
|
+
f = renderings[xml["id"]][:formattedref]
|
51
|
+
f &&= "<formattedref>#{f}</formattedref>"
|
52
|
+
xml.children =
|
53
|
+
"#{f}#{xml.xpath(ns('./docidentifier | ./uri | ./note | ./title'))
|
54
|
+
.to_xml}"
|
55
|
+
@author[xml["id"]] = renderings[xml["id"]][:author]
|
56
|
+
end
|
57
|
+
|
58
|
+
def creatornames(bibitem)
|
59
|
+
::Relaton::Render::IEEE::General
|
60
|
+
.new(language: @lang, i18nhash: @i18n.get,
|
61
|
+
template: { (bibitem["type"] || "misc").to_sym =>
|
62
|
+
"{{ creatornames }}" })
|
63
|
+
.parse1(RelatonBib::XMLParser.from_xml(bibitem.to_xml))
|
64
|
+
end
|
65
|
+
|
66
|
+
def bibliography_bibitem_number1(bibitem, idx)
|
67
|
+
if mn = bibitem.at(ns(".//docidentifier[@type = 'metanorma']"))
|
68
|
+
/^\[?\d\]?$/.match?(mn&.text) and
|
69
|
+
idx = mn.text.sub(/^\[B?/, "").sub(/\]$/, "").to_i
|
70
|
+
end
|
71
|
+
unless bibliography_bibitem_number_skip(bibitem)
|
72
|
+
|
73
|
+
idx += 1
|
74
|
+
bibitem.at(ns(".//docidentifier")).previous =
|
75
|
+
"<docidentifier type='metanorma-ordinal'>[B#{idx}]</docidentifier>"
|
76
|
+
end
|
77
|
+
idx
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -12,7 +12,8 @@ module IsoDoc
|
|
12
12
|
c = IsoDoc::XrefGen::Counter.new("@")
|
13
13
|
elem.xpath(ns("./definition")).each do |d|
|
14
14
|
c.increment(d)
|
15
|
-
d.elements.first.previous =
|
15
|
+
d.elements.first.children.first.previous =
|
16
|
+
"<strong>(#{c.print})</strong> "
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -20,19 +21,29 @@ module IsoDoc
|
|
20
21
|
ins = elem.at(ns("./definition")).previous_element
|
21
22
|
coll = elem.xpath(ns("./definition"))
|
22
23
|
coll.each(&:remove)
|
23
|
-
ins.next = "<definition>#{coll
|
24
|
-
|
25
|
-
|
24
|
+
ins.next = "<definition>#{unwrap_multidef(coll)}</definition>"
|
25
|
+
end
|
26
|
+
|
27
|
+
def unwrap_multidef(coll)
|
28
|
+
if coll.all? do |c|
|
29
|
+
c.elements.size == 1 && c.elements.first.name == "p"
|
30
|
+
end
|
31
|
+
ret = coll.map do |c|
|
32
|
+
c.elements.first.children.to_xml
|
33
|
+
end
|
34
|
+
return "<p>#{ret.join}</p>"
|
35
|
+
end
|
36
|
+
coll.map { |c| c.children.to_xml }.join
|
26
37
|
end
|
27
38
|
|
28
39
|
def unwrap_definition(docxml)
|
29
40
|
docxml.xpath(ns("//definition/verbal-definition")).each do |v|
|
30
41
|
next unless v.elements.all? { |e| %w(termsource p).include?(e.name) }
|
31
42
|
|
32
|
-
s = v.xpath(ns("./termsource"))
|
33
43
|
p = v.xpath(ns("./p"))
|
34
44
|
v.children =
|
35
|
-
"<p>#{p.map(&:children).map(&:to_xml).join("\n")}</p
|
45
|
+
"<p>#{p.map(&:children).map(&:to_xml).join("\n")}</p>"\
|
46
|
+
"#{v.xpath(ns('./termsource')).to_xml}"
|
36
47
|
end
|
37
48
|
super
|
38
49
|
end
|
@@ -49,21 +60,28 @@ module IsoDoc
|
|
49
60
|
def term_related_collapse(coll)
|
50
61
|
prev = 0
|
51
62
|
coll[1..-1].each_with_index do |r, i|
|
52
|
-
if coll[prev]["type"]
|
53
|
-
|
54
|
-
|
55
|
-
r.remove
|
56
|
-
else prev = i
|
63
|
+
if coll[prev]["type"] != r["type"]
|
64
|
+
prev = i
|
65
|
+
next
|
57
66
|
end
|
67
|
+
coll[prev].at(ns("./preferred")) << "; #{r.at(ns('./preferred'))
|
68
|
+
.children.to_xml}"
|
69
|
+
r.remove
|
58
70
|
end
|
59
71
|
end
|
60
72
|
|
61
73
|
def sort_terms_key(term)
|
62
74
|
d = term.at(ns("./preferred/expression/name | "\
|
63
|
-
"./preferred/letter-
|
75
|
+
"./preferred/letter-symbol/name | "\
|
64
76
|
"./preferred/graphical-symbol/figure/name | "\
|
65
|
-
"./preferred/graphical-symbol/figure/@id"
|
66
|
-
|
77
|
+
"./preferred/graphical-symbol/figure/@id | "\
|
78
|
+
"./preferred"))
|
79
|
+
f = term.at(ns("./field-of-application")) || term.at(ns("./domain"))
|
80
|
+
HTMLEntities.new.decode("#{sort_terms_key1(d)} :: #{sort_terms_key1(f)}")
|
81
|
+
end
|
82
|
+
|
83
|
+
def sort_terms_key1(elem)
|
84
|
+
elem&.text&.strip&.downcase || "zzzz"
|
67
85
|
end
|
68
86
|
|
69
87
|
def term_related_reorder(coll)
|
@@ -98,22 +116,52 @@ module IsoDoc
|
|
98
116
|
end
|
99
117
|
|
100
118
|
def admitted_to_related(docxml)
|
101
|
-
docxml.xpath(ns("//term
|
102
|
-
|
103
|
-
|
104
|
-
|
119
|
+
docxml.xpath(ns("//term")).each do |t|
|
120
|
+
t.xpath(ns("./admitted | ./preferred")).each_with_index do |a, i|
|
121
|
+
(i.zero? ||
|
122
|
+
a.at(ns("./abbreviation-type | ./graphical-symbol"))) and next
|
123
|
+
admitted_to_related1(a, t.at(ns("./preferred")))
|
124
|
+
end
|
105
125
|
end
|
126
|
+
term_reorder(docxml)
|
106
127
|
end
|
107
128
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
129
|
+
def admitted_to_related1(adm, pref)
|
130
|
+
new = adm.dup
|
131
|
+
adm["type"] = "equivalent"
|
132
|
+
adm.name = "related"
|
133
|
+
adm.children = "<preferred>#{adm.children.to_xml}</preferred>"
|
134
|
+
adm.parent.next = <<~TERM
|
135
|
+
<term><preferred>#{new.children.to_xml}</preferred>
|
136
|
+
<related type='see'><preferred>#{pref.children.to_xml}</preferred></related></term>
|
137
|
+
TERM
|
138
|
+
end
|
139
|
+
|
140
|
+
def term_reorder(xmldoc)
|
141
|
+
xmldoc.xpath(ns("//terms")).each { |t| term_reorder1(t) }
|
142
|
+
end
|
143
|
+
|
144
|
+
def term_reorder1(terms)
|
145
|
+
ins = terms.at(ns("./term"))&.previous_element or return
|
146
|
+
coll = terms.xpath(ns("./term"))
|
147
|
+
ret = sort_terms(coll)
|
148
|
+
coll.each(&:remove)
|
149
|
+
ret.reverse.each { |t| ins.next = t }
|
150
|
+
end
|
151
|
+
|
152
|
+
def sort_terms(terms)
|
153
|
+
terms.sort do |a, b|
|
154
|
+
sort_terms_key(a) <=> sort_terms_key(b)
|
111
155
|
end
|
112
156
|
end
|
113
157
|
|
158
|
+
def collapse_term(docxml)
|
159
|
+
docxml.xpath(ns("//term")).each { |t| collapse_term1(t) }
|
160
|
+
end
|
161
|
+
|
114
162
|
def collapse_term1(term)
|
115
163
|
ret = collapse_term_template(
|
116
|
-
pref: term.at(ns("./preferred"))
|
164
|
+
pref: term.at(ns("./preferred"))&.remove,
|
117
165
|
def: term.at(ns("./definition")),
|
118
166
|
rels: term.xpath(ns("./related")).map(&:remove),
|
119
167
|
source: term.at(ns("./termsource")),
|
@@ -124,8 +172,9 @@ module IsoDoc
|
|
124
172
|
|
125
173
|
def collapse_term_related(rels)
|
126
174
|
ret = rels.map do |r|
|
175
|
+
p = r.at(ns("./preferred"))
|
127
176
|
"<em>#{@i18n.relatedterms[r['type']]}:</em> "\
|
128
|
-
"#{
|
177
|
+
"#{p&.children&.to_xml || '**RELATED TERM NOT FOUND**'}"
|
129
178
|
end.join(". ")
|
130
179
|
ret += "." unless ret.empty?
|
131
180
|
ret
|
@@ -136,7 +185,7 @@ module IsoDoc
|
|
136
185
|
src = nil
|
137
186
|
opt[:source] and src = "(#{opt[:source].remove.children.to_xml.strip})"
|
138
187
|
<<~TERM
|
139
|
-
<p>#{opt[:pref]
|
188
|
+
<p>#{opt[:pref]&.children&.to_xml || '**TERM NOT FOUND**'}: #{defn}
|
140
189
|
#{collapse_term_related(opt[:rels])}
|
141
190
|
#{src}</p>
|
142
191
|
TERM
|
@@ -158,6 +207,14 @@ module IsoDoc
|
|
158
207
|
while elem&.next_element&.name == "termsource"
|
159
208
|
elem << "; #{elem.next_element.remove.children.to_xml}"
|
160
209
|
end
|
210
|
+
adapt = termsource_adapt(elem["status"]) and
|
211
|
+
elem.children = l10n("#{adapt}#{elem.children.to_xml.strip}")
|
212
|
+
end
|
213
|
+
|
214
|
+
def termsource_adapt(status)
|
215
|
+
case status
|
216
|
+
when "adapted" then @i18n.adapted_from
|
217
|
+
end
|
161
218
|
end
|
162
219
|
|
163
220
|
def designation_field(desgn, name)
|
@@ -170,12 +227,15 @@ module IsoDoc
|
|
170
227
|
end
|
171
228
|
|
172
229
|
def merge_second_preferred(term)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
230
|
+
pref =
|
231
|
+
term.at(ns("./preferred[not(abbreviation-type)]/expression/name"))
|
232
|
+
x = term.xpath(ns("./preferred[expression/name][abbreviation-type] | "\
|
233
|
+
"./admitted[expression/name][abbreviation-type]"))
|
234
|
+
(pref && !x.empty?) or return
|
235
|
+
tail = x.map do |p|
|
236
|
+
p.remove.at(ns("./expression/name")).children.to_xml.strip
|
237
|
+
end.join(", ")
|
238
|
+
pref << " (#{tail})"
|
179
239
|
end
|
180
240
|
|
181
241
|
def termnote1(elem)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "init"
|
2
2
|
require_relative "presentation_terms"
|
3
|
+
require_relative "presentation_ref"
|
3
4
|
require "isodoc"
|
4
5
|
|
5
6
|
module IsoDoc
|
@@ -53,35 +54,6 @@ module IsoDoc
|
|
53
54
|
l10n(ret)
|
54
55
|
end
|
55
56
|
|
56
|
-
# Style manual 19
|
57
|
-
def anchor_linkend(node, linkend)
|
58
|
-
@bibanchors ||= biblio_ids_titles(node.document)
|
59
|
-
if node["citeas"] && i = @bibanchors[node["bibitemid"]]
|
60
|
-
biblio_anchor_linkend(node, i)
|
61
|
-
else super
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def biblio_anchor_linkend(node, bib)
|
66
|
-
if %w(techreport standard).include?(bib[:type])
|
67
|
-
node["citeas"] + " #{bib[:ord]}"
|
68
|
-
else
|
69
|
-
"#{bib[:title]} " + node["citeas"]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def biblio_ids_titles(xmldoc)
|
74
|
-
xmldoc.xpath(ns("//references[@normative = 'false']/bibitem"))
|
75
|
-
.each_with_object({}) do |b, m|
|
76
|
-
m[b["id"]] =
|
77
|
-
{ docid: pref_ref_code(b), type: b["type"],
|
78
|
-
title: b.at(ns("./title"))&.text ||
|
79
|
-
b.at(ns("./formattedref"))&.text,
|
80
|
-
ord: b.at(ns("./docidentifier[@type = 'metanorma' or "\
|
81
|
-
"@type = 'metanorma-ordinal']")).text }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
57
|
def anchor_linkend1(node)
|
86
58
|
linkend = @xrefs.anchor(node["target"], :xref)
|
87
59
|
@xrefs.anchor(node["target"], :type) == "clause" &&
|
@@ -102,10 +74,8 @@ module IsoDoc
|
|
102
74
|
return if elem.parent.name == "bibitem" || elem["notag"] == "true"
|
103
75
|
|
104
76
|
n = @xrefs.get[elem["id"]]
|
105
|
-
lbl = if n.nil? || n[:label].nil? || n[:label].empty?
|
106
|
-
|
107
|
-
else
|
108
|
-
l10n("#{@i18n.note} #{n[:label]}")
|
77
|
+
lbl = if n.nil? || n[:label].nil? || n[:label].empty? then @i18n.note
|
78
|
+
else l10n("#{@i18n.note} #{n[:label]}")
|
109
79
|
end
|
110
80
|
prefix_name(elem, block_delim, lbl, "name")
|
111
81
|
end
|
@@ -124,48 +94,129 @@ module IsoDoc
|
|
124
94
|
display_order_xpath(docxml, "//indexsect", i)
|
125
95
|
end
|
126
96
|
|
127
|
-
def
|
128
|
-
|
129
|
-
|
97
|
+
def annex1(elem)
|
98
|
+
lbl = @xrefs.anchor(elem["id"], :label)
|
99
|
+
if t = elem.at(ns("./title"))
|
100
|
+
t.children = "<strong>#{t.children.to_xml}</strong>"
|
101
|
+
end
|
102
|
+
prefix_name(elem, "<br/>", lbl, "title")
|
130
103
|
end
|
131
104
|
|
132
|
-
def
|
133
|
-
|
134
|
-
bib
|
135
|
-
bib.xpath(ns("./docidentifier")).each(&:remove)
|
136
|
-
xml.children =
|
137
|
-
"#{bibrenderer.render(bib.to_xml)}"\
|
138
|
-
"#{xml.xpath(ns('./docidentifier | ./uri | ./note | ./title')).to_xml}"
|
105
|
+
def bibdata_i18n(bib)
|
106
|
+
super
|
107
|
+
bibdata_dates(bib)
|
139
108
|
end
|
140
109
|
|
141
|
-
def
|
142
|
-
|
143
|
-
.
|
144
|
-
|
145
|
-
|
146
|
-
|
110
|
+
def bibdata_dates(bib)
|
111
|
+
bib.xpath(ns("./date")).each do |d|
|
112
|
+
d.next = d.dup
|
113
|
+
d.next["format"] = "ddMMMyyyy"
|
114
|
+
d.next.xpath(ns("./from | ./to | ./on")).each do |x|
|
115
|
+
x.children = ddMMMyyyy(x.text)
|
116
|
+
end
|
117
|
+
end
|
147
118
|
end
|
148
119
|
|
149
|
-
def
|
150
|
-
|
151
|
-
|
152
|
-
|
120
|
+
def ddMMMyyyy(isodate)
|
121
|
+
return nil if isodate.nil?
|
122
|
+
|
123
|
+
arr = isodate.split("-")
|
124
|
+
if arr.size == 1 && (/^\d+$/.match isodate)
|
125
|
+
Date.new(*arr.map(&:to_i)).strftime("%Y")
|
126
|
+
elsif arr.size == 2
|
127
|
+
Date.new(*arr.map(&:to_i)).strftime("%b %Y")
|
128
|
+
else
|
129
|
+
Date.parse(isodate).strftime("%d %b %Y")
|
153
130
|
end
|
154
|
-
|
131
|
+
end
|
155
132
|
|
156
|
-
|
157
|
-
|
158
|
-
|
133
|
+
def amend1(elem)
|
134
|
+
elem.xpath(ns("./description/p")).each do |p|
|
135
|
+
p.children = p.children.to_xml.strip
|
136
|
+
amend_format(p)
|
159
137
|
end
|
160
|
-
|
138
|
+
super
|
161
139
|
end
|
162
140
|
|
163
|
-
def
|
164
|
-
|
165
|
-
|
166
|
-
|
141
|
+
def amend_format(para)
|
142
|
+
2.times do
|
143
|
+
para.children.size == 1 &&
|
144
|
+
%(em strong).include?(para.children.first.name) and
|
145
|
+
para.children = para.elements.first.children
|
167
146
|
end
|
168
|
-
|
147
|
+
para.children = "<strong><em>#{para.children.to_xml}</em></strong>"
|
148
|
+
end
|
149
|
+
|
150
|
+
def section(docxml)
|
151
|
+
boilerplate(docxml)
|
152
|
+
super
|
153
|
+
end
|
154
|
+
|
155
|
+
def boilerplate(docxml)
|
156
|
+
docxml.xpath(ns("//clause[@id = 'boilerplate-participants']/"\
|
157
|
+
"clause/title")).each(&:remove)
|
158
|
+
docxml.xpath(ns("//clause[@id = 'boilerplate-participants']/clause"))
|
159
|
+
.each do |clause|
|
160
|
+
participants(clause)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def participants(clause)
|
165
|
+
clause.xpath(ns(".//ul")).each_with_index do |ulist, idx|
|
166
|
+
ulist.xpath(ns("./li")).each { |list| participants1(list, idx) }
|
167
|
+
ulist.replace(ulist.children)
|
168
|
+
end
|
169
|
+
affiliation_header(clause)
|
170
|
+
end
|
171
|
+
|
172
|
+
def affiliation_header(clause)
|
173
|
+
clause.xpath(ns(".//p[@type = 'officeorgrepmember']")).each do |p|
|
174
|
+
prev = p.previous_element
|
175
|
+
prev && prev.name == "p" &&
|
176
|
+
prev["type"] == "officeorgrepmember" and next
|
177
|
+
p.previous = <<~HDR
|
178
|
+
<p type='officeorgrepmemberhdr'><em>Organization
|
179
|
+
Represented</em><tab/><em>Name of Representative</em></p>
|
180
|
+
HDR
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def participants1(list, idx)
|
185
|
+
key = ""
|
186
|
+
map = list.xpath(ns(".//dt | .//dd")).each_with_object({}) do |dtd, m|
|
187
|
+
(dtd.name == "dt" and key = dtd.text) or
|
188
|
+
m[key] = @c.encode(dtd.text.strip, :hexadecimal)
|
189
|
+
end
|
190
|
+
list.replace(participant_para(map, idx))
|
191
|
+
end
|
192
|
+
|
193
|
+
def participant_para(map, idx)
|
194
|
+
name = participant_name(map)
|
195
|
+
if map["role"]&.casecmp("member")&.zero?
|
196
|
+
participant_member_para(map, name, idx)
|
197
|
+
else
|
198
|
+
participant_officeholder_para(map, name, idx)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def participant_member_para(map, name, _idx)
|
203
|
+
if map["company"] && (map["name"] || map["surname"])
|
204
|
+
pers = map["name"] || "#{map['given']} #{map['surname']}"
|
205
|
+
"<p type='officeorgrepmember'>#{name}<tab/>#{pers}</p>"
|
206
|
+
elsif map["company"] then "<p type='officeorgmember'>#{name}</p>"
|
207
|
+
else "<p type='officemember'>#{name}</p>"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def participant_officeholder_para(map, name, idx)
|
212
|
+
name = "<strong>#{name}</strong>" if idx.zero?
|
213
|
+
br = map["role"].size > 30 ? "<br/>" : ""
|
214
|
+
"<p type='officeholder' align='center'>#{name}, #{br}"\
|
215
|
+
"<em>#{map['role']}</em></p>"
|
216
|
+
end
|
217
|
+
|
218
|
+
def participant_name(map)
|
219
|
+
map["company"] || map["name"] || "#{map['given']} #{map['surname']}"
|
169
220
|
end
|
170
221
|
|
171
222
|
include Init
|