Sha256: f4c7c803e7345cababe629a52bfacf87c2c8273c6981a630e347ae3f2ded19c0

Contents?: true

Size: 1.85 KB

Versions: 7

Compression:

Stored size: 1.85 KB

Contents

require_relative "base_convert"
require "isodoc"

module IsoDoc
  module Generic

    # A {Converter} implementation that generates HTML output, and a document
    # schema encapsulation of the document for validation
    #
    class HtmlConvert < IsoDoc::HtmlConvert
      def initialize(options)
        @libdir = File.dirname(__FILE__)
        super
      end

      class << self
        attr_accessor :_file
      end

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

      def default_fonts(options)
        {
          bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' 
                     : configuration.html_bodyfont || '"Overpass",sans-serif'),
          headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : 
                       configuration.html_headerfont || '"Overpass",sans-serif'),
          monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
        }
      end

      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) ||
            html_doc_path("scripts.html"),
          i18nyaml: baselocation(configuration.i18nyaml)
        }
      end

      def configuration
        Metanorma::Generic.configuration
      end

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

      include BaseConvert
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/metanorma-generic-1.5.1/lib/isodoc/generic/html_convert.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/metanorma-generic-1.5.1/lib/isodoc/generic/html_convert.rb
metanorma-generic-1.5.1 lib/isodoc/generic/html_convert.rb
metanorma-generic-1.5.0 lib/isodoc/generic/html_convert.rb
metanorma-generic-1.4.10 lib/isodoc/generic/html_convert.rb
metanorma-generic-1.4.9 lib/isodoc/generic/html_convert.rb
metanorma-generic-1.4.8 lib/isodoc/generic/html_convert.rb