Class: IsoDoc::Gb::HtmlConvert

Inherits:
HtmlConvert
  • Object
show all
Includes:
BaseConvert
Defined in:
lib/isodoc/gb/gbhtmlconvert.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 BaseConvert

#clause_name, #clausedelimspace, #cleanup, #deprecated_term_parse, #end_line, #error_parse, #example_cleanup, #example_label, #example_p_parse, #example_parse, #example_parse1, #example_span_label, #extract_fonts, #foreword, #formula_dl_parse, #formula_parse, #formula_where, #i18n_init, #metadata_init, #middle, #node_begins_with_para, #note_parse, #note_parse1, #omit_docid_prefix, #string_parse, #termnote_parse, #termref_render, #termref_resolve, #textcleanup

Constructor Details

#initialize(options) ⇒ HtmlConvert

Returns a new instance of HtmlConvert.



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

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

#annex_name(annex, name, div) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/isodoc/gb/gbhtmlconvert.rb', line 55

def annex_name(annex, name, div)
  div.h1 **{ class: "Annex" } do |t|
    t << "#{anchor(annex['id'], :label)}<br/><br/>"
    t.b do |b|
      name&.children&.each { |c2| parse(c2, b) }
    end
  end
end

#default_file_locations(options) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/isodoc/gb/gbhtmlconvert.rb', line 30

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



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

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

#populate_template(docxml, format) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/isodoc/gb/gbhtmlconvert.rb', line 39

def populate_template(docxml, format)
  meta = @meta.get.merge(@labels)
   = @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)

  #template = liquid(docxml)
#template.render(meta.map { |k, v| [k.to_s, empty2nil(v)] }.to_h).
  #gsub('&lt;', '&#x3c;').gsub('&gt;', '&#x3e;').gsub('&amp;', '&#x26;')
end