Skip to content

Commit c0b5bca

Browse files
committed
update build script for better management of PDF
1 parent eda1fbb commit c0b5bca

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Diff for: Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ gem 'awesome_print'
88

99
gem 'asciidoctor-epub3', :git => 'https://github.com/asciidoctor/asciidoctor-epub3'
1010
gem 'asciidoctor-pdf', '1.5.0.alpha.16'
11+
gem 'asciidoctor-pdf-cjk', '~> 0.1.3'
12+
gem 'asciidoctor-pdf-cjk-kai_gen_gothic', '~> 0.1.1'
1113

1214
gem 'coderay'
1315
gem 'pygments.rb'

Diff for: Rakefile

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
# coding: utf-8
22
require 'octokit'
33

4+
def exec_or_raise(command)
5+
puts `#{command}`
6+
if (! $?.success?)
7+
raise "'#{command}' failed"
8+
end
9+
end
10+
411
namespace :book do
512
desc 'build basic book formats'
613
task :build do
714

815
puts "Generating contributors list"
9-
`git shortlog -s --all| grep -v -E "(Straub|Chacon)" | cut -f 2- | column -c 120 > book/contributors.txt`
16+
exec_or_raise("git shortlog -s --all| grep -v -E '(Straub|Chacon)' | cut -f 2- | column -c 120 > book/contributors.txt")
1017

1118
puts "Converting to HTML..."
12-
`bundle exec asciidoctor progit.asc`
19+
exec_or_raise("bundle exec asciidoctor progit.asc")
1320
puts " -- HTML output at progit.html"
1421

1522
puts "Converting to EPub..."
16-
`bundle exec asciidoctor-epub3 progit.asc`
23+
exec_or_raise("bundle exec asciidoctor-epub3 progit.asc")
1724
puts " -- Epub output at progit.epub"
1825

19-
sh "epubcheck progit.epub"
26+
exec_or_raise("epubcheck progit.epub")
2027

2128
puts "Converting to Mobi (kf8)..."
22-
`bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc`
29+
exec_or_raise("bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc")
2330
puts " -- Mobi output at progit.mobi"
2431

32+
repo = ENV['TRAVIS_REPO_SLUG']
2533
puts "Converting to PDF... (this one takes a while)"
26-
`bundle exec asciidoctor-pdf progit.asc 2>/dev/null`
34+
exec_or_raise("asciidoctor-pdf-cjk-kai_gen_gothic-install")
35+
exec_or_raise("bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicJP progit.asc")
2736
puts " -- PDF output at progit.pdf"
2837
end
2938

@@ -148,7 +157,7 @@ namespace :book do
148157
content = File.read (filename)
149158
new_contents = content.gsub(/include::(.*?)asc/) {|match|
150159
"include::book/#{num}-#{title}/#{$1}asc"}
151-
`git rm #{filename}`
160+
`git rm -f #{filename}`
152161
File.open("#{chap}.asc", "w") {|file|
153162
file.puts "[##{chap}]\n"
154163
file.puts new_contents }

0 commit comments

Comments
 (0)