isodoc 0.5.8 → 0.5.9

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.tb.yml +20 -10
  3. data/lib/isodoc/blocks.rb +13 -13
  4. data/lib/isodoc/cleanup.rb +19 -3
  5. data/lib/isodoc/comments.rb +1 -1
  6. data/lib/isodoc/convert.rb +2 -0
  7. data/lib/isodoc/footnotes.rb +4 -2
  8. data/lib/isodoc/html.rb +28 -10
  9. data/lib/isodoc/i18n-en.yaml +9 -0
  10. data/lib/isodoc/i18n-fr.yaml +12 -3
  11. data/lib/isodoc/i18n-zh-Hans.yaml +10 -1
  12. data/lib/isodoc/i18n.rb +9 -2
  13. data/lib/isodoc/inline.rb +5 -6
  14. data/lib/isodoc/iso2wordhtml.rb +9 -6
  15. data/lib/isodoc/lists.rb +7 -5
  16. data/lib/isodoc/metadata.rb +27 -10
  17. data/lib/isodoc/references.rb +12 -6
  18. data/lib/isodoc/section.rb +17 -11
  19. data/lib/isodoc/table.rb +2 -4
  20. data/lib/isodoc/terms.rb +3 -3
  21. data/lib/isodoc/utils.rb +15 -14
  22. data/lib/isodoc/version.rb +1 -1
  23. data/lib/isodoc/wordconvert/comments.rb +1 -1
  24. data/lib/isodoc/wordconvert/wordconvertmodule.rb +51 -12
  25. data/lib/isodoc/xref_gen.rb +30 -26
  26. data/lib/isodoc/xref_sect_gen.rb +31 -13
  27. data/spec/assets/scripts.html +1 -0
  28. data/spec/isodoc/blocks_spec.rb +50 -49
  29. data/spec/isodoc/cleanup_spec.rb +6 -6
  30. data/spec/isodoc/footnotes_spec.rb +10 -2
  31. data/spec/isodoc/i18n_spec.rb +86 -54
  32. data/spec/isodoc/inline_spec.rb +22 -18
  33. data/spec/isodoc/lists_spec.rb +25 -11
  34. data/spec/isodoc/metadata_spec.rb +4 -3
  35. data/spec/isodoc/postproc_spec.rb +108 -42
  36. data/spec/isodoc/ref_spec.rb +9 -7
  37. data/spec/isodoc/section_spec.rb +162 -141
  38. data/spec/isodoc/table_spec.rb +18 -16
  39. data/spec/isodoc/terms_spec.rb +9 -9
  40. data/spec/isodoc/xref_spec.rb +153 -122
  41. metadata +3 -2
@@ -33,13 +33,13 @@ module IsoDoc
33
33
  end
34
34
 
35
35
  def get_linkend(node)
36
- linkend = anchor_linkend(node, node["target"] || node["citeas"])
37
- linkend += eref_localities(node.xpath(ns("./locality")))
36
+ link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
37
+ link += eref_localities(node.xpath(ns("./locality")))
38
38
  text = node.children.select { |c| c.text? && !c.text.empty? }
39
- linkend = text.join(" ") unless text.nil? || text.empty?
39
+ link = text.join(" ") unless text.nil? || text.empty?
40
40
  # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
41
41
  # <locality type="section"><reference>3.1</reference></locality></origin>
42
- linkend
42
+ link
43
43
  end
44
44
 
45
45
  def xref_parse(node, out)
@@ -50,8 +50,7 @@ module IsoDoc
50
50
  def eref_localities(refs)
51
51
  ret = ""
52
52
  refs.each do |r|
53
- ret += if r["type"] == "whole"
54
- l10n(", #{@whole_of_text}")
53
+ ret += if r["type"] == "whole" then l10n(", #{@whole_of_text}")
55
54
  else
56
55
  eref_localities1(r["type"], r.at(ns("./referenceFrom")),
57
56
  r.at(ns("./referenceTo")), @lang)
@@ -82,7 +82,9 @@ module IsoDoc
82
82
  def info(isoxml, out)
83
83
  title isoxml, out
84
84
  subtitle isoxml, out
85
- id isoxml, out
85
+ docstatus isoxml, out
86
+ docid isoxml, out
87
+ doctype isoxml, out
86
88
  author isoxml, out
87
89
  bibdate isoxml, out
88
90
  relations isoxml, out
