isodoc 1.7.3.1 → 1.7.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +7 -4
  3. data/lib/isodoc/class_utils.rb +2 -2
  4. data/lib/isodoc/convert.rb +2 -0
  5. data/lib/isodoc/function/blocks_example_note.rb +85 -79
  6. data/lib/isodoc/function/cleanup.rb +181 -175
  7. data/lib/isodoc/function/inline.rb +110 -108
  8. data/lib/isodoc/function/inline_simple.rb +55 -55
  9. data/lib/isodoc/function/lists.rb +75 -71
  10. data/lib/isodoc/function/references.rb +165 -160
  11. data/lib/isodoc/function/section.rb +140 -190
  12. data/lib/isodoc/function/section_titles.rb +82 -0
  13. data/lib/isodoc/function/table.rb +90 -87
  14. data/lib/isodoc/function/terms.rb +58 -56
  15. data/lib/isodoc/function/to_word_html.rb +3 -1
  16. data/lib/isodoc/function/utils.rb +34 -14
  17. data/lib/isodoc/html_function/comments.rb +107 -111
  18. data/lib/isodoc/html_function/footnotes.rb +68 -67
  19. data/lib/isodoc/html_function/html.rb +113 -103
  20. data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
  21. data/lib/isodoc/presentation_function/block.rb +73 -78
  22. data/lib/isodoc/presentation_function/concept.rb +68 -0
  23. data/lib/isodoc/presentation_function/image.rb +112 -0
  24. data/lib/isodoc/presentation_function/inline.rb +6 -39
  25. data/lib/isodoc/presentation_function/math.rb +9 -0
  26. data/lib/isodoc/presentation_function/section.rb +12 -1
  27. data/lib/isodoc/presentation_xml_convert.rb +3 -0
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_function/body.rb +176 -174
  30. data/lib/isodoc/word_function/comments.rb +117 -112
  31. data/lib/isodoc/word_function/footnotes.rb +88 -86
  32. data/lib/isodoc/word_function/inline.rb +42 -67
  33. data/lib/isodoc/word_function/postprocess_cover.rb +121 -110
  34. data/lib/isodoc/xref/xref_gen.rb +153 -150
  35. data/lib/isodoc/xslfo_convert.rb +2 -2
  36. data/spec/assets/odf.svg +1 -4
  37. data/spec/isodoc/blocks_spec.rb +187 -32
  38. data/spec/isodoc/inline_spec.rb +300 -116
  39. data/spec/isodoc/postproc_spec.rb +38 -0
  40. data/spec/isodoc/presentation_xml_spec.rb +144 -0
  41. data/spec/isodoc/section_spec.rb +764 -0
  42. data/spec/isodoc/terms_spec.rb +116 -0
  43. metadata +63 -18
@@ -1,146 +1,142 @@
1
- module IsoDoc::HtmlFunction
2
- module Comments
3
-
4
- def in_comment
5
- @in_comment
6
- end
1
+ module IsoDoc
2
+ module HtmlFunction
3
+ module Comments
4
+ def in_comment
5
+ @in_comment
6
+ end
7
7
 
8
- def comments(div)
9
- =begin
10
- return if @comments.empty?
11
- div.div **{ style: "mso-element:comment-list" } do |div1|
12
- @comments.each { |fn| div1.parent << fn }
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
- def review_note_parse(node, out)
18
- =begin
19
- fn = @comments.length + 1
20
- make_comment_link(out, fn, node)
21
- @in_comment = true
22
- @comments << make_comment_text(node, fn)
23
- @in_comment = false
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
- def comment_link_attrs(fnote, node)
28
- { style: "MsoCommentReference", target: fnote,
29
- class: "commentLink", from: node["from"],
30
- to: node["to"] }
31
- end
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
- # add in from and to links to move the comment into place
34
- def make_comment_link(out, fnote, node)
35
- out.span(**comment_link_attrs(fnote, node)) do |s1|
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
- "mso-comment-date:#{node['date'].gsub(/[-:Z]/, '')}" }
33
+ "mso-comment-date:#{node['date'].gsub(/[-:Z]/,
34
+ '')}" }
38
35
  end
39
- end
36
+ end
40
37
 
41
- def make_comment_target(out)
42
- out.span **{ style: "MsoCommentReference" } do |s1|
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
- end
42
+ end
46
43
 
