Skip to content

Commit 844800e

Browse files
committed
Remove trailing whitespace
1 parent 63cab3d commit 844800e

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

Rakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ namespace :book do
1010
desc 'build basic book formats'
1111
task :build => :prebuild do
1212
puts "Converting to HTML..."
13-
`bundle exec asciidoctor progit.asc`
13+
`bundle exec asciidoctor -r ./config.rb progit.asc`
1414
puts " -- HTML output at progit.html"
1515

1616
puts "Converting to EPub..."
17-
`bundle exec asciidoctor-epub3 progit.asc`
17+
`bundle exec asciidoctor-epub3 -r ./config.rb progit.asc`
1818
puts " -- Epub output at progit.epub"
1919

2020
puts "Converting to Mobi (kf8)..."
21-
`bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc`
21+
`bundle exec asciidoctor-epub3 -r ./config.rb -a ebook-format=kf8 progit.asc`
2222
puts " -- Mobi output at progit.mobi"
2323

2424
puts "Converting to PDF... (this one takes a while)"
25-
`bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicCN progit.asc 2>/dev/null`
25+
`bundle exec asciidoctor-pdf -r ./config.rb -a pdf-style=KaiGenGothicCN progit.asc 2>/dev/null`
2626
puts " -- PDF output at progit.pdf"
2727
end
2828
end

config.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Bundler.require(:default)
2+
3+
class TrailingTreeprocessor < Asciidoctor::Extensions::Treeprocessor
4+
def process document
5+
return unless document.blocks?
6+
process_blocks document
7+
nil
8+
end
9+
10+
def process_blocks node
11+
node.blocks.each_with_index do |block, index|
12+
if block.context == :paragraph
13+
node.blocks[index] = create_paragraph block.document, block.content.gsub("\n", ''), block.attributes
14+
else
15+
process_blocks block
16+
end
17+
end
18+
end
19+
end
20+
21+
Asciidoctor::Extensions.register do
22+
treeprocessor TrailingTreeprocessor
23+
end

0 commit comments

Comments
 (0)