Class: IsoDoc::Iso::WordConvert

Inherits:
WordConvert
  • Object
show all
Includes:
BaseConvert, Init
Defined in:
lib/isodoc/iso/word_convert.rb

Instance Method Summary collapse

Methods included from Init

#amd, #clausedelim, #i18n_init, #metadata_init, #xref_init

Methods included from BaseConvert

#admonition_name_parse, #admonition_p_parse, #admonition_parse, #admonition_parse1, #annex, #cleanup, #convert1, #error_parse, #example_p_parse, #example_parse, #example_parse1, #example_span_label, #figure_name_parse, #foreword, #formula_where, #implicit_reference, #indexsect, #insertall_after_here, #introduction, #middle, #middle_title, #middle_title_amd, #middle_title_main, #node_begins_with_para, #table_th_center, #termdef_parse, #termexamples_before_termnotes

Constructor Details

#initialize(options) ⇒ WordConvert

Returns a new instance of WordConvert.



8
9
10
11
12
13
14
15
# File 'lib/isodoc/iso/word_convert.rb', line 8

def initialize(options)
  @libdir = File.dirname(__FILE__)
  super
  @wordToClevels = options[:doctoclevels].to_i
  @wordToClevels = 3 if @wordToClevels.zero?
  @htmlToClevels = options[:htmltoclevels].to_i
  @htmlToClevels = 3 if @htmlToClevels.zero?
end

Instance Method Details

#authority_cleanup(docxml) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/isodoc/iso/word_convert.rb', line 107

def authority_cleanup(docxml)
  insert = docxml.at("//div[@id = 'boilerplate-license-destination']")
  auth = docxml&.at("//div[@class = 'boilerplate-license']")&.remove
  auth&.xpath(".//p[not(@class)]")&.each { |p| p["class"] = "zzWarning" }
  auth and insert.children = auth
  insert = docxml.at("//div[@id = 'boilerplate-copyright-destination']")
  auth = docxml&.at("//div[@class = 'boilerplate-copyright']")&.remove
  auth&.xpath(".//p[not(@class)]")&.each { |p| p["class"] = "zzCopyright" }
  auth&.xpath(".//p[@id = 'boilerplate-message']")&.each { |p| p["class"] = "zzCopyright1" }
  auth&.xpath(".//p[@id = 'boilerplate-address']")&.each { |p| p["class"] = "zzAddress" }
  auth&.xpath(".//p[@id = 'boilerplate-place']")&.each { |p| p["class"] = "zzCopyright1" }
  auth and insert.children = auth
end

#authority_hdr_cleanup(docxml) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/isodoc/iso/word_convert.rb', line 92

def authority_hdr_cleanup(docxml)
  docxml&.xpath("//div[@class = 'boilerplate-license']").each do |d|
    d.xpath(".//h1").each do |p|
      p.name = "p"
      p["class"] = "zzWarningHdr"
    end
  end
  docxml&.xpath("//div[@class = 'boilerplate-copyright']").each do |d|
    d.xpath(".//h1").each do |p|
      p.name = "p"
      p["class"] = "zzCopyrightHdr"
    end
  end
end

#colophon(body, docxml) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/isodoc/iso/word_convert.rb', line 58

def colophon(body, docxml)
  stage =  @meta.get[:stage_int]
  return if !stage.nil? && stage < 60
  body.br **{ clear: "all", style: "page-break-before:left;"\
              "mso-break-type:section-break" }
  body.div **{ class: "colophon" } do |div|
  end
end

#default_file_locations(options) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/isodoc/iso/word_convert.rb', line 31

def default_file_locations(options)
  {
    htmlstylesheet: (options[:alt] ? html_doc_path("style-human.scss") :
                     html_doc_path("style-iso.scss")),
  htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
  htmlintropage: html_doc_path("html_iso_intro.html"),
  scripts: html_doc_path("scripts.html"),
  wordstylesheet: html_doc_path("wordstyle.scss"),
  standardstylesheet: html_doc_path("isodoc.scss"),
  header: html_doc_path("header.html"),
  wordcoverpage: html_doc_path("word_iso_titlepage.html"),
  wordintropage: html_doc_path("word_iso_intro.html"),
  ulstyle: "l3", 
  olstyle: "l2",
  }
end

#default_fonts(options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/isodoc/iso/word_convert.rb', line 17

def default_fonts(options)
  {
    bodyfont: (options[:script] == "Hans" ? '"Source Han Sans",serif' :
               '"Cambria",serif'),
               headerfont: (options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
                            '"Cambria",serif'),
                            monospacefont: '"Courier New",monospace',
                            normalfontsize: "11.0pt",
                            monospacefontsize: "9.0pt",
                            smallerfontsize: "10.0pt",
                            footnotefontsize: "10.0pt",
  }
end

#figure_cleanup(xml) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/isodoc/iso/word_convert.rb', line 67

def figure_cleanup(xml)
  super
  xml.xpath("//div[@class = 'figure']//table[@class = 'dl']").each do |t|
    t["class"] = "figdl"
    d = t.add_previous_sibling("<div class='figdl'/>")
    t.parent = d.first
  end
end

#footnote_reference_format(a) ⇒ Object



127
128
129
# File 'lib/isodoc/iso/word_convert.rb', line 127

def footnote_reference_format(a)
  a.children = "<span class='MsoFootnoteReference'>#{a.children.to_xml}</span>)"
end

#make_body(xml, docxml) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/isodoc/iso/word_convert.rb', line 48

def make_body(xml, docxml)
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
  xml.body **body_attr do |body|
    make_body1(body, docxml)
    make_body2(body, docxml)
    make_body3(body, docxml)
    colophon(body, docxml)
  end
end

#word_annex_cleanup(docxml) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/isodoc/iso/word_convert.rb', line 84

def word_annex_cleanup(docxml)
  word_annex_cleanup1(docxml, 2)
  word_annex_cleanup1(docxml, 3)
  word_annex_cleanup1(docxml, 4)
  word_annex_cleanup1(docxml, 5)
  word_annex_cleanup1(docxml, 6)
end

#word_annex_cleanup1(docxml, i) ⇒ Object

force Annex h2 down to be p.h2Annex, so it is not picked up by ToC



77
78
79
80
81
82
# File 'lib/isodoc/iso/word_convert.rb', line 77

def word_annex_cleanup1(docxml, i)
  docxml.xpath("//h#{i}[ancestor::*[@class = 'Section3']]").each do |h2|
    h2.name = "p"
    h2["class"] = "h#{i}Annex"
  end
end

#word_cleanup(docxml) ⇒ Object



121
122
123
124
125
# File 'lib/isodoc/iso/word_convert.rb', line 121

def word_cleanup(docxml)
  authority_hdr_cleanup(docxml)
  super
  docxml
end