-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarka.cr
63 lines (52 loc) · 1.58 KB
/
marka.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "./combiner"
class Marka
property filters = [] of Path
property silent = true
property latex_output = false
property beamer_output = false
property output_file = "result.pdf"
property bibliography : Path | Nil = nil
property meta : Path | Nil = nil
property extra_pandoc_args = [] of String
def render(file)
puts "Running Combiner on #{file}" unless silent
input = Combiner.combine file
if ! bibliography.nil?
puts "Adding bibliography header" unless silent
input += "\n# Bibliography\n"
end
puts "Running Pandoc" unless silent
pipe = IO::Memory.new input
if latex_output
output = "--to=latex"
else
output = "--output=./#{output_file}"
end
args = [
output,
"--fail-if-warning",
"--standalone",
] + extra_pandoc_args + filters.map do |f|
"--lua-filter=#{f}"
end
if ! meta.nil?
args << "--metadata-file=#{meta}"
end
if ! bibliography.nil?
args << "--bibliography=#{bibliography}"
args << "--citeproc"
end
if beamer_output
args << "--to=beamer"
end
puts "Running pandoc with args: #{args.join(" ")}" unless silent
proc = Process.new(
"pandoc",
args,
input: pipe,
error: Process::Redirect::Inherit,
output: Process::Redirect::Inherit,
)
proc.wait
end
end