Class: IsoDoc::Generic::HtmlConvert

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

Overview

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

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Init

#i18n_init, #metadata_init, #xref_init

Methods included from Utils

#baselocation, #configuration, #fileloc

Methods included from BaseConvert

#cleanup, #info, #make_body, #term_cleanup

Constructor Details

#initialize(options) ⇒ HtmlConvert

Returns a new instance of HtmlConvert.


12
13
14
15
# File 'lib/isodoc/generic/html_convert.rb', line 12

def initialize(options)
  @libdir = File.dirname(__FILE__)
  super
end

Class Attribute Details

._fileObject

Returns the value of attribute _file.


18
19
20
# File 'lib/isodoc/generic/html_convert.rb', line 18

def _file
  @_file
end

Class Method Details

.inherited(k) ⇒ Object


21
22
23
# File 'lib/isodoc/generic/html_convert.rb', line 21

def self.inherited( k )
  k._file = caller_locations.first.absolute_path
end

Instance Method Details

#default_file_locations(_options) ⇒ Object


43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/isodoc/generic/html_convert.rb', line 43

def default_file_locations(_options)
  {
    htmlstylesheet: baselocation(configuration.htmlstylesheet) ||
    html_doc_path("htmlstyle.scss"),
    htmlcoverpage: baselocation(configuration.htmlcoverpage) ||
    html_doc_path("html_generic_titlepage.html"),
    htmlintropage: baselocation(configuration.htmlintropage) ||
    html_doc_path("html_generic_intro.html"),
    scripts: baselocation(configuration.scripts),
    i18nyaml: (configuration.i18nyaml.is_a?(String) ? 
               baselocation(configuration.i18nyaml) : nil)
  }.transform_values { |v| v&.empty? ? nil : v }
end

#default_fonts(options) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/isodoc/generic/html_convert.rb', line 25

def default_fonts(options)
  {
    bodyfont: (
      options[:script] == "Hans" ? '"Source Han Sans",serif' :
      configuration.html_bodyfont || '"Overpass",sans-serif'
    ),
    headerfont: (
      options[:script] == "Hans" ? '"Source Han Sans",sans-serif' : 
      configuration.html_headerfont || '"Overpass",sans-serif'
    ),
    monospacefont: configuration.html_monospacefont || '"Space Mono",monospace',
    normalfontsize: configuration.html_normalfontsize,
    smallerfontsize: configuration.html_smallerfontsize,
    footnotefontsize: configuration.html_footnotefontsize,
    monospacefontsize: configuration.html_monospacefontsize,
  }.transform_values { |v| v&.empty? ? nil : v }
end

#googlefontsObject


57
58
59
60
61
62
# File 'lib/isodoc/generic/html_convert.rb', line 57

def googlefonts
  return unless configuration.webfont
  Array(configuration.webfont).map do |x|
    %{<link href="#{x.gsub(/\&amp;/, '&')}" rel="stylesheet">}
  end.join("\n")
end