Sha256: cb6034c88eecd87275c9a1437c48d19e3b5c141b58191b81148a2874488bceb8

Contents?: true

Size: 2 KB

Versions: 14

Compression:

Stored size: 2 KB

Contents

require "date"
require "nokogiri"
require "json"
require "pathname"
require "open-uri"
require "pp"
require "isodoc"
require "fileutils"

module Asciidoctor
  module ISO
    class Converter < Standoc::Converter
      def html_converter(node)
        IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node))
      end

      def html_converter_alt(node)
        IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node).
                                     merge(alt: true))
      end

      def doc_converter(node)
        IsoDoc::Iso::WordConvert.new(doc_extract_attributes(node))
      end

      def document(node)
        init(node)
        ret = makexml(node).to_xml(indent: 2)
        unless node.attr("nodoc") || !node.attr("docfile")
          File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
          html_converter_alt(node).convert(@filename + ".xml")
          FileUtils.mv "#{@filename}.html", "#{@filename}_alt.html"
          html_converter(node).convert(@filename + ".xml")
          doc_converter(node).convert(@filename + ".xml")
        end
        @files_to_delete.each { |f| FileUtils.rm f }
        ret
      end

      def makexml1(node)
        result = ["<?xml version='1.0' encoding='UTF-8'?>\n<iso-standard>"]
        result << noko { |ixml| front node, ixml }
        result << noko { |ixml| middle node, ixml }
        result << "</iso-standard>"
        textcleanup(result)
      end

      def load_yaml(lang, script)
        y = if @i18nyaml then YAML.load_file(@i18nyaml)
            elsif lang == "en"
              YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
            elsif lang == "fr"
              YAML.load_file(File.join(File.dirname(__FILE__), "i18n-fr.yaml"))
            elsif lang == "zh" && script == "Hans"
              YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
            else
              YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
            end
        super.merge(y)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
metanorma-iso-1.3.15 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.13 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.12 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.11 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.10 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.9 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.8 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.7 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.6 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.5 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.4 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.3 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.2 lib/asciidoctor/iso/base.rb
metanorma-iso-1.3.1 lib/asciidoctor/iso/base.rb