isodoc 3.1.3 → 3.1.5
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 +5 -3
- data/lib/isodoc/base_style/all.css +7 -0
- data/lib/isodoc/base_style/reset.css +7 -0
- data/lib/isodoc/base_style/reset.scss +4 -0
- data/lib/isodoc/function/blocks.rb +3 -3
- data/lib/isodoc/function/cleanup.rb +0 -10
- data/lib/isodoc/function/footnotes.rb +9 -3
- data/lib/isodoc/function/inline.rb +26 -11
- data/lib/isodoc/function/lists.rb +20 -10
- data/lib/isodoc/function/table.rb +8 -3
- data/lib/isodoc/function/to_word_html.rb +4 -1
- data/lib/isodoc/headlesshtml_convert.rb +0 -2
- data/lib/isodoc/html_convert.rb +0 -2
- data/lib/isodoc/html_function/html.rb +7 -0
- data/lib/isodoc/html_function/postprocess_footnotes.rb +0 -15
- data/lib/isodoc/init.rb +1 -0
- data/lib/isodoc/pdf_convert.rb +0 -2
- data/lib/isodoc/presentation_function/block.rb +0 -47
- data/lib/isodoc/presentation_function/footnotes.rb +72 -3
- data/lib/isodoc/presentation_function/image.rb +6 -2
- data/lib/isodoc/presentation_function/list.rb +78 -0
- data/lib/isodoc/presentation_function/math.rb +2 -10
- data/lib/isodoc/presentation_function/xrefs.rb +1 -1
- data/lib/isodoc/presentation_xml_convert.rb +54 -28
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +1 -26
- data/lib/isodoc/word_function/comments.rb +51 -30
- data/lib/isodoc/word_function/footnotes.rb +26 -30
- data/lib/isodoc/word_function/lists.rb +6 -8
- data/lib/isodoc/word_function/postprocess.rb +0 -17
- data/lib/isodoc/word_function/table.rb +1 -0
- data/lib/isodoc/xref/ol_type_provider.rb +16 -0
- data/lib/isodoc/xref/xref_counter.rb +2 -11
- metadata +6 -33
- data/lib/isodoc/html_function/comments.rb +0 -142
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aab1e285713806592294433b8009ca144fe193d9a0f43019448580c8fbe1dd9d
|
4
|
+
data.tar.gz: 58fc680a7a698f4f714a1c9577e7d0f48c382ccadc720b2c588fe870dc643273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fb892bcc672a38de31ab3d6fc9a3e3088d8c4ebba8c46010167a0646284747fca650de1c48c39b07b7177e7674494a05273d63204f4c0702b15a9dc09fe8c2b
|
7
|
+
data.tar.gz: ad8a5996bef31064b9b2fda5245f32caa2c16378468ba36bdf96933fe84c67ec6f0220907a1cde46e571d240dfc866d4363f9712b83c6544c923bea5087ae1a7
|
data/isodoc.gemspec
CHANGED
@@ -30,21 +30,19 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency "base64"
|
32
32
|
spec.add_dependency "bigdecimal"
|
33
|
-
spec.add_dependency "html2doc", "~> 1.
|
33
|
+
spec.add_dependency "html2doc", "~> 1.9.0"
|
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
37
|
spec.add_dependency "mn2pdf", ">= 2.13"
|
38
38
|
spec.add_dependency "mn-requirements", "~> 0.5.0"
|
39
39
|
|
40
|
-
spec.add_dependency "nokogiri", "<= 1.16.8"
|
41
40
|
spec.add_dependency "relaton-render", "~> 0.9.0"
|
42
41
|
spec.add_dependency "roman-numerals"
|
43
42
|
spec.add_dependency "rouge", "~> 4.0"
|
44
43
|
spec.add_dependency "thread_safe"
|
45
44
|
spec.add_dependency "twitter_cldr", ">= 6.6.0"
|
46
45
|
spec.add_dependency "uuidtools"
|
47
|
-
spec.add_dependency "lutaml-model", "~> 0.6.0"
|
48
46
|
|
49
47
|
spec.add_development_dependency "bigdecimal"
|
50
48
|
spec.add_development_dependency "debug"
|
@@ -59,5 +57,9 @@ Gem::Specification.new do |spec|
|
|
59
57
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
60
58
|
spec.add_development_dependency "timecop", "~> 0.9"
|
61
59
|
spec.add_development_dependency "xml-c14n"
|
60
|
+
# html2doc locks lutaml-model to ~ 0.7.0, but until testing of lutaml-model
|
61
|
+
# releases against dowmstream gems (notably Plurimath) is in place, locking at
|
62
|
+
# patch level
|
63
|
+
#spec.add_dependency "lutaml-model", "0.7.1"
|
62
64
|
# spec.metadata["rubygems_mfa_required"] = "true"
|
63
65
|
end
|
@@ -198,9 +198,9 @@ module IsoDoc
|
|
198
198
|
def fmt_fn_body_parse(node, out)
|
199
199
|
node.ancestors("table, figure").empty? and
|
200
200
|
node.at(ns(".//fmt-fn-label"))&.remove
|
201
|
-
|
202
|
-
|
203
|
-
out.send tag, id: "fn:#{
|
201
|
+
tag = node.parent.name == "fmt-footnote-container" ? "aside" : "div"
|
202
|
+
id = node["is_table"] ? node["reference"] : node["id"]
|
203
|
+
out.send tag, id: "fn:#{id}", class: "footnote" do |div|
|
204
204
|
node.children.each { |n| parse(n, div) }
|
205
205
|
end
|
206
206
|
end
|
@@ -16,7 +16,6 @@ module IsoDoc
|
|
16
16
|
def cleanup(docxml)
|
17
17
|
@i18n ||= i18n_init(@lang, @script, @locale)
|
18
18
|
comment_cleanup(docxml)
|
19
|
-
#footnote_cleanup(docxml)
|
20
19
|
inline_header_cleanup(docxml)
|
21
20
|
figure_cleanup(docxml)
|
22
21
|
table_cleanup(docxml)
|
@@ -58,15 +57,6 @@ module IsoDoc
|
|
58
57
|
docxml
|
59
58
|
end
|
60
59
|
|
61
|
-
# KILL
|
62
|
-
def footnote_cleanup(docxml)
|
63
|
-
docxml.xpath('//a[@class = "FootnoteRef"]/sup')
|
64
|
-
.each_with_index do |x, i|
|
65
|
-
x.content = (i + 1).to_s
|
66
|
-
end
|
67
|
-
docxml
|
68
|
-
end
|
69
|
-
|
70
60
|
def merge_fnref_into_fn_text(elem)
|
71
61
|
fn = elem.at('.//span[@class="TableFootnoteRef"]/..') or return
|
72
62
|
n = fn.next_element
|
@@ -32,6 +32,7 @@ module IsoDoc
|
|
32
32
|
def update_table_fn_body_ref(fnote, table, reference)
|
33
33
|
fnbody = table.at(ns(".//fmt-fn-body[@id = '#{fnote['target']}']")) or return
|
34
34
|
fnbody["reference"] = reference
|
35
|
+
fnbody["is_table"] = true
|
35
36
|
sup = fnbody.at(ns(".//fmt-fn-label/sup")) and sup.replace(sup.children)
|
36
37
|
fnbody.xpath(ns(".//fmt-fn-label")).each do |s|
|
37
38
|
s["class"] = "TableFootnoteRef"
|
@@ -41,17 +42,22 @@ module IsoDoc
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
-
|
45
|
+
def table_footnote?(node)
|
46
|
+
(@in_table || @in_figure) &&
|
46
47
|
!node.ancestors.map(&:name).include?("fmt-name")
|
48
|
+
end
|
47
49
|
|
48
|
-
|
50
|
+
def footnote_parse(node, out)
|
51
|
+
table_footnote?(node) and return table_footnote_parse(node, out)
|
52
|
+
fn = node["target"] # || UUIDTools::UUID.random_create.to_s
|
49
53
|
attrs = { class: "FootnoteRef", href: "#fn:#{fn}" }
|
50
54
|
f = node.at(ns("./fmt-fn-label"))
|
51
55
|
out.a **attrs do |a|
|
52
56
|
children_parse(f, a)
|
53
57
|
end
|
54
58
|
end
|
59
|
+
|
60
|
+
def fmt_review_body_parse(node, out); end
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
@@ -81,35 +81,41 @@ module IsoDoc
|
|
81
81
|
|
82
82
|
def stem_parse(node, out)
|
83
83
|
ret = node.at(ns("./semx[@element = 'stem']")) || node
|
84
|
-
ooml =
|
85
|
-
|
86
|
-
|
87
|
-
when "LaTeX" then latexmath_parse(ret)
|
88
|
-
else HTMLEntities.new.encode(ret.text)
|
89
|
-
end
|
90
|
-
out.span class: "stem" do |span|
|
84
|
+
ooml, text_only = stem_parse1(ret, node["type"])
|
85
|
+
klass = text_only ? {} : { class: "stem" }
|
86
|
+
out.span **klass do |span|
|
91
87
|
span.parent.add_child ooml
|
92
88
|
end
|
93
89
|
end
|
94
90
|
|
91
|
+
def stem_parse1(ret, type)
|
92
|
+
case type
|
93
|
+
when "AsciiMath" then asciimath_parse(ret)
|
94
|
+
when "MathML" then mathml_parse(ret)
|
95
|
+
when "LaTeX" then latexmath_parse(ret)
|
96
|
+
else [HTMLEntities.new.encode(ret.text),
|
97
|
+
/^[[0-9,.+-]]*$/.match?(ret.text)]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
95
101
|
MATHML = { "m" => "http://www.w3.org/1998/Math/MathML" }.freeze
|
96
102
|
|
97
103
|
def mathml_parse(node)
|
98
104
|
# node.xpath("./m:math", MATHML).map(&:to_xml).join
|
99
105
|
node.xpath(ns("./asciimath | ./latexmath")).each(&:remove)
|
100
106
|
node.xpath(ns("./br")).each { |e| e.namespace = nil }
|
101
|
-
node.elements
|
107
|
+
[node.children, node.elements.empty?]
|
102
108
|
end
|
103
109
|
|
104
110
|
def asciimath_parse(node)
|
105
111
|
a = node.at(ns("./asciimath"))&.text || node.text
|
106
|
-
"#{@openmathdelim}#{HTMLEntities.new.encode(a)}" \
|
107
|
-
"#{@closemathdelim}"
|
112
|
+
["#{@openmathdelim}#{HTMLEntities.new.encode(a)}" \
|
113
|
+
"#{@closemathdelim}", /^[[0-9,.+-]]*$/.match?(a)]
|
108
114
|
end
|
109
115
|
|
110
116
|
def latexmath_parse(node)
|
111
117
|
a = node.at(ns("./latexmath"))&.text || node.text
|
112
|
-
HTMLEntities.new.encode(a)
|
118
|
+
[HTMLEntities.new.encode(a), /^[[0-9,.+-]]*$/.match?(a)]
|
113
119
|
end
|
114
120
|
|
115
121
|
def image_title_parse(out, caption)
|
@@ -213,6 +219,7 @@ module IsoDoc
|
|
213
219
|
def svgmap_parse(node, out); end
|
214
220
|
def amend_parse(node, out); end
|
215
221
|
def semx_sourcecode_parse(node, out); end
|
222
|
+
def review_note_parse(node, out); end
|
216
223
|
|
217
224
|
def fmt_name_parse(node, out)
|
218
225
|
children_parse(node, out)
|
@@ -237,6 +244,14 @@ module IsoDoc
|
|
237
244
|
def fmt_footnote_container_parse(node, out)
|
238
245
|
children_parse(node, out)
|
239
246
|
end
|
247
|
+
|
248
|
+
def fmt_review_start_parse(node, out)
|
249
|
+
children_parse(node, out)
|
250
|
+
end
|
251
|
+
|
252
|
+
def fmt_review_end_parse(node, out)
|
253
|
+
children_parse(node, out)
|
254
|
+
end
|
240
255
|
end
|
241
256
|
end
|
242
257
|
end
|
@@ -37,8 +37,9 @@ module IsoDoc
|
|
37
37
|
# We don't really want users to specify type of ordered list;
|
38
38
|
# we will use a fixed hierarchy as practiced by ISO (though not
|
39
39
|
# fully spelled out): a) 1) i) A) I)
|
40
|
-
|
41
|
-
|
40
|
+
# Fallback, this is now being done in Presentation XML
|
41
|
+
# KILL
|
42
|
+
def ol_depthx(node)
|
42
43
|
depth = node.ancestors("ul, ol").size + 1
|
43
44
|
type = :alphabet
|
44
45
|
type = :arabic if [2, 7].include? depth
|
@@ -49,7 +50,8 @@ module IsoDoc
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def ol_attrs(node)
|
52
|
-
{ type: node["type"] ? ol_style(node["type"].to_sym) : ol_depth(node),
|
53
|
+
{ # type: node["type"] ? ol_style(node["type"].to_sym) : ol_depth(node),
|
54
|
+
type: ol_style(node["type"]&.to_sym),
|
53
55
|
id: node["id"], style: keep_style(node) }
|
54
56
|
end
|
55
57
|
|
@@ -62,16 +64,24 @@ module IsoDoc
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
67
|
+
def li_checkbox(node)
|
68
|
+
if node["uncheckedcheckbox"] == "true"
|
69
|
+
'<span class="zzMoveToFollowing">' \
|
70
|
+
'<input type="checkbox" checked="checked"/></span>'
|
71
|
+
elsif node["checkedcheckbox"] == "true"
|
72
|
+
'<span class="zzMoveToFollowing">' \
|
73
|
+
'<input type="checkbox"/></span>'
|
74
|
+
else ""
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
65
78
|
def li_parse(node, out)
|
66
79
|
out.li **attr_code(id: node["id"]) do |li|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
li << '<span class="zzMoveToFollowing">' \
|
72
|
-
'<input type="checkbox"/></span>'
|
80
|
+
li << li_checkbox(node)
|
81
|
+
node.children.each do |n|
|
82
|
+
n.name == "fmt-name" and next
|
83
|
+
parse(n, li)
|
73
84
|
end
|
74
|
-
node.children.each { |n| parse(n, li) }
|
75
85
|
end
|
76
86
|
end
|
77
87
|
|
@@ -106,6 +106,7 @@ module IsoDoc
|
|
106
106
|
|
107
107
|
def make_tr_attr(cell, row, totalrows, header, bordered)
|
108
108
|
style = cell.name == "th" ? "font-weight:bold;" : ""
|
109
|
+
cell["style"] and style += "#{cell['style']};"
|
109
110
|
cell["align"] and style += "text-align:#{cell['align']};"
|
110
111
|
cell["valign"] and style += "vertical-align:#{cell['valign']};"
|
111
112
|
rowmax = cell["rowspan"] ? row + cell["rowspan"].to_i - 1 : row
|
@@ -125,10 +126,14 @@ module IsoDoc
|
|
125
126
|
STYLE
|
126
127
|
end
|
127
128
|
|
128
|
-
def
|
129
|
+
def table_bordered?(node)
|
129
130
|
c = node.parent.parent["class"]
|
130
|
-
|
131
|
-
|
131
|
+
%w(modspec).include?(c) || !c
|
132
|
+
end
|
133
|
+
|
134
|
+
def tr_parse(node, out, ord, totalrows, header)
|
135
|
+
bordered = table_bordered?(node)
|
136
|
+
out.tr **attr_code(style: node["style"]) do |r|
|
132
137
|
node.elements.each do |td|
|
133
138
|
attrs = make_tr_attr(td, ord, totalrows - 1, header, bordered)
|
134
139
|
r.send td.name, **attr_code(attrs) do |entry|
|
@@ -54,7 +54,7 @@ module IsoDoc
|
|
54
54
|
boilerplate docxml, div3
|
55
55
|
content(div3, docxml, ns(self.class::TOP_ELEMENTS))
|
56
56
|
footnotes docxml, div3
|
57
|
-
comments div3
|
57
|
+
comments docxml, div3
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -234,6 +234,9 @@ module IsoDoc
|
|
234
234
|
when "fmt-fn-body" then fmt_fn_body_parse(node, out)
|
235
235
|
when "fmt-fn-label" then fmt_fn_label_parse(node, out)
|
236
236
|
when "fmt-footnote-container" then fmt_footnote_container_parse(node, out)
|
237
|
+
when "fmt-review-start" then fmt_review_start_parse(node, out)
|
238
|
+
when "fmt-review-end" then fmt_review_end_parse(node, out)
|
239
|
+
when "fmt-review-body" then fmt_review_body_parse(node, out)
|
237
240
|
else error_parse(node, out)
|
238
241
|
end
|
239
242
|
end
|
data/lib/isodoc/html_convert.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require_relative "html_function/comments"
|
2
1
|
require_relative "html_function/html"
|
3
2
|
require_relative "html_function/postprocess"
|
4
3
|
require_relative "html_function/form"
|
@@ -6,7 +5,6 @@ require_relative "html_function/form"
|
|
6
5
|
module IsoDoc
|
7
6
|
class HtmlConvert < ::IsoDoc::Convert
|
8
7
|
|
9
|
-
include HtmlFunction::Comments
|
10
8
|
include HtmlFunction::Form
|
11
9
|
include HtmlFunction::Html
|
12
10
|
|
@@ -28,11 +28,8 @@ module IsoDoc
|
|
28
28
|
xdup = xref.dup
|
29
29
|
xdup.remove["id"]
|
30
30
|
if footnote.elements.empty?
|
31
|
-
#footnote.children.empty? and footnote << " "
|
32
|
-
#footnote.children.first.previous = xdup
|
33
31
|
footnote.add_first_child xdup
|
34
32
|
else
|
35
|
-
#footnote.elements.first.children.first.previous = xdup
|
36
33
|
footnote.elements.first.add_first_child xdup
|
37
34
|
end
|
38
35
|
end
|
@@ -48,18 +45,6 @@ module IsoDoc
|
|
48
45
|
end
|
49
46
|
docxml
|
50
47
|
end
|
51
|
-
|
52
|
-
# KILL
|
53
|
-
def footnote_formatx(docxml)
|
54
|
-
docxml.xpath("//a[@class = 'FootnoteRef']/sup").each do |x|
|
55
|
-
footnote_reference_format(x)
|
56
|
-
end
|
57
|
-
docxml.xpath("//a[@class = 'TableFootnoteRef'] | "\
|
58
|
-
"//span[@class = 'TableFootnoteRef']").each do |x|
|
59
|
-
table_footnote_reference_format(x)
|
60
|
-
end
|
61
|
-
docxml
|
62
|
-
end
|
63
48
|
end
|
64
49
|
end
|
65
50
|
end
|
data/lib/isodoc/init.rb
CHANGED
@@ -20,6 +20,7 @@ module IsoDoc
|
|
20
20
|
|
21
21
|
def toc_init(docxml)
|
22
22
|
@doctype = docxml.at(ns("//bibdata/ext/doctype"))&.text
|
23
|
+
@subdoctype = docxml.at(ns("//bibdata/ext/subdoctype"))&.text
|
23
24
|
@xrefs.klass.doctype = @doctype
|
24
25
|
x = "//metanorma-extension/presentation-metadata" \
|
25
26
|
"[name[text() = 'TOC Heading Levels']]/value"
|
data/lib/isodoc/pdf_convert.rb
CHANGED
@@ -138,53 +138,6 @@ module IsoDoc
|
|
138
138
|
elem.next = ret
|
139
139
|
end
|
140
140
|
|
141
|
-
def dl(docxml)
|
142
|
-
docxml.xpath(ns("//dl")).each { |f| dl1(f) }
|
143
|
-
end
|
144
|
-
|
145
|
-
def dl1(elem)
|
146
|
-
elem.at(ns("./name")) and
|
147
|
-
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
148
|
-
end
|
149
|
-
|
150
|
-
def ul(docxml)
|
151
|
-
docxml.xpath(ns("//ul")).each { |f| ul1(f) }
|
152
|
-
end
|
153
|
-
|
154
|
-
def ul1(elem)
|
155
|
-
elem.at(ns("./name")) and
|
156
|
-
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
157
|
-
end
|
158
|
-
|
159
|
-
def ol(docxml)
|
160
|
-
docxml.xpath(ns("//ol")).each { |f| ol1(f) }
|
161
|
-
@xrefs.list_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
|
162
|
-
docxml.xpath(ns("//ol/li")).each { |f| ol_label(f) }
|
163
|
-
end
|
164
|
-
|
165
|
-
# We don't really want users to specify type of ordered list;
|
166
|
-
# we will use by default a fixed hierarchy as practiced by ISO (though not
|
167
|
-
# fully spelled out): a) 1) i) A) I)
|
168
|
-
def ol_depth(node)
|
169
|
-
depth = node.ancestors("ul, ol").size + 1
|
170
|
-
type = :alphabet
|
171
|
-
type = :arabic if [2, 7].include? depth
|
172
|
-
type = :roman if [3, 8].include? depth
|
173
|
-
type = :alphabet_upper if [4, 9].include? depth
|
174
|
-
type = :roman_upper if [5, 10].include? depth
|
175
|
-
type
|
176
|
-
end
|
177
|
-
|
178
|
-
def ol1(elem)
|
179
|
-
elem["type"] ||= ol_depth(elem).to_s
|
180
|
-
elem.at(ns("./name")) and
|
181
|
-
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
182
|
-
end
|
183
|
-
|
184
|
-
def ol_label(elem)
|
185
|
-
elem["label"] = @xrefs.anchor(elem["id"], :label, false)
|
186
|
-
end
|
187
|
-
|
188
141
|
def source(docxml)
|
189
142
|
docxml.xpath(ns("//source/modification")).each do |f|
|
190
143
|
source_modification(f)
|
@@ -125,10 +125,10 @@ module IsoDoc
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
def figure_fn_to_dt_dd(
|
129
|
-
label =
|
128
|
+
def figure_fn_to_dt_dd(fnote)
|
129
|
+
label = fnote.at(ns(".//fmt-fn-label")).remove
|
130
130
|
label.at(ns(".//span[@class = 'fmt-caption-delim']"))&.remove
|
131
|
-
[label,
|
131
|
+
[label, fnote]
|
132
132
|
end
|
133
133
|
|
134
134
|
def figure_key_insert_pt(elem)
|
@@ -136,5 +136,74 @@ module IsoDoc
|
|
136
136
|
elem.at(ns(".//dl"))&.children&.first ||
|
137
137
|
elem.add_child("<dl> </dl>").first.children.first
|
138
138
|
end
|
139
|
+
|
140
|
+
def comments(docxml)
|
141
|
+
docxml.xpath(ns("//review")).each do |c|
|
142
|
+
c1 = comment_body(c)
|
143
|
+
comment_bookmarks(c1)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def comment_body(elem)
|
148
|
+
elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
149
|
+
c1 = elem.after("<fmt-review-body/>").next
|
150
|
+
elem.attributes.each_key { |k| c1[k] = elem[k] }
|
151
|
+
c1["id"] = "_#{UUIDTools::UUID.random_create}"
|
152
|
+
c1 << semx_fmt_dup(elem)
|
153
|
+
end
|
154
|
+
|
155
|
+
def comment_bookmarks(elem)
|
156
|
+
from, to = comment_bookmarks_locate(elem)
|
157
|
+
new_from = comment_bookmark_start(from, elem)
|
158
|
+
new_to = comment_bookmark_end(to, elem)
|
159
|
+
elem["from"] = new_from["id"]
|
160
|
+
elem["to"] = new_to["id"]
|
161
|
+
end
|
162
|
+
|
163
|
+
# Do not insert a comment bookmark inside another comment bookmark
|
164
|
+
AVOID_COMMENT_BOOKMARKS = <<~XPATH.freeze
|
165
|
+
[not(ancestor::xmlns:fmt-review-start)][not(ancestor::xmlns:fmt-review-end)]
|
166
|
+
XPATH
|
167
|
+
|
168
|
+
def comment_bookmarks_locate(elem)
|
169
|
+
from = elem.document.at("//*[@id = '#{elem['from']}']")
|
170
|
+
f = from.at(".//text()#{AVOID_COMMENT_BOOKMARKS}") and from = f
|
171
|
+
to = elem.document.at("//*[@id = '#{elem['to']}']") || from
|
172
|
+
f = to.at(".//text()[last()]#{AVOID_COMMENT_BOOKMARKS}") and to = f
|
173
|
+
[from, to]
|
174
|
+
end
|
175
|
+
|
176
|
+
def comment_to_bookmark_attrs(elem, bookmark, start: true)
|
177
|
+
bookmark["target"] = elem["id"]
|
178
|
+
if start then bookmark["end"] = elem["to"]
|
179
|
+
else bookmark["start"] = elem["from"] end
|
180
|
+
%w(author date).each { |k| bookmark[k] = elem[k] }
|
181
|
+
end
|
182
|
+
|
183
|
+
def comment_bookmark_start(from, elem)
|
184
|
+
ret = from.before("<fmt-review-start/>").previous
|
185
|
+
ret["id"] = "_#{UUIDTools::UUID.random_create}"
|
186
|
+
ret["source"] = elem["from"]
|
187
|
+
comment_to_bookmark_attrs(elem, ret, start: true)
|
188
|
+
ret << comment_bookmark_start_label(elem)
|
189
|
+
ret
|
190
|
+
end
|
191
|
+
|
192
|
+
def comment_bookmark_end(to, elem)
|
193
|
+
ret = to.after("<fmt-review-end/>").next
|
194
|
+
ret["id"] = "_#{UUIDTools::UUID.random_create}"
|
195
|
+
ret["source"] = elem["to"]
|
196
|
+
comment_to_bookmark_attrs(elem, ret, start: false)
|
197
|
+
ret << comment_bookmark_end_label(elem)
|
198
|
+
ret
|
199
|
+
end
|
200
|
+
|
201
|
+
def comment_bookmark_start_label(_elem)
|
202
|
+
""
|
203
|
+
end
|
204
|
+
|
205
|
+
def comment_bookmark_end_label(_elem)
|
206
|
+
""
|
207
|
+
end
|
139
208
|
end
|
140
209
|
end
|
@@ -10,15 +10,19 @@ module IsoDoc
|
|
10
10
|
docxml.xpath(ns("//figure")).each { |f| figure1(f) }
|
11
11
|
docxml.xpath(ns("//svgmap")).each { |s| svgmap_extract(s) }
|
12
12
|
imageconvert(docxml)
|
13
|
+
docxml.xpath("//m:svg", SVG).each { |f| svg_scale(f) }
|
13
14
|
end
|
14
15
|
|
15
16
|
def svg_wrap(elem)
|
16
|
-
|
17
|
-
|
17
|
+
elem.parent.name == "image" and return
|
18
18
|
elem.wrap("<image src='' mimetype='image/svg+xml' height='auto' " \
|
19
19
|
"width='auto'></image>")
|
20
20
|
end
|
21
21
|
|
22
|
+
def svg_scale(elem)
|
23
|
+
elem["preserveaspectratio"] = "xMidYMin slice"
|
24
|
+
end
|
25
|
+
|
22
26
|
def svgmap_extract(elem)
|
23
27
|
if elem.at(ns("./figure"))# then elem.replace(f)
|
24
28
|
n = semx_fmt_dup(elem)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
def dl(docxml)
|
4
|
+
docxml.xpath(ns("//dl")).each { |f| dl1(f) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def dl1(elem)
|
8
|
+
elem.at(ns("./name")) and
|
9
|
+
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
10
|
+
end
|
11
|
+
|
12
|
+
def ul(docxml)
|
13
|
+
docxml.xpath(ns("//ul")).each { |f| ul1(f) }
|
14
|
+
docxml.xpath(ns("//ul/li")).each { |f| ul_label(f) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def ul1(elem)
|
18
|
+
elem.at(ns("./name")) and
|
19
|
+
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
20
|
+
end
|
21
|
+
|
22
|
+
def ol(docxml)
|
23
|
+
docxml.xpath(ns("//ol")).each { |f| ol1(f) }
|
24
|
+
@xrefs.list_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
|
25
|
+
docxml.xpath(ns("//ol/li")).each { |f| ol_label(f) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def ol_depth(node)
|
29
|
+
depth = node.ancestors("ul, ol").size + 1
|
30
|
+
@counter.ol_type(node, depth) # defined in Xref::Counter
|
31
|
+
end
|
32
|
+
|
33
|
+
def ol1(elem)
|
34
|
+
elem["type"] ||= ol_depth(elem).to_s # feeds ol_label_format
|
35
|
+
elem.at(ns("./name")) and
|
36
|
+
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
37
|
+
end
|
38
|
+
|
39
|
+
def ol_label(elem)
|
40
|
+
val = @xrefs.anchor(elem["id"], :label, false)
|
41
|
+
semx = "<semx element='autonum' source='#{elem['id']}'>#{val}</semx>"
|
42
|
+
lbl = "<fmt-name>#{ol_label_format(semx, elem)}</fmt-name>"
|
43
|
+
elem.add_first_child(lbl)
|
44
|
+
end
|
45
|
+
|
46
|
+
def ol_label_template(_elem)
|
47
|
+
{
|
48
|
+
alphabet: %{%<span class="fmt-label-delim">)</span>},
|
49
|
+
alphabet_upper: %{%<span class="fmt-label-delim">.</span>},
|
50
|
+
roman: %{%<span class="fmt-label-delim">)</span>},
|
51
|
+
roman_upper: %{%<span class="fmt-label-delim">.</span>},
|
52
|
+
arabic: %{%<span class="fmt-label-delim">)</span>},
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def ol_label_format(semx, elem)
|
57
|
+
template = ol_label_template(elem)[elem.parent["type"].to_sym]
|
58
|
+
template.sub("%", semx)
|
59
|
+
end
|
60
|
+
|
61
|
+
def ul_label_list(_elem)
|
62
|
+
%w(—)
|
63
|
+
end
|
64
|
+
|
65
|
+
def ul_label(elem)
|
66
|
+
val = ul_label_value(elem)
|
67
|
+
semx = "<semx element='autonum' source='#{elem['id']}'>#{val}</semx>"
|
68
|
+
lbl = "<fmt-name>#{semx}</fmt-name>"
|
69
|
+
elem.add_first_child(lbl)
|
70
|
+
end
|
71
|
+
|
72
|
+
def ul_label_value(elem)
|
73
|
+
depth = elem.ancestors("ul, ol").size
|
74
|
+
val = ul_label_list(elem)
|
75
|
+
val[(depth - 1) % val.size]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|