@@ -97,10 +99,10 @@ module IsoDoc
97
99
 
98
100
  def middle(isoxml, out)
99
101
  middle_title(out)
100
- scope isoxml, out
101
- norm_ref isoxml, out
102
- terms_defs isoxml, out
103
- symbols_abbrevs isoxml, out
102
+ i = scope isoxml, out, 0
103
+ i = norm_ref isoxml, out, i
104
+ i = terms_defs isoxml, out, i
105
+ i = symbols_abbrevs isoxml, out, i
104
106
  clause isoxml, out
105
107
  annex isoxml, out
106
108
  bibliography isoxml, out
@@ -142,7 +144,8 @@ module IsoDoc
142
144
  when "callout" then callout_parse(node, out)
143
145
  when "stem" then stem_parse(node, out)
144
146
  when "clause" then clause_parse(node, out)
145
- when "subsection" then clause_parse(node, out)
147
+ # when "subclause" then clause_parse(node, out)
148
+ when "appendix" then clause_parse(node, out)
146
149
  when "xref" then xref_parse(node, out)
147
150
  when "eref" then eref_parse(node, out)
148
151
  when "origin" then eref_parse(node, out)
@@ -22,7 +22,6 @@ module IsoDoc
22
22
  # We don't really want users to specify type of ordered list;
23
23
  # we will use a fixed hierarchy as practiced by ISO (though not
24
24
  # fully spelled out): a) 1) i) A) I)
25
- #
26
25
 
27
26
  def ol_depth(node)
28
27
  depth = node.ancestors("ul, ol").size + 1
@@ -58,17 +57,20 @@ module IsoDoc
58
57
  end
59
58
  end
60
59
 
60
+ def dt_dd?(n)
61
+ %w{dt dd}.include? n.name
62
+ end
63
+
61
64
  def dl_parse(node, out)
62
65
  out.dl do |v|
63
- node.elements.each_slice(2) do |dt, dd|
64
- v.dt do |term|
65
- dt_parse(dt, term)
66
- end
66
+ node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
67
+ v.dt { |term| dt_parse(dt, term) }
67
68
  v.dd do |listitem|
68
69
  dd.children.each { |n| parse(n, listitem) }
69
70
  end
70
71
  end
71
72
  end
73
+ node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, out) }
72
74
  end
73
75
  end
74
76
  end
@@ -2,15 +2,16 @@ require "htmlentities"
2
2
 
3
3
  module IsoDoc
4
4
  class Convert
5
+ DATETYPES = %w{published accessed created implemented obsoleted confirmed
6
+ updated issued}.freeze
7
+
5
8
  def init_metadata
6
9
  @meta = { tc: "XXXX", sc: "XXXX", wg: "XXXX",
7
10
  editorialgroup: [],
8
11
  secretariat: "XXXX",
9
12
  obsoletes: nil,
10
13
  obsoletes_part: nil }
11
- %w{published accessed created activated obsoleted}.each do |w|
12
- @meta["#{w}date".to_sym] = "XXX"
13
- end
14
+ DATETYPES.each { |w| @meta["#{w}date".to_sym] = "XXX" }
14
15
  end
15
16
 
16
17
  def get_metadata
@@ -79,6 +80,13 @@ module IsoDoc
79
80
  end
80
81
  end
81
82
 
83
+ def doctype(isoxml, _out)
84
+ b = isoxml.at(ns("//bibdata")) || return
85
+ return unless b["type"]
86
+ t = b["type"].split(/-/).map{ |w| w.capitalize }.join(" ")
87
+ set_metadata(:doctype, t)
88
+ end
89
+
82
90
  def iso?(org)
83
91
  name = org&.at(ns("./name"))&.text
84
92
  abbrev = org&.at(ns("./abbreviation"))&.text
@@ -108,14 +116,23 @@ module IsoDoc
108
116
  dn
109
117
  end
110
118
 
111
- def id(isoxml, _out)
112
- dn = docnumber(isoxml)
113
- documentstatus = isoxml.at(ns("//status/stage"))
114
- if documentstatus
115
- set_metadata(:stage, documentstatus.text)
116
- abbr = stage_abbreviation(documentstatus.text)
119
+ def docstatus(isoxml, _out)
120
+ docstatus = isoxml.at(ns("//status/stage"))
121
+ if docstatus
122
+ set_metadata(:stage, docstatus.text)
123
+ abbr = stage_abbrev(docstatus.text, isoxml.at(ns("//status/iteration")),
124
+ isoxml.at(ns("//version/draft")))
117
125
  set_metadata(:stageabbr, abbr)
