Class: IsoDoc::Gb::WordConvert
- Inherits:
-
Convert
- Object
- Convert
- Convert
- IsoDoc::Gb::WordConvert
show all
- Includes:
- WordConvertModule
- Defined in:
- lib/isodoc/gb/gbwordconvert.rb
Overview
A Converter implementation that generates GB output, and a document schema encapsulation of the document for validation
Constant Summary
collapse
- ENDLINE =
<<~END.freeze
<v:line id="_x0000_s1026"
alt="" style='position:absolute;left:0;text-align:left;z-index:251662848;
mso-wrap-edited:f;mso-width-percent:0;mso-height-percent:0;
mso-width-percent:0;mso-height-percent:0'
from="6.375cm,20.95pt" to="10.625cm,20.95pt"
strokeweight="1.5pt"/>
END
Constants inherited
from Convert
Convert::ISO_STD_XPATH, Convert::LOCAL, Convert::NATIONAL, Convert::SCOPEPFX, Convert::SECTOR, Convert::STAGE_ABBRS_CN
Instance Method Summary
collapse
Methods inherited from Convert
#annex_name, #author, #bibdate, #clause_name, #clause_parse_title, #cleanup, #default_fonts, #deprecated_single_label, #deprecated_term_parse, #docid, #docid1, #docidentifier, #docstatus, #error_parse, #example_cleanup, #fileloc, #foreword, #format_agency, #format_agency1, #format_logo, #format_logo1, #formula_cleanup, #gb_equivalence, #gb_identifier, #gb_library_identifier, #gb_mandate_suffix, #gbtype_validate, #i18n_init, #init_metadata, #local_logo_suffix, #mandate_suffix, #middle, #part_label, #populate_template, #set_doctitle, #spaerdruck, #stage_abbrev_cn, #standard_agency, #standard_agency1, #standard_class, #standard_logo, #string_parse, #subtitle, #term_defs_boilerplate, #term_merge, #termref_render, #termref_resolve, #terms_cleanup, #title, #title_cleanup
Constructor Details
#initialize(options) ⇒ WordConvert
Returns a new instance of WordConvert.
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/isodoc/gb/gbwordconvert.rb', line 15
def initialize(options)
super
@wordstylesheet = generate_css(html_doc_path("wordstyle.scss"), false, default_fonts(options))
@standardstylesheet = generate_css(html_doc_path("gb.scss"), false, default_fonts(options))
@header = html_doc_path("header.html")
@wordcoverpage = html_doc_path("word_gb_titlepage.html")
@wordintropage = html_doc_path("word_gb_intro.html")
@ulstyle = "l7"
@olstyle = "l10"
end
|
Instance Method Details
#end_line(_isoxml, out) ⇒ Object
35
36
37
|
# File 'lib/isodoc/gb/gbwordconvert.rb', line 35
def end_line(_isoxml, out)
out.parent.add_child(ENDLINE)
end
|
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/isodoc/gb/gbwordconvert.rb', line 39
def (filename, dir)
return unless @header
template = Liquid::Template.parse(File.read(@header, encoding: "UTF-8"))
meta = get_metadata
meta[:filename] = filename
params = meta.map { |k, v| [k.to_s, v] }.to_h
File.open("header.html", "w") { |f| f.write(template.render(params)) }
system "cp #{fileloc(File.join('html', 'blank.png'))} blank.png"
@files_to_delete << "blank.png"
@files_to_delete << "header.html"
end
|
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/isodoc/gb/gbwordconvert.rb', line 51
def (h)
h = h.to_s.gsub(%r{<br/>}, " ").sub(/<\/?h[12][^>]*>/, "")
h1 = to_xhtml_fragment(h.dup)
h1.traverse do |x|
x.replace(" ") if x.name == "span" &&
/mso-tab-count/.match?(x["style"])
x.remove if x.name == "span" && x["class"] == "MsoCommentReference"
x.remove if x.name == "a" && x["epub:type"] == "footnote"
x.replace(x.children) if x.name == "a"
end
from_xhtml(h1)
end
|
#html_doc_path(file) ⇒ Object
11
12
13
|
# File 'lib/isodoc/gb/gbwordconvert.rb', line 11
def html_doc_path(file)
File.join(File.dirname(__FILE__), File.join("html", file))
end
|
#word_cleanup(docxml) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/isodoc/gb/gbwordconvert.rb', line 64
def word_cleanup(docxml)
word_preface(docxml)
word_annex_cleanup(docxml)
title_cleanup(docxml.at('//div[@class="WordSection2"]'))
docxml
end
|