isodoc 2.12.9 → 3.0.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 +3 -2
- data/lib/isodoc/base_style/all.scss +6 -6
- data/lib/isodoc/base_style/bands.css +135 -0
- data/lib/isodoc/base_style/bands.scss +6 -3
- data/lib/isodoc/base_style/blocks.scss +1 -1
- data/lib/isodoc/base_style/metanorma_word.css +33 -17
- data/lib/isodoc/base_style/nav.scss +7 -7
- data/lib/isodoc/base_style/reset.css +100 -54
- data/lib/isodoc/css.rb +1 -1
- data/lib/isodoc/function/blocks.rb +9 -6
- data/lib/isodoc/function/inline.rb +30 -7
- data/lib/isodoc/function/reqt.rb +3 -2
- data/lib/isodoc/function/section.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +19 -6
- data/lib/isodoc/gem_tasks.rb +1 -1
- data/lib/isodoc/html_function/html.rb +4 -2
- data/lib/isodoc/init.rb +1 -0
- data/lib/isodoc/presentation_function/block.rb +14 -8
- data/lib/isodoc/presentation_function/concepts.rb +37 -13
- data/lib/isodoc/presentation_function/erefs.rb +13 -8
- data/lib/isodoc/presentation_function/image.rb +5 -2
- data/lib/isodoc/presentation_function/inline.rb +41 -16
- data/lib/isodoc/presentation_function/math.rb +19 -8
- data/lib/isodoc/presentation_function/sourcecode.rb +46 -15
- data/lib/isodoc/presentation_function/xrefs.rb +14 -1
- data/lib/isodoc/presentation_xml_convert.rb +24 -4
- data/lib/isodoc/sassc_importer.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +1 -1
- data/lib/isodoc/xref/xref_sect_gen.rb +4 -2
- metadata +8 -8
- data/lib/isodoc/base_style/all.css +0 -368
@@ -38,8 +38,9 @@ module IsoDoc
|
|
38
38
|
def pseudocode_parse(node, out)
|
39
39
|
@in_figure = true
|
40
40
|
name = node.at(ns("./fmt-name"))
|
41
|
+
s = node.at(ns("./fmt-figure")) || node
|
41
42
|
out.div **pseudocode_attrs(node) do |div|
|
42
|
-
|
43
|
+
s.children.each { |n| parse(n, div) unless n.name == "fmt-name" }
|
43
44
|
sourcecode_name_parse(node, div, name)
|
44
45
|
end
|
45
46
|
@in_figure = false
|
@@ -58,10 +59,12 @@ module IsoDoc
|
|
58
59
|
|
59
60
|
def sourcecode_parse(node, out)
|
60
61
|
name = node.at(ns("./fmt-name"))
|
62
|
+
n = node.at(ns("./fmt-sourcecode"))
|
63
|
+
s = n || node
|
61
64
|
out.p **sourcecode_attrs(node) do |div|
|
62
|
-
sourcecode_parse1(
|
65
|
+
sourcecode_parse1(s, div)
|
63
66
|
end
|
64
|
-
annotation_parse(
|
67
|
+
annotation_parse(s, out)
|
65
68
|
sourcecode_name_parse(node, out, name)
|
66
69
|
end
|
67
70
|
|
@@ -92,7 +95,7 @@ module IsoDoc
|
|
92
95
|
def formula_parse1(node, out)
|
93
96
|
out.div **attr_code(class: "formula") do |div|
|
94
97
|
div.p do |_p|
|
95
|
-
parse(node.at(ns("./stem")), div)
|
98
|
+
parse(node.at(ns("./fmt-stem")), div)
|
96
99
|
if lbl = node&.at(ns("./fmt-name"))&.text
|
97
100
|
insert_tab(div, 1)
|
98
101
|
div << lbl
|
@@ -109,7 +112,7 @@ module IsoDoc
|
|
109
112
|
out.div **formula_attrs(node) do |div|
|
110
113
|
formula_parse1(node, div)
|
111
114
|
node.children.each do |n|
|
112
|
-
%w(stem fmt-name).include? n.name and next
|
115
|
+
%w(stem fmt-name fmt-stem).include? n.name and next
|
113
116
|
parse(n, div)
|
114
117
|
end
|
115
118
|
end
|
@@ -148,7 +151,7 @@ module IsoDoc
|
|
148
151
|
attrs = para_attrs(node)
|
149
152
|
attrs[:class] = "Quote"
|
150
153
|
out.div **attr_code(attrs) do |p|
|
151
|
-
node.children.each { |n| parse(n, p) }
|
154
|
+
node.children.each { |n| parse(n, p) unless n.name == "source" }
|
152
155
|
end
|
153
156
|
end
|
154
157
|
|
@@ -82,11 +82,12 @@ module IsoDoc
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def stem_parse(node, out)
|
85
|
+
ret = node.at(ns("./semx[@element = 'stem']")) || node
|
85
86
|
ooml = case node["type"]
|
86
|
-
when "AsciiMath" then asciimath_parse(
|
87
|
-
when "MathML" then mathml_parse(
|
88
|
-
when "LaTeX" then latexmath_parse(
|
89
|
-
else HTMLEntities.new.encode(
|
87
|
+
when "AsciiMath" then asciimath_parse(ret)
|
88
|
+
when "MathML" then mathml_parse(ret)
|
89
|
+
when "LaTeX" then latexmath_parse(ret)
|
90
|
+
else HTMLEntities.new.encode(ret.text)
|
90
91
|
end
|
91
92
|
out.span class: "stem" do |span|
|
92
93
|
span.parent.add_child ooml
|
@@ -188,9 +189,7 @@ module IsoDoc
|
|
188
189
|
end
|
189
190
|
end
|
190
191
|
|
191
|
-
def author_parse(node, out)
|
192
|
-
children_parse(node, out)
|
193
|
-
end
|
192
|
+
def author_parse(node, out); end
|
194
193
|
|
195
194
|
def semx_parse(node, out)
|
196
195
|
children_parse(node, out)
|
@@ -204,12 +203,36 @@ module IsoDoc
|
|
204
203
|
|
205
204
|
def name_parse(node, out); end
|
206
205
|
def semx_definition_parse(node, out); end
|
206
|
+
def semx_xref_parse(node, out); end
|
207
|
+
def semx_eref_parse(node, out); end
|
208
|
+
def semx_link_parse(node, out); end
|
209
|
+
def semx_origin_parse(node, out); end
|
210
|
+
def date_parse(node, out); end
|
211
|
+
def semx_stem_parse(node, out); end
|
207
212
|
|
208
213
|
def floating_title_parse(node, out); end
|
214
|
+
def identifier_parse(node, out); end
|
215
|
+
def concept_parse(node, out); end
|
216
|
+
def erefstack_parse(node, out); end
|
217
|
+
def svgmap_parse(node, out); end
|
218
|
+
def amend_parse(node, out); end
|
219
|
+
def semx_sourcecode_parse(node, out); end
|
209
220
|
|
210
221
|
def fmt_name_parse(node, out)
|
211
222
|
children_parse(node, out)
|
212
223
|
end
|
224
|
+
|
225
|
+
def fmt_identifier_parse(node, out)
|
226
|
+
children_parse(node, out)
|
227
|
+
end
|
228
|
+
|
229
|
+
def fmt_concept_parse(node, out)
|
230
|
+
children_parse(node, out)
|
231
|
+
end
|
232
|
+
|
233
|
+
def fmt_date_parse(node, out)
|
234
|
+
children_parse(node, out)
|
235
|
+
end
|
213
236
|
end
|
214
237
|
end
|
215
238
|
end
|
data/lib/isodoc/function/reqt.rb
CHANGED
@@ -20,9 +20,10 @@ module IsoDoc
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def recommendation_parse1(node, out)
|
23
|
+
p = node.at(ns("./fmt-provision")) or return
|
23
24
|
recommendation_name(node.at(ns("./fmt-name")), out)
|
24
|
-
|
25
|
-
parse(n, out)
|
25
|
+
p.children.each do |n|
|
26
|
+
parse(n, out)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -188,12 +188,17 @@ module IsoDoc
|
|
188
188
|
when "bookmark" then bookmark_parse(node, out)
|
189
189
|
when "pagebreak" then pagebreak_parse(node, out)
|
190
190
|
when "callout" then callout_parse(node, out)
|
191
|
-
when "stem" then stem_parse(node, out)
|
191
|
+
when "fmt-stem" then stem_parse(node, out)
|
192
|
+
when "stem" then semx_stem_parse(node, out)
|
192
193
|
when "clause" then clause_parse(node, out)
|
193
|
-
when "xref" then
|
194
|
-
when "
|
195
|
-
when "
|
196
|
-
when "
|
194
|
+
when "xref" then semx_xref_parse(node, out)
|
195
|
+
when "fmt-xref" then xref_parse(node, out)
|
196
|
+
when "eref" then semx_eref_parse(node, out)
|
197
|
+
when "fmt-eref" then eref_parse(node, out)
|
198
|
+
when "origin" then semx_origin_parse(node, out)
|
199
|
+
when "fmt-origin" then origin_parse(node, out)
|
200
|
+
when "link" then semx_link_parse(node, out)
|
201
|
+
when "fmt-link" then link_parse(node, out)
|
197
202
|
when "ul" then ul_parse(node, out)
|
198
203
|
when "ol" then ol_parse(node, out)
|
199
204
|
when "li" then li_parse(node, out)
|
@@ -245,7 +250,6 @@ module IsoDoc
|
|
245
250
|
when "legal-statement" then legal_parse(node, out)
|
246
251
|
when "feedback-statement" then feedback_parse(node, out)
|
247
252
|
when "passthrough" then passthrough_parse(node, out)
|
248
|
-
when "amend" then amend_parse(node, out)
|
249
253
|
when "tab" then clausedelimspace(node, out) # in Presentation XML only
|
250
254
|
when "svg" then svg_parse(node, out) # in Presentation XML only
|
251
255
|
when "add" then add_parse(node, out)
|
@@ -273,6 +277,15 @@ module IsoDoc
|
|
273
277
|
when "fmt-xref-label" then xref_label_parse(node, out)
|
274
278
|
when "fmt-name" then fmt_name_parse(node, out)
|
275
279
|
when "floating-title" then floating_title_parse(node, out)
|
280
|
+
when "fmt-identifier" then fmt_identifier_parse(node, out)
|
281
|
+
when "identifier" then identifier_parse(node, out)
|
282
|
+
when "fmt-concept" then fmt_concept_parse(node, out)
|
283
|
+
when "concept" then concept_parse(node, out)
|
284
|
+
when "erefstack" then erefstack_parse(node, out)
|
285
|
+
when "svgmap" then svgmap_parse(node, out)
|
286
|
+
when "amend" then amend_parse(node, out)
|
287
|
+
when "date" then date_parse(node, out)
|
288
|
+
when "fmt-date" then fmt_date_parse(node, out)
|
276
289
|
else error_parse(node, out)
|
277
290
|
end
|
278
291
|
end
|
data/lib/isodoc/gem_tasks.rb
CHANGED
@@ -76,11 +76,13 @@ module IsoDoc
|
|
76
76
|
def sourcecode_parse(node, out)
|
77
77
|
name = node.at(ns("./fmt-name"))
|
78
78
|
tag = node.at(ns(".//sourcecode | .//table")) ? "div" : "pre"
|
79
|
+
n = node.at(ns("./fmt-sourcecode"))
|
80
|
+
s = n || node
|
79
81
|
attr = sourcecode_attrs(node).merge(class: "sourcecode")
|
80
82
|
out.send tag, **attr do |div|
|
81
|
-
sourcecode_parse1(
|
83
|
+
sourcecode_parse1(s, div)
|
82
84
|
end
|
83
|
-
annotation_parse(
|
85
|
+
annotation_parse(s, out)
|
84
86
|
sourcecode_name_parse(node, out, name)
|
85
87
|
end
|
86
88
|
|
data/lib/isodoc/init.rb
CHANGED
@@ -137,17 +137,18 @@ module IsoDoc
|
|
137
137
|
|
138
138
|
def table_fn1(table, fnote, idx); end
|
139
139
|
|
140
|
-
# we use this to eliminate the semantic amend blocks from rendering
|
141
140
|
def amend(docxml)
|
142
141
|
docxml.xpath(ns("//amend")).each { |f| amend1(f) }
|
143
142
|
end
|
144
143
|
|
145
144
|
def amend1(elem)
|
146
|
-
|
145
|
+
ret = semx_fmt_dup(elem)
|
146
|
+
ret.xpath(ns("./locality | ./localityStack | ./autonumber | " \
|
147
147
|
"./classification | ./contributor")).each(&:remove)
|
148
|
-
|
149
|
-
|
150
|
-
elem.
|
148
|
+
ret.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
|
149
|
+
ret.xpath(ns("./description")).each { |a| a.replace(a.children) }
|
150
|
+
elem.xpath(ns(".//fmt-name | .//fmt-xref-label")).each(&:remove)
|
151
|
+
elem.next = ret
|
151
152
|
end
|
152
153
|
|
153
154
|
def dl(docxml)
|
@@ -233,11 +234,16 @@ module IsoDoc
|
|
233
234
|
source = elem.at(ns("./source"))
|
234
235
|
author.nil? && source.nil? and return
|
235
236
|
p = "— "
|
236
|
-
p += author
|
237
|
+
p += to_xml(semx_fmt_dup(author)) if author
|
237
238
|
p += ", " if author && source
|
238
239
|
if source
|
239
|
-
|
240
|
-
|
240
|
+
s = semx_fmt_dup(source)
|
241
|
+
e = Nokogiri::XML::Node.new("eref", elem.document)
|
242
|
+
e << s.children
|
243
|
+
s << e
|
244
|
+
source.attributes.each_key { |k| e[k] = source[k] }
|
245
|
+
e["deleteme"] = "true" # duplicate of source, will be duplicated in fmt-eref, need to delete after
|
246
|
+
p += to_xml(s)
|
241
247
|
end
|
242
248
|
elem << "<attribution><p>#{l10n p}</p></attribution>"
|
243
249
|
end
|
@@ -8,7 +8,7 @@ module IsoDoc
|
|
8
8
|
|
9
9
|
def concept1(node)
|
10
10
|
node.ancestors("definition, termsource, related").empty? or return
|
11
|
-
xref = node&.at(ns("./xref/@target"))&.text or
|
11
|
+
xref = node&.at(ns("./semx/fmt-xref/@target"))&.text or
|
12
12
|
return concept_render(node, ital: "true", ref: "true", bold: "false",
|
13
13
|
linkref: "true", linkmention: "false")
|
14
14
|
if @definition_ids[xref]
|
@@ -20,13 +20,25 @@ module IsoDoc
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def concept_render(node, defaults)
|
23
|
-
|
24
|
-
node
|
23
|
+
#require "debug"; binding.b
|
24
|
+
opts, render, ref, ret = concept_render_init(node, defaults)
|
25
|
+
ret&.at(ns("./refterm"))&.remove
|
25
26
|
ref && opts[:ref] != "false" and render&.next = " "
|
26
27
|
concept1_linkmention(ref, render, opts)
|
27
|
-
concept1_ref(
|
28
|
-
concept1_style(
|
29
|
-
|
28
|
+
concept1_ref(ret, ref, opts)
|
29
|
+
concept1_style(ret, opts)
|
30
|
+
concept_dup(node, ret)
|
31
|
+
end
|
32
|
+
|
33
|
+
def concept_dup(node, ret)
|
34
|
+
node.xpath(".//xmlns:semx[xmlns:fmt-xref | xmlns:fmt-eref | xmlns:fmt-origin | xmlns:fmt-link]").each(&:remove)
|
35
|
+
ret.xpath(ns(".//xref | .//eref | .//origin | .//link")).each(&:remove)
|
36
|
+
ret.xpath(ns(".//semx")).each do |s|
|
37
|
+
s.children.empty? and s.remove
|
38
|
+
end
|
39
|
+
f = Nokogiri::XML::Node.new("fmt-concept", node.document)
|
40
|
+
f << ret
|
41
|
+
node.next = f
|
30
42
|
end
|
31
43
|
|
32
44
|
def concept1_style(node, opts)
|
@@ -38,25 +50,37 @@ module IsoDoc
|
|
38
50
|
end
|
39
51
|
|
40
52
|
def concept_render_init(node, defaults)
|
41
|
-
opts =
|
53
|
+
opts = concept_render_opts(node, defaults)
|
54
|
+
ret = semx_fmt_dup(node)
|
55
|
+
ret.children.each { |x| x.text? and x.remove }
|
56
|
+
[opts, ret.at(ns("./renderterm")),
|
57
|
+
ret.at(ns("./semx/fmt-xref | ./semx/fmt-eref | ./termref")), ret]
|
58
|
+
end
|
59
|
+
|
60
|
+
def concept_render_opts(node, defaults)
|
61
|
+
%i(bold ital ref linkref linkmention)
|
42
62
|
.each_with_object({}) { |x, m| m[x] = node[x.to_s] || defaults[x] }
|
43
|
-
[opts, node.at(ns("./renderterm")),
|
44
|
-
node.at(ns("./xref | ./eref | ./termref"))]
|
45
63
|
end
|
46
64
|
|
47
65
|
def concept1_linkmention(ref, renderterm, opts)
|
48
66
|
(opts[:linkmention] == "true" && !renderterm.nil? && !ref.nil?) or return
|
49
67
|
ref2 = ref.clone
|
50
68
|
r2 = renderterm.clone
|
51
|
-
renderterm.replace(ref2).children = r2
|
69
|
+
#renderterm.replace(ref2).children = r2
|
70
|
+
ref2.children = r2
|
71
|
+
if ref.parent.name == "semx"
|
72
|
+
renderterm.replace("<semx element='#{ref.parent['element']}' source='#{ref.parent['source']}'>#{to_xml(ref2)}</semx>")
|
73
|
+
else
|
74
|
+
renderterm.replace(ref2)
|
75
|
+
end
|
52
76
|
end
|
53
77
|
|
54
78
|
def concept1_ref(_node, ref, opts)
|
55
79
|
ref.nil? and return
|
56
80
|
opts[:ref] == "false" and return ref.remove
|
57
81
|
concept1_ref_content(ref)
|
58
|
-
%w(xref eref).include? ref.name and get_linkend(ref)
|
59
|
-
opts[:linkref] == "false" && %w(xref eref).include?(ref.name) and
|
82
|
+
%w(fmt-xref fmt-eref).include? ref.name and get_linkend(ref)
|
83
|
+
opts[:linkref] == "false" && %w(fmt-xref fmt-eref).include?(ref.name) and
|
60
84
|
ref.replace(ref.children)
|
61
85
|
end
|
62
86
|
|
@@ -65,7 +89,7 @@ module IsoDoc
|
|
65
89
|
foll = "]"
|
66
90
|
non_locality_elems(ref).select do |c|
|
67
91
|
!c.text? || /\S/.match(c)
|
68
|
-
end.empty?
|
92
|
+
end.empty? or
|
69
93
|
(prev, foll = @i18n.term_defined_in.split("%"))
|
70
94
|
ref.previous = prev
|
71
95
|
ref.next = foll
|
@@ -3,13 +3,14 @@ require "metanorma-utils"
|
|
3
3
|
module IsoDoc
|
4
4
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
5
5
|
def citeas(xmldoc)
|
6
|
-
xmldoc.xpath(ns("//eref | //origin | //
|
6
|
+
xmldoc.xpath(ns("//fmt-eref | //fmt-origin | //fmt-link"))
|
7
7
|
.each do |e|
|
8
|
+
sem_xml_descendant?(e) and next
|
8
9
|
e["bibitemid"] && e["citeas"] or next
|
9
10
|
a = @xrefs.anchor(e["bibitemid"], :xref, false) or next
|
10
11
|
e["citeas"] = citeas_cleanup(a)
|
11
12
|
# link generated in collection postprocessing from eref
|
12
|
-
e.name == "link" && e.text.empty? and e.children = e["citeas"]
|
13
|
+
e.name == "fmt-link" && e.text.empty? and e.children = e["citeas"]
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -28,11 +29,13 @@ module IsoDoc
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def erefstack1(elem)
|
31
|
-
locs = elem.xpath(ns("./eref")).map do |e|
|
32
|
-
[e["connective"], to_xml(e)]
|
32
|
+
locs = elem.xpath(ns("./semx/fmt-eref")).map do |e|
|
33
|
+
[e["connective"], to_xml(e.parent.remove)]
|
33
34
|
end.flatten
|
34
35
|
ret = resolve_eref_connectives(locs)
|
35
|
-
elem
|
36
|
+
elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
37
|
+
elem.next = "<semx element='erefstack' source='#{elem['id']}'>#{ret[1]}</semx>"
|
38
|
+
#elem.replace(ret[1])
|
36
39
|
end
|
37
40
|
|
38
41
|
def eref_localities(refs, target, node)
|
@@ -192,8 +195,10 @@ module IsoDoc
|
|
192
195
|
end
|
193
196
|
|
194
197
|
def eref2link(docxml)
|
195
|
-
docxml.xpath(ns("//
|
198
|
+
docxml.xpath(ns("//display-text")).each { |f| f.replace(f.children) }
|
199
|
+
docxml.xpath(ns("//fmt-eref | //fmt-origin[not(.//termref)]"))
|
196
200
|
.each do |e|
|
201
|
+
sem_xml_descendant?(e) and next
|
197
202
|
href = eref_target(e) or next
|
198
203
|
e.xpath(ns("./locality | ./localityStack")).each(&:remove)
|
199
204
|
if href[:type] == :anchor then eref2xref(e)
|
@@ -203,7 +208,7 @@ module IsoDoc
|
|
203
208
|
end
|
204
209
|
|
205
210
|
def eref2xref(node)
|
206
|
-
node.name = "xref"
|
211
|
+
node.name = "fmt-xref"
|
207
212
|
node["target"] = node["bibitemid"]
|
208
213
|
node.delete("bibitemid")
|
209
214
|
node.delete("citeas")
|
@@ -213,7 +218,7 @@ module IsoDoc
|
|
213
218
|
def eref2link1(node, href)
|
214
219
|
url = href[:link]
|
215
220
|
att = href[:type] == :attachment ? "attachment='true'" : ""
|
216
|
-
repl = "<link #{att} target='#{url}'>#{node.children}</link>"
|
221
|
+
repl = "<fmt-link #{att} target='#{url}'>#{node.children}</link>"
|
217
222
|
node["type"] == "footnote" and repl = "<sup>#{repl}</sup>"
|
218
223
|
node.replace(repl)
|
219
224
|
end
|
@@ -20,8 +20,11 @@ module IsoDoc
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def svgmap_extract(elem)
|
23
|
-
if
|
24
|
-
|
23
|
+
if elem.at(ns("./figure"))# then elem.replace(f)
|
24
|
+
n = semx_fmt_dup(elem)
|
25
|
+
n.xpath(ns("./target")).each(&:remove)
|
26
|
+
elem.next = n
|
27
|
+
#else elem.remove
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -25,8 +25,8 @@ module IsoDoc
|
|
25
25
|
# <locality type="section"><reference>3.1</reference></locality></origin>
|
26
26
|
|
27
27
|
def unnest_linkend(node)
|
28
|
-
node.at(ns("./xref[@nested]")) or return
|
29
|
-
node.xpath(ns("./xref[@nested]")).each { |x| x.delete("nested") }
|
28
|
+
node.at(ns("./fmt-xref[@nested]")) or return
|
29
|
+
node.xpath(ns("./fmt-xref[@nested]")).each { |x| x.delete("nested") }
|
30
30
|
node.xpath(ns("./location | ./locationStack")).each(&:remove)
|
31
31
|
node.replace(node.children)
|
32
32
|
end
|
@@ -39,30 +39,52 @@ module IsoDoc
|
|
39
39
|
def anchor_id_postprocess(node); end
|
40
40
|
|
41
41
|
def xref(docxml)
|
42
|
-
docxml.xpath(ns("//
|
43
|
-
docxml.xpath(ns("//xref
|
42
|
+
#docxml.xpath(ns("//display-text")).each { |f| f.replace(f.children) }
|
43
|
+
docxml.xpath(ns("//fmt-xref")).each { |f| xref1(f) }
|
44
|
+
docxml.xpath(ns("//fmt-xref//fmt-xref")).each { |f| f.replace(f.children) }
|
45
|
+
docxml.xpath(ns("//fmt-xref//xref")).each { |f| f.replace(f.children) }
|
44
46
|
end
|
45
47
|
|
46
48
|
def eref(docxml)
|
47
|
-
docxml.xpath(ns("//eref")).each { |f|
|
48
|
-
docxml.xpath(ns("//eref
|
49
|
+
docxml.xpath(ns("//eref[@deleteme]")).each { |f| redundant_eref(f) }
|
50
|
+
docxml.xpath(ns("//fmt-eref")).each { |f| xref1(f) }
|
51
|
+
docxml.xpath(ns("//fmt-eref//fmt-xref")).each { |f| f.replace(f.children) }
|
49
52
|
docxml.xpath(ns("//erefstack")).each { |f| erefstack1(f) }
|
50
53
|
end
|
51
54
|
|
55
|
+
# redundant eref copied from quote/source
|
56
|
+
def redundant_eref(elem)
|
57
|
+
if elem.next.name == "semx"
|
58
|
+
elem.next.elements.first.delete("deleteme")
|
59
|
+
elem.next.replace(elem.next.children)
|
60
|
+
end
|
61
|
+
elem.remove
|
62
|
+
end
|
63
|
+
|
52
64
|
def origin(docxml)
|
53
|
-
docxml.xpath(ns("//origin[not(termref)]")).each { |f| xref1(f) }
|
65
|
+
docxml.xpath(ns("//fmt-origin[not(.//termref)]")).each { |f| xref1(f) }
|
54
66
|
end
|
55
67
|
|
56
|
-
|
68
|
+
# KILL
|
69
|
+
def quotesourcex(docxml)
|
57
70
|
docxml.xpath(ns("//quote//source")).each { |f| xref1(f) }
|
58
71
|
docxml.xpath(ns("//quote//source//xref")).each do |f|
|
59
72
|
f.replace(f.children)
|
60
73
|
end
|
61
74
|
end
|
62
75
|
|
76
|
+
# do not change to Presentation XML rendering
|
77
|
+
def sem_xml_descendant?(node)
|
78
|
+
!node.ancestors("preferred, admitted, deprecated, related, " \
|
79
|
+
"definition, termsource").empty? and return true
|
80
|
+
!node.ancestors("xref, eref, origin, link").empty? and return true
|
81
|
+
!node.ancestors("requirement, recommendation, permission").empty? &&
|
82
|
+
node.ancestors("fmt-provision").empty? and return true
|
83
|
+
false
|
84
|
+
end
|
85
|
+
|
63
86
|
def xref1(node)
|
64
|
-
|
65
|
-
node.ancestors("related, definition, termsource").empty? or return
|
87
|
+
sem_xml_descendant?(node) and return
|
66
88
|
get_linkend(node)
|
67
89
|
end
|
68
90
|
|
@@ -87,11 +109,11 @@ module IsoDoc
|
|
87
109
|
end
|
88
110
|
|
89
111
|
def identifier(docxml)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
112
|
+
docxml.xpath(ns("//identifier")).each do |n|
|
113
|
+
%w(bibdata bibitem requirement recommendation permission)
|
114
|
+
.include?(n.parent.name) and next
|
115
|
+
s = semx_fmt_dup(n)
|
116
|
+
n.next = "<fmt-identifier><tt>#{to_xml(s)}</tt></fmt-identifier>"
|
95
117
|
end
|
96
118
|
end
|
97
119
|
|
@@ -104,7 +126,10 @@ module IsoDoc
|
|
104
126
|
|
105
127
|
def date1(elem)
|
106
128
|
elem["value"] && elem["format"] or return
|
107
|
-
|
129
|
+
val = @i18n.date(elem["value"], elem["format"].strip)
|
130
|
+
d = semx_fmt_dup(elem)
|
131
|
+
d << val
|
132
|
+
elem.next = "<fmt-date>#{to_xml(d)}</fmt-date>"
|
108
133
|
end
|
109
134
|
|
110
135
|
def inline_format(docxml)
|
@@ -7,11 +7,13 @@ module IsoDoc
|
|
7
7
|
MATHML = { "m" => "http://www.w3.org/1998/Math/MathML" }.freeze
|
8
8
|
|
9
9
|
def mathml(docxml)
|
10
|
+
docxml.xpath(ns("//stem")).each { |s| stem_dup(s) }
|
10
11
|
locale = @lang.to_sym
|
11
12
|
@numfmt = Plurimath::NumberFormatter
|
12
13
|
.new(locale, localize_number: @localizenumber,
|
13
14
|
localizer_symbols: twitter_cldr_localiser_symbols)
|
14
15
|
docxml.xpath("//m:math", MATHML).each do |f| # rubocop:disable Style/CombinableLoops
|
16
|
+
f.parent&.parent&.name == "fmt-stem" or next
|
15
17
|
mathml1(f, locale)
|
16
18
|
end
|
17
19
|
end
|
@@ -147,11 +149,11 @@ module IsoDoc
|
|
147
149
|
def maths_just_numeral(node)
|
148
150
|
mn = node.at(".//m:mn", MATHML).children.text
|
149
151
|
.sub(/\^([0-9+-]+)$/, "<sup>\\1</sup>")
|
150
|
-
if node.parent.name == "stem"
|
151
|
-
node.
|
152
|
-
else
|
152
|
+
#if node.parent.parent.name == "stem"
|
153
|
+
#node.replace(mn)
|
154
|
+
#else
|
153
155
|
node.replace(mn)
|
154
|
-
end
|
156
|
+
#end
|
155
157
|
end
|
156
158
|
|
157
159
|
def mathml1(node, locale)
|
@@ -159,6 +161,15 @@ module IsoDoc
|
|
159
161
|
mathml_number(node, locale)
|
160
162
|
end
|
161
163
|
|
164
|
+
def stem_dup(node)
|
165
|
+
sem_xml_descendant?(node) and return
|
166
|
+
ret = semx_fmt_dup(node)
|
167
|
+
f = Nokogiri::XML::Node.new("fmt-stem", node.document)
|
168
|
+
t = node["type"] and f["type"] = t
|
169
|
+
f << ret
|
170
|
+
node.next = f
|
171
|
+
end
|
172
|
+
|
162
173
|
# convert any Ascii superscripts to correct(ish) MathML
|
163
174
|
# Not bothering to match times, base of 1.0 x 10^-20, just ^-20
|
164
175
|
def mn_to_msup(node)
|
@@ -198,11 +209,11 @@ module IsoDoc
|
|
198
209
|
def mathml_number_to_number(node)
|
199
210
|
(node.elements.size == 1 && node.elements.first.name == "mn") or return
|
200
211
|
repl = node.at("./m:mn", MATHML).children
|
201
|
-
if node.parent.name == "stem"
|
202
|
-
node.parent.replace(repl)
|
203
|
-
else
|
212
|
+
#if node.parent.name == "stem"
|
213
|
+
#node.parent.replace(repl)
|
214
|
+
#else
|
204
215
|
node.replace(repl)
|
205
|
-
end
|
216
|
+
#end
|
206
217
|
end
|
207
218
|
end
|
208
219
|
end
|