Class: Gmi2LaTeX::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/gmi2latex/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



7
8
9
# File 'lib/gmi2latex/command.rb', line 7

def self.run
  new.run
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gmi2latex/command.rb', line 11

def run
  header = <<~LaTeX
    \\RequirePackage{plautopatch}
    \\documentclass[a4paper,article,dvipdfmx]{jlreq}
    \\usepackage{hyperref}
    \\begin{document}
  LaTeX
  footer = "\\end{document}\n"

  OptionParser.new do |parser|
    parser.on("--header=SOURCE") { |source| header = source }
    parser.on("--footer=SOURCE") { |source| footer = source }
  end.parse!

  doc = Gemtext::Parser.new($stdin).parse
  Renderer.new(doc, header:, footer:).render
end