isodoc 0.4.5 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,15 +2,12 @@ require "htmlentities"
2
2
 
3
3
  module IsoDoc
4
4
  class Convert
5
-
6
5
  def init_metadata
7
- @meta = {
8
- tc: "XXXX",
9
- sc: "XXXX",
10
- wg: "XXXX",
11
- editorialgroup: [],
12
- secretariat: "XXXX",
13
- }
6
+ @meta = { tc: "XXXX", sc: "XXXX", wg: "XXXX",
7
+ editorialgroup: [],
8
+ secretariat: "XXXX",
9
+ obsoletes: nil,
10
+ obsoletes_part: nil }
14
11
  %w{published accessed created activated obsoleted}.each do |w|
15
12
  @meta["#{w}date".to_sym] = "XXX"
16
13
  end
@@ -57,7 +54,7 @@ module IsoDoc
57
54
  wg_num = xml.at(ns("//editorialgroup/workgroup/@number"))
58
55
  wg_type = xml.at(ns("//editorialgroup/workgroup/@type"))&.text || "WG"
59
56
  if wg_num
60
- wgid = "#{wg_type} #{wg_num.text}"
57
+ wgid = "#{wg_type} #{wg_num.text}"
61
58
  set_metadata(:wg, wgid)
62
59
  set_metadata(:editorialgroup, get_metadata[:editorialgroup] << wgid)
63
60
  end
@@ -70,32 +67,37 @@ module IsoDoc
70
67
 
71
68
  def bibdate(isoxml, _out)
72
69
  isoxml.xpath(ns("//bibdata/date")).each do |d|
73
- set_metadata("#{d["type"]}date".to_sym, d.text)
70
+ set_metadata("#{d['type']}date".to_sym, d.text)
74
71
  end
75
72
  end
76
73
 
77
74
  def agency(xml)
78
75
  agency = ""
79
- pub = xml.xpath(ns("//bibdata/contributor"\
80
- "[xmlns:role/@type = 'publisher']/"\
81
- "organization/name")).each do |org|
76
+ xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/"\
77
+ "organization/name")).each do |org|
82
78
  agency = org.text == "ISO" ? "ISO/#{agency}" : "#{agency}#{org.text}/"
83
79
  end
84
80
  set_metadata(:agency, agency.sub(%r{/$}, ""))
85
81
  end
86
82
 
87
- def id(isoxml, _out)
83
+ def docnumber(isoxml)
88
84
  docnumber = isoxml.at(ns("//project-number"))
89
85
  partnumber = isoxml.at(ns("//project-number/@part"))
90
- documentstatus = isoxml.at(ns("//status/stage"))
91
- dn = docnumber.text
86
+ subpartnumber = isoxml.at(ns("//project-number/@subpart"))
87
+ dn = docnumber&.text || ""
92
88
  dn += "-#{partnumber.text}" if partnumber
89
+ dn += "-#{subpartnumber.text}" if subpartnumber
90
+ dn
91
+ end
92
+
93
+ def id(isoxml, _out)
94
+ dn = docnumber(isoxml)
95
+ documentstatus = isoxml.at(ns("//status/stage"))
93
96
  if documentstatus
94
97
  set_metadata(:stage, documentstatus.text)
95
98
  abbr = stage_abbreviation(documentstatus.text)
96
99
  set_metadata(:stageabbr, abbr)
97
- documentstatus.text.to_i < 60 and
98
- dn = abbr + " " + dn
100
+ (documentstatus.text.to_i < 60) && dn = abbr + " " + dn
99
101
  end
100
102
  set_metadata(:docnumber, dn)
101
103
  end
@@ -103,38 +105,42 @@ module IsoDoc
103
105
  def draftinfo(draft, revdate)
104
106
  draftinfo = ""
105
107
  if draft
106
- draftinfo = " (draft #{draft.text}"
108
+ draftinfo = " (#{@draft_lbl} #{draft.text}"
107
109
  draftinfo += ", #{revdate.text}" if revdate
108
110
  draftinfo += ")"
109
111
  end
110
- draftinfo
112
+ l10n(draftinfo)
111
113
  end
112
114
 
113
115
  def version(isoxml, _out)
