isodoc 1.7.1 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +2 -1
  3. data/lib/isodoc/convert.rb +1 -0
  4. data/lib/isodoc/css.rb +3 -3
  5. data/lib/isodoc/function/blocks.rb +180 -168
  6. data/lib/isodoc/function/blocks_example_note.rb +85 -79
  7. data/lib/isodoc/function/cleanup.rb +181 -175
  8. data/lib/isodoc/function/inline.rb +110 -108
  9. data/lib/isodoc/function/inline_simple.rb +55 -55
  10. data/lib/isodoc/function/lists.rb +75 -71
  11. data/lib/isodoc/function/references.rb +165 -160
  12. data/lib/isodoc/function/reqt.rb +91 -85
  13. data/lib/isodoc/function/section.rb +140 -190
  14. data/lib/isodoc/function/section_titles.rb +82 -0
  15. data/lib/isodoc/function/table.rb +90 -87
  16. data/lib/isodoc/function/terms.rb +58 -56
  17. data/lib/isodoc/function/to_word_html.rb +208 -204
  18. data/lib/isodoc/html_convert.rb +0 -4
  19. data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
  20. data/lib/isodoc/presentation_function/inline.rb +1 -1
  21. data/lib/isodoc/presentation_function/math.rb +9 -0
  22. data/lib/isodoc/presentation_function/section.rb +12 -1
  23. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  24. data/lib/isodoc/version.rb +1 -1
  25. data/lib/isodoc/word_function/body.rb +5 -5
  26. data/lib/isodoc/xslfo_convert.rb +2 -2
  27. data/lib/isodoc.rb +2 -1
  28. data/lib/metanorma/output/base.rb +13 -0
  29. data/lib/metanorma/output/utils.rb +17 -0
  30. data/lib/metanorma/output/xslfo.rb +21 -0
  31. data/lib/metanorma/output.rb +7 -0
  32. data/spec/assets/outputtest/a.xml +66 -0
  33. data/spec/assets/outputtest/iso.international-standard.xsl +3011 -0
  34. data/spec/isodoc/blocks_spec.rb +441 -243
  35. data/spec/isodoc/inline_spec.rb +197 -114
  36. data/spec/isodoc/postproc_spec.rb +2 -2
  37. data/spec/isodoc/presentation_xml_spec.rb +84 -0
  38. data/spec/isodoc/section_spec.rb +639 -0
  39. metadata +23 -18
  40. data/lib/isodoc/html_function/sectionsplit.rb +0 -244
  41. data/spec/isodoc/sectionsplit_spec.rb +0 -190
@@ -1,107 +1,113 @@
1
- module IsoDoc::Function
2
- module Blocks
3
- def example_label(node, div, name)
4
- return if name.nil?
5
- div.p **{ class: "example-title" } do |p|
6
- name.children.each { |n| parse(n, div) }
1
+ module IsoDoc
2
+ module Function
3
+ module Blocks
4
+ def example_label(_node, div, name)
5
+ return if name.nil?
6
+
7
+ div.p **{ class: "example-title" } do |_p|
8
+ name.children.each { |n| parse(n, div) }
9
+ end
7
10
  end
8
- end
9
11
 