118
- (documentstatus.text.to_i < 60) && dn = abbr + " " + dn
126
+ end
127
+ end
128
+
129
+ def docid(isoxml, _out)
130
+ dn = docnumber(isoxml)
131
+ docstatus = get_metadata[:stage]
132
+ if docstatus
133
+ abbr = get_metadata[:stageabbr]
134
+ docstatus = get_metadata[:stage]
135
+ (docstatus.to_i < 60) && dn = abbr + " " + dn
119
136
  end
120
137
  set_metadata(:docnumber, dn)
121
138
  end
@@ -1,6 +1,7 @@
1
1
  module IsoDoc
2
2
  class Convert
3
3
  def docid_l10n(x)
4
+ return x if x.nil?
4
5
  x.gsub(/All Parts/, @all_parts_lbl)
5
6
  end
6
7
 
@@ -106,19 +107,24 @@ module IsoDoc
106
107
  div.p pref
107
108
  end
108
109
 
109
- def norm_ref(isoxml, out)
110
- q = "./*/references[title = 'Normative References']"
111
- f = isoxml.at(ns(q)) || return
110
+ def norm_ref(isoxml, out, num)
111
+ q = "//bibliography/references[title = 'Normative References']"
112
+ f = isoxml.at(ns(q)) or return num
112
113
  out.div do |div|
113
- clause_name("2.", @normref_lbl, div, nil)
114
+ num = num + 1
115
+ clause_name("#{num}.", @normref_lbl, div, nil)
114
116
  norm_ref_preface(f, div)
115
117
  biblio_list(f, div, false)
116
118
  end
119
+ num
117
120
  end
118
121
 
122
+ BIBLIOGRAPHY_XPATH = "//bibliography/clause[title = 'Bibliography'] | "\
123
+ "//bibliography/references[title = 'Bibliography']".freeze
124
+
125
+
119
126
  def bibliography(isoxml, out)
120
- q = "//clause[title = 'Bibliography'][descendant::references] | //references[title = 'Bibliography']"
121
- f = isoxml.at(ns(q)) || return
127
+ f = isoxml.at(ns(BIBLIOGRAPHY_XPATH)) || return
122
128
  page_break(out)
123
129
  out.div do |div|
124
130
  div.h1 @bibliography_lbl, **{ class: "Section3" }
@@ -83,14 +83,16 @@ module IsoDoc
83
83
  end
84
84
  end
85
85
 
86
- def scope(isoxml, out)
87
- f = isoxml.at(ns("//clause[title = 'Scope']")) || return
86
+ def scope(isoxml, out, num)
87
+ f = isoxml.at(ns("//clause[title = 'Scope']")) or return num
88
88
  out.div **attr_code(id: f["id"]) do |div|
89
- clause_name("1.", @scope_lbl, div, nil)
89
+ num = num + 1
90
+ clause_name("#{num}.", @scope_lbl, div, nil)
90
91
  f.elements.each do |e|
91
92
  parse(e, div) unless e.name == "title"
92
93
  end
93
94
  end
95
+ num
94
96
  end
95
97
 
96
98
  def external_terms_boilerplate(sources)
@@ -111,7 +113,7 @@ module IsoDoc
111
113
  end
112
114
 
113
115
  def term_defs_boilerplate_cont(src, term)
114
- sources = sentence_join(src.map { |s| s["citeas"] })
116
+ sources = sentence_join(src.map { |s| @anchors[s["target"]][:xref] })
115
117
  if src.empty?
116
118
  @internal_terms_boilerplate
117
119
  elsif term.nil?
@@ -130,16 +132,18 @@ module IsoDoc
130
132
  TERM_CLAUSE = "//sections/terms | "\
131
133
  "//sections/clause[descendant::terms]".freeze
132
134
 
133
- def terms_defs(isoxml, out)
134
- f = isoxml.at(ns(TERM_CLAUSE)) || return
135
+ def terms_defs(isoxml, out, num)
136
+ f = isoxml.at(ns(TERM_CLAUSE)) or return num
135
137
  out.div **attr_code(id: f["id"]) do |div|
