isodoc 1.7.3 → 1.7.6
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 +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,146 +1,142 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module IsoDoc
|
2
|
+
module HtmlFunction
|
3
|
+
module Comments
|
4
|
+
def in_comment
|
5
|
+
@in_comment
|
6
|
+
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def comments(div)
|
9
|
+
# return if @comments.empty?
|
10
|
+
# div.div **{ style: "mso-element:comment-list" } do |div1|
|
11
|
+
# @comments.each { |fn| div1.parent << fn }
|
12
|
+
# end
|
13
13
|
end
|
14
|
-
=end
|
15
|
-
end
|
16
14
|
|
17
|
-
|
18
|
-
=
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
=end
|
25
|
-
end
|
15
|
+
def review_note_parse(node, out)
|
16
|
+
# fn = @comments.length + 1
|
17
|
+
# make_comment_link(out, fn, node)
|
18
|
+
# @in_comment = true
|
19
|
+
# @comments << make_comment_text(node, fn)
|
20
|
+
# @in_comment = false
|
21
|
+
end
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
def comment_link_attrs(fnote, node)
|
24
|
+
{ style: "MsoCommentReference", target: fnote,
|
25
|
+
class: "commentLink", from: node["from"],
|
26
|
+
to: node["to"] }
|
27
|
+
end
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
# add in from and to links to move the comment into place
|
30
|
+
def make_comment_link(out, fnote, node)
|
31
|
+
out.span(**comment_link_attrs(fnote, node)) do |s1|
|
36
32
|
s1.a **{ style: "mso-comment-reference:SMC_#{fnote};"\
|
37
|
-
|
33
|
+
"mso-comment-date:#{node['date'].gsub(/[-:Z]/,
|
34
|
+
'')}" }
|
38
35
|
end
|
39
|
-
|
36
|
+
end
|
40
37
|
|
41
|
-
|
42
|
-
|
38
|
+
def make_comment_target(out)
|
39
|
+
out.span **{ style: "MsoCommentReference" } do |s1|
|
43
40
|
s1.span **{ style: "mso-special-character:comment" }
|
44
41
|
end
|
45
|
-
|
42
|
+
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
44
|
+
def make_comment_text(node, fnote)
|
45
|
+
noko do |xml|
|
46
|
+
xml.div **{ style: "mso-element:comment", id: fnote } do |div|
|
47
|
+
div.span **{ style: %{mso-comment-author:"#{node['reviewer']}"} }
|
48
|
+
make_comment_target(div)
|
49
|
+
node.children.each { |n| parse(n, div) }
|
50
|
+
end
|
51
|
+
end.join("\n")
|
52
|
+
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
=end
|
63
|
-
end
|
54
|
+
def comment_cleanup(docxml)
|
55
|
+
# move_comment_link_to_from(docxml)
|
56
|
+
# reorder_comments_by_comment_link(docxml)
|
57
|
+
# embed_comment_in_comment_list(docxml)
|
58
|
+
end
|
64
59
|
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
COMMENT_IN_COMMENT_LIST =
|
61
|
+
'//div[@style="mso-element:comment-list"]//'\
|
62
|
+
'span[@style="MsoCommentReference"]'.freeze
|
68
63
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
64
|
+
def embed_comment_in_comment_list(docxml)
|
65
|
+
docxml.xpath(COMMENT_IN_COMMENT_LIST).each do |x|
|
66
|
+
n = x.next_element
|
67
|
+
n&.children&.first&.add_previous_sibling(x.remove)
|
68
|
+
end
|
69
|
+
docxml
|
73
70
|
end
|
74
|
-
docxml
|
75
|
-
end
|
76
71
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
72
|
+
def move_comment_link_to_from1(x, fromlink)
|
73
|
+
x.remove
|
74
|
+
link = x.at(".//a")
|
75
|
+
fromlink.replace(x)
|
76
|
+
link.children = fromlink
|
77
|
+
end
|
83
78
|
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
def comment_attributes(docxml, x)
|
80
|
+
fromlink = docxml.at("//*[@id='#{x['from']}']")
|
81
|
+
return(nil) if fromlink.nil?
|
87
82
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
83
|
+
tolink = docxml.at("//*[@id='#{x['to']}']") || fromlink
|
84
|
+
target = docxml.at("//*[@id='#{x['target']}']")
|
85
|
+
{ from: fromlink, to: tolink, target: target }
|
86
|
+
end
|
92
87
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
88
|
+
def wrap_comment_cont(from, target)
|
89
|
+
s = from.replace("<span style='mso-comment-continuation:#{target}'>")
|
90
|
+
s.first.children = from
|
91
|
+
end
|
97
92
|
|
98
|
-
|
99
|
-
|
100
|
-
|
93
|
+
def skip_comment_wrap(from)
|
94
|
+
from["style"] != "mso-special-character:comment"
|
95
|
+
end
|
101
96
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
(from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
|
107
|
-
while !incl_to.nil? && !from.nil? && skip_comment_wrap(from)
|
97
|
+
def insert_comment_cont(from, upto, target)
|
98
|
+
# includes_to = from.at(".//*[@id='#{upto}']")
|
99
|
+
while !from.nil? && from["id"] != upto
|
100
|
+
following = from.xpath("./following::*")
|
108
101
|
(from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
|
102
|
+
while !incl_to.nil? && !from.nil? && skip_comment_wrap(from)
|
103
|
+
(from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
|
104
|
+
end
|
105
|
+
wrap_comment_cont(from, target) if !from.nil?
|
109
106
|
end
|
110
|
-
wrap_comment_cont(from, target) if !from.nil?
|
111
107
|
end
|
112
|
-
end
|
113
108
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
109
|
+
def move_comment_link_to_from(docxml)
|
110
|
+
docxml.xpath('//span[@style="MsoCommentReference"][@from]').each do |x|
|
111
|
+
attrs = comment_attributes(docxml, x) || next
|
112
|
+
move_comment_link_to_from1(x, attrs[:from])
|
113
|
+
insert_comment_cont(attrs[:from], x["to"], x["target"])
|
114
|
+
end
|
119
115
|
end
|
120
|
-
end
|
121
116
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
117
|
+
def get_comments_from_text(docxml, link_order)
|
118
|
+
comments = []
|
119
|
+
docxml.xpath("//div[@style='mso-element:comment']").each do |c|
|
120
|
+
next unless c["id"] && !link_order[c["id"]].nil?
|
126
121
|
|
127
|
-
|
122
|
+
comments << { text: c.remove.to_s, id: c["id"] }
|
123
|
+
end
|
124
|
+
comments.sort! { |a, b| link_order[a[:id]] <=> link_order[b[:id]] }
|
125
|
+
# comments
|
128
126
|
end
|
129
|
-
comments.sort! { |a, b| link_order[a[:id]] <=> link_order[b[:id]] }
|
130
|
-
# comments
|
131
|
-
end
|
132
127
|
|
133
|
-
|
134
|
-
|
128
|
+
COMMENT_TARGET_XREFS =
|
129
|
+
"//span[@style='mso-special-character:comment']/@target".freeze
|
135
130
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
131
|
+
def reorder_comments_by_comment_link(docxml)
|
132
|
+
link_order = {}
|
133
|
+
docxml.xpath(COMMENT_TARGET_XREFS).each_with_index do |target, i|
|
134
|
+
link_order[target.value] = i
|
135
|
+
end
|
136
|
+
comments = get_comments_from_text(docxml, link_order)
|
137
|
+
list = docxml.at("//*[@style='mso-element:comment-list']") || return
|
138
|
+
list.children = comments.map { |c| c[:text] }.join("\n")
|
140
139
|
end
|
141
|
-
comments = get_comments_from_text(docxml, link_order)
|
142
|
-
list = docxml.at("//*[@style='mso-element:comment-list']") || return
|
143
|
-
list.children = comments.map { |c| c[:text] }.join("\n")
|
144
140
|
end
|
145
141
|
end
|
146
142
|
end
|
@@ -1,90 +1,91 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module
|
1
|
+
module IsoDoc
|
2
|
+
module HtmlFunction
|
3
|
+
module Footnotes
|
4
|
+
def footnotes(div)
|
5
|
+
return if @footnotes.empty?
|
3
6
|
|
4
|
-
|
5
|
-
return if @footnotes.empty?
|
6
|
-
|
7
|
-
@footnotes.each { |fn| div.parent << fn }
|
8
|
-
end
|
9
|
-
|
10
|
-
def make_table_footnote_link(out, fnid, fnref)
|
11
|
-
attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
|
12
|
-
out.a **attrs do |a|
|
13
|
-
a << fnref
|
7
|
+
@footnotes.each { |fn| div.parent << fn }
|
14
8
|
end
|
15
|
-
end
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
out.span **attrs do |a|
|
10
|
+
def make_table_footnote_link(out, fnid, fnref)
|
11
|
+
attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
|
12
|
+
out.a **attrs do |a|
|
21
13
|
a << fnref
|
22
14
|
end
|
23
|
-
insert_tab(s, 1)
|
24
15
|
end
|
25
|
-
end
|
26
16
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
def make_table_footnote_target(out, fnid, fnref)
|
18
|
+
attrs = { id: fnid, class: "TableFootnoteRef" }
|
19
|
+
out.span do |s|
|
20
|
+
out.span **attrs do |a|
|
21
|
+
a << fnref
|
22
|
+
end
|
23
|
+
insert_tab(s, 1)
|
33
24
|
end
|
34
|
-
end
|
35
|
-
end
|
25
|
+
end
|
36
26
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
27
|
+
def make_table_footnote_text(node, fnid, fnref)
|
28
|
+
attrs = { id: "fn:#{fnid}" }
|
29
|
+
noko do |xml|
|
30
|
+
xml.div **attr_code(attrs) do |div|
|
31
|
+
make_table_footnote_target(div, fnid, fnref)
|
32
|
+
node.children.each { |n| parse(n, div) }
|
33
|
+
end
|
34
|
+
end.join("\n")
|
35
|
+
end
|
44
36
|
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
def make_generic_footnote_text(node, fnid)
|
38
|
+
noko do |xml|
|
39
|
+
xml.aside **{ id: "fn:#{fnid}", class: "footnote" } do |div|
|
40
|
+
node.children.each { |n| parse(n, div) }
|
41
|
+
end
|
42
|
+
end.join("\n")
|
43
|
+
end
|
48
44
|
|
49
|
-
|
50
|
-
|
45
|
+
def get_table_ancestor_id(node)
|
46
|
+
table = node.ancestors("table") || node.ancestors("figure")
|
47
|
+
return UUIDTools::UUID.random_create.to_s if table.empty?
|
51
48
|
|
52
|
-
|
53
|
-
|
49
|
+
table.last["id"]
|
50
|
+
end
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
tid = get_table_ancestor_id(node)
|
58
|
-
make_table_footnote_link(out, tid + fn, fn)
|
59
|
-
return if @seen_footnote.include?(tid + fn)
|
52
|
+
# @seen_footnote:
|
53
|
+
# do not output footnote text if we have already seen it for this table
|
60
54
|
|
61
|
-
|
62
|
-
|
63
|
-
|
55
|
+
def table_footnote_parse(node, out)
|
56
|
+
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
57
|
+
tid = get_table_ancestor_id(node)
|
58
|
+
make_table_footnote_link(out, tid + fn, fn)
|
59
|
+
return if @seen_footnote.include?(tid + fn)
|
60
|
+
|
61
|
+
@in_footnote = true
|
62
|
+
out.aside **{ class: "footnote" } do |a|
|
63
|
+
a << make_table_footnote_text(node, tid + fn, fn)
|
64
|
+
end
|
65
|
+
@in_footnote = false
|
66
|
+
@seen_footnote << (tid + fn)
|
64
67
|
end
|
65
|
-
@in_footnote = false
|
66
|
-
@seen_footnote << (tid + fn)
|
67
|
-
end
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
def footnote_parse(node, out)
|
70
|
+
return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
|
71
|
+
!node.ancestors.map(&:name).include?("name")
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
74
|
+
attrs = { class: "FootnoteRef", href: "#fn:#{fn}" }
|
75
|
+
out.a **attrs do |a|
|
76
|
+
a.sup { |sup| sup << fn }
|
77
|
+
end
|
78
|
+
make_footnote(node, fn)
|
77
79
|
end
|
78
|
-
make_footnote(node, fn)
|
79
|
-
end
|
80
80
|
|
81
|
-
|
82
|
-
|
81
|
+
def make_footnote(node, fnote)
|
82
|
+
return if @seen_footnote.include?(fnote)
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
@in_footnote = true
|
85
|
+
@footnotes << make_generic_footnote_text(node, fnote)
|
86
|
+
@in_footnote = false
|
87
|
+
@seen_footnote << fnote
|
88
|
+
end
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
@@ -1,129 +1,139 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
require "base64"
|
3
3
|
|
4
|
-
module IsoDoc
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
module IsoDoc
|
5
|
+
module HtmlFunction
|
6
|
+
module Html
|
7
|
+
def convert1(docxml, filename, dir)
|
8
|
+
noko do |xml|
|
9
|
+
xml.html **{ lang: @lang.to_s } do |html|
|
10
|
+
info docxml, nil
|
11
|
+
populate_css
|
12
|
+
html.head { |head| define_head head, filename, dir }
|
13
|
+
make_body(html, docxml)
|
14
|
+
end
|
15
|
+
end.join("\n")
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
def make_body1(body, _docxml)
|
19
|
+
return if @bare
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
body.div **{ class: "title-section" } do |div1|
|
22
|
+
div1.p { |p| p << " " } # placeholder
|
23
|
+
end
|
24
|
+
section_break(body)
|
22
25
|
end
|
23
|
-
section_break(body)
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def make_body2(body, _docxml)
|
28
|
+
return if @bare
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
body.div **{ class: "prefatory-section" } do |div2|
|
31
|
+
div2.p { |p| p << " " } # placeholder
|
32
|
+
end
|
33
|
+
section_break(body)
|
31
34
|
end
|
32
|
-
section_break(body)
|
33
|
-
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
def make_body3(body, docxml)
|
37
|
+
body.div **{ class: "main-section" } do |div3|
|
38
|
+
boilerplate docxml, div3
|
39
|
+
preface_block docxml, div3
|
40
|
+
abstract docxml, div3
|
41
|
+
foreword docxml, div3
|
42
|
+
introduction docxml, div3
|
43
|
+
preface docxml, div3
|
44
|
+
acknowledgements docxml, div3
|
45
|
+
middle docxml, div3
|
46
|
+
footnotes div3
|
47
|
+
comments div3
|
48
|
+
end
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
def googlefonts
|
52
|
+
<<~HEAD.freeze
|
53
|
+
<link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
|
54
|
+
<link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
|
55
|
+
HEAD
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
58
|
+
def html_head
|
59
|
+
<<~HEAD.freeze
|
60
|
+
<title>#{@meta&.get&.dig(:doctitle)}</title>
|
61
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
62
|
+
|
63
|
+
<!--TOC script import-->
|
64
|
+
<script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
|
65
|
+
<script type="text/javascript">#{toclevel}</script>
|
66
|
+
|
67
|
+
<!--Google fonts-->
|
68
|
+
<link rel="preconnect" href="https://fonts.gstatic.com">#{' '}
|
69
|
+
#{googlefonts}
|
70
|
+
<!--Font awesome import for the link icon-->
|
71
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
|
72
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
|
73
|
+
<style class="anchorjs"></style>
|
74
|
+
HEAD
|
75
|
+
end
|
75
76
|
|
76
|
-
|
77
|
-
|
77
|
+
def html_button
|
78
|
+
return "" if @bare
|
78
79
|
|
79
|
-
|
80
|
+
'<button onclick="topFunction()" id="myBtn" '\
|
80
81
|
'title="Go to top">Top</button>'.freeze
|
81
|
-
|
82
|
+
end
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
def html_main(docxml)
|
85
|
+
docxml.at("//head").add_child(html_head)
|
86
|
+
d = docxml.at('//div[@class="main-section"]')
|
87
|
+
d.name = "main"
|
88
|
+
d.children.empty? or d.children.first.previous = html_button
|
89
|
+
end
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
91
|
+
def sourcecodelang(lang)
|
92
|
+
return unless lang
|
93
|
+
|
94
|
+
case lang.downcase
|
95
|
+
when "javascript" then "lang-js"
|
96
|
+
when "c" then "lang-c"
|
97
|
+
when "c+" then "lang-cpp"
|
98
|
+
when "console" then "lang-bsh"
|
99
|
+
when "ruby" then "lang-rb"
|
100
|
+
when "html" then "lang-html"
|
101
|
+
when "java" then "lang-java"
|
102
|
+
when "xml" then "lang-xml"
|
103
|
+
when "perl" then "lang-perl"
|
104
|
+
when "python" then "lang-py"
|
105
|
+
when "xsl" then "lang-xsl"
|
106
|
+
else
|
107
|
+
""
|
108
|
+
end
|
107
109
|
end
|
108
|
-
end
|
109
110
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
111
|
+
def sourcecode_parse(node, out)
|
112
|
+
name = node.at(ns("./name"))
|
113
|
+
class1 = "prettyprint #{sourcecodelang(node&.at(ns('./@lang'))&.value)}"
|
114
|
+
out.pre **sourcecode_attrs(node).merge(class: class1) do |div|
|
115
|
+
@sourcecode = true
|
116
|
+
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
117
|
+
@sourcecode = false
|
118
|
+
end
|
119
|
+
sourcecode_name_parse(node, out, name)
|
117
120
|
end
|
118
|
-
sourcecode_name_parse(node, out, name)
|
119
|
-
end
|
120
121
|
|
121
|
-
|
122
|
-
|
123
|
-
|
122
|
+
def underline_parse(node, out)
|
123
|
+
out.span **{ style: "text-decoration: underline;" } do |e|
|
124
|
+
node.children.each { |n| parse(n, e) }
|
125
|
+
end
|
124
126
|
end
|
125
|
-
end
|
126
127
|
|
127
|
-
|
128
|
+
def table_long_strings_cleanup(docxml); end
|
129
|
+
|
130
|
+
def image_parse(node, out, caption)
|
131
|
+
if svg = node.at("./m:svg", "m" => "http://www.w3.org/2000/svg")
|
132
|
+
svg_parse(svg, out)
|
133
|
+
return
|
134
|
+
end
|
135
|
+
super
|
136
|
+
end
|
137
|
+
end
|
128
138
|
end
|
129
139
|
end
|