114
- yr = isoxml.at(ns("//copyright/from"))
115
- set_metadata(:docyear, yr.text)
116
- draft = isoxml.at(ns("//version/draft"))
117
- set_metadata(:draft, draft.nil? ? nil : draft.text)
118
- revdate = isoxml.at(ns("//version/revision-date"))
119
- set_metadata(:revdate, revdate.nil? ? nil : revdate.text)
120
- draftinfo = draftinfo(draft, revdate)
121
- set_metadata(:draftinfo, draftinfo(draft, revdate))
122
- end
123
-
116
+ set_metadata(:docyear, isoxml&.at(ns("//copyright/from"))&.text)
117
+ # draft = isoxml.at(ns("//version/draft"))
118
+ # set_metadata(:draft, draft.nil? ? nil : draft.text)
119
+ set_metadata(:draft, isoxml&.at(ns("//version/draft"))&.text)
120
+ # revdate = isoxml.at(ns("//version/revision-date"))
121
+ #set_metadata(:revdate, revdate.nil? ? nil : revdate.text)
122
+ set_metadata(:revdate, isoxml&.at(ns("//version/revision-date"))&.text)
123
+ #set_metadata(:draftinfo, draftinfo(draft, revdate))
124
+ set_metadata(:draftinfo,
125
+ draftinfo(get_metadata[:draft], get_metadata[:revdate]))
126
+ end
127
+
128
+ # we don't leave this to i18n.rb, because we have both English and
129
+ # French titles in the same document
124
130
  def part_label(lang)
125
131
  case lang
126
132
  when "en" then "Part"
127
- when "fr" then "Part"
133
+ when "fr" then "Partie"
128
134
  end
129
135
  end
130
136
 
131
- def compose_title(main, intro, part, partnum, lang)
132
- c = HTMLEntities.new
133
- main = c.encode(main.text, :hexadecimal)
137
+ def compose_title(main, intro, part, partnum, subpartnum, lang)
138
+ main = main.nil? ? "" : @c.encode(main.text, :hexadecimal)
134
139
  intro &&
135
- main = "#{c.encode(intro.text, :hexadecimal)}&nbsp;&mdash; #{main}"
140
+ main = "#{@c.encode(intro.text, :hexadecimal)}&nbsp;&mdash; #{main}"
136
141
  if part
137
- suffix = c.encode(part.text, :hexadecimal)
142
+ suffix = @c.encode(part.text, :hexadecimal)
143
+ partnum = "#{partnum}&ndash;#{subpartnum}" if partnum && subpartnum
138
144
  suffix = "#{part_label(lang)}&nbsp;#{partnum}: " + suffix if partnum
139
145
  main = "#{main}&nbsp;&mdash; #{suffix}"
140
146
  end
@@ -146,7 +152,8 @@ module IsoDoc
146
152
  main = isoxml.at(ns("//title-main[@language='en']"))
147
153
  part = isoxml.at(ns("//title-part[@language='en']"))
148
154
  partnumber = isoxml.at(ns("//project-number/@part"))
149
- main = compose_title(main, intro, part, partnumber, "en")
155
+ subpartnumber = isoxml.at(ns("//project-number/@subpart"))
156
+ main = compose_title(main, intro, part, partnumber, subpartnumber, "en")
150
157
  set_metadata(:doctitle, main)
151
158
  end
152
159
 
@@ -155,8 +162,17 @@ module IsoDoc
155
162
  main = isoxml.at(ns("//title-main[@language='fr']"))
156
163
  part = isoxml.at(ns("//title-part[@language='fr']"))
157
164
  partnumber = isoxml.at(ns("//project-number/@part"))
158
- main = compose_title(main, intro, part, partnumber, "fr")
165
+ subpartnumber = isoxml.at(ns("//project-number/@subpart"))
166
+ main = compose_title(main, intro, part, partnumber, subpartnumber, "fr")
159
167
  set_metadata(:docsubtitle, main)
160
168
  end
169
+
170
+ def relations(isoxml, _out)
171
+ std = isoxml.at(ns("//bibdata/relation[@type = 'obsoletes']")) || return
172
+ locality = std.at(ns(".//locality"))
173
+ id = std.at(ns(".//docidentifier"))
174
+ set_metadata(:obsoletes, id.text)
175
+ set_metadata(:obsoletes_part, locality.text)
176
+ end
161
177
  end
162
178
  end
@@ -40,7 +40,7 @@ module IsoDoc
40
40
  end.join("\n")
41
41
  end
42
42
 
43
- def make_generic_footnote_text(node, fnid, fn_ref)
43
+ def make_generic_footnote_text(node, fnid)
44
44
  noko do |xml|
45
45
  xml.aside **{ id: "ftn#{fnid}" } do |div|