47
- def make_comment_text(node, fnote)
48
- noko do |xml|
49
- xml.div **{ style: "mso-element:comment", id: fnote } do |div|
50
- div.span **{ style: %{mso-comment-author:"#{node['reviewer']}"} }
51
- make_comment_target(div)
52
- node.children.each { |n| parse(n, div) }
53
- end
54
- end.join("\n")
55
- end
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
- def comment_cleanup(docxml)
58
- =begin
59
- move_comment_link_to_from(docxml)
60
- reorder_comments_by_comment_link(docxml)
61
- embed_comment_in_comment_list(docxml)
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
- COMMENT_IN_COMMENT_LIST =
66
- '//div[@style="mso-element:comment-list"]//'\
67
- 'span[@style="MsoCommentReference"]'.freeze
60
+ COMMENT_IN_COMMENT_LIST =
61
+ '//div[@style="mso-element:comment-list"]//'\
62
+ 'span[@style="MsoCommentReference"]'.freeze
68
63
 
69
- def embed_comment_in_comment_list(docxml)
70
- docxml.xpath(COMMENT_IN_COMMENT_LIST).each do |x|
71
- n = x.next_element
72
- n&.children&.first&.add_previous_sibling(x.remove)
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
- def move_comment_link_to_from1(x, fromlink)
78
- x.remove
79
- link = x.at(".//a")
80
- fromlink.replace(x)
81
- link.children = fromlink
82
- end
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
- def comment_attributes(docxml, x)
85
- fromlink = docxml.at("//*[@id='#{x['from']}']")
86
- return(nil) if fromlink.nil?
79
+ def comment_attributes(docxml, x)
80
+ fromlink = docxml.at("//*[@id='#{x['from']}']")
81
+ return(nil) if fromlink.nil?
87
82
 
88
- tolink = docxml.at("//*[@id='#{x['to']}']") || fromlink
89
- target = docxml.at("//*[@id='#{x['target']}']")
90
- { from: fromlink, to: tolink, target: target }
91
- end
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
- def wrap_comment_cont(from, target)
94
- s = from.replace("<span style='mso-comment-continuation:#{target}'>")
95
- s.first.children = from
96
- end
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
- def skip_comment_wrap(from)
99
- from["style"] != "mso-special-character:comment"
100
- end
93
+ def skip_comment_wrap(from)
94
+ from["style"] != "mso-special-character:comment"
95
+ end
101
96
 
102
- def insert_comment_cont(from, upto, target)
103
- # includes_to = from.at(".//*[@id='#{upto}']")
104
- while !from.nil? && from["id"] != upto
105
- following = from.xpath("./following::*")
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
- def move_comment_link_to_from(docxml)
115
- docxml.xpath('//span[@style="MsoCommentReference"][@from]').each do |x|
116
- attrs = comment_attributes(docxml, x) || next
117
- move_comment_link_to_from1(x, attrs[:from])
118
- insert_comment_cont(attrs[:from], x["to"], x["target"])
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
- def get_comments_from_text(docxml, link_order)
123
- comments = []
124
- docxml.xpath("//div[@style='mso-element:comment']").each do |c|
125
- next unless c["id"] && !link_order[c["id"]].nil?
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
- comments << { text: c.remove.to_s, id: c["id"] }
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
- COMMENT_TARGET_XREFS =
134
- "//span[@style='mso-special-character:comment']/@target".freeze
128
+ COMMENT_TARGET_XREFS =
129
+ "//span[@style='mso-special-character:comment']/@target".freeze
135
130
 
136
- def reorder_comments_by_comment_link(docxml)
137
- link_order = {}
138
- docxml.xpath(COMMENT_TARGET_XREFS).each_with_index do |target, i|
139
- link_order[target.value] = i
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::HtmlFunction
2
- module Footnotes
1
+ module IsoDoc
2
+ module HtmlFunction
3
+ module Footnotes
4
+ def footnotes(div)
5
+ return if @footnotes.empty?
3
6
 
4
- def footnotes(div)
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
- 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|
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
- 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) }
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.join("\n")
35
- end
25
+ end
36
26
 
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
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
- 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?
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
- table.last["id"]
50
- end
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
- # @seen_footnote:
53
- # do not output footnote text if we have already seen it for this table
49
+ table.last["id"]
50
+ end
54
51
 
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)
52
+ # @seen_footnote:
53
+ # do not output footnote text if we have already seen it for this table
60
54
 
61
- @in_footnote = true
62
- out.aside **{ class: "footnote" } do |a|
63
- a << make_table_footnote_text(node, tid + fn, fn)
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
- def footnote_parse(node, out)
70
- return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
71
- !node.ancestors.map(&:name).include?("name")
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
- 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 }
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
- def make_footnote(node, fnote)
82
- return if @seen_footnote.include?(fnote)
81
+ def make_footnote(node, fnote)
82
+ return if @seen_footnote.include?(fnote)
83
83
 
