-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rb
45 lines (37 loc) · 1.14 KB
/
build.rb
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
#!/usr/bin/env ruby
require 'fileutils'
# pandocのオプションを設定
PANDOC='pandoc -f markdown+east_asian_line_breaks -t latex -N --pdf-engine=lualatex --top-level-division=chapter --table-of-contents --toc-depth=3'
puts 'use make'
exit
# kijiの中身を雑にoutにコピー(ディレクトリつくるのめんどいので)
Dir.glob('kiji/*') do |file|
FileUtils.cp_r(file, 'out')
end
# カバー画像もoutにコピー
Dir.glob('cover/*.png') do |file|
FileUtils.cp_r(file, 'out')
end
# クラスファイルを生成
system("lualatex luakmcbook.ins")
# latexmkrcをコピー
#FileUtils.cp_r('latexmkrc', './out/latexmkrc')
# MarkdownをTeXに変換
Dir.glob('kiji/**/*') do |file|
if FileTest.file? file then
next unless file =~ /\.md$/
outfile = file.sub(/^kiji\//, '').sub(/\.md$/, '.tex')
cmd = "#{PANDOC} -o out/#{outfile} #{file}"
puts "exec: #{cmd}"
system(cmd)
puts "exit code: #{$?}" if $?
exit $? if $?.to_i > 0
end
end
# 全体をPDFに変換
FileUtils.cp("bushi.tex", "out/bushi.tex")
FileUtils.cd("out") do
system("latexmk -lualatex bushi.tex")
puts $? if $?
exit $? if $?.to_i > 0
end