46
46
  node.children.each { |n| parse(n, div) }
@@ -69,12 +69,12 @@ module IsoDoc
69
69
  def footnote_parse(node, out)
70
70
  return table_footnote_parse(node, out) if @in_table || @in_figure
71
71
  fn = node["reference"]
72
- out.a **{"epub:type": "footnote", href: "#ftn#{fn}" } do |a|
72
+ out.a **{ "epub:type": "footnote", href: "#ftn#{fn}" } do |a|
73
73
  a.sup { |sup| sup << fn }
74
74
  end
75
- return if @seen_footnote.include?(fn)
75
+ return if @seen_footnote.include?(fn)
76
76
  @in_footnote = true
77
- @footnotes << make_generic_footnote_text(node, fn, fn)
77
+ @footnotes << make_generic_footnote_text(node, fn)
78
78
  @in_footnote = false
79
79
  @seen_footnote << fn
80
80
  end
@@ -94,28 +94,28 @@ module IsoDoc
94
94
  @in_comment = false
95
95
  end
96
96
 
97
+ def comment_link_attrs(fn, node)
98
+ { style: "MsoCommentReference", target: fn,
99
+ class: "commentLink", from: node["from"],
100
+ to: node["to"] }
101
+ end
102
+
97
103
  # add in from and to links to move the comment into place
98
104
  def make_comment_link(out, fn, node)
99
- out.span **{ style: "MsoCommentReference", target: fn,
100
- class: "commentLink", from: node['from'],
101
- to: node['to']} do |s1|
102
- s1.span **{ lang: "EN-GB", style: "font-size:9.0pt"} do |s2|
103
- s2.a **{ style: "mso-comment-reference:SMC_#{fn};"\
104
- "mso-comment-date:#{node['date']}"}
105
- s2.span **{ style: "mso-special-character:comment",
106
- target: fn } # do |s|
107
- #s << "&nbsp;"
108
- #end
109
- end
110
- end
105
+ out.span(**comment_link_attrs(fn, node)) do |s1|
106
+ s1.span **{ lang: "EN-GB", style: "font-size:9.0pt" } do |s2|
107
+ s2.a **{ style: "mso-comment-reference:SMC_#{fn};"\
108
+ "mso-comment-date:#{node['date']}" }
109
+ s2.span **{ style: "mso-special-character:comment",
110
+ target: fn } # do |s|
111
+ end
112
+ end
111
113
  end
112
114
 
113
115
  def make_comment_target(out)
114
116
  out.span **{ style: "MsoCommentReference" } do |s1|
115
- s1.span **{ lang: "EN-GB", style: "font-size:9.0pt"} do |s2|
116
- s2.span **{ style: "mso-special-character:comment" } # do |s|
117
- # s << "&nbsp;"
118
- # end
117
+ s1.span **{ lang: "EN-GB", style: "font-size:9.0pt" } do |s2|
118
+ s2.span **{ style: "mso-special-character:comment" }
119
119
  end
120
120
  end
121
121
  end
@@ -123,7 +123,7 @@ module IsoDoc
123
123
  def make_comment_text(node, fn)
124
124
  noko do |xml|
125
125
  xml.div **{ style: "mso-element:comment", id: fn } do |div|
126
- div.span **{ style: %{mso-comment-author:"#{node["reviewer"]}"} }
126
+ div.span **{ style: %{mso-comment-author:"#{node['reviewer']}"} }
127
127
  make_comment_target(div)
128
128
  node.children.each { |n| parse(n, div) }
129
129
  end
@@ -138,7 +138,7 @@ module IsoDoc
138
138
 
139
139
  COMMENT_IN_COMMENT_LIST =
140
140
  '//div[@style="mso-element:comment-list"]//'\
141
- 'span[@style="MsoCommentReference"]'
141
+ 'span[@style="MsoCommentReference"]'.freeze
142
142
 
143
143
  def embed_comment_in_comment_list(docxml)
144
144
  docxml.xpath(COMMENT_IN_COMMENT_LIST).each do |x|
@@ -148,7 +148,7 @@ module IsoDoc
148
148
  docxml
149
149
  end
150
150
 
151
- def move_comment_link_to_from1(x, fromlink, docxml)
151
+ def move_comment_link_to_from1(x, fromlink)
152
152
  x.remove
153
153
  link = x.at(".//a")
154
154
  fromlink.replace(x)
@@ -156,10 +156,10 @@ module IsoDoc
156
156
  end
