Replacing command with paru

Using the pandoc wrapper Paru  to allow cross platform compatability
This commit is contained in:
MikaelBergquist 2017-09-20 23:04:05 +02:00
parent 51e03981a2
commit 226b2a8695
1 changed files with 14 additions and 6 deletions

View File

@ -33,12 +33,20 @@ def format_match(format)
end
def gen_epub(name, _format)
if command?('pandoc') && format_match(:epub)
# Convert it to epub
`pandoc -S -o books/#{name}.epub --epub-metadata=metadata/#{name}.xml --epub-cover-image=covers/#{name}.jpg books/#{name}.html`
puts '[epub] Generated EPUB file'
else
puts "[error] Can't generate EPUB without pandoc"
if format_match(:epub)
begin
require "paru/pandoc"
Paru::Pandoc.new do
from "html"
to "epub"
epub_metadata "metadata/#{name}.xml"
epub_cover_image "covers/#{name}.jpg"
output "books/#{name}.epub"
end.convert File.read("books/#{name}.html")
puts '[epub] Generated EPUB file'
rescue LoadError
puts "[error] Can't generate EPUB without paru"
end
end
end