Sha256: 392d5dd71f003c87fdd5a29fc284ef7b27d62580e099d1275b3c889b52712a4a

Contents?: true

Size: 1.17 KB

Versions: 24

Compression:

Stored size: 1.17 KB

Contents

require "isodoc"

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

      def configuration
        Metanorma::BIPM.configuration
      end

      def pdf_stylesheet(docxml)
        docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))
        &.value == "JCGM" and
          return "jcgm.standard.xsl"

        doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
        doctype = "brochure" unless %w(guide mise-en-pratique rapport)
          .include? doctype
        "bipm.#{doctype}.xsl"
      end

      def pdf_options(docxml)
        n = configuration.document_namespace
        q = "//m:bipm-standard/m:bibdata/m:language[@current = 'true']"
        if docxml.root.name == "metanorma-collection" &&
            docxml.at("#{q}[. = 'fr']", "m" => n) &&
            docxml.at("#{q}[. = 'en']", "m" => n)
          "#{super} --split-by-language"
        else
          super
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
metanorma-bipm-2.0.3 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-2.0.2 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-2.0.1 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-2.0.0.1 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-2.0.0 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.2.5 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.2.4 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.2.3 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.2.2 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.2.1 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.2.0 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.11 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.10 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.9 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.8 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.7 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.6 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.5.1 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.5 lib/isodoc/bipm/pdf_convert.rb
metanorma-bipm-1.1.4 lib/isodoc/bipm/pdf_convert.rb