136
- clause_name("3.", terms_defs_title(f), div, nil)
138
+ num = num + 1
139
+ clause_name("#{num}.", terms_defs_title(f), div, nil)
137
140
  term_defs_boilerplate(div, isoxml.xpath(ns(".//termdocsource")),
138
141
  f.at(ns(".//term")))
139
142
  f.elements.each do |e|
140
143
  parse(e, div) unless %w{title source}.include? e.name
141
144
  end
142
145
  end
146
+ num
143
147
  end
144
148
 
145
149
  # subclause
@@ -147,14 +151,16 @@ module IsoDoc
147
151
  clause_parse(isoxml, out)
148
152
  end
149
153
 
150
- def symbols_abbrevs(isoxml, out)
151
- f = isoxml.at(ns("//sections/symbols-abbrevs")) || return
154
+ def symbols_abbrevs(isoxml, out, num)
155
+ f = isoxml.at(ns("//sections/symbols-abbrevs")) or return num
152
156
  out.div **attr_code(id: f["id"], class: "Symbols") do |div|
153
- clause_name("4.", @symbols_lbl, div, nil)
157
+ num = num + 1
158
+ clause_name("#{num}.", @symbols_lbl, div, nil)
154
159
  f.elements.each do |e|
155
160
  parse(e, div) unless e.name == "title"
156
161
  end
157
162
  end
163
+ num
158
164
  end
159
165
 
160
166
  # subclause
@@ -166,7 +172,7 @@ module IsoDoc
166
172
 
167
173
  def introduction(isoxml, out)
168
174
  f = isoxml.at(ns("//introduction")) || return
169
- num = f.at(ns(".//subsection")) ? "0." : nil
175
+ num = f.at(ns(".//clause")) ? "0." : nil
170
176
  title_attr = { class: "IntroTitle" }
171
177
  page_break(out)
172
178
  out.div **{ class: "Section3", id: f["id"] } do |div|
@@ -3,10 +3,8 @@ module IsoDoc
3
3
  def table_title_parse(node, out)
4
4
  name = node.at(ns("./name"))
5
5
  out.p **{ class: "TableTitle", align: "center" } do |p|
6
- p.b do |b|
7
- b << l10n("#{@table_lbl} #{get_anchors[node['id']][:label]}")
8
- b << l10n("&nbsp;&mdash; #{name.text}") if name
9
- end
6
+ p << l10n("#{@table_lbl} #{get_anchors[node['id']][:label]}")
7
+ p << l10n("&nbsp;&mdash; #{name.text}") if name
10
8
  end
11
9
  end
12
10
 
@@ -11,20 +11,20 @@ module IsoDoc
11
11
  end
12
12
 
13
13
  def deprecated_term_parse(node, out)
14
- out.p **{ class: "DeprecatedTerms" } do |p|
14
+ out.p **{ class: "DeprecatedTerms", style:"text-align:left;" } do |p|
15
15
  p << l10n("#{@deprecated_lbl}: ")
16
16
  node.children.each { |c| parse(c, p) }
17
17
  end
18
18
  end
19
19
 
20
20
  def admitted_term_parse(node, out)
21
- out.p **{ class: "AltTerms" } do |p|
21
+ out.p **{ class: "AltTerms", style:"text-align:left;" } do |p|
22
22
  node.children.each { |c| parse(c, p) }
23
23
  end
24
24
  end
25
25
 
26
26
  def term_parse(node, out)
27
- out.p **{ class: "Terms" } do |p|
27
+ out.p **{ class: "Terms", style:"text-align:left;" } do |p|
28
28
  node.children.each { |c| parse(c, p) }
29
29
  end
30
30
  end
@@ -3,8 +3,8 @@ module IsoDoc
3
3
  def ns(xpath)
4
4
  xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1").
5
5
  gsub(%r{::([a-zA-z])}, "::xmlns:\\1").
6
- gsub(%r{\[([a-zA-z]+ ?=)}, "[xmlns:\\1").
7
- gsub(%r{\[([a-zA-z]+\])}, "[xmlns:\\1")
6
+ gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1").
7
+ gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1")
8
8
  end
9
9
 
10
10
  def insert_tab(out, n)
@@ -23,8 +23,11 @@ module IsoDoc
23
23
  "95": "(Withdrawal)",
24
24
  }.freeze
25
25
 
