Method: Polytexnic::Utils#tralics

Defined in:
lib/polytexnic/utils.rb

#tralicsObject

Returns the executable for the Tralics LaTeX-to-XML converter.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/polytexnic/utils.rb', line 10

def tralics
  executable = `which tralics`.chomp
  return executable unless executable.empty?
  filename = if apple_silicon?
               'tralics-apple-silicon'
             elsif os_x_newer?
               'tralics-os-x-newer'
             elsif os_x_older?
               'tralics-os-x-older'
             elsif linux?
               "tralics-#{RUBY_PLATFORM}"
             end
  project_root = File.join(File.dirname(__FILE__), '..', '..')
  executable = File.join(project_root, 'precompiled_binaries', filename)
  output = `#{executable}`
  unless output.include?('This is tralics')
    url = 'https://github.com/softcover/tralics'
    $stderr.puts "\nError: Document not built"
    $stderr.puts "No compatible Tralics LaTeX-to-XML translator found"
    $stderr.puts "Follow the instructions at\n  #{url}\n"
    $stderr.puts "to compile tralics and put it on your path"
    exit(1)
  end
  @tralics ||= executable
end