84
- @in_footnote = true
85
- @footnotes << make_generic_footnote_text(node, fnote)
86
- @in_footnote = false
87
- @seen_footnote << fnote
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::HtmlFunction
5
- module Html
6
- def convert1(docxml, filename, dir)
7
- noko do |xml|
8
- xml.html **{ lang: @lang.to_s } do |html|
9
- info docxml, nil
10
- populate_css
11
- html.head { |head| define_head head, filename, dir }
12
- make_body(html, docxml)
13
- end
14
- end.join("\n")
15
- end
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
- def make_body1(body, _docxml)
18
- return if @bare
18
+ def make_body1(body, _docxml)
19
+ return if @bare
19
20
 
20
- body.div **{ class: "title-section" } do |div1|
21
- div1.p { |p| p << "&nbsp;" } # placeholder
21
+ body.div **{ class: "title-section" } do |div1|
22
+ div1.p { |p| p << "&nbsp;" } # placeholder
23
+ end
24
+ section_break(body)
22
25
  end
23
- section_break(body)
24
- end
25
26
 
26
- def make_body2(body, _docxml)
27
- return if @bare
27
+ def make_body2(body, _docxml)
28
+ return if @bare
28
29
 
29
- body.div **{ class: "prefatory-section" } do |div2|
30
- div2.p { |p| p << "&nbsp;" } # placeholder
30
+ body.div **{ class: "prefatory-section" } do |div2|
31
+ div2.p { |p| p << "&nbsp;" } # placeholder
32
+ end
33
+ section_break(body)
31
34
  end
32
- section_break(body)
33
- end
34
35
 
35
- def make_body3(body, docxml)
36
- body.div **{ class: "main-section" } do |div3|
37
- boilerplate docxml, div3
38
- preface_block docxml, div3
39
- abstract docxml, div3
40
- foreword docxml, div3
41
- introduction docxml, div3
42
- preface docxml, div3
43
- acknowledgements docxml, div3
44
- middle docxml, div3
45
- footnotes div3
46
- comments div3
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
- def googlefonts
51
- <<~HEAD.freeze
52
- <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
53
- <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
54
- HEAD
55
- end
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
- def html_head
58
- <<~HEAD.freeze
59
- <title>#{@meta&.get&.dig(:doctitle)}</title>
60
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
61
-
62
- <!--TOC script import-->
63
- <script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
64
- <script type="text/javascript">#{toclevel}</script>
65
-
66
- <!--Google fonts-->
67
- <link rel="preconnect" href="https://fonts.gstatic.com">#{' '}
68
- #{googlefonts}
69
- <!--Font awesome import for the link icon-->
70
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
71
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
72
- <style class="anchorjs"></style>
73
- HEAD
74
- end
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
- def html_button
77
- return "" if @bare
77
+ def html_button
78
+ return "" if @bare
78
79
 
79
- '<button onclick="topFunction()" id="myBtn" '\
80
+ '<button onclick="topFunction()" id="myBtn" '\
80
81
  'title="Go to top">Top</button>'.freeze
81
- end
82
+ end
82
83
 
83
- def html_main(docxml)
84
- docxml.at("//head").add_child(html_head)
85
- d = docxml.at('//div[@class="main-section"]')
86
- d.name = "main"
87
- d.children.empty? or d.children.first.previous = html_button
88
- end
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
- def sourcecodelang(lang)
91
- return unless lang
92
-
93
- case lang.downcase
94
- when "javascript" then "lang-js"
95
- when "c" then "lang-c"
96
- when "c+" then "lang-cpp"
97
- when "console" then "lang-bsh"
98
- when "ruby" then "lang-rb"
99
- when "html" then "lang-html"
100
- when "java" then "lang-java"
101
- when "xml" then "lang-xml"
102
- when "perl" then "lang-perl"
103
- when "python" then "lang-py"
104
- when "xsl" then "lang-xsl"
105
- else
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
- def sourcecode_parse(node, out)
111
- name = node.at(ns("./name"))
112
- class1 = "prettyprint #{sourcecodelang(node&.at(ns('./@lang'))&.value)}"
113
- out.pre **sourcecode_attrs(node).merge(class: class1) do |div|
114
- @sourcecode = true
115
- node.children.each { |n| parse(n, div) unless n.name == "name" }
116
- @sourcecode = false
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
- def underline_parse(node, out)
122
- out.span **{ style: "text-decoration: underline;" } do |e|
123
- node.children.each { |n| parse(n, e) }
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
- def table_long_strings_cleanup(docxml); end
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