isodoc 1.7.3 → 1.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +7 -4
- data/lib/isodoc/class_utils.rb +2 -2
- data/lib/isodoc/convert.rb +2 -0
- data/lib/isodoc/function/blocks_example_note.rb +85 -79
- data/lib/isodoc/function/cleanup.rb +181 -175
- data/lib/isodoc/function/inline.rb +110 -108
- data/lib/isodoc/function/inline_simple.rb +55 -55
- data/lib/isodoc/function/lists.rb +75 -71
- data/lib/isodoc/function/references.rb +165 -160
- data/lib/isodoc/function/section.rb +140 -190
- data/lib/isodoc/function/section_titles.rb +82 -0
- data/lib/isodoc/function/table.rb +90 -87
- data/lib/isodoc/function/terms.rb +58 -56
- data/lib/isodoc/function/to_word_html.rb +3 -1
- data/lib/isodoc/function/utils.rb +34 -14
- data/lib/isodoc/html_function/comments.rb +107 -111
- data/lib/isodoc/html_function/footnotes.rb +68 -67
- data/lib/isodoc/html_function/html.rb +113 -103
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
- data/lib/isodoc/presentation_function/block.rb +73 -78
- data/lib/isodoc/presentation_function/concept.rb +68 -0
- data/lib/isodoc/presentation_function/image.rb +112 -0
- data/lib/isodoc/presentation_function/inline.rb +6 -39
- data/lib/isodoc/presentation_function/math.rb +9 -0
- data/lib/isodoc/presentation_function/section.rb +12 -1
- data/lib/isodoc/presentation_xml_convert.rb +3 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +176 -174
- data/lib/isodoc/word_function/comments.rb +117 -112
- data/lib/isodoc/word_function/footnotes.rb +88 -86
- data/lib/isodoc/word_function/inline.rb +42 -67
- data/lib/isodoc/word_function/postprocess_cover.rb +121 -110
- data/lib/isodoc/xref/xref_gen.rb +153 -150
- data/lib/isodoc/xslfo_convert.rb +2 -2
- data/lib/isodoc.rb +1 -1
- data/spec/assets/odf.svg +1 -4
- data/spec/isodoc/blocks_spec.rb +187 -32
- data/spec/isodoc/inline_spec.rb +300 -116
- data/spec/isodoc/postproc_spec.rb +38 -0
- data/spec/isodoc/presentation_xml_spec.rb +144 -0
- data/spec/isodoc/section_spec.rb +764 -0
- data/spec/isodoc/terms_spec.rb +116 -0
- metadata +63 -18
@@ -1,226 +1,232 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module IsoDoc
|
2
|
+
module Function
|
3
|
+
module Cleanup
|
4
|
+
def textcleanup(docxml)
|
5
|
+
termref_cleanup(passthrough_cleanup(docxml))
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
def termref_cleanup(docxml)
|
9
|
+
docxml
|
10
|
+
.gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/,
|
11
|
+
l10n(", #{@i18n.modified} [/TERMREF]"))
|
12
|
+
.gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ")
|
13
|
+
.gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source}: "))
|
14
|
+
.gsub(%r{\s*\[/TERMREF\]\s*}, l10n("]"))
|
15
|
+
.gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} — "))
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def passthrough_cleanup(docxml)
|
19
|
+
docxml.split(%r{(<passthrough>|</passthrough>)}).each_slice(4)
|
20
|
+
.map do |a|
|
21
|
+
a.size > 2 and a[2] = HTMLEntities.new.decode(a[2])
|
22
|
+
[a[0], a[2]]
|
23
|
+
end.join
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
def cleanup(docxml)
|
27
|
+
@i18n ||= i18n_init(@lang, @script)
|
28
|
+
comment_cleanup(docxml)
|
29
|
+
footnote_cleanup(docxml)
|
30
|
+
inline_header_cleanup(docxml)
|
31
|
+
figure_cleanup(docxml)
|
32
|
+
table_cleanup(docxml)
|
33
|
+
symbols_cleanup(docxml)
|
34
|
+
example_cleanup(docxml)
|
35
|
+
admonition_cleanup(docxml)
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
def table_long_strings_cleanup(docxml)
|
39
|
+
return unless @break_up_urls_in_tables == true
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
docxml.xpath("//td | //th").each do |d|
|
42
|
+
d.traverse do |n|
|
43
|
+
next unless n.text?
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
n.replace(HTMLEntities.new.encode(
|
46
|
+
break_up_long_strings(n.text),
|
47
|
+
))
|
48
|
+
end
|
46
49
|
end
|
47
50
|
end
|
48
|
-
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
+
def break_up_long_strings(text)
|
53
|
+
return text if /^\s*$/.match?(text)
|
54
|
+
|
55
|
+
text.split(/(?=\s)/).map do |w|
|
56
|
+
if /^\s*$/.match(text) || (w.size < 30) then w
|
57
|
+
else
|
58
|
+
w.scan(/.{,30}/).map do |w1|
|
59
|
+
w1.size < 30 ? w1 : break_up_long_strings1(w1)
|
60
|
+
end.join
|
61
|
+
end
|
62
|
+
end.join
|
63
|
+
end
|
52
64
|
|
53
|
-
text
|
54
|
-
|
65
|
+
def break_up_long_strings1(text)
|
66
|
+
s = text.split(%r{(?<=[,.?+;/=])})
|
67
|
+
if s.size == 1 then "#{text} "
|
55
68
|
else
|
56
|
-
|
57
|
-
|
58
|
-
end.join
|
69
|
+
s[-1] = " #{s[-1]}"
|
70
|
+
s.join
|
59
71
|
end
|
60
|
-
end.join
|
61
|
-
end
|
62
|
-
|
63
|
-
def break_up_long_strings1(text)
|
64
|
-
s = text.split(%r{(?<=[,.?+;/=])})
|
65
|
-
if s.size == 1 then "#{text} "
|
66
|
-
else
|
67
|
-
s[-1] = " #{s[-1]}"
|
68
|
-
s.join
|
69
72
|
end
|
70
|
-
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
def admonition_cleanup(docxml)
|
75
|
+
docxml.xpath("//div[@class = 'Admonition'][title]").each do |d|
|
76
|
+
title = d.at("./title")
|
77
|
+
n = title.next_element
|
78
|
+
n&.children&.first
|
79
|
+
&.add_previous_sibling("#{title.remove.text}—")
|
80
|
+
end
|
81
|
+
docxml
|
77
82
|
end
|
78
|
-
docxml
|
79
|
-
end
|
80
83
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
def example_cleanup(docxml)
|
85
|
+
docxml.xpath("//table[@class = 'example']//p[not(@class)]").each do |p|
|
86
|
+
p["class"] = "example"
|
87
|
+
end
|
88
|
+
docxml
|
84
89
|
end
|
85
|
-
docxml
|
86
|
-
end
|
87
90
|
|
88
|
-
|
89
|
-
dl = elem.at(".//dl")
|
90
|
-
if dl.nil?
|
91
|
-
elem.add_child("<p><b>#{@i18n.key}</b></p><dl></dl>")
|
91
|
+
def figure_get_or_make_dl(elem)
|
92
92
|
dl = elem.at(".//dl")
|
93
|
+
if dl.nil?
|
94
|
+
elem.add_child("<p><b>#{@i18n.key}</b></p><dl></dl>")
|
95
|
+
dl = elem.at(".//dl")
|
96
|
+
end
|
97
|
+
dl
|
93
98
|
end
|
94
|
-
dl
|
95
|
-
end
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
100
|
+
FIGURE_WITH_FOOTNOTES =
|
101
|
+
"//div[@class = 'figure'][descendant::aside]"\
|
102
|
+
"[not(descendant::div[@class = 'figure'])]".freeze
|
103
|
+
|
104
|
+
def figure_aside_process(elem, aside, key)
|
105
|
+
# get rid of footnote link, it is in diagram
|
106
|
+
elem&.at("./a[@class='TableFootnoteRef']")&.remove
|
107
|
+
fnref = elem.at(".//span[@class='TableFootnoteRef']/..")
|
108
|
+
dt = key.add_child("<dt></dt>").first
|
109
|
+
dd = key.add_child("<dd></dd>").first
|
110
|
+
fnref.parent = dt
|
111
|
+
aside.xpath(".//p").each do |a|
|
112
|
+
a.delete("class")
|
113
|
+
a.parent = dd
|
114
|
+
end
|
111
115
|
end
|
112
|
-
end
|
113
116
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
# move footnotes into key, and get rid of footnote reference
|
118
|
+
# since it is in diagram
|
119
|
+
def figure_cleanup(docxml)
|
120
|
+
docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|
|
121
|
+
next unless f.at(".//aside[not(ancestor::p[@class = 'FigureTitle'])]")
|
119
122
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
+
key = figure_get_or_make_dl(f)
|
124
|
+
f.xpath(".//aside").each do |aside|
|
125
|
+
figure_aside_process(f, aside, key)
|
126
|
+
end
|
123
127
|
end
|
128
|
+
docxml
|
124
129
|
end
|
125
|
-
docxml
|
126
|
-
end
|
127
130
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
def inline_header_cleanup(docxml)
|
132
|
+
docxml.xpath('//span[@class="zzMoveToFollowing"]').each do |x|
|
133
|
+
x.delete("class")
|
134
|
+
n = x.next_element
|
135
|
+
if n.nil?
|
136
|
+
x.name = "p"
|
137
|
+
else
|
138
|
+
n.children.first.previous = x.remove
|
139
|
+
end
|
136
140
|
end
|
141
|
+
docxml
|
137
142
|
end
|
138
|
-
docxml
|
139
|
-
end
|
140
143
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
+
def footnote_cleanup(docxml)
|
145
|
+
docxml.xpath('//a[@class = "FootnoteRef"]/sup')
|
146
|
+
.each_with_index do |x, i|
|
147
|
+
x.content = (i + 1).to_s
|
148
|
+
end
|
149
|
+
docxml
|
144
150
|
end
|
145
|
-
docxml
|
146
|
-
end
|
147
151
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
152
|
+
def merge_fnref_into_fn_text(elem)
|
153
|
+
fn = elem.at('.//span[@class="TableFootnoteRef"]/..')
|
154
|
+
n = fn.next_element
|
155
|
+
n&.children&.first&.add_previous_sibling(fn.remove)
|
156
|
+
end
|
153
157
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
158
|
+
# preempt html2doc putting MsoNormal under TableFootnote class
|
159
|
+
def table_footnote_cleanup(docxml)
|
160
|
+
docxml.xpath("//table[descendant::aside]").each do |t|
|
161
|
+
t.xpath(".//aside").each do |a|
|
162
|
+
merge_fnref_into_fn_text(a)
|
163
|
+
a.name = "div"
|
164
|
+
a["class"] = "TableFootnote"
|
165
|
+
t << a.remove
|
166
|
+
end
|
167
|
+
end
|
168
|
+
docxml.xpath("//p[not(self::*[@class])]"\
|
169
|
+
"[ancestor::*[@class = 'TableFootnote']]").each do |p|
|
170
|
+
p["class"] = "TableFootnote"
|
162
171
|
end
|
163
172
|
end
|
164
|
-
docxml.xpath("//p[not(self::*[@class])]"\
|
165
|
-
"[ancestor::*[@class = 'TableFootnote']]").each do |p|
|
166
|
-
p["class"] = "TableFootnote"
|
167
|
-
end
|
168
|
-
end
|
169
173
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
+
def remove_bottom_border(cell)
|
175
|
+
cell["style"] =
|
176
|
+
cell["style"].gsub(/border-bottom:[^;]+;/, "border-bottom:0pt;")
|
177
|
+
end
|
174
178
|
|
175
|
-
|
176
|
-
tfoot = table.at(".//tfoot")
|
177
|
-
if tfoot.nil?
|
178
|
-
table.add_child("<tfoot></tfoot>")
|
179
|
+
def table_get_or_make_tfoot(table)
|
179
180
|
tfoot = table.at(".//tfoot")
|
180
|
-
|
181
|
-
|
181
|
+
if tfoot.nil?
|
182
|
+
table.add_child("<tfoot></tfoot>")
|
183
|
+
tfoot = table.at(".//tfoot")
|
184
|
+
else
|
185
|
+
tfoot.xpath(".//td | .//th").each { |td| remove_bottom_border(td) }
|
186
|
+
end
|
187
|
+
tfoot
|
182
188
|
end
|
183
|
-
tfoot
|
184
|
-
end
|
185
189
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
190
|
+
def new_fullcolspan_row(table, tfoot)
|
191
|
+
# how many columns in the table?
|
192
|
+
cols = 0
|
193
|
+
table.at(".//tr").xpath("./td | ./th").each do |td|
|
194
|
+
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
195
|
+
end
|
196
|
+
style =
|
197
|
+
%{border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;}
|
198
|
+
tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
|
199
|
+
tfoot.xpath(".//td").last
|
191
200
|
end
|
192
|
-
style =
|
193
|
-
%{border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;}
|
194
|
-
tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
|
195
|
-
tfoot.xpath(".//td").last
|
196
|
-
end
|
197
201
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
202
|
+
def table_note_cleanup(docxml)
|
203
|
+
docxml.xpath("//table[div[@class = 'Note' or "\
|
204
|
+
"@class = 'TableFootnote']]").each do |t|
|
205
|
+
tfoot = table_get_or_make_tfoot(t)
|
206
|
+
insert_here = new_fullcolspan_row(t, tfoot)
|
207
|
+
t.xpath("div[@class = 'Note' or @class = 'TableFootnote']")
|
208
|
+
.each do |d|
|
209
|
+
d.parent = insert_here
|
210
|
+
end
|
205
211
|
end
|
206
212
|
end
|
207
|
-
end
|
208
213
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
214
|
+
def table_cleanup(docxml)
|
215
|
+
table_footnote_cleanup(docxml)
|
216
|
+
table_note_cleanup(docxml)
|
217
|
+
table_long_strings_cleanup(docxml)
|
218
|
+
docxml
|
219
|
+
end
|
215
220
|
|
216
|
-
|
221
|
+
def symbols_cleanup(docxml); end
|
217
222
|
|
218
|
-
|
219
|
-
|
220
|
-
|
223
|
+
def table_footnote_reference_format(link)
|
224
|
+
link
|
225
|
+
end
|
221
226
|
|
222
|
-
|
223
|
-
|
227
|
+
def footnote_reference_format(link)
|
228
|
+
link
|
229
|
+
end
|
224
230
|
end
|
225
231
|
end
|
226
232
|
end
|
@@ -1,147 +1,149 @@
|
|
1
1
|
require_relative "inline_simple"
|
2
2
|
|
3
|
-
module IsoDoc
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
module IsoDoc
|
4
|
+
module Function
|
5
|
+
module Inline
|
6
|
+
def link_parse(node, out)
|
7
|
+
url = node["target"]
|
8
|
+
node["updatetype"] == "true" and url = suffix_url(url)
|
9
|
+
out.a **attr_code(href: url, title: node["alt"]) do |l|
|
10
|
+
if node.text.empty?
|
11
|
+
l << node["target"].sub(/^mailto:/, "")
|
12
|
+
else node.children.each { |n| parse(n, l) }
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
|
-
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def callout_parse(node, out)
|
18
|
+
out << " <#{node.text}>"
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
def no_locality_parse(node, out)
|
22
|
+
node.children.each do |n|
|
23
|
+
parse(n, out) unless %w{locality localityStack}.include? n.name
|
24
|
+
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
def xref_parse(node, out)
|
28
|
+
target = if /#/.match?(node["target"])
|
29
|
+
node["target"].sub(/#/, ".html#")
|
30
|
+
else
|
31
|
+
"##{node['target']}"
|
32
|
+
end
|
33
|
+
out.a(**{ href: target }) { |l| no_locality_parse(node, l) }
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def suffix_url(url)
|
37
|
+
return url if %r{^https?://}.match?(url)
|
38
|
+
return url unless File.extname(url).empty?
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
url.sub(/#{File.extname(url)}$/, ".html")
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
def eref_target(node)
|
44
|
+
href = "##{node['bibitemid']}"
|
45
|
+
url = node.at(ns("//bibitem[@id = '#{node['bibitemid']}']/"\
|
46
|
+
"uri[@type = 'citation']"))
|
47
|
+
return href unless url
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
href = suffix_url(url.text)
|
50
|
+
anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text&.strip
|
51
|
+
anchor and href += "##{anchor}"
|
52
|
+
href
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
def eref_parse(node, out)
|
56
|
+
href = eref_target(node)
|
57
|
+
if node["type"] == "footnote"
|
58
|
+
out.sup do |s|
|
59
|
+
s.a(**{ href: href }) { |l| no_locality_parse(node, l) }
|
60
|
+
end
|
61
|
+
else
|
62
|
+
out.a(**{ href: href }) { |l| no_locality_parse(node, l) }
|
59
63
|
end
|
60
|
-
else
|
61
|
-
out.a(**{ "href": href }) { |l| no_locality_parse(node, l) }
|
62
64
|
end
|
63
|
-
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
def origin_parse(node, out)
|
67
|
+
if t = node.at(ns("./termref"))
|
68
|
+
termrefelem_parse(t, out)
|
69
|
+
else
|
70
|
+
eref_parse(node, out)
|
71
|
+
end
|
70
72
|
end
|
71
|
-
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
def termrefelem_parse(node, out)
|
75
|
+
if node.text.strip.empty?
|
76
|
+
out << "Termbase #{node['base']}, term ID #{node['target']}"
|
77
|
+
else
|
78
|
+
node.children.each { |n| parse(n, out) }
|
79
|
+
end
|
78
80
|
end
|
79
|
-
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
def stem_parse(node, out)
|
83
|
+
ooml = case node["type"]
|
84
|
+
when "AsciiMath"
|
85
|
+
"#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}"\
|
85
86
|
"#{@closemathdelim}"
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
when "MathML" then node.first_element_child.to_s
|
88
|
+
else HTMLEntities.new.encode(node.text)
|
89
|
+
end
|
90
|
+
out.span **{ class: "stem" } do |span|
|
91
|
+
span.parent.add_child ooml
|
92
|
+
end
|
91
93
|
end
|
92
|
-
end
|
93
94
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
def image_title_parse(out, caption)
|
96
|
+
unless caption.nil?
|
97
|
+
out.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
|
98
|
+
p.b { |b| b << caption.to_s }
|
99
|
+
end
|
98
100
|
end
|
99
101
|
end
|
100
|
-
end
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
103
|
+
def image_parse(node, out, caption)
|
104
|
+
attrs = { src: node["src"],
|
105
|
+
height: node["height"] || "auto",
|
106
|
+
width: node["width"] || "auto",
|
107
|
+
title: node["title"],
|
108
|
+
alt: node["alt"] }
|
109
|
+
out.img **attr_code(attrs)
|
110
|
+
image_title_parse(out, caption)
|
111
|
+
end
|
111
112
|
|
112
|
-
|
113
|
-
|
114
|
-
|
113
|
+
def smallcap_parse(node, xml)
|
114
|
+
xml.span **{ style: "font-variant:small-caps;" } do |s|
|
115
|
+
node.children.each { |n| parse(n, s) }
|
116
|
+
end
|
115
117
|
end
|
116
|
-
end
|
117
118
|
|
118
|
-
|
119
|
-
|
119
|
+
def text_parse(node, out)
|
120
|
+
return if node.nil? || node.text.nil?
|
120
121
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
text = node.to_s
|
123
|
+
if in_sourcecode
|
124
|
+
text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/> ")
|
125
|
+
.gsub(/ (?= )/, " ")
|
126
|
+
end
|
127
|
+
out << text
|
125
128
|
end
|
126
|
-
out << text
|
127
|
-
end
|
128
129
|
|
129
|
-
|
130
|
-
|
131
|
-
|
130
|
+
def add_parse(node, out)
|
131
|
+
out.span **{ class: "addition" } do |e|
|
132
|
+
node.children.each { |n| parse(n, e) }
|
133
|
+
end
|
132
134
|
end
|
133
|
-
end
|
134
135
|
|
135
|
-
|
136
|
-
|
137
|
-
|
136
|
+
def del_parse(node, out)
|
137
|
+
out.span **{ class: "deletion" } do |e|
|
138
|
+
node.children.each { |n| parse(n, e) }
|
139
|
+
end
|
138
140
|
end
|
139
|
-
end
|
140
141
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
def error_parse(node, out)
|
143
|
+
text = node.to_xml.gsub(/</, "<").gsub(/>/, ">")
|
144
|
+
out.para do |p|
|
145
|
+
p.b(**{ role: "strong" }) { |e| e << text }
|
146
|
+
end
|
145
147
|
end
|
146
148
|
end
|
147
149
|
end
|