From 668e168cea2879100f579f2a469fe8f06515b0c0 Mon Sep 17 00:00:00 2001 From: fauno <fauno@endefensadelsl.org> Date: Wed, 27 May 2020 16:18:52 -0300 Subject: [PATCH] prefer tectonic to add covers --- README.md | 8 +++++ lib/jekyll-pandoc-multiple-formats/printer.rb | 32 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3afa31a..1074c85 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 e5f2cef..2de8d49 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 -- GitLab