10
- EXAMPLE_TBL_ATTR =
11
- { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
12
+ EXAMPLE_TBL_ATTR =
13
+ { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
12
14
  margin-left:0pt;vertical-align:top;" }.freeze
13
15
 
14
- def example_div_attr(node)
15
- attr_code(id: node["id"], class: "example", style: keep_style(node))
16
- end
16
+ def example_div_attr(node)
17
+ attr_code(id: node["id"], class: "example", style: keep_style(node))
18
+ end
17
19
 
18
- # used if we are boxing examples
19
- def example_div_parse(node, out)
20
- out.div **example_div_attr(node) do |div|
21
- example_label(node, div, node.at(ns("./name")))
22
- node.children.each do |n|
23
- parse(n, div) unless n.name == "name"
20
+ # used if we are boxing examples
21
+ def example_div_parse(node, out)
22
+ out.div **example_div_attr(node) do |div|
23
+ example_label(node, div, node.at(ns("./name")))
24
+ node.children.each do |n|
25
+ parse(n, div) unless n.name == "name"
26
+ end
24
27
  end
25
28
  end
26
- end
27
29
 
28
- def example_table_attr(node)
29
- attr_code(id: node["id"], class: "example",
30
- style: "border-collapse:collapse;border-spacing:0;"\
31
- "#{keep_style(node)}" )
32
- end
30
+ def example_table_attr(node)
31
+ attr_code(id: node["id"], class: "example",
32
+ style: "border-collapse:collapse;border-spacing:0;"\
33
+ "#{keep_style(node)}")
34
+ end
33
35
 
34
- EXAMPLE_TD_ATTR =
35
- { style: "vertical-align:top;padding:0;", class: "example" }.freeze
36
+ EXAMPLE_TD_ATTR =
37
+ { style: "vertical-align:top;padding:0;", class: "example" }.freeze
36
38
 
37
- def example_table_parse(node, out)
38
- out.table **example_table_attr(node) do |t|
39
- t.tr do |tr|
40
- tr.td **EXAMPLE_TBL_ATTR do |td|
41
- example_label(node, td, node.at(ns("./name")))
42
- end
43
- tr.td **EXAMPLE_TD_ATTR do |td|
44
- node.children.each { |n| parse(n, td) unless n.name == "name" }
39
+ def example_table_parse(node, out)
40
+ out.table **example_table_attr(node) do |t|
41
+ t.tr do |tr|
42
+ tr.td **EXAMPLE_TBL_ATTR do |td|
43
+ example_label(node, td, node.at(ns("./name")))
44
+ end
45
+ tr.td **EXAMPLE_TD_ATTR do |td|
46
+ node.children.each { |n| parse(n, td) unless n.name == "name" }
47
+ end
45
48
  end
46
49
  end
47
50
  end
48
- end
49
51
 
50
- def example_parse(node, out)
51
- example_div_parse(node, out)
52
- end
52
+ def example_parse(node, out)
53
+ example_div_parse(node, out)
54
+ end
53
55
 
54
- def note_delim
55
- ""
56
- end
56
+ def note_delim
57
+ ""
58
+ end
57
59
 
58
- def note_p_parse(node, div)
59
- name = node&.at(ns("./name"))&.remove
60
- div.p do |p|
61
- name and p.span **{ class: "note_label" } do |s|
62
- name.children.each { |n| parse(n, s) }
63
- s << note_delim
60
+ def note_p_parse(node, div)
61
+ name = node&.at(ns("./name"))&.remove
62
+ div.p do |p|
63
+ name and p.span **{ class: "note_label" } do |s|
64
+ name.children.each { |n| parse(n, s) }
65
+ s << note_delim
66
+ end
67
+ insert_tab(p, 1)
68
+ node.first_element_child.children.each { |n| parse(n, p) }
64
69
  end
65
- insert_tab(p, 1)
66
- node.first_element_child.children.each { |n| parse(n, p) }
70
+ node.element_children[1..-1].each { |n| parse(n, div) }
67
71
  end
68
- node.element_children[1..-1].each { |n| parse(n, div) }
69
- end
70
72
 
71
- def note_parse1(node, div)
72
- name = node&.at(ns("./name"))&.remove
73
- name and div.p do |p|
74
- p.span **{ class: "note_label" } do |s|
75
- name.children.each { |n| parse(n, s) }
76
- s << note_delim
73
+ def note_parse1(node, div)
74
+ name = node&.at(ns("./name"))&.remove
75
+ name and div.p do |p|
76
+ p.span **{ class: "note_label" } do |s|
77
+ name.children.each { |n| parse(n, s) }
78
+ s << note_delim
79
+ end
80
+ insert_tab(p, 1)
77
81
  end
78
- insert_tab(p, 1)
82
+ node.children.each { |n| parse(n, div) }
79
83
  end
80
- node.children.each { |n| parse(n, div) }
81
- end
82
84
 
83
- def keep_style(node)
84
- ret = ""
85
- node["keep-with-next"] == "true" and
86
- ret += "page-break-after: avoid;"
87
- node["keep-lines-together"] == "true" and
88
- ret += "page-break-inside: avoid;"
89
- return nil if ret.empty?
90
- ret
91
- end
85
+ def keep_style(node)
86
+ ret = ""
87
+ node["keep-with-next"] == "true" and
88
+ ret += "page-break-after: avoid;"
89
+ node["keep-lines-together"] == "true" and
90
+ ret += "page-break-inside: avoid;"
91
+ return nil if ret.empty?
92
92
 
93
- def note_attrs(node)
94
- attr_code(id: node["id"], class: "Note", style: keep_style(node))
95
- end
93
+ ret
94
+ end
95
+
96
+ def note_attrs(node)
97
+ attr_code(id: node["id"], class: "Note", style: keep_style(node))
98
+ end
96
99
 
97
- def note_parse(node, out)
98
- @note = true
99
- out.div **note_attrs(node) do |div|
100
- node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p" ?
101
- # node.first_element_child.name == "p" ?
102
- note_p_parse(node, div) : note_parse1(node, div)
100
+ def note_parse(node, out)
101
+ @note = true
102
+ out.div **note_attrs(node) do |div|
103
+ if node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p"
104
+ note_p_parse(node, div)
105
+ else
106
+ note_parse1(node, div)
107
+ end
108
+ end
109
+ @note = false
103
110
  end
104
- @note = false
105
111
  end
106
112
  end
107
113
  end
@@ -1,226 +1,232 @@
1
- module IsoDoc::Function
2
- module Cleanup
3
- def textcleanup(docxml)
4
- termref_cleanup(passthrough_cleanup(docxml))
5
- end
1
+ module IsoDoc
2
+ module Function
3
+ module Cleanup
4
+ def textcleanup(docxml)
5
+ termref_cleanup(passthrough_cleanup(docxml))
6
+ end
6
7
 
7
- def termref_cleanup(docxml)
8
- docxml
9
- .gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/,
10
- l10n(", #{@i18n.modified} [/TERMREF]"))
11
- .gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ")
12
- .gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source}: "))
13
- .gsub(%r{\s*\[/TERMREF\]\s*}, l10n("]"))
14
- .gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
15
- end
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} &mdash; "))
16
+ end
16
17
 
