Sha256: 632101b8bb8dae90d7253be872d9a7af11bdbbe22d71d95d5a1fd28bbd189b71

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

module Metanorma
  module Input

    class Asciidoc < Base

      def process(file, type)
        Asciidoctor.convert(
          file,
          to_file: false,
          safe: :safe,
          backend: type,
          header_footer: true,
          attributes: %w(nodoc stem xrefstyle=short)
        )
      end

      def extract_options(file)
        header = file.sub(/\n\n.*$/m, "")

        /\n:script: (?<script>[^\n]+)\n/ =~ header
        /\n:body-font: (?<bodyfont>[^\n]+)\n/ =~ header
        /\n:header-font: (?<headerfont>[^\n]+)\n/ =~ header
        /\n:monospace-font: (?<monospacefont>[^\n]+)\n/ =~ header
        /\n:title-font: (?<titlefont>[^\n]+)\n/ =~ header
        /\n:i18nyaml: (?<ni18nyaml>[^\n]+)\n/ =~ header
        {
          script: defined?(script) ? script : nil,
          bodyfont: defined?(bodyfont) ? bodyfont : nil,
          headerfont: defined?(headerfont) ? headerfont : nil,
          monospacefont: defined?(monospacefont) ? monospacefont : nil,
          titlefont: defined?(titlefont) ? titlefont : nil,
          i18nyaml: defined?(i18nyaml) ? i18nyaml : nil,
        }.reject { |_, val| val.nil? }
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
metanorma-0.2.6 lib/metanorma/input/asciidoc.rb
metanorma-0.2.5 lib/metanorma/input/asciidoc.rb
metanorma-0.2.4 lib/metanorma/input/asciidoc.rb
metanorma-0.2.3 lib/metanorma/input/asciidoc.rb