From 844800eeb135978798513a4a1e2fd6c11727a3e5 Mon Sep 17 00:00:00 2001 From: Rei Date: Sat, 17 Oct 2015 14:52:32 +0800 Subject: [PATCH 1/2] Remove trailing whitespace --- Rakefile | 8 ++++---- config.rb | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 config.rb diff --git a/Rakefile b/Rakefile index a98de2cf..a1487a92 100644 --- a/Rakefile +++ b/Rakefile @@ -10,19 +10,19 @@ namespace :book do desc 'build basic book formats' task :build => :prebuild do puts "Converting to HTML..." - `bundle exec asciidoctor progit.asc` + `bundle exec asciidoctor -r ./config.rb progit.asc` puts " -- HTML output at progit.html" puts "Converting to EPub..." - `bundle exec asciidoctor-epub3 progit.asc` + `bundle exec asciidoctor-epub3 -r ./config.rb progit.asc` puts " -- Epub output at progit.epub" puts "Converting to Mobi (kf8)..." - `bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc` + `bundle exec asciidoctor-epub3 -r ./config.rb -a ebook-format=kf8 progit.asc` puts " -- Mobi output at progit.mobi" puts "Converting to PDF... (this one takes a while)" - `bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicCN progit.asc 2>/dev/null` + `bundle exec asciidoctor-pdf -r ./config.rb -a pdf-style=KaiGenGothicCN progit.asc 2>/dev/null` puts " -- PDF output at progit.pdf" end end diff --git a/config.rb b/config.rb new file mode 100644 index 00000000..d5c58f57 --- /dev/null +++ b/config.rb @@ -0,0 +1,23 @@ +Bundler.require(:default) + +class TrailingTreeprocessor < Asciidoctor::Extensions::Treeprocessor + def process document + return unless document.blocks? + process_blocks document + nil + end + + def process_blocks node + node.blocks.each_with_index do |block, index| + if block.context == :paragraph + node.blocks[index] = create_paragraph block.document, block.content.gsub("\n", ''), block.attributes + else + process_blocks block + end + end + end +end + +Asciidoctor::Extensions.register do + treeprocessor TrailingTreeprocessor +end From 8c0593e69f0a7e685c5789dd085de47d80bba653 Mon Sep 17 00:00:00 2001 From: Rei Date: Sat, 17 Oct 2015 17:08:56 +0800 Subject: [PATCH 2/2] Update pdf theme --- Gemfile | 2 +- Gemfile.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index ecf5622e..0f098c3f 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'awesome_print' gem 'asciidoctor-epub3', '1.0.0.alpha.2' gem 'asciidoctor-pdf', '1.5.0.alpha.8' -gem 'asciidoctor-pdf-cjk-kai_gen_gothic', '~> 0.1.0' +gem 'asciidoctor-pdf-cjk-kai_gen_gothic', '~> 0.1.1' gem 'coderay' gem 'pygments.rb' diff --git a/Gemfile.lock b/Gemfile.lock index 44657151..fc3dbd27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,13 +19,13 @@ GEM safe_yaml (= 1.0.4) thread_safe (= 0.3.4) treetop (= 1.5.3) - asciidoctor-pdf-cjk (0.1.1) + asciidoctor-pdf-cjk (0.1.2) asciidoctor-pdf (~> 1.5.0.alpha.8) - asciidoctor-pdf-cjk-kai_gen_gothic (0.1.0) - asciidoctor-pdf-cjk (~> 0.1.1) + asciidoctor-pdf-cjk-kai_gen_gothic (0.1.1) + asciidoctor-pdf-cjk (~> 0.1.2) awesome_print (1.2.0) coderay (1.1.0) - css_parser (1.3.6) + css_parser (1.3.7) addressable epubcheck (3.0.1) gepub (0.6.9.2) @@ -37,7 +37,7 @@ GEM mini_portile (0.6.0) nokogiri (1.6.3.1) mini_portile (= 0.6.0) - pdf-core (0.5.1) + pdf-core (0.6.0) pdf-reader (1.3.3) Ascii85 (~> 1.0.0) afm (~> 0.2.0) @@ -46,8 +46,8 @@ GEM ttfunk polyglot (0.3.5) posix-spawn (0.3.9) - prawn (2.0.1) - pdf-core (~> 0.5.1) + prawn (2.0.2) + pdf-core (~> 0.6.0) ttfunk (~> 1.4.0) prawn-icon (0.6.4) prawn (>= 1.1.0, < 3.0.0) @@ -78,7 +78,7 @@ DEPENDENCIES asciidoctor (= 1.5.0) asciidoctor-epub3 (= 1.0.0.alpha.2) asciidoctor-pdf (= 1.5.0.alpha.8) - asciidoctor-pdf-cjk-kai_gen_gothic (~> 0.1.0) + asciidoctor-pdf-cjk-kai_gen_gothic (~> 0.1.1) awesome_print coderay epubcheck