157
157
 
158
158
  def comment_attributes(docxml, x)
159
- fromlink = docxml.at("//*[@id='#{x["from"]}']")
159
+ fromlink = docxml.at("//*[@id='#{x['from']}']")
160
160
  return(nil) if fromlink.nil?
161
- tolink = docxml.at("//*[@id='#{x["to"]}']") || fromlink
162
- target = docxml.at("//*[@id='#{x["target"]}']")
161
+ tolink = docxml.at("//*[@id='#{x['to']}']") || fromlink
162
+ target = docxml.at("//*[@id='#{x['target']}']")
163
163
  { from: fromlink, to: tolink, target: target }
164
164
  end
165
165
 
@@ -172,7 +172,7 @@ module IsoDoc
172
172
  from["style"] != "mso-special-character:comment"
173
173
  end
174
174
 
175
- def insert_comment_cont(from, to, target, docxml)
175
+ def insert_comment_cont(from, to, target)
176
176
  # includes_to = from.at(".//*[@id='#{to}']")
177
177
  while !from.nil? && from["id"] != to
178
178
  following = from.xpath("./following::*")
@@ -187,8 +187,8 @@ module IsoDoc
187
187
  def move_comment_link_to_from(docxml)
188
188
  docxml.xpath('//span[@style="MsoCommentReference"][@from]').each do |x|
189
189
  attrs = comment_attributes(docxml, x) || next
190
- move_comment_link_to_from1(x, attrs[:from], docxml)
191
- insert_comment_cont(attrs[:from], x["to"], x["target"], docxml)
190
+ move_comment_link_to_from1(x, attrs[:from])
191
+ insert_comment_cont(attrs[:from], x["to"], x["target"])
192
192
  end
193
193
  end
194
194
 
@@ -199,11 +199,11 @@ module IsoDoc
199
199
  comments << { text: c.remove.to_s, id: c["id"] }
200
200
  end
201
201
  comments.sort! { |a, b| link_order[a[:id]] <=> link_order[b[:id]] }
202
- comments
202
+ # comments
203
203
  end
204
204
 
205
205
  COMMENT_TARGET_XREFS =
206
- "//span[@style='mso-special-character:comment']/@target"
206
+ "//span[@style='mso-special-character:comment']/@target".freeze
207
207
 
208
208
  def reorder_comments_by_comment_link(docxml)
209
209
  link_order = {}
@@ -211,7 +211,7 @@ module IsoDoc
211
211
  link_order[target.value] = i
212
212
  end
213
213
  comments = get_comments_from_text(docxml, link_order)
214
- list = docxml.at("//*[@style='mso-element:comment-list']") or return
214
+ list = docxml.at("//*[@style='mso-element:comment-list']") || return
215
215
  list.children = comments.map { |c| c[:text] }.join("\n")
216
216
  end
217
217
  end
@@ -6,7 +6,6 @@ require "pp"
6
6
 
7
7
  module IsoDoc
8
8
  class Convert
9
-
10
9
  def postprocess(result, filename, dir)
11
10
  generate_header(filename, dir)
12
11
  result = from_xhtml(cleanup(to_xhtml(result)))
@@ -15,49 +14,70 @@ module IsoDoc
15
14
  end
16
15
 
17
16
  def toWord(result, filename, dir)
18
- result = from_xhtml(wordCleanup(to_xhtml(result)))
17
+ result = from_xhtml(word_cleanup(to_xhtml(result)))
19
18
  result = populate_template(result, :word)
20
- Html2Doc.process(result, filename, @wordstylesheet, "header.html",
21
- dir, ['`', '`'])
19
+ Html2Doc.process(result, filename: filename, stylesheet: @wordstylesheet,
20
+ header_file: "header.html", dir: dir,
21
+ asciimathdelims: [@openmathdelim, @closemathdelim],
22
+ liststyles: { ul: @ulstyle, ol: @olstyle })
22
23
  end
23
24
 
24
- def wordCleanup(docxml)
25
- wordPreface(docxml)
26
- wordAnnexCleanup(docxml)
25
+ def word_cleanup(docxml)
26
+ word_preface(docxml)
27
+ word_annex_cleanup(docxml)
28
+ word_dl_cleanup(docxml)
27
29
  docxml
28
30
  end
29
31
 