17
- def passthrough_cleanup(docxml)
18
- docxml.split(%r{(<passthrough>|</passthrough>)}).each_slice(4).map do |a|
19
- a.size > 2 and a[2] = HTMLEntities.new.decode(a[2])
20
- [a[0], a[2]]
21
- end.join
22
- end
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
- def cleanup(docxml)
25
- @i18n ||= i18n_init(@lang, @script)
26
- comment_cleanup(docxml)
27
- footnote_cleanup(docxml)
28
- inline_header_cleanup(docxml)
29
- figure_cleanup(docxml)
30
- table_cleanup(docxml)
31
- symbols_cleanup(docxml)
32
- example_cleanup(docxml)
33
- admonition_cleanup(docxml)
34
- end
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
- def table_long_strings_cleanup(docxml)
37
- return unless @break_up_urls_in_tables == true
38
+ def table_long_strings_cleanup(docxml)
39
+ return unless @break_up_urls_in_tables == true
38
40
 
39
- docxml.xpath("//td | //th").each do |d|
40
- d.traverse do |n|
41
- next unless n.text?
41
+ docxml.xpath("//td | //th").each do |d|
42
+ d.traverse do |n|
43
+ next unless n.text?
42
44
 
43
- n.replace(HTMLEntities.new.encode(
44
- break_up_long_strings(n.text),
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
- def break_up_long_strings(text)
51
- return text if /^\s*$/.match?(text)
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.split(/(?=\s)/).map do |w|
54
- if /^\s*$/.match(text) || (w.size < 30) then w
65
+ def break_up_long_strings1(text)
66
+ s = text.split(%r{(?<=[,.?+;/=])})
67
+ if s.size == 1 then "#{text} "
55
68
  else
56
- w.scan(/.{,30}/).map do |w1|
57
- w1.size < 30 ? w1 : break_up_long_strings1(w1)
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
- def admonition_cleanup(docxml)
73
- docxml.xpath("//div[@class = 'Admonition'][title]").each do |d|
74
- title = d.at("./title")
75
- n = title.next_element
76
- n&.children&.first&.add_previous_sibling(title.remove.text + "&mdash;")
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}&mdash;")
80
+ end
81
+ docxml
77
82
  end
78
- docxml
79
- end
80
83
 
81
- def example_cleanup(docxml)
82
- docxml.xpath("//table[@class = 'example']//p[not(@class)]").each do |p|
83
- p["class"] = "example"
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
- def figure_get_or_make_dl(elem)
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
- FIGURE_WITH_FOOTNOTES =
98
- "//div[@class = 'figure'][descendant::aside]"\
99
- "[not(descendant::div[@class = 'figure'])]".freeze
100
-
101
- def figure_aside_process(elem, aside, key)
102
- # get rid of footnote link, it is in diagram
103
- elem&.at("./a[@class='TableFootnoteRef']")&.remove
104
- fnref = elem.at(".//span[@class='TableFootnoteRef']/..")
105
- dt = key.add_child("<dt></dt>").first
106
- dd = key.add_child("<dd></dd>").first
107
- fnref.parent = dt
108
- aside.xpath(".//p").each do |a|
109
- a.delete("class")
110
- a.parent = dd
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
- # move footnotes into key, and get rid of footnote reference
115
- # since it is in diagram
116
- def figure_cleanup(docxml)
117
- docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|
118
- next unless f.at(".//aside[not(ancestor::p[@class = 'FigureTitle'])]")
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
- key = figure_get_or_make_dl(f)
121
- f.xpath(".//aside").each do |aside|
122
- figure_aside_process(f, aside, key)
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
- def inline_header_cleanup(docxml)
129
- docxml.xpath('//span[@class="zzMoveToFollowing"]').each do |x|
130
- x.delete("class")
131
- n = x.next_element
132
- if n.nil?
133
- x.name = "p"
134
- else
135
- n.children.first.previous = x.remove
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
- def footnote_cleanup(docxml)
142
- docxml.xpath('//a[@class = "FootnoteRef"]/sup').each_with_index do |x, i|
143
- x.content = (i + 1).to_s
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
- def merge_fnref_into_fn_text(elem)
149
- fn = elem.at('.//span[@class="TableFootnoteRef"]/..')
150
- n = fn.next_element
151
- n&.children&.first&.add_previous_sibling(fn.remove)
152
- end
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
- # preempt html2doc putting MsoNormal under TableFootnote class
155
- def table_footnote_cleanup(docxml)
156
- docxml.xpath("//table[descendant::aside]").each do |t|
157
- t.xpath(".//aside").each do |a|
158
- merge_fnref_into_fn_text(a)
159
- a.name = "div"
160
- a["class"] = "TableFootnote"
161
- t << a.remove
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
- def remove_bottom_border(cell)
171
- cell["style"] =
172
- cell["style"].gsub(/border-bottom:[^;]+;/, "border-bottom:0pt;")
173
- end
174
+ def remove_bottom_border(cell)
175
+ cell["style"] =
176
+ cell["style"].gsub(/border-bottom:[^;]+;/, "border-bottom:0pt;")
177
+ end
174
178
 
175
- def table_get_or_make_tfoot(table)
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
- else
181
- tfoot.xpath(".//td | .//th").each { |td| remove_bottom_border(td) }
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
- def new_fullcolspan_row(table, tfoot)
187
- # how many columns in the table?
188
- cols = 0
189
- table.at(".//tr").xpath("./td | ./th").each do |td|
190
- cols += (td["colspan"] ? td["colspan"].to_i : 1)
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
- def table_note_cleanup(docxml)
199
- docxml.xpath("//table[div[@class = 'Note' or "\
200
- "@class = 'TableFootnote']]").each do |t|
201
- tfoot = table_get_or_make_tfoot(t)
202
- insert_here = new_fullcolspan_row(t, tfoot)
203
- t.xpath("div[@class = 'Note' or @class = 'TableFootnote']").each do |d|
204
- d.parent = insert_here
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
- def table_cleanup(docxml)
210
- table_footnote_cleanup(docxml)
211
- table_note_cleanup(docxml)
212
- table_long_strings_cleanup(docxml)
213
- docxml
214
- end
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
- def symbols_cleanup(docxml); end
221
+ def symbols_cleanup(docxml); end
217
222
 
218
- def table_footnote_reference_format(link)
219
- link
220
- end
223
+ def table_footnote_reference_format(link)
224
+ link
225
+ end
221
226
 
222
- def footnote_reference_format(link)
223
- link
227
+ def footnote_reference_format(link)
228
+ link
229
+ end
224
230
  end
225
231
  end
226
232
  end