Sha256: 1c5124eaddec28980c76c33b59234aafddba63fffb3003a05c305cb0c251aefa

Contents?: true

Size: 1.48 KB

Versions: 33

Compression:

Stored size: 1.48 KB

Contents

require_relative "html_function/comments.rb"
require_relative "html_function/footnotes.rb"
require_relative "html_function/html.rb"
require "metanorma"

module IsoDoc
  class PdfConvert < ::IsoDoc::Convert

    include HtmlFunction::Comments
    include HtmlFunction::Footnotes
    include HtmlFunction::Html

    def initialize(options)
      @standardstylesheet = nil
      super
      @scripts = @scripts_pdf if @scripts_pdf
      @maxwidth = 500
      @maxheight = 800
    end

    def tmpimagedir_suffix
      "_pdfimages"
    end

    def initialize(options)
      @format = :pdf
      @suffix = "pdf"
      super
    end

    def convert(input_filename, file = nil, debug = false, output_filename = nil)
      file = File.read(input_filename, encoding: "utf-8") if file.nil?
      @openmathdelim, @closemathdelim = extract_delims(file)
      docxml, filename, dir = convert_init(file, input_filename, debug)
      result = convert1(docxml, filename, dir)
      return result if debug
      postprocess(result, filename + ".tmp.html", dir)
      FileUtils.rm_rf dir
      ::Metanorma::Output::Pdf.new.convert("#{filename}.tmp.html",
                                           output_filename || "#{filename}.#{@suffix}")
      FileUtils.rm_rf ["#{filename}.tmp.html", tmpimagedir]
    end

    def xref_parse(node, out)
      target = /#/.match(node["target"]) ? node["target"].sub(/#/, ".pdf#") :
        "##{node["target"]}"
      out.a(**{ "href": target }) { |l| l << get_linkend(node) }
    end
  end
end

Version data entries

33 entries across 30 versions & 2 rubygems

Version Path
isodoc-1.5.5 lib/isodoc/pdf_convert.rb
isodoc-1.5.4 lib/isodoc/pdf_convert.rb
isodoc-1.5.3 lib/isodoc/pdf_convert.rb
isodoc-1.5.2 lib/isodoc/pdf_convert.rb
isodoc-1.5.1 lib/isodoc/pdf_convert.rb
isodoc-1.5.0 lib/isodoc/pdf_convert.rb
isodoc-1.4.2 lib/isodoc/pdf_convert.rb
isodoc-1.4.1 lib/isodoc/pdf_convert.rb
isodoc-1.4.0 lib/isodoc/pdf_convert.rb
isodoc-1.3.1 lib/isodoc/pdf_convert.rb
isodoc-1.3.0 lib/isodoc/pdf_convert.rb
isodoc-1.2.8 lib/isodoc/pdf_convert.rb
isodoc-1.2.7 lib/isodoc/pdf_convert.rb
isodoc-1.2.6 lib/isodoc/pdf_convert.rb
isodoc-1.2.5 lib/isodoc/pdf_convert.rb
isodoc-1.2.4 lib/isodoc/pdf_convert.rb
isodoc-1.2.3 lib/isodoc/pdf_convert.rb
isodoc-1.2.2 lib/isodoc/pdf_convert.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.2.1/lib/isodoc/pdf_convert.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.1.2/lib/isodoc/pdf_convert.rb