32
+ def word_dl_cleanup1(dtd, tr)
33
+ dtd[:dt].name = "td"
34
+ dtd[:dt]["valign"] = "top"
35
+ dtd[:dt].parent = tr
36
+ dtd[:dd].name = "td"
37
+ dtd[:dd]["valign"] = "top"
38
+ dtd[:dd].parent = tr
39
+ end
40
+
41
+ def word_dl_cleanup(docxml)
42
+ docxml.xpath("//dl").each do |dl|
43
+ dl.name = "table"
44
+ extract_symbols_list(dl).each do |dtd|
45
+ tr = dl.add_child("<tr></tr>").first
46
+ word_dl_cleanup1(dtd, tr)
47
+ end
48
+ end
49
+ end
50
+
30
51
  # force Annex h2 to be p.h2Annex, so it is not picked up by ToC
31
- def wordAnnexCleanup(docxml)
32
- d = docxml.xpath("//h2[ancestor::*[@class = 'Section3']]").each do |h2|
52
+ def word_annex_cleanup(docxml)
53
+ docxml.xpath("//h2[ancestor::*[@class = 'Section3']]").each do |h2|
33
54
  h2.name = "p"
34
55
  h2["class"] = "h2Annex"
35
56
  end
36
57
  end
37
58
 
38
- def wordPreface(docxml)
59
+ def word_preface(docxml)
39
60
  cover = to_xhtml_fragment(File.read(@wordcoverpage, encoding: "UTF-8"))
40
- d = docxml.at('//div[@class="WordSection1"]')
41
- d.children.first.add_previous_sibling cover.to_xml(encoding: 'US-ASCII')
42
- intro = to_xhtml_fragment(
43
- File.read(@wordintropage, encoding: "UTF-8").
44
- sub(/WORDTOC/, makeWordToC(docxml)))
45
- d = docxml.at('//div[@class="WordSection2"]')
46
- d.children.first.add_previous_sibling intro.to_xml(encoding: 'US-ASCII')
61
+ docxml.at('//div[@class="WordSection1"]').children.first.previous =
62
+ cover.to_xml(encoding: "US-ASCII")
63
+ intro = to_xhtml_fragment(File.read(@wordintropage, encoding: "UTF-8").
64
+ sub(/WORDTOC/, make_WordToC(docxml)))
65
+ docxml.at('//div[@class="WordSection2"]').children.first.previous =
66
+ intro.to_xml(encoding: "US-ASCII")
47
67
  end
48
68
 
49
69
  def populate_template(docxml, _format)
50
70
  meta = get_metadata
51
- docxml.
52
- gsub(/\[TERMREF\]\s*/, "[SOURCE: ").
53
- gsub(/\s*\[\/TERMREF\]\s*/, "]").
54
- gsub(/\s*\[ISOSECTION\]/, ", ").
55
- gsub(/\s*\[MODIFICATION\]/, ", modified &mdash; ")
71
+ docxml = docxml.
72
+ gsub(/\[TERMREF\]\s*/, l10n("[#{@source_lbl}: ")).
73
+ gsub(/\s*\[\/TERMREF\]\s*/, l10n("]")).
74
+ gsub(/\s*\[ISOSECTION\]/, l10n(", ")).
75
+ gsub(/\s*\[MODIFICATION\]/, l10n(", #{@modified_lbl} &mdash; "))
56
76
  template = Liquid::Template.parse(docxml)
57
77
  template.render(meta.map { |k, v| [k.to_s, v] }.to_h)
58
78
  end
59
79
 
60
- def generate_header(filename, dir)
80
+ def generate_header(filename, _dir)
61
81
  template = Liquid::Template.parse(File.read(@header, encoding: "UTF-8"))
62
82
  meta = get_metadata
63
83
  meta[:filename] = filename
@@ -76,9 +96,10 @@ module IsoDoc
76
96
 
77
97
  # isodoc.css overrides any CSS injected by Html2Doc, which
78
98
  # is inserted before this CSS.
79
- def define_head(html, filename, dir)
99
+ def define_head(html, filename, _dir)
80
100
  html.head do |head|
81
101
  head.title { |t| t << filename }
102
+ return unless @standardstylesheet
82
103
  head.style do |style|
83
104
  stylesheet = File.read(@standardstylesheet).
84
105
  gsub("FILENAME", filename)
@@ -92,50 +113,49 @@ module IsoDoc
92
113
  div.parent.add_child titlepage
93
114
  end
94
115
 
95
- def wordTocEntry(toclevel, heading)
116
+ def word_toc_entry(toclevel, heading)
96
117
  bookmark = Random.rand(1000000000)
