Class: IsoDoc::ITU::WordConvert
- Inherits:
-
WordConvert
- Object
- WordConvert
- IsoDoc::ITU::WordConvert
show all
- Includes:
- BaseConvert
- Defined in:
- lib/isodoc/itu/word_convert.rb
Overview
A Converter implementation that generates Word output, and a document schema encapsulation of the document for validation
Constant Summary
Constants included
from BaseConvert
BaseConvert::ELSEWHERE_TERMS, BaseConvert::FRONT_CLAUSE, BaseConvert::HERE_TERMS
Instance Method Summary
collapse
#annex_name, #biblio_list, #cleanup, #eref_parse, #fileloc, #get_eref_linkend, #i18n_init, #info, #initial_anchor_names, #load_yaml, #metadata_init, #noniso_bibitem_entry, #norm_ref, #norm_ref_preface, #preface, #split_bibitems, #term_cleanup, #term_defs_boilerplate, #termdef_parse, #termdef_parse1, #terms_parse
Constructor Details
#initialize(options) ⇒ WordConvert
Returns a new instance of WordConvert.
11
12
13
14
|
# File 'lib/isodoc/itu/word_convert.rb', line 11
def initialize(options)
@libdir = File.dirname(__FILE__)
super
end
|
Instance Method Details
#abstract(isoxml, out) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/isodoc/itu/word_convert.rb', line 36
def abstract(isoxml, out)
f = isoxml.at(ns("//preface/abstract")) || return
out.div **attr_code(id: f["id"]) do |s|
clause_name(nil, "Summary", s, class: "AbstractTitle")
f.elements.each { |e| parse(e, s) unless e.name == "title" }
end
end
|
#convert1(docxml, filename, dir) ⇒ Object
86
87
88
89
90
|
# File 'lib/isodoc/itu/word_convert.rb', line 86
def convert1(docxml, filename, dir)
FileUtils.cp html_doc_path('itu-document-comb.png'), File.join(@localdir, "itu-document-comb.png")
FileUtils.cp html_doc_path('logo.png'), File.join(@localdir, "logo.png")
super
end
|
#default_file_locations(options) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/isodoc/itu/word_convert.rb', line 100
def default_file_locations(options)
{
wordstylesheet: html_doc_path("wordstyle.scss"),
standardstylesheet: html_doc_path("itu.scss"),
header: html_doc_path("header.html"),
wordcoverpage: html_doc_path("word_itu_titlepage.html"),
wordintropage: html_doc_path("word_itu_intro.html"),
ulstyle: "l3",
olstyle: "l2",
}
end
|
#default_fonts(options) ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/isodoc/itu/word_convert.rb', line 92
def default_fonts(options)
{
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Times New Roman",serif'),
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Times New Roman",serif'),
monospacefont: '"Courier New",monospace'
}
end
|
#keywords(_docxml, out) ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/isodoc/itu/word_convert.rb', line 44
def keywords(_docxml, out)
kw = @meta.get[:keywords]
kw.nil? || kw.empty? and return
out.div do |div|
clause_name(nil, "Keywords", div, class: "IntroTitle")
div.p kw.sort.join(", ") + "."
end
end
|
#make_body(xml, docxml) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/isodoc/itu/word_convert.rb', line 16
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)
end
end
|
#make_body2(body, docxml) ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/isodoc/itu/word_convert.rb', line 25
def make_body2(body, docxml)
body.div **{ class: "WordSection2" } do |div2|
info docxml, div2
abstract docxml, div2
keywords docxml, div2
preface docxml, div2
div2.p { |p| p << " " } end
section_break(body)
end
|
#middle_title(out) ⇒ Object
67
68
69
70
|
# File 'lib/isodoc/itu/word_convert.rb', line 67
def middle_title(out)
out.p(**{ class: "zzSTDTitle1" }) { |p| p << "Recommendation " + @meta.get[:docidentifier] }
out.p(**{ class: "zzSTDTitle2" }) { |p| p << @meta.get[:doctitle] }
end
|
#word_cleanup(docxml) ⇒ Object
61
62
63
64
65
|
# File 'lib/isodoc/itu/word_convert.rb', line 61
def word_cleanup(docxml)
word_preface_cleanup(docxml)
super
docxml
end
|
#word_preface(docxml) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/isodoc/itu/word_convert.rb', line 72
def word_preface(docxml)
super
abstractbox = docxml.at("//div[@id='abstractbox']")
historybox = docxml.at("//div[@id='historybox']")
keywordsbox = docxml.at("//div[@id='keywordsbox']")
abstract = docxml.at("//p[@class = 'h1Preface' and text() = 'Summary']/..")
history = docxml.at("//p[@class = 'h1Preface' and text() = 'History']/..")
keywords = docxml.at("//p[@class = 'h1Preface' and text() = 'Keywords']/..")
abstract.parent = abstractbox if abstract && abstractbox
history.parent = historybox if history && historybox
keywords.parent = keywordsbox if keywords && keywordsbox
end
|
#word_preface_cleanup(docxml) ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/isodoc/itu/word_convert.rb', line 53
def word_preface_cleanup(docxml)
docxml.xpath("//h1[@class = 'AbstractTitle'] | "\
"//h1[@class = 'IntroTitle']").each do |h2|
h2.name = "p"
h2["class"] = "h1Preface"
end
end
|