isodoc 2.12.7 → 2.12.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/function/inline.rb +2 -1
- data/lib/isodoc/function/terms.rb +32 -10
- data/lib/isodoc/function/to_word_html.rb +11 -5
- data/lib/isodoc/presentation_function/autonum.rb +16 -2
- data/lib/isodoc/presentation_function/concepts.rb +147 -6
- data/lib/isodoc/presentation_function/inline.rb +2 -0
- data/lib/isodoc/presentation_function/refs.rb +1 -1
- data/lib/isodoc/presentation_function/terms.rb +85 -121
- data/lib/isodoc/presentation_xml_convert.rb +2 -0
- data/lib/isodoc/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d46387b5edc802722718eee916f95086aaf651066ca34ff37b440ddcd98ea600
|
4
|
+
data.tar.gz: ec777b74ccacf348dc787500b6e40c1a310c60ba248562fb4534837531e9e690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34a90598b6fb6c91a2650761a105bce1d2509895106566ae0296235031f768b0330fb419a247b29670d1f6e56df1911b2cbf099c040101a3bc0ce8352ece2391
|
7
|
+
data.tar.gz: c9491f85801636ee19d61e1185211e407e0dbbf58ffa5a8cfa41d5e7f0b3a8e2a84d262ced72fcf70c9bfa71bea29308d6e2757dc39a0a17eab9b841e78a1619
|
data/isodoc.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
# spec.add_dependency "isodoc-i18n", "~> 1.1.0" # already in relaton-render and mn-requirements
|
35
35
|
# spec.add_dependency "relaton-cli"
|
36
36
|
# spec.add_dependency "metanorma-utils", "~> 1.5.0" # already in isodoc-i18n
|
37
|
-
spec.add_dependency "mn2pdf", ">= 2.
|
37
|
+
spec.add_dependency "mn2pdf", ">= 2.13"
|
38
38
|
spec.add_dependency "mn-requirements", "~> 0.4.0"
|
39
39
|
|
40
40
|
spec.add_dependency "relaton-render", "~> 0.9.0"
|
@@ -21,7 +21,7 @@ module IsoDoc
|
|
21
21
|
SPAN_UNWRAP_CLASSES =
|
22
22
|
%w[fmt-caption-label fmt-label-delim fmt-caption-delim fmt-autonum-delim
|
23
23
|
fmt-element-name fmt-conn fmt-comma fmt-enum-comma fmt-obligation
|
24
|
-
fmt-xref-container].freeze
|
24
|
+
fmt-xref-container fmt-designation-field].freeze
|
25
25
|
|
26
26
|
def span_parse(node, out)
|
27
27
|
klass = node["style"] || node["class"]
|
@@ -203,6 +203,7 @@ module IsoDoc
|
|
203
203
|
def xref_label_parse(node, out); end
|
204
204
|
|
205
205
|
def name_parse(node, out); end
|
206
|
+
def semx_definition_parse(node, out); end
|
206
207
|
|
207
208
|
def floating_title_parse(node, out); end
|
208
209
|
|
@@ -10,21 +10,44 @@ module IsoDoc
|
|
10
10
|
para.children.each { |n| parse(n, out) }
|
11
11
|
end
|
12
12
|
|
13
|
+
def semx_deprecated_term_parse(node, out); end
|
14
|
+
|
13
15
|
def deprecated_term_parse(node, out)
|
14
|
-
|
15
|
-
|
16
|
+
node.children.each do |c|
|
17
|
+
if c.name == "p"
|
18
|
+
out.p class: "DeprecatedTerms", style: "text-align:left;" do |p|
|
19
|
+
c.children.each { |c1| parse(c1, p) }
|
20
|
+
end
|
21
|
+
else parse(c, out)
|
22
|
+
end
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
26
|
+
def semx_admitted_term_parse(node, out); end
|
27
|
+
|
19
28
|
def admitted_term_parse(node, out)
|
20
|
-
|
21
|
-
|
29
|
+
node.children.each do |c|
|
30
|
+
if c.name == "p"
|
31
|
+
out.p class: "AltTerms", style: "text-align:left;" do |p|
|
32
|
+
c.children.each { |c1| parse(c1, p) }
|
33
|
+
end
|
34
|
+
else parse(c, out)
|
35
|
+
end
|
22
36
|
end
|
23
37
|
end
|
24
38
|
|
39
|
+
def semx_term_parse(node, out); end
|
40
|
+
|
41
|
+
def semx_related_parse(node, out); end
|
42
|
+
|
25
43
|
def term_parse(node, out)
|
26
|
-
|
27
|
-
|
44
|
+
node.children.each do |c|
|
45
|
+
if c.name == "p"
|
46
|
+
out.p class: "Terms", style: "text-align:left;" do |p|
|
47
|
+
c.children.each { |c1| parse(c1, p) }
|
48
|
+
end
|
49
|
+
else parse(c, out)
|
50
|
+
end
|
28
51
|
end
|
29
52
|
end
|
30
53
|
|
@@ -51,16 +74,15 @@ module IsoDoc
|
|
51
74
|
para&.name != "p" and parse(para, div)
|
52
75
|
end
|
53
76
|
|
77
|
+
def semx_termref_parse(node, out); end
|
78
|
+
|
54
79
|
def termref_parse(node, out)
|
55
80
|
out.p do |p|
|
56
81
|
node.children.each { |n| parse(n, p) }
|
57
82
|
end
|
58
83
|
end
|
59
84
|
|
60
|
-
def termdomain_parse(node, out)
|
61
|
-
node["hidden"] == "true" and return
|
62
|
-
node.children.each { |n| parse(n, out) }
|
63
|
-
end
|
85
|
+
def termdomain_parse(node, out); end
|
64
86
|
|
65
87
|
def termdef_parse(node, out)
|
66
88
|
name = node.at(ns("./fmt-name"))&.remove
|
@@ -215,12 +215,18 @@ module IsoDoc
|
|
215
215
|
when "pre" then pre_parse(node, out)
|
216
216
|
when "annotation" then annotation_parse(node, out)
|
217
217
|
when "term" then termdef_parse(node, out)
|
218
|
-
when "preferred" then
|
219
|
-
when "
|
220
|
-
when "
|
218
|
+
when "preferred" then semx_term_parse(node, out)
|
219
|
+
when "fmt-preferred" then term_parse(node, out)
|
220
|
+
when "admitted" then semx_admitted_term_parse(node, out)
|
221
|
+
when "fmt-admitted" then admitted_term_parse(node, out)
|
222
|
+
when "deprecates" then semx_deprecated_term_parse(node, out)
|
223
|
+
when "fmt-deprecates" then deprecated_term_parse(node, out)
|
221
224
|
when "domain" then termdomain_parse(node, out)
|
222
|
-
when "definition" then
|
223
|
-
when "
|
225
|
+
when "definition" then semx_definition_parse(node, out)
|
226
|
+
when "fmt-definition" then definition_parse(node, out)
|
227
|
+
when "termsource" then semx_termref_parse(node, out)
|
228
|
+
when "fmt-termsource" then termref_parse(node, out)
|
229
|
+
when "related" then semx_related_parse(node, out)
|
224
230
|
when "modification" then modification_parse(node, out)
|
225
231
|
when "termnote" then termnote_parse(node, out)
|
226
232
|
when "terms" then terms_parse(node, out)
|
@@ -44,14 +44,23 @@ module IsoDoc
|
|
44
44
|
old.delete("id")
|
45
45
|
end
|
46
46
|
|
47
|
+
def semx_fmt_dup(elem)
|
48
|
+
elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
49
|
+
new = Nokogiri::XML(<<~XML).root
|
50
|
+
<semx xmlns='#{elem.namespace.href}' element='#{elem.name}' source='#{elem['original-id'] || elem['id']}'>#{to_xml(elem.children)}</semx>
|
51
|
+
XML
|
52
|
+
strip_duplicate_ids(nil, elem, new)
|
53
|
+
new
|
54
|
+
end
|
55
|
+
|
47
56
|
def gather_all_ids(elem)
|
48
57
|
elem.xpath(".//*[@id]").each_with_object([]) do |i, m|
|
49
58
|
m << i["id"]
|
50
59
|
end
|
51
60
|
end
|
52
61
|
|
53
|
-
# remove ids duplicated between
|
54
|
-
# index terms are assumed transferred to
|
62
|
+
# remove ids duplicated between sem_title and pres_title
|
63
|
+
# index terms are assumed transferred to pres_title from sem_title
|
55
64
|
def strip_duplicate_ids(_node, sem_title, pres_title)
|
56
65
|
sem_title && pres_title or return
|
57
66
|
ids = gather_all_ids(pres_title)
|
@@ -75,6 +84,11 @@ module IsoDoc
|
|
75
84
|
"<semx element='autonum' source='#{id}'>#{num}</semx>"
|
76
85
|
end
|
77
86
|
|
87
|
+
def semx_orig(node, orig = nil)
|
88
|
+
orig ||= node.parent.parent
|
89
|
+
orig.at(".//*[@id = '#{node['source']}']")
|
90
|
+
end
|
91
|
+
|
78
92
|
def labelled_autonum(label, id, num)
|
79
93
|
elem = "<span class='fmt-element-name'>#{label}</span>"
|
80
94
|
num.blank? and return elem
|
@@ -7,6 +7,7 @@ module IsoDoc
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def concept1(node)
|
10
|
+
node.ancestors("definition, termsource, related").empty? or return
|
10
11
|
xref = node&.at(ns("./xref/@target"))&.text or
|
11
12
|
return concept_render(node, ital: "true", ref: "true", bold: "false",
|
12
13
|
linkref: "true", linkmention: "false")
|
@@ -71,20 +72,160 @@ module IsoDoc
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def related(docxml)
|
74
|
-
docxml.xpath(ns("//related")).each { |f| related1(f) }
|
75
|
+
docxml.xpath(ns("//fmt-related/semx")).each { |f| related1(f) }
|
75
76
|
end
|
76
77
|
|
77
78
|
def related1(node)
|
78
|
-
p = node
|
79
|
-
|
80
|
-
label = @i18n.relatedterms[node["type"]].upcase
|
79
|
+
p, ref, orig = related1_prep(node)
|
80
|
+
label = @i18n.relatedterms[orig["type"]].upcase
|
81
81
|
if p && ref
|
82
|
-
node.
|
82
|
+
node.children =(l10n("<p><strong>#{label}:</strong> " \
|
83
83
|
"<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})</p>"))
|
84
84
|
else
|
85
|
-
node.
|
85
|
+
node.children = (l10n("<p><strong>#{label}:</strong> " \
|
86
86
|
"<strong>**RELATED TERM NOT FOUND**</strong></p>"))
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
def related1_prep(node)
|
91
|
+
p = node.at(ns("./fmt-preferred"))&.children
|
92
|
+
ref = node.at(ns("./xref | ./eref | ./termref"))
|
93
|
+
orig = semx_orig(node)
|
94
|
+
[p, ref, orig]
|
95
|
+
end
|
96
|
+
|
97
|
+
def related_designation1(desgn)
|
98
|
+
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
99
|
+
d1 = semx_fmt_dup(desgn)
|
100
|
+
%w(preferred admitted deprecates).each do |w|
|
101
|
+
d = d1.at(ns("./#{w}[last()]")) and d.after("<fmt-#{w}/>")
|
102
|
+
end
|
103
|
+
out << d1
|
104
|
+
end
|
105
|
+
|
106
|
+
def designation(docxml)
|
107
|
+
docxml.xpath(ns("//related")).each { |p| related_designation1(p) }
|
108
|
+
docxml.xpath(ns("//preferred | //admitted | //deprecates"))
|
109
|
+
.each { |p| designation1(p) }
|
110
|
+
docxml.xpath(ns("//fmt-preferred | //fmt-admitted | //fmt-deprecates"))
|
111
|
+
.each { |t| merge_second_preferred(t) }
|
112
|
+
docxml.xpath(ns("//fmt-deprecates")).each { |d| deprecates(d) }
|
113
|
+
docxml.xpath(ns("//fmt-admitted")).each { |d| admits(d) }
|
114
|
+
end
|
115
|
+
|
116
|
+
def deprecates(elem)
|
117
|
+
elem.xpath(ns(".//semx[@element = 'deprecates']")).each do |t|
|
118
|
+
t.previous = @i18n.l10n("#{@i18n.deprecated}: ")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def admits(elem); end
|
123
|
+
|
124
|
+
def merge_second_preferred(term)
|
125
|
+
pref = nil
|
126
|
+
out = term.xpath(ns("./semx")).each_with_index
|
127
|
+
.with_object([]) do |(p, i), m|
|
128
|
+
if (i.zero? && (pref = p)) || merge_preferred_eligible?(pref, p)
|
129
|
+
m << p
|
130
|
+
else
|
131
|
+
p.wrap("<p></p>")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
pref&.replace(merge_second_preferred1(out, term))
|
135
|
+
end
|
136
|
+
|
137
|
+
def merge_second_preferred1(desgns, term)
|
138
|
+
desgns[1..].each(&:remove)
|
139
|
+
ret = l10n(desgns.map { |x| to_xml(x) }.join("; "))
|
140
|
+
term.ancestors("fmt-related").empty? and ret = "<p>#{ret}</p>"
|
141
|
+
ret
|
142
|
+
end
|
143
|
+
|
144
|
+
def merge_preferred_eligible?(first, second)
|
145
|
+
orig_first, orig_second, firstex, secondex =
|
146
|
+
merge_preferred_eligible_prep(first, second)
|
147
|
+
orig_first["geographic-area"] == orig_second["geographic-area"] &&
|
148
|
+
firstex["language"] == secondex["language"] &&
|
149
|
+
!orig_first.at(ns("./pronunciation | ./grammar | ./graphical-symbol")) &&
|
150
|
+
!orig_second.at(ns("./pronunciation | ./grammar | ./graphical-symbol")) &&
|
151
|
+
orig_first.name == "preferred" && orig_second.name == "preferred"
|
152
|
+
end
|
153
|
+
|
154
|
+
def merge_preferred_eligible_prep(first, second)
|
155
|
+
orig_first = semx_orig(first)
|
156
|
+
orig_second = semx_orig(second)
|
157
|
+
firstex = orig_first.at(ns("./expression")) || {}
|
158
|
+
secondex = orig_second.at(ns("./expression")) || {}
|
159
|
+
[orig_first, orig_second, firstex, secondex]
|
160
|
+
end
|
161
|
+
|
162
|
+
def designation1(desgn)
|
163
|
+
desgn.parent.name == "related" and return
|
164
|
+
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
165
|
+
d1 = semx_fmt_dup(desgn)
|
166
|
+
s = d1.at(ns("./termsource"))
|
167
|
+
name = d1.at(ns("./expression/name | ./letter-symbol/name | " \
|
168
|
+
"./graphical-symbol")) or return
|
169
|
+
designation_annotate(d1, name, desgn)
|
170
|
+
out << d1
|
171
|
+
s and out << s.wrap("<fmt-termsource></fmt-termsource>").parent
|
172
|
+
end
|
173
|
+
|
174
|
+
def designation_annotate(desgn, name, orig)
|
175
|
+
designation_boldface(desgn)
|
176
|
+
designation_field(desgn, name, orig)
|
177
|
+
#g = desgn.at(ns("./expression/grammar")) and
|
178
|
+
#name << ", #{designation_grammar(g).join(', ')}"
|
179
|
+
designation_grammar(desgn, name)
|
180
|
+
designation_localization(desgn, name, orig)
|
181
|
+
designation_pronunciation(desgn, name)
|
182
|
+
designation_bookmarks(desgn, name)
|
183
|
+
desgn.children = name.children
|
184
|
+
end
|
185
|
+
|
186
|
+
def designation_boldface(desgn)
|
187
|
+
desgn["element"] == "preferred" or return
|
188
|
+
name = desgn.at(ns("./expression/name | ./letter-symbol/name")) or return
|
189
|
+
name.children = "<strong>#{name.children}</strong>"
|
190
|
+
end
|
191
|
+
|
192
|
+
def designation_field(desgn, name, orig)
|
193
|
+
f = orig.xpath(ns("./field-of-application | ./usage-info"))
|
194
|
+
&.map { |u| to_xml(semx_fmt_dup(u)) }&.join(", ")
|
195
|
+
f&.empty? and return nil
|
196
|
+
name << "<span class='fmt-designation-field'>, <#{f}></span>"
|
197
|
+
end
|
198
|
+
|
199
|
+
def designation_grammar(desgn, name)
|
200
|
+
g = desgn.at(ns("./expression/grammar")) or return
|
201
|
+
ret = []
|
202
|
+
g.xpath(ns("./gender | ./number")).each do |x|
|
203
|
+
ret << @i18n.grammar_abbrevs[x.text]
|
204
|
+
end
|
205
|
+
%w(isPreposition isParticiple isAdjective isVerb isAdverb isNoun)
|
206
|
+
.each do |x|
|
207
|
+
g.at(ns("./#{x}[text() = 'true']")) and ret << @i18n.grammar_abbrevs[x]
|
208
|
+
end
|
209
|
+
name << ", #{ret.join(', ')}"
|
210
|
+
end
|
211
|
+
|
212
|
+
def designation_localization(desgn, name, orig_desgn)
|
213
|
+
loc = [desgn.at(ns("./expression/@language"))&.text,
|
214
|
+
desgn.at(ns("./expression/@script"))&.text,
|
215
|
+
orig_desgn.at("./@geographic-area")&.text].compact
|
216
|
+
loc.empty? and return
|
217
|
+
name << ", #{loc.join(' ')}"
|
218
|
+
end
|
219
|
+
|
220
|
+
def designation_pronunciation(desgn, name)
|
221
|
+
f = desgn.at(ns("./expression/pronunciation")) or return
|
222
|
+
name << ", /#{to_xml(f.children)}/"
|
223
|
+
end
|
224
|
+
|
225
|
+
def designation_bookmarks(desgn, name)
|
226
|
+
desgn.xpath(ns(".//bookmark")).each do |b|
|
227
|
+
name << b.remove
|
228
|
+
end
|
229
|
+
end
|
89
230
|
end
|
90
231
|
end
|
@@ -107,7 +107,7 @@ module IsoDoc
|
|
107
107
|
def bibliography_bibitem_number(docxml)
|
108
108
|
i = 0
|
109
109
|
docxml.xpath(ns("//references")).each do |r|
|
110
|
-
r.xpath(ns("
|
110
|
+
r.xpath(ns("./bibitem")).each do |b|
|
111
111
|
i = bibliography_bibitem_number1(b, i, r["normative"] == "true")
|
112
112
|
end
|
113
113
|
end
|
@@ -1,103 +1,25 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
-
def
|
4
|
-
docxml.xpath(ns("//term")).each
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def deprecates(elem)
|
12
|
-
elem.add_first_child @i18n.l10n("#{@i18n.deprecated}: ")
|
13
|
-
end
|
14
|
-
|
15
|
-
def admits(elem); end
|
16
|
-
|
17
|
-
def merge_second_preferred(term)
|
18
|
-
pref = nil
|
19
|
-
term.xpath(ns("./preferred[expression/name]")).each_with_index do |p, i|
|
20
|
-
(i.zero? and pref = p) or merge_second_preferred1(pref, p)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def merge_second_preferred1(pref, second)
|
25
|
-
merge_preferred_eligible?(pref, second) or return
|
26
|
-
n1 = pref.at(ns("./expression/name"))
|
27
|
-
n2 = second.remove.at(ns("./expression/name"))
|
28
|
-
n1.children = l10n("#{to_xml(n1.children)}; #{Common::to_xml(n2.children)}")
|
29
|
-
end
|
30
|
-
|
31
|
-
def merge_preferred_eligible?(first, second)
|
32
|
-
firstex = first.at(ns("./expression")) || {}
|
33
|
-
secondex = second.at(ns("./expression")) || {}
|
34
|
-
first["geographic-area"] == second["geographic-area"] &&
|
35
|
-
firstex["language"] == secondex["language"] &&
|
36
|
-
!first.at(ns("./pronunciation | ./grammar")) &&
|
37
|
-
!second.at(ns("./pronunciation | ./grammar"))
|
38
|
-
end
|
39
|
-
|
40
|
-
def designation1(desgn)
|
41
|
-
s = desgn.at(ns("./termsource"))
|
42
|
-
name = desgn.at(ns("./expression/name | ./letter-symbol/name | " \
|
43
|
-
"./graphical-symbol")) or return
|
44
|
-
designation_annotate(desgn, name)
|
45
|
-
s and desgn.next = s
|
46
|
-
end
|
47
|
-
|
48
|
-
def designation_annotate(desgn, name)
|
49
|
-
designation_boldface(desgn)
|
50
|
-
designation_field(desgn, name)
|
51
|
-
g = desgn.at(ns("./expression/grammar")) and
|
52
|
-
name << ", #{designation_grammar(g).join(', ')}"
|
53
|
-
designation_localization(desgn, name)
|
54
|
-
designation_pronunciation(desgn, name)
|
55
|
-
designation_bookmarks(desgn, name)
|
56
|
-
desgn.children = name.children
|
57
|
-
end
|
58
|
-
|
59
|
-
def designation_boldface(desgn)
|
60
|
-
desgn.name == "preferred" or return
|
61
|
-
name = desgn.at(ns("./expression/name | ./letter-symbol/name")) or return
|
62
|
-
name.children = "<strong>#{name.children}</strong>"
|
63
|
-
end
|
64
|
-
|
65
|
-
def designation_field(desgn, name)
|
66
|
-
f = desgn.xpath(ns("./field-of-application | ./usage-info"))
|
67
|
-
&.map { |u| to_xml(u.children) }&.join(", ")
|
68
|
-
f&.empty? and return nil
|
69
|
-
name << ", <#{f}>"
|
70
|
-
end
|
71
|
-
|
72
|
-
def designation_grammar(grammar)
|
73
|
-
ret = []
|
74
|
-
grammar.xpath(ns("./gender | ./number")).each do |x|
|
75
|
-
ret << @i18n.grammar_abbrevs[x.text]
|
3
|
+
def termcontainers(docxml)
|
4
|
+
docxml.xpath(ns("//term")).each do |t|
|
5
|
+
%w(preferred admitted deprecates related definition termsource)
|
6
|
+
.each do |w|
|
7
|
+
d = t.at(ns("./#{w}[last()]")) and d.after("<fmt-#{w}/>")
|
8
|
+
end
|
76
9
|
end
|
77
|
-
|
78
|
-
|
79
|
-
grammar.at(ns("./#{x}[text() = 'true']")) and
|
80
|
-
ret << @i18n.grammar_abbrevs[x]
|
10
|
+
docxml.xpath(ns("//termsource")).each do |s|
|
11
|
+
s["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
81
12
|
end
|
82
|
-
ret
|
83
13
|
end
|
84
14
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
def designation_pronunciation(desgn, name)
|
94
|
-
f = desgn.at(ns("./expression/pronunciation")) or return
|
95
|
-
name << ", /#{to_xml(f.children)}/"
|
96
|
-
end
|
97
|
-
|
98
|
-
def designation_bookmarks(desgn, name)
|
99
|
-
desgn.xpath(ns(".//bookmark")).each do |b|
|
100
|
-
name << b.remove
|
15
|
+
def termcleanup(docxml)
|
16
|
+
docxml.xpath(ns("//term")).each do |t|
|
17
|
+
%w(preferred admitted deprecates related definition termsource)
|
18
|
+
.each do |w|
|
19
|
+
t.xpath(ns("./#{w}//fmt-name | ./#{w}//fmt-xref-label")).each(&:remove)
|
20
|
+
f = t.at(ns(".//fmt-#{w}"))
|
21
|
+
f&.children&.empty? and f.remove
|
22
|
+
end
|
101
23
|
end
|
102
24
|
end
|
103
25
|
|
@@ -123,29 +45,32 @@ module IsoDoc
|
|
123
45
|
end
|
124
46
|
|
125
47
|
def termdefinition(docxml)
|
126
|
-
docxml.xpath(ns("//term[definition]")).each
|
127
|
-
termdefinition1(f)
|
128
|
-
end
|
48
|
+
docxml.xpath(ns("//term[definition]")).each { |f| termdefinition1(f) }
|
129
49
|
end
|
130
50
|
|
131
51
|
def termdefinition1(elem)
|
132
|
-
|
133
|
-
|
134
|
-
|
52
|
+
d = elem.xpath(ns("./definition"))
|
53
|
+
d1 = elem.at(ns("./fmt-definition"))
|
54
|
+
if d.size > 1 then multidef(elem, d, d1)
|
55
|
+
else singledef(elem, d, d1)
|
56
|
+
end
|
57
|
+
unwrap_definition(elem, d1)
|
58
|
+
termdomain(elem, d1)
|
135
59
|
end
|
136
60
|
|
137
|
-
def multidef(
|
138
|
-
|
139
|
-
|
140
|
-
elem.xpath(ns("./definition")).each do |f|
|
141
|
-
f = f.replace("<li>#{to_xml(f.children)}</li>").first
|
142
|
-
d << f
|
61
|
+
def multidef(_elem, defn, fmt_defn)
|
62
|
+
ret = defn.each_with_object([]) do |f, m|
|
63
|
+
m << "<li>#{to_xml(semx_fmt_dup(f))}</li>"
|
143
64
|
end
|
144
|
-
|
65
|
+
fmt_defn << "<ol>#{ret.join("\n")}</ol>"
|
145
66
|
end
|
146
67
|
|
147
|
-
def
|
148
|
-
|
68
|
+
def singledef(_elem, defn, fmt_defn)
|
69
|
+
fmt_defn << semx_fmt_dup(defn.first)
|
70
|
+
end
|
71
|
+
|
72
|
+
def unwrap_definition(_elem, fmt_defn)
|
73
|
+
fmt_defn.xpath(ns(".//semx[@element = 'definition']")).each do |d|
|
149
74
|
%w(verbal-definition non-verbal-representation).each do |e|
|
150
75
|
v = d&.at(ns("./#{e}"))
|
151
76
|
v&.replace(v.children)
|
@@ -153,26 +78,62 @@ module IsoDoc
|
|
153
78
|
end
|
154
79
|
end
|
155
80
|
|
156
|
-
def termdomain(elem)
|
81
|
+
def termdomain(elem, fmt_defn)
|
157
82
|
d = elem.at(ns(".//domain")) or return
|
158
|
-
p =
|
159
|
-
|
160
|
-
|
83
|
+
p = fmt_defn.at(ns(".//p")) or return
|
84
|
+
d1 = semx_fmt_dup(d)
|
85
|
+
p.add_first_child "<#{to_xml(d1)}> "
|
161
86
|
end
|
162
87
|
|
163
88
|
def termsource(docxml)
|
164
|
-
docxml
|
165
|
-
|
89
|
+
copy_baselevel_termsource(docxml)
|
90
|
+
# TODO should I wrap fmt-definition//termsource in fmt-termsource, in order to preserve termsource attributes?
|
91
|
+
docxml.xpath(ns("//fmt-termsource/termsource | //fmt-definition//termsource | //fmt-preferred//termsource | //fmt-admitted//termsource | //fmt-deprecates//termsource"))
|
92
|
+
.each do |f|
|
93
|
+
termsource_modification(f)
|
94
|
+
end
|
95
|
+
docxml.xpath(ns("//fmt-preferred//fmt-termsource | //fmt-admitted//fmt-termsource | //fmt-deprecates//fmt-termsource"))
|
96
|
+
.each do |f|
|
97
|
+
termsource_designation(f)
|
98
|
+
end
|
99
|
+
docxml.xpath(ns("//fmt-termsource/termsource | //fmt-definition//termsource | //fmt-preferred//termsource | //fmt-admitted//termsource | //fmt-deprecates//termsource"))
|
100
|
+
.each do |f|
|
101
|
+
f.parent and termsource1(f)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def termsource_designation(fmtsource)
|
106
|
+
p = fmtsource.previous_element
|
107
|
+
p&.name == "p" or return
|
108
|
+
p << " "
|
109
|
+
p << fmtsource.children
|
110
|
+
end
|
111
|
+
|
112
|
+
def copy_baselevel_termsource(docxml)
|
113
|
+
docxml.xpath(ns("//term[termsource]")).each do |x|
|
114
|
+
s = x.xpath(ns("./termsource"))
|
115
|
+
s1 = x.at(ns("./fmt-termsource"))
|
116
|
+
s.each { |ss| s1 << ss.clone }
|
117
|
+
strip_duplicate_ids(nil, s, s1)
|
118
|
+
%w(status type).each { |a| s[0][a] and s1[a] = s[0][a] }
|
119
|
+
end
|
166
120
|
end
|
167
121
|
|
168
122
|
def termsource1(elem)
|
123
|
+
ret = [semx_fmt_dup(elem)]
|
169
124
|
while elem&.next_element&.name == "termsource"
|
170
|
-
|
125
|
+
ret << semx_fmt_dup(elem.next_element.remove)
|
171
126
|
end
|
172
|
-
|
127
|
+
s = ret.map { |x| to_xml(x) }.map(&:strip).join("; ")
|
128
|
+
termsource_label(elem, s)
|
129
|
+
end
|
130
|
+
|
131
|
+
def termsource_label(elem, sources)
|
132
|
+
elem.replace(l10n("[#{@i18n.source}: #{sources}]"))
|
173
133
|
end
|
174
134
|
|
175
135
|
def termsource_modification(elem)
|
136
|
+
elem.xpath(".//text()[normalize-space() = '']").each(&:remove)
|
176
137
|
origin = elem.at(ns("./origin"))
|
177
138
|
s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
|
178
139
|
termsource_add_modification_text(elem.at(ns("./modification")))
|
@@ -180,10 +141,13 @@ module IsoDoc
|
|
180
141
|
|
181
142
|
def termsource_add_modification_text(mod)
|
182
143
|
mod or return
|
183
|
-
mod.text.strip.empty?
|
184
|
-
|
185
|
-
|
186
|
-
|
144
|
+
if mod.text.strip.empty?
|
145
|
+
mod.remove
|
146
|
+
return
|
147
|
+
end
|
148
|
+
mod.previous = " — "
|
149
|
+
mod.elements.size == 1 and mod.children = to_xml(mod.elements[0].children)
|
150
|
+
mod.replace(semx_fmt_dup(mod))
|
187
151
|
end
|
188
152
|
|
189
153
|
def termsource_status(status)
|
@@ -108,6 +108,7 @@ module IsoDoc
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def terms(docxml)
|
111
|
+
termcontainers docxml
|
111
112
|
termexample docxml
|
112
113
|
termnote docxml
|
113
114
|
termdefinition docxml
|
@@ -115,6 +116,7 @@ module IsoDoc
|
|
115
116
|
termsource docxml
|
116
117
|
concept docxml
|
117
118
|
related docxml
|
119
|
+
termcleanup docxml
|
118
120
|
end
|
119
121
|
|
120
122
|
def semantic_xml_insert(xml)
|
data/lib/isodoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.12.
|
4
|
+
version: 2.12.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2.
|
61
|
+
version: '2.13'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '2.
|
68
|
+
version: '2.13'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mn-requirements
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -486,7 +486,7 @@ homepage: https://github.com/metanorma/isodoc
|
|
486
486
|
licenses:
|
487
487
|
- BSD-2-Clause
|
488
488
|
metadata: {}
|
489
|
-
post_install_message:
|
489
|
+
post_install_message:
|
490
490
|
rdoc_options: []
|
491
491
|
require_paths:
|
492
492
|
- lib
|
@@ -502,7 +502,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
502
502
|
version: '0'
|
503
503
|
requirements: []
|
504
504
|
rubygems_version: 3.3.27
|
505
|
-
signing_key:
|
505
|
+
signing_key:
|
506
506
|
specification_version: 4
|
507
507
|
summary: Convert documents in IsoDoc into Word and HTML in AsciiDoc.
|
508
508
|
test_files: []
|