97
118
  <<~TOC
98
- <p class="MsoToc#{toclevel}"><span class="MsoHyperlink"><span
99
- lang="EN-GB" style='mso-no-proof:yes'>
100
- <a href="#_Toc#{bookmark}">#{heading}<span lang="EN-GB"
101
- class="MsoTocTextSpan">
119
+ <p class="MsoToc#{toclevel}"><span class="MsoHyperlink"><span
120
+ lang="EN-GB" style='mso-no-proof:yes'>
121
+ <a href="#_Toc#{bookmark}">#{heading}<span lang="EN-GB"
122
+ class="MsoTocTextSpan">
102
123
  <span style='mso-tab-count:1 dotted'>. </span>
103
- </span><span lang="EN-GB" class="MsoTocTextSpan">
124
+ </span><span lang="EN-GB" class="MsoTocTextSpan">
104
125
  <span style='mso-element:field-begin'></span></span>
105
- <span lang="EN-GB"
126
+ <span lang="EN-GB"
106
127
  class="MsoTocTextSpan"> PAGEREF _Toc#{bookmark} \\h </span>
107
128
  <span lang="EN-GB" class="MsoTocTextSpan"><span
108
129
  style='mso-element:field-separator'></span></span><span
109
130
  lang="EN-GB" class="MsoTocTextSpan">1</span>
110
- <span lang="EN-GB"
111
- class="MsoTocTextSpan"></span><span
131
+ <span lang="EN-GB"
132
+ class="MsoTocTextSpan"></span><span
112
133
  lang="EN-GB" class="MsoTocTextSpan"><span
113
134
  style='mso-element:field-end'></span></span></a></span></span></p>
114
135
 
115
136
  TOC
116
137
  end
117
138
 
118
- WORD_TOC_PREFACE = <<~TOC
139
+ WORD_TOC_PREFACE = <<~TOC.freeze
119
140
  <span lang="EN-GB"><span
120
- style='mso-element:field-begin'></span><span
141
+ style='mso-element:field-begin'></span><span
121
142
  style='mso-spacerun:yes'>&#xA0;</span>TOC
122
- \\o &quot;1-2&quot; \\h \\z \\u <span
143
+ \\o &quot;1-2&quot; \\h \\z \\u <span
123
144
  style='mso-element:field-separator'></span></span>
124
145
  TOC
125
146
 
126
- WORD_TOC_SUFFIX = <<~TOC
127
- <p class="MsoToc1"><span lang="EN-GB"><span
128
- style='mso-element:field-end'></span></span><span
147
+ WORD_TOC_SUFFIX = <<~TOC.freeze
148
+ <p class="MsoToc1"><span lang="EN-GB"><span
149
+ style='mso-element:field-end'></span></span><span
129
150
  lang="EN-GB"><o:p>&nbsp;</o:p></span></p>
130
151
  TOC
131
152
 
132
153
  def header_strip(h)
133
154
  h = h.to_s.gsub(%r{<br/>}, " ").
134
155
  sub(/<h[12][^>]*>/, "").sub(%r{</h[12]>}, "")
135
- h1 = to_xhtml_fragment(h)
136
- #h1.xpath(".//*[@style = 'MsoCommentReference']").each do |x|
156
+ h1 = to_xhtml_fragment(h)
137
157
  h1.xpath(".//*").each do |x|
138
- if x.name == "span" && x['style'] == "MsoCommentReference"
158
+ if x.name == "span" && x["style"] == "MsoCommentReference"
139
159
  x.children.remove
140
160
  x.content = ""
141
161
  end
@@ -143,15 +163,14 @@ module IsoDoc
143
163
  from_xhtml(h1)
144
164
  end
145
165
 
146
- def makeWordToC(docxml)
166
+ def make_WordToC(docxml)
147
167
  toc = ""
148
168
  docxml.xpath("//h1 | //h2[not(ancestor::*[@class = 'Section3'])]").
149
169
  each do |h|
150
- toc += wordTocEntry(h.name == "h1" ? 1 : 2, header_strip(h))
170
+ toc += word_toc_entry(h.name == "h1" ? 1 : 2, header_strip(h))
151
171
  end
152
- toc.sub(/(<p class="MsoToc1">)/,
172
+ toc.sub(/(<p class="MsoToc1">)/,
153
173
  %{\\1#{WORD_TOC_PREFACE}}) + WORD_TOC_SUFFIX
154
174
  end
155
-
156
175
  end
157
176
  end