Class: Metanorma::Input::Asciidoc

Inherits:
Base
  • Object
show all
Defined in:
lib/metanorma/input/asciidoc.rb

Instance Method Summary collapse

Instance Method Details

#extract_options(file) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/metanorma/input/asciidoc.rb', line 18

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

#process(file, type) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/metanorma/input/asciidoc.rb', line 7

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