diff --git a/README.md b/README.md index 3afa31a3da3a9a7f7e37b0e1c2a1c1a2504c7e2c..1074c85176129b38ccdb21da8c08262d90214803 100644 --- a/README.md +++ b/README.md @@ -212,3 +212,11 @@ Alternative, see Execute `jekyll build` normally :D +## Tectonic + +If you want to use Tectonic, make sure it's installed into +`/usr/bin/tectonic` (or symlink it). It will be used instead of rtex +for imposition and adding covers. + +It's specially useful if you're using unicode characters in your file +names. diff --git a/lib/jekyll-pandoc-multiple-formats/printer.rb b/lib/jekyll-pandoc-multiple-formats/printer.rb index e5f2cef24b406d577829ff4c81df5c0acf0a548b..2de8d49831f077fc060dffc7a2837e674e831369 100644 --- a/lib/jekyll-pandoc-multiple-formats/printer.rb +++ b/lib/jekyll-pandoc-multiple-formats/printer.rb @@ -52,7 +52,8 @@ module JekyllPandocMultipleFormats } attr_accessor :output_file, :original_file, :pages, :template, - :papersize, :sheetsize, :nup, :extra_options, :relative_path + :papersize, :sheetsize, :nup, :extra_options, :relative_path, + :tectonic def initialize(file, papersize = nil, sheetsize = nil, extra_options = nil) return unless /\.pdf\Z/ =~ file @@ -85,15 +86,36 @@ module JekyllPandocMultipleFormats return true end - # Create the imposed file - pdflatex = RTeX::Document.new(template) - pdflatex.to_pdf do |pdf_file| - FileUtils.cp pdf_file, @output_file + # Create the imposed file. Using tectonic allows us to have a + # minimal LaTeX distribution that can understand unicode + # filenames. Otherwise use RTeX as best effort. + if tectonic? + Open3::popen2e(tectonic, '-') do |stdin, stdout, thread| + stdin.puts template + stdin.close + STDERR.print stdout.read + + # Wait for the process to finish + thread.value + end + + FileUtils.mv 'texput.pdf', @output_file + else + pdflatex = RTeX::Document.new(template) + pdflatex.to_pdf do |pdf_file| + FileUtils.cp pdf_file, @output_file + end end File.exists? @output_file end + def tectonic? + @tectonic ||= '/usr/bin/tectonic' + + File.exists? tectonic + end + def is_landscape? [2,8,32,128].include? @nup end