isodoc 3.2.7 → 3.3.1
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/isodoc.gemspec +1 -1
- data/lib/isodoc/convert.rb +3 -2
- data/lib/isodoc/function/terms.rb +6 -0
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/init.rb +5 -4
- data/lib/isodoc/metadata.rb +4 -3
- data/lib/isodoc/presentation_function/autonum.rb +2 -2
- data/lib/isodoc/presentation_function/bibdata.rb +1 -0
- data/lib/isodoc/presentation_function/block.rb +20 -7
- data/lib/isodoc/presentation_function/concepts.rb +0 -148
- data/lib/isodoc/presentation_function/designations.rb +158 -0
- data/lib/isodoc/presentation_function/docid.rb +5 -3
- data/lib/isodoc/presentation_function/erefs.rb +17 -113
- data/lib/isodoc/presentation_function/erefs_locality.rb +113 -0
- data/lib/isodoc/presentation_function/image.rb +1 -1
- data/lib/isodoc/presentation_function/list.rb +14 -1
- data/lib/isodoc/presentation_function/refs.rb +2 -1
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/terms.rb +19 -8
- data/lib/isodoc/presentation_function/xrefs.rb +10 -6
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_anchor.rb +1 -2
- data/lib/isodoc/xref/xref_gen.rb +0 -1
- data/lib/isodoc/xref/xref_gen_seq.rb +27 -30
- data/lib/isodoc/xref/xref_util.rb +6 -4
- data/lib/isodoc/xref.rb +9 -6
- data/lib/isodoc-yaml/i18n-ja.yaml +25 -3
- data/lib/isodoc-yaml/i18n-ko.yaml +22 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +24 -2
- data/lib/isodoc-yaml/i18n-zh-Hant.yaml +22 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb4af3689c8908e75e4b6919cb448f2f909b35de01d4fdf44e30d2f080b7a7ce
|
4
|
+
data.tar.gz: 18ac32a56d90f11d83ebfc57d6ab17044228b7ab7a7aba65a90e2f6436505793
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36124955f274bdc52944895c0b7742e89da9ec7646ad0801e1711393a266e405ab22087aeb475a513a46c4b8e4421b83e6b09c4092add9782cd5320ecb28c471
|
7
|
+
data.tar.gz: 462d5b598a87eaa3016b2cb5cc81ec94bf5da6a02608f9e5e008bc142c7dc5d67dfc043255ec773929132035f882b8d7555a886bc6ea0288c32487a6ba9614ec
|
data/isodoc.gemspec
CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "mn2pdf", ">= 2.13"
|
38
38
|
spec.add_dependency "mn-requirements", "~> 0.5.0"
|
39
39
|
|
40
|
-
spec.add_dependency "relaton-render", "~> 0.
|
40
|
+
spec.add_dependency "relaton-render", "~> 0.10.0"
|
41
41
|
spec.add_dependency "roman-numerals"
|
42
42
|
spec.add_dependency "rouge", "~> 4.0"
|
43
43
|
spec.add_dependency "thread_safe"
|
data/lib/isodoc/convert.rb
CHANGED
@@ -86,8 +86,9 @@ module IsoDoc
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def bibrenderer(options = {})
|
89
|
-
::Relaton::Render::IsoDoc::General
|
90
|
-
|
89
|
+
::Relaton::Render::IsoDoc::General
|
90
|
+
.new(options.merge(language: @lang, script: @script,
|
91
|
+
i18nhash: @i18n.get))
|
91
92
|
end
|
92
93
|
|
93
94
|
def convert1_namespaces(html)
|
@@ -36,6 +36,12 @@ module IsoDoc
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def related_parse(node, out)
|
40
|
+
out.div class: "RelatedTerms", style: "text-align:left;" do |p|
|
41
|
+
node.children.each { |c1| parse(c1, p) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
39
45
|
def semx_term_parse(node, out); end
|
40
46
|
|
41
47
|
def semx_related_parse(node, out); end
|
@@ -180,6 +180,7 @@ module IsoDoc
|
|
180
180
|
when "termsource" then semx_termref_parse(node, out)
|
181
181
|
when "fmt-termsource" then termref_parse(node, out)
|
182
182
|
when "related" then semx_related_parse(node, out)
|
183
|
+
when "fmt-related" then related_parse(node, out)
|
183
184
|
when "modification" then modification_parse(node, out)
|
184
185
|
when "termnote" then termnote_parse(node, out)
|
185
186
|
when "terms" then terms_parse(node, out)
|
data/lib/isodoc/init.rb
CHANGED
@@ -14,8 +14,9 @@ module IsoDoc
|
|
14
14
|
i18nyaml: i18nyaml || @i18nyaml)
|
15
15
|
end
|
16
16
|
|
17
|
-
def l10n(expr, lang = @lang, script = @script,
|
18
|
-
|
17
|
+
def l10n(expr, lang = @lang, script = @script, opt = {})
|
18
|
+
opt[:locale] ||= @locale
|
19
|
+
@i18n.l10n(expr, lang, script, opt)
|
19
20
|
end
|
20
21
|
|
21
22
|
def toc_init(docxml)
|
@@ -170,8 +171,8 @@ module IsoDoc
|
|
170
171
|
|
171
172
|
def omit_docid_prefix(prefix)
|
172
173
|
prefix.nil? || prefix.empty? and return true
|
173
|
-
%w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal
|
174
|
-
|
174
|
+
%w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal
|
175
|
+
title).include? prefix
|
175
176
|
end
|
176
177
|
|
177
178
|
def connectives_spans(text)
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -9,8 +9,9 @@ module IsoDoc
|
|
9
9
|
Common::ns(xpath)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
def l10n(expr, lang = @lang, script = @script, opt = {})
|
13
|
+
opt[:locale] ||= @locale
|
14
|
+
@i18n.l10n(expr, lang, script, opt)
|
14
15
|
end
|
15
16
|
|
16
17
|
def connectives_strip(text)
|
@@ -115,7 +116,7 @@ module IsoDoc
|
|
115
116
|
draftinfo = " (#{@labels['draft_label']} #{draft}"
|
116
117
|
draftinfo += ", #{revdate}" if revdate
|
117
118
|
draftinfo += ")"
|
118
|
-
l10n(draftinfo, @lang, @script
|
119
|
+
l10n(draftinfo, @lang, @script)
|
119
120
|
end
|
120
121
|
|
121
122
|
def version(isoxml, _out)
|
@@ -78,7 +78,7 @@ module IsoDoc
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def semx(node, label, element = "autonum")
|
81
|
-
id = node["id"] || node[:id]
|
81
|
+
id = node["id"] || node[:id] || elem['original-id']
|
82
82
|
/<semx element='[^']+' source='#{id}'/.match?(label) and return label
|
83
83
|
l = stripsemx(label)
|
84
84
|
%(<semx element='#{element}' source='#{id}'>#{l}</semx>)
|
@@ -118,7 +118,7 @@ module IsoDoc
|
|
118
118
|
prefix_container_fmt_xref_label(container_container,
|
119
119
|
@xrefs.anchor(container, :xref, false))
|
120
120
|
l10n(connectives_spans(@i18n.nested_xref
|
121
|
-
.sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
|
121
|
+
.sub("%1", "<span class='fmt-xref-container'><esc>#{container_label}</esc></span>")
|
122
122
|
.sub("%2", xref)))
|
123
123
|
end
|
124
124
|
|
@@ -87,7 +87,8 @@ module IsoDoc
|
|
87
87
|
|
88
88
|
def admonition_label(elem, num)
|
89
89
|
lbl = if elem["type"] == "box" then @i18n.box
|
90
|
-
else @i18n.admonition[elem["type"]]&.upcase
|
90
|
+
else @i18n.admonition[elem["type"]]&.upcase
|
91
|
+
end
|
91
92
|
labelled_autonum(lbl, elem["id"], num)
|
92
93
|
end
|
93
94
|
|
@@ -107,7 +108,7 @@ module IsoDoc
|
|
107
108
|
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
108
109
|
n = @xrefs.anchor(elem["id"], :label, false)
|
109
110
|
lbl = labelled_autonum(lower2cap(@i18n.table), elem["id"], n)
|
110
|
-
prefix_name(elem, { caption: table_delim },
|
111
|
+
prefix_name(elem, { caption: table_delim }, lbl, "name")
|
111
112
|
end
|
112
113
|
|
113
114
|
def table_css(elem)
|
@@ -184,17 +185,29 @@ module IsoDoc
|
|
184
185
|
source1(elem, :figure)
|
185
186
|
end
|
186
187
|
|
188
|
+
def source_join_delim(_elem)
|
189
|
+
"; "
|
190
|
+
end
|
191
|
+
|
187
192
|
def source1(elem, ancestor)
|
188
|
-
|
189
|
-
|
190
|
-
|
193
|
+
source_elems = source1_gather(elem)
|
194
|
+
source_elems.each do |e|
|
195
|
+
elem << "#{source_join_delim(elem)}#{to_xml(e.remove.children).strip}"
|
196
|
+
end
|
197
|
+
source1_label(elem, to_xml(elem.children).strip, ancestor)
|
198
|
+
end
|
199
|
+
|
200
|
+
def source1_gather(elem)
|
201
|
+
source_elems = []
|
202
|
+
while elem = elem&.next_element
|
203
|
+
case elem.name
|
191
204
|
when "source"
|
192
205
|
when "fmt-source"
|
193
|
-
|
206
|
+
source_elems << elem
|
194
207
|
else break
|
195
208
|
end
|
196
209
|
end
|
197
|
-
|
210
|
+
source_elems
|
198
211
|
end
|
199
212
|
|
200
213
|
def source1_label(elem, sources, _ancestor)
|
@@ -104,153 +104,5 @@ module IsoDoc
|
|
104
104
|
ref.previous = prev
|
105
105
|
ref.next = foll
|
106
106
|
end
|
107
|
-
|
108
|
-
def related(docxml)
|
109
|
-
docxml.xpath(ns("//fmt-related/semx")).each { |f| related1(f) }
|
110
|
-
end
|
111
|
-
|
112
|
-
def related1(node)
|
113
|
-
p, ref, orig = related1_prep(node)
|
114
|
-
label = @i18n.relatedterms[orig["type"]].upcase
|
115
|
-
ret = "<strong>**RELATED TERM NOT FOUND**</strong>"
|
116
|
-
p && ref and ret = "<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})"
|
117
|
-
node.children = (l10n("<p><strong>#{label}:</strong> #{ret}</p>"))
|
118
|
-
end
|
119
|
-
|
120
|
-
def related1_prep(node)
|
121
|
-
p = node.at(ns("./fmt-preferred"))&.children
|
122
|
-
ref = node.at(ns("./xref | ./eref | ./termref"))
|
123
|
-
orig = semx_orig(node)
|
124
|
-
[p, ref, orig]
|
125
|
-
end
|
126
|
-
|
127
|
-
def related_designation1(desgn)
|
128
|
-
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
129
|
-
d1 = semx_fmt_dup(desgn)
|
130
|
-
%w(preferred admitted deprecates).each do |w|
|
131
|
-
d = d1.at(ns("./#{w}[last()]")) and d.after("<fmt-#{w}/>")
|
132
|
-
end
|
133
|
-
out << d1
|
134
|
-
end
|
135
|
-
|
136
|
-
def designation(docxml)
|
137
|
-
docxml.xpath(ns("//related")).each { |p| related_designation1(p) }
|
138
|
-
docxml.xpath(ns("//preferred | //admitted | //deprecates"))
|
139
|
-
.each { |p| designation1(p) }
|
140
|
-
docxml.xpath(ns("//fmt-preferred | //fmt-admitted | //fmt-deprecates"))
|
141
|
-
.each { |t| merge_second_preferred(t) }
|
142
|
-
docxml.xpath(ns("//fmt-deprecates")).each { |d| deprecates(d) }
|
143
|
-
docxml.xpath(ns("//fmt-admitted")).each { |d| admits(d) }
|
144
|
-
end
|
145
|
-
|
146
|
-
def deprecates(elem)
|
147
|
-
elem.xpath(ns(".//semx[@element = 'deprecates']")).each do |t|
|
148
|
-
t.previous = @i18n.l10n("#{@i18n.deprecated}: ")
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def admits(elem); end
|
153
|
-
|
154
|
-
def merge_second_preferred(term)
|
155
|
-
pref = nil
|
156
|
-
out = term.xpath(ns("./semx")).each_with_index
|
157
|
-
.with_object([]) do |(p, i), m|
|
158
|
-
if (i.zero? && (pref = p)) || merge_preferred_eligible?(pref, p)
|
159
|
-
m << p
|
160
|
-
else p.wrap("<p></p>")
|
161
|
-
end
|
162
|
-
end
|
163
|
-
pref&.replace(merge_second_preferred1(out, term))
|
164
|
-
end
|
165
|
-
|
166
|
-
def merge_second_preferred1(desgns, term)
|
167
|
-
desgns[1..].each(&:remove)
|
168
|
-
ret = l10n(desgns.map { |x| to_xml(x) }.join("; "))
|
169
|
-
term.ancestors("fmt-related").empty? and ret = "<p>#{ret}</p>"
|
170
|
-
ret
|
171
|
-
end
|
172
|
-
|
173
|
-
def merge_preferred_eligible?(first, second)
|
174
|
-
orig_first, orig_second, firstex, secondex =
|
175
|
-
merge_preferred_eligible_prep(first, second)
|
176
|
-
orig_first["geographic-area"] == orig_second["geographic-area"] &&
|
177
|
-
firstex["language"] == secondex["language"] &&
|
178
|
-
!orig_first.at(ns("./pronunciation | ./grammar | ./graphical-symbol")) &&
|
179
|
-
!orig_second.at(ns("./pronunciation | ./grammar | ./graphical-symbol")) &&
|
180
|
-
orig_first.name == "preferred" && orig_second.name == "preferred"
|
181
|
-
end
|
182
|
-
|
183
|
-
def merge_preferred_eligible_prep(first, second)
|
184
|
-
orig_first = semx_orig(first)
|
185
|
-
orig_second = semx_orig(second)
|
186
|
-
firstex = orig_first.at(ns("./expression")) || {}
|
187
|
-
secondex = orig_second.at(ns("./expression")) || {}
|
188
|
-
[orig_first, orig_second, firstex, secondex]
|
189
|
-
end
|
190
|
-
|
191
|
-
def designation1(desgn)
|
192
|
-
desgn.parent.name == "related" and return
|
193
|
-
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
194
|
-
d1 = semx_fmt_dup(desgn)
|
195
|
-
s = d1.at(ns("./source"))
|
196
|
-
modification_dup_align(desgn.at(ns("./source")), s)
|
197
|
-
name = d1.at(ns("./expression/name | ./letter-symbol/name | " \
|
198
|
-
"./graphical-symbol")) or return
|
199
|
-
designation_annotate(d1, name, desgn)
|
200
|
-
out << d1
|
201
|
-
s and out << s.wrap("<fmt-termsource></fmt-termsource>").parent
|
202
|
-
end
|
203
|
-
|
204
|
-
def designation_annotate(desgn, name, orig)
|
205
|
-
designation_boldface(desgn)
|
206
|
-
designation_field(desgn, name, orig)
|
207
|
-
designation_grammar(desgn, name)
|
208
|
-
designation_localization(desgn, name, orig)
|
209
|
-
designation_pronunciation(desgn, name)
|
210
|
-
designation_bookmarks(desgn, name)
|
211
|
-
desgn.children = name.children
|
212
|
-
end
|
213
|
-
|
214
|
-
def designation_boldface(desgn)
|
215
|
-
desgn["element"] == "preferred" or return
|
216
|
-
name = desgn.at(ns("./expression/name | ./letter-symbol/name")) or return
|
217
|
-
name.children = "<strong>#{name.children}</strong>"
|
218
|
-
end
|
219
|
-
|
220
|
-
def designation_field(_desgn, name, orig)
|
221
|
-
f = orig.xpath(ns("./field-of-application | ./usage-info"))
|
222
|
-
&.map { |u| to_xml(semx_fmt_dup(u)) }&.join(", ")
|
223
|
-
f&.empty? and return nil
|
224
|
-
name << "<span class='fmt-designation-field'>, <#{f}></span>"
|
225
|
-
end
|
226
|
-
|
227
|
-
def designation_grammar(desgn, name)
|
228
|
-
g = desgn.at(ns("./expression/grammar")) or return
|
229
|
-
ret = g.xpath(ns("./gender | ./number")).each_with_object([]) do |x, m|
|
230
|
-
m << @i18n.grammar_abbrevs[x.text]
|
231
|
-
end
|
232
|
-
%w(isPreposition isParticiple isAdjective isVerb isAdverb isNoun)
|
233
|
-
.each do |x|
|
234
|
-
g.at(ns("./#{x}[text() = 'true']")) and ret << @i18n.grammar_abbrevs[x]
|
235
|
-
end
|
236
|
-
name << ", #{ret.join(', ')}"
|
237
|
-
end
|
238
|
-
|
239
|
-
def designation_localization(desgn, name, orig_desgn)
|
240
|
-
loc = [desgn.at(ns("./expression/@language"))&.text,
|
241
|
-
desgn.at(ns("./expression/@script"))&.text,
|
242
|
-
orig_desgn.at("./@geographic-area")&.text].compact
|
243
|
-
loc.empty? and return
|
244
|
-
name << ", #{loc.join(' ')}"
|
245
|
-
end
|
246
|
-
|
247
|
-
def designation_pronunciation(desgn, name)
|
248
|
-
f = desgn.at(ns("./expression/pronunciation")) or return
|
249
|
-
name << ", /#{to_xml(f.children)}/"
|
250
|
-
end
|
251
|
-
|
252
|
-
def designation_bookmarks(desgn, name)
|
253
|
-
desgn.xpath(ns(".//bookmark")).each { |b| name << b.remove }
|
254
|
-
end
|
255
107
|
end
|
256
108
|
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
def related(docxml)
|
4
|
+
docxml.xpath(ns("//fmt-related/semx")).each { |f| related1(f) }
|
5
|
+
end
|
6
|
+
|
7
|
+
# Only render related if rendered and hyperlinked
|
8
|
+
def related1(node)
|
9
|
+
p, ref, orig = related1_prep(node)
|
10
|
+
label = @i18n.relatedterms[orig["type"]].upcase
|
11
|
+
ret = if p && ref
|
12
|
+
if p.text == ref.text
|
13
|
+
"<em>#{Common::to_xml(ref)}</em>"
|
14
|
+
else
|
15
|
+
"<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})"
|
16
|
+
end
|
17
|
+
else "<strong>**RELATED TERM NOT FOUND**</strong>"
|
18
|
+
end
|
19
|
+
node.children = (l10n("<p><strong>#{label}:</strong> #{ret}</p>"))
|
20
|
+
end
|
21
|
+
|
22
|
+
def related1_prep(node)
|
23
|
+
p = node.at(ns("./fmt-preferred"))&.children
|
24
|
+
ref = node.at(ns("./xref | ./eref | ./termref"))
|
25
|
+
orig = semx_orig(node)
|
26
|
+
[p, ref, orig]
|
27
|
+
end
|
28
|
+
|
29
|
+
def related_designation1(desgn)
|
30
|
+
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
31
|
+
d1 = semx_fmt_dup(desgn)
|
32
|
+
%w(preferred admitted deprecates).each do |w|
|
33
|
+
d = d1.at(ns("./#{w}[last()]")) and d.after("<fmt-#{w}/>")
|
34
|
+
end
|
35
|
+
out << d1
|
36
|
+
end
|
37
|
+
|
38
|
+
def designation(docxml)
|
39
|
+
docxml.xpath(ns("//related")).each { |p| related_designation1(p) }
|
40
|
+
docxml.xpath(ns("//preferred | //admitted | //deprecates"))
|
41
|
+
.each { |p| designation1(p) }
|
42
|
+
docxml.xpath(ns("//fmt-preferred | //fmt-admitted | //fmt-deprecates"))
|
43
|
+
.each { |t| merge_second_preferred(t) }
|
44
|
+
docxml.xpath(ns("//fmt-deprecates")).each { |d| deprecates(d) }
|
45
|
+
docxml.xpath(ns("//fmt-admitted")).each { |d| admits(d) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def deprecates(elem)
|
49
|
+
elem.xpath(ns(".//semx[@element = 'deprecates']")).each do |t|
|
50
|
+
t.previous = @i18n.l10n("#{@i18n.deprecated}: ")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def admits(elem); end
|
55
|
+
|
56
|
+
def merge_second_preferred(term)
|
57
|
+
pref = nil
|
58
|
+
out = term.xpath(ns("./semx")).each_with_index
|
59
|
+
.with_object([]) do |(p, i), m|
|
60
|
+
if (i.zero? && (pref = p)) || merge_preferred_eligible?(pref, p)
|
61
|
+
m << p
|
62
|
+
else p.wrap("<p></p>")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
pref&.replace(merge_second_preferred1(out, term))
|
66
|
+
end
|
67
|
+
|
68
|
+
def merge_second_preferred1(desgns, term)
|
69
|
+
desgns[1..].each(&:remove)
|
70
|
+
ret = l10n(desgns.map { |x| to_xml(x) }.join("; "))
|
71
|
+
term.ancestors("fmt-related").empty? and ret = "<p>#{ret}</p>"
|
72
|
+
ret
|
73
|
+
end
|
74
|
+
|
75
|
+
def merge_preferred_eligible?(first, second)
|
76
|
+
orig_first, orig_second, firstex, secondex =
|
77
|
+
merge_preferred_eligible_prep(first, second)
|
78
|
+
orig_first["geographic-area"] == orig_second["geographic-area"] &&
|
79
|
+
firstex["language"] == secondex["language"] &&
|
80
|
+
!orig_first.at(ns("./pronunciation | ./grammar | ./graphical-symbol")) &&
|
81
|
+
!orig_second.at(ns("./pronunciation | ./grammar | ./graphical-symbol")) &&
|
82
|
+
orig_first.name == "preferred" && orig_second.name == "preferred"
|
83
|
+
end
|
84
|
+
|
85
|
+
def merge_preferred_eligible_prep(first, second)
|
86
|
+
orig_first = semx_orig(first)
|
87
|
+
orig_second = semx_orig(second)
|
88
|
+
firstex = orig_first.at(ns("./expression")) || {}
|
89
|
+
secondex = orig_second.at(ns("./expression")) || {}
|
90
|
+
[orig_first, orig_second, firstex, secondex]
|
91
|
+
end
|
92
|
+
|
93
|
+
def designation1(desgn)
|
94
|
+
desgn.parent.name == "related" and return
|
95
|
+
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
96
|
+
d1 = semx_fmt_dup(desgn)
|
97
|
+
s = d1.at(ns("./source"))
|
98
|
+
modification_dup_align(desgn.at(ns("./source")), s)
|
99
|
+
name = d1.at(ns("./expression/name | ./letter-symbol/name | " \
|
100
|
+
"./graphical-symbol")) or return
|
101
|
+
designation_annotate(d1, name, desgn)
|
102
|
+
out << d1
|
103
|
+
s and out << s.wrap("<fmt-termsource></fmt-termsource>").parent
|
104
|
+
end
|
105
|
+
|
106
|
+
def designation_annotate(desgn, name, orig)
|
107
|
+
designation_boldface(desgn)
|
108
|
+
designation_field(desgn, name, orig)
|
109
|
+
designation_grammar(desgn, name)
|
110
|
+
designation_localization(desgn, name, orig)
|
111
|
+
designation_pronunciation(desgn, name)
|
112
|
+
designation_bookmarks(desgn, name)
|
113
|
+
desgn.children = name.children
|
114
|
+
end
|
115
|
+
|
116
|
+
def designation_boldface(desgn)
|
117
|
+
desgn["element"] == "preferred" or return
|
118
|
+
name = desgn.at(ns("./expression/name | ./letter-symbol/name")) or return
|
119
|
+
name.children = "<strong>#{name.children}</strong>"
|
120
|
+
end
|
121
|
+
|
122
|
+
def designation_field(_desgn, name, orig)
|
123
|
+
f = orig.xpath(ns("./field-of-application | ./usage-info"))
|
124
|
+
&.map { |u| to_xml(semx_fmt_dup(u)) }&.join(", ")
|
125
|
+
f&.empty? and return nil
|
126
|
+
name << "<span class='fmt-designation-field'>, <#{f}></span>"
|
127
|
+
end
|
128
|
+
|
129
|
+
def designation_grammar(desgn, name)
|
130
|
+
g = desgn.at(ns("./expression/grammar")) or return
|
131
|
+
ret = g.xpath(ns("./gender | ./number")).each_with_object([]) do |x, m|
|
132
|
+
m << @i18n.grammar_abbrevs[x.text]
|
133
|
+
end
|
134
|
+
%w(isPreposition isParticiple isAdjective isVerb isAdverb isNoun)
|
135
|
+
.each do |x|
|
136
|
+
g.at(ns("./#{x}[text() = 'true']")) and ret << @i18n.grammar_abbrevs[x]
|
137
|
+
end
|
138
|
+
name << ", #{ret.join(', ')}"
|
139
|
+
end
|
140
|
+
|
141
|
+
def designation_localization(desgn, name, orig_desgn)
|
142
|
+
loc = [desgn.at(ns("./expression/@language"))&.text,
|
143
|
+
desgn.at(ns("./expression/@script"))&.text,
|
144
|
+
orig_desgn.at("./@geographic-area")&.text].compact
|
145
|
+
loc.empty? and return
|
146
|
+
name << ", #{loc.join(' ')}"
|
147
|
+
end
|
148
|
+
|
149
|
+
def designation_pronunciation(desgn, name)
|
150
|
+
f = desgn.at(ns("./expression/pronunciation")) or return
|
151
|
+
name << ", /#{to_xml(f.children)}/"
|
152
|
+
end
|
153
|
+
|
154
|
+
def designation_bookmarks(desgn, name)
|
155
|
+
desgn.xpath(ns(".//bookmark")).each { |b| name << b.remove }
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -23,7 +23,7 @@ module IsoDoc
|
|
23
23
|
data, = @bibrender.parse(bib)
|
24
24
|
ret = data[:authoritative_identifier] or return nil
|
25
25
|
ret.empty? and return nil
|
26
|
-
ret
|
26
|
+
ret.map { |x| @i18n.l10n(x) } # get rid of `<esc>` wrappers
|
27
27
|
end
|
28
28
|
|
29
29
|
# returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
|
@@ -31,11 +31,13 @@ module IsoDoc
|
|
31
31
|
id, id1, id2, id3 = bibitem_ref_code_prep(bib)
|
32
32
|
id || id1 || id2 || id3 and return [id, id1, id2, id3]
|
33
33
|
bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil]
|
34
|
-
[nil, no_identifier(bib), nil, nil]
|
34
|
+
# [nil, no_identifier(bib), nil, nil]
|
35
|
+
[nil, nil, nil, nil]
|
35
36
|
end
|
36
37
|
|
37
38
|
def bibitem_ref_code_prep(bib)
|
38
|
-
id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
|
39
|
+
id = bib.at(ns("./docidentifier[@type = 'metanorma']")) ||
|
40
|
+
bib.at(ns("./docidentifier[@type = 'title']"))
|
39
41
|
id1 = pref_ref_code(bib)
|
40
42
|
id2 = bib.at(ns("./docidentifier[#{SKIP_DOCID}]"))
|
41
43
|
id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
|