Skip to content

Commit 238c689

Browse files
committed
Update Rakefile
The pdf can compile better with the addition from chloerei
1 parent cb259e6 commit 238c689

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
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'

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ GEM
2525
safe_yaml (~> 1.0.4)
2626
thread_safe (~> 0.3.6)
2727
treetop (= 1.5.3)
28+
asciidoctor-pdf-cjk (0.1.3)
29+
asciidoctor-pdf (~> 1.5.0.alpha.8)
30+
asciidoctor-pdf-cjk-kai_gen_gothic (0.1.1)
31+
asciidoctor-pdf-cjk (~> 0.1.2)
2832
awesome_print (1.8.0)
2933
coderay (1.1.2)
3034
css_parser (1.6.0)
@@ -90,6 +94,8 @@ DEPENDENCIES
9094
asciidoctor (= 1.5.6.1)
9195
asciidoctor-epub3!
9296
asciidoctor-pdf (= 1.5.0.alpha.16)
97+
asciidoctor-pdf-cjk (~> 0.1.3)
98+
asciidoctor-pdf-cjk-kai_gen_gothic (~> 0.1.1)
9399
awesome_print
94100
coderay
95101
epubcheck

Rakefile

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
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+
if (repo == "progit/progit2-zh")
35+
exec_or_raise("asciidoctor-pdf-cjk-kai_gen_gothic-install")
36+
exec_or_raise("bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicCN progit.asc")
37+
else
38+
exec_or_raise("bundle exec asciidoctor-pdf progit.asc 2>/dev/null")
39+
end
2740
puts " -- PDF output at progit.pdf"
2841
end
2942

3043
desc 'tag the repo with the latest version'
3144
task :tag do
3245
api_token = ENV['GITHUB_API_TOKEN']
33-
if (api_token && (ENV['TRAVIS_PULL_REQUEST'] == 'false') && (ENV['TRAVIS_BRANCH']=='master') && !ENV['TRAVIS_TAG'])
46+
if (api_token && (ENV['TRAVIS_PULL_REQUEST'] == 'false') && (ENV['TRAVIS_BRANCH']=='master'))
3447
repo = ENV['TRAVIS_REPO_SLUG']
3548
@octokit = Octokit::Client.new(:access_token => api_token)
3649
begin
@@ -148,7 +161,7 @@ namespace :book do
148161
content = File.read (filename)
149162
new_contents = content.gsub(/include::(.*?)asc/) {|match|
150163
"include::book/#{num}-#{title}/#{$1}asc"}
151-
`git rm #{filename}`
164+
`git rm -f #{filename}`
152165
File.open("#{chap}.asc", "w") {|file|
153166
file.puts "[##{chap}]\n"
154167
file.puts new_contents }

0 commit comments

Comments
 (0)