26
- def stage_abbreviation(stage)
27
- STAGE_ABBRS[stage.to_sym] || "??"
26
+ def stage_abbrev(stage, iter, draft)
27
+ stage = STAGE_ABBRS[stage.to_sym] || "??"
28
+ stage += iter.text if iter
29
+ stage = "Pre" + stage if draft&.text =~ /^0\./
30
+ stage
28
31
  end
29
32
 
30
33
  NOKOHEAD = <<~HERE.freeze
@@ -73,11 +76,10 @@ module IsoDoc
73
76
  end
74
77
 
75
78
  CLAUSE_ANCESTOR =
76
- ".//ancestor::*[local-name() = 'subsection' or "\
77
- "local-name() = 'foreword' or "\
79
+ ".//ancestor::*[local-name() = 'annex' or "\
80
+ "local-name() = 'appendix' or local-name() = 'foreword' or "\
78
81
  "local-name() = 'introduction' or local-name() = 'terms' or "\
79
- "local-name() = 'clause' or local-name() = 'references' or "\
80
- "local-name() = 'annex']/@id".freeze
82
+ "local-name() = 'clause' or local-name() = 'references']/@id".freeze
81
83
 
82
84
  def get_clause_id(node)
83
85
  clause = node.xpath(CLAUSE_ANCESTOR)
@@ -85,13 +87,12 @@ module IsoDoc
85
87
  end
86
88
 
87
89
  NOTE_CONTAINER_ANCESTOR =
88
- ".//ancestor::*[local-name() = 'subsection' or "\
89
- "local-name() = 'foreword' or "\
90
+ ".//ancestor::*[local-name() = 'annex' or "\
91
+ "local-name() = 'foreword' or local-name() = 'appendix' or "\
90
92
  "local-name() = 'introduction' or local-name() = 'terms' or "\
91
93
  "local-name() = 'clause' or local-name() = 'references' or "\
92
- "local-name() = 'annex' or local-name() = 'formula' or "\
93
- "local-name() = 'table' or local-name() = 'example' or "\
94
- "local-name() = 'figure']/@id".freeze
94
+ "local-name() = 'figure' or local-name() = 'formula' or "\
95
+ "local-name() = 'table' or local-name() = 'example']/@id".freeze
95
96
 
96
97
  def get_note_container_id(node)
97
98
  container = node.xpath(NOTE_CONTAINER_ANCESTOR)
@@ -132,7 +133,7 @@ module IsoDoc
132
133
  end
133
134
 
134
135
  def populate_template(docxml, _format)
135
- meta = get_metadata
136
+ meta = get_metadata.merge(@labels)
136
137
  docxml = docxml.
137
138
  gsub(/\[TERMREF\]\s*/, l10n("[#{@source_lbl}: ")).
138
139
  gsub(/\s*\[\/TERMREF\]\s*/, l10n("]")).
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "0.5.8".freeze
2
+ VERSION = "0.5.9".freeze
3
3
  end
@@ -36,7 +36,7 @@ def make_comment_link(out, fn, node)
36
36
  out.span(**comment_link_attrs(fn, node)) do |s1|
37
37
  s1.span **{ lang: "EN-GB", style: "font-size:9.0pt" } do |s2|
38
38
  s2.a **{ style: "mso-comment-reference:SMC_#{fn};"\
39
- "mso-comment-date:#{node['date']}" }
39
+ "mso-comment-date:#{node['date'].gsub(/[:-]+/, '')}" }
40
40
  s2.span **{ style: "mso-special-character:comment",
41
41
  target: fn } # do |s|
42
42
  end
@@ -71,20 +71,22 @@ def page_break(out)
71
71
  }
72
72
  end
73
73
 
74
+ WORD_DT_ATTRS = {class: @note ? "Note" : nil, align: "left",
75
+ style: "margin-left:0pt;text-align:left;"}.freeze
76
+
74
77
  def dt_parse(dt, term)
75
- if dt.elements.empty?
76
- term.p **attr_code(class: note? ? "Note" : nil,
77
- style: "text-align: left;") do |p|
78
+ term.p **attr_code(WORD_DT_ATTRS) do |p|
79
+ if dt.elements.empty?
78
80
  p << dt.text
81
+ else
82
+ dt.children.each { |n| parse(n, p) }
79
83
  end
80
- else
81
- dt.children.each { |n| parse(n, term) }
82
84
  end
83
85
  end
84
86
 
85
87
  def dl_parse(node, out)
