Class: IsoDoc::Gb::HtmlConvert

Inherits:
HtmlConvert
  • Object
show all
Includes:
BaseConvert, Init
Defined in:
lib/isodoc/gb/html_convert.rb

Overview

A Converter implementation that generates GB output, and a document schema encapsulation of the document for validation

Constant Summary

Constants included from BaseConvert

BaseConvert::EXAMPLE_TBL_ATTR

Instance Method Summary collapse

Methods included from Init

#i18n_init, #metadata_init, #xref_init

Methods included from BaseConvert

#clausedelimspace, #cleanup, #deprecated_term_parse, #end_line, #error_parse, #example_cleanup, #example_p_parse, #example_parse, #example_parse1, #example_span_label, #formula_dl_parse, #formula_parse1, #formula_where, #middle, #node_begins_with_para, #note_delim, #note_parse, #note_parse_table, #note_parse_table1, #omit_docid_prefix, #scss_fontheader, #string_parse, #termnote_parse, #termref_render, #termref_resolve, #textcleanup

Constructor Details

#initialize(options) ⇒ HtmlConvert

Returns a new instance of HtmlConvert.



10
11
12
13
14
15
16
17
# File 'lib/isodoc/gb/html_convert.rb', line 10

def initialize(options)
  @common = IsoDoc::Gb::Common.new(options)
  @standardclassimg = options[:standardclassimg]
  @libdir = File.dirname(__FILE__)
  super
  @lang = "zh"
  @script = "Hans"
end

Instance Method Details

#default_file_locations(options) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/isodoc/gb/html_convert.rb', line 41

def default_file_locations(options)
  {
    htmlstylesheet: options[:compliant] ? html_doc_path("htmlcompliantstyle.scss") : html_doc_path("htmlstyle.scss"),
    htmlcoverpage: html_doc_path("html_compliant_gb_titlepage.html"),
    htmlintropage: html_doc_path("html_gb_intro.html"),
    scripts: html_doc_path("scripts.html"),
  }
end

#default_fonts(options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/isodoc/gb/html_convert.rb', line 19

def default_fonts(options)
  script = options[:script] || "Hans"
  scope = options[:scope] || "national"
  {
    bodyfont: (script == "Hans" ? '"SimSun",serif' : '"Cambria",serif'),
    headerfont: (script == "Hans" ? '"SimHei",sans-serif' : '"Calibri",sans-serif'),
    monospacefont: '"Courier New",monospace',
    titlefont: (scope == "national" ? (script != "Hans" ? '"Cambria",serif' : '"SimSun",serif' ) :
                (script == "Hans" ? '"SimHei",sans-serif' : '"Calibri",sans-serif' ))
  }
end

#fonts_optionsObject



31
32
33
34
35
36
37
38
39
# File 'lib/isodoc/gb/html_convert.rb', line 31

def fonts_options
  default_font_options = default_fonts(options)
  {
    bodyfont: options[:bodyfont] || default_font_options[:bodyfont],
    headerfont: options[:headerfont] || default_font_options[:headerfont],
    monospacefont: options[:monospacefont] || default_font_options[:monospacefont],
    titlefont: options[:titlefont] || default_font_options[:titlefont]
  }
end

#insert_tab(out, n) ⇒ Object



61
62
63
64
# File 'lib/isodoc/gb/html_convert.rb', line 61

def insert_tab(out, n)
  tab = " "
  [1..n].each { out << tab }
end

#populate_template(docxml, format) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/isodoc/gb/html_convert.rb', line 50

def populate_template(docxml, format)
  meta = @meta.get.merge(@i18n.get).merge(@meta.fonts_options || {})
   = @common.(meta[:gbprefix], meta[:gbscope], format, @localdir)
  logofile = @meta.(meta[:gbprefix])
  meta[:standard_agency_formatted] =
    @common.format_agency(meta[:standard_agency], format, @localdir)
  meta[:standard_logo] = 
  template = Liquid::Template.parse(docxml)
  template.render(meta.map { |k, v| [k.to_s, v] }.to_h)
end