Sha256: ada8ad8686fde8ff9db5ccc5a1599ad11b55c0a5dafe8fccb98635ca22edfaab

Contents?: true

Size: 1.15 KB

Versions: 3

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, "")

        /\nscript: (?<script>[^\n]+)\n/ =~ header
        /\nbody-font: (?<bodyfont>[^\n]+)\n/ =~ header
        /\nheader-font: (?<headerfont>[^\n]+)\n/ =~ header
        /\nmonospace-font: (?<monospacefont>[^\n]+)\n/ =~ header
        /\ntitle-font: (?<titlefont>[^\n]+)\n/ =~ header
        /\ni18nyaml: (?<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? }.map
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
metanorma-0.2.2 lib/metanorma/input/asciidoc.rb
metanorma-0.2.1 lib/metanorma/input/asciidoc.rb
metanorma-0.2.0 lib/metanorma/input/asciidoc.rb