86
88
  out.table **{ class: "dl" } do |v|
87
- node.elements.each_slice(2) do |dt, dd|
89
+ node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
88
90
  v.tr do |tr|
89
91
  tr.td **{ valign: "top", align: "left" } do |term|
90
92
  dt_parse(dt, term)
@@ -94,20 +96,52 @@ def dl_parse(node, out)
94
96
  end
95
97
  end
96
98
  end
99
+ dl_parse_notes(node, v)
97
100
  end
98
101
  end
99
102
 
103
+ def dl_parse_notes(node, v)
104
+ return if node.elements.reject { |n| dt_dd? n }.empty?
105
+ v.tr do |tr|
106
+ tr.td **{ rowspan: 2 } do |td|
107
+ node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, td) }
108
+ end
109
+ end
110
+ end
100
111
 
112
+ def figure_get_or_make_dl(t)
113
+ dl = t.at(".//table[@class = 'dl']")
114
+ if dl.nil?
115
+ t.add_child("<p><b>#{@key_lbl}</b></p><table class='dl'></table>")
116
+ dl = t.at(".//table[@class = 'dl']")
117
+ end
118
+ dl
119
+ end
120
+
121
+ def figure_aside_process(f, aside, key)
122
+ # get rid of footnote link, it is in diagram
123
+ f&.at("./a[@class='TableFootnoteRef']")&.remove
124
+ fnref = f.at(".//a[@class='TableFootnoteRef']")
125
+ tr = key.add_child("<tr></tr>").first
126
+ dt = tr.add_child("<td valign='top' align='left'></td>").first
127
+ dd = tr.add_child("<td valign='top'></td>").first
128
+ fnref.parent = dt
129
+ aside.xpath(".//p").each do |a|
130
+ a.delete("class")
131
+ a.parent = dd
132
+ end
133
+ end
101
134
 
102
135
  def postprocess(result, filename, dir)
103
136
  generate_header(filename, dir)
104
137
  result = from_xhtml(cleanup(to_xhtml(result)))
105
138
  toWord(result, filename, dir)
139
+ @files_to_delete.each { |f| system "rm #{f}" }
106
140
  end
107
141
 
108
142
  def toWord(result, filename, dir)
109
- result = from_xhtml(word_cleanup(to_xhtml(result)))
110
143
  result = populate_template(result, :word)
144
+ result = from_xhtml(word_cleanup(to_xhtml(result)))
111
145
  Html2Doc.process(result, filename: filename, stylesheet: @wordstylesheet,
112
146
  header_file: "header.html", dir: dir,
113
147
  asciimathdelims: [@openmathdelim, @closemathdelim],
@@ -134,16 +168,20 @@ def word_preface(docxml)
134
168
  end
135
169
 
136
170
  def word_cover(docxml)
137
- cover = to_xhtml_fragment(File.read(@wordcoverpage, encoding: "UTF-8"))
171
+ cover = File.read(@wordcoverpage, encoding: "UTF-8")
172
+ cover = populate_template(cover, :word)
173
+ coverxml = to_xhtml_fragment(cover)
138
174
  docxml.at('//div[@class="WordSection1"]').children.first.previous =
139
- cover.to_xml(encoding: "US-ASCII")
175
+ coverxml.to_xml(encoding: "US-ASCII")
140
176
  end
141
177
 
142
178
  def word_intro(docxml)
143
- intro = to_xhtml_fragment(File.read(@wordintropage, encoding: "UTF-8").
144
- sub(/WORDTOC/, make_WordToC(docxml)))
179
+ intro = File.read(@wordintropage, encoding: "UTF-8").
180
+ sub(/WORDTOC/, make_WordToC(docxml))
181
+ intro = populate_template(intro, :word)
182
+ introxml = to_xhtml_fragment(intro)
145
183
  docxml.at('//div[@class="WordSection2"]').children.first.previous =
146
- intro.to_xml(encoding: "US-ASCII")
184
+ introxml.to_xml(encoding: "US-ASCII")
147
185
  end
148
186
 
149
187
  def generate_header(filename, _dir)
@@ -155,6 +193,7 @@ def generate_header(filename, _dir)
155
193
  File.open("header.html", "w") do |f|
156
194
  f.write(template.render(params))
157
195
  end
196
+ @files_to_delete << "header.html"
158
197
  end
159
198
 
160
199
  def word_toc_entry(toclevel, heading)