nanoc-latexmk 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31432aeef559015397ad00d6f276e265896c3b80
4
- data.tar.gz: 8f1ac7dc2a96aed15ef0a528dd6b9b65c9ebc9d0
3
+ metadata.gz: 07db9e5256a5237edc34e3047940216d30d72fb3
4
+ data.tar.gz: 65ab3406dc23d0f6dd874ea3c62560aa50c0868d
5
5
  SHA512:
6
- metadata.gz: '049a200efb3b01b6b5256956f3360b95a6eaf822a62c5323cabd18a6939eaf3e0360eb67d902a36ecc92598675bff4b3b1f55707777a849850868d006b20228c'
7
- data.tar.gz: 62057f6a30b0a4cfa78c3f6e724bf0506b294e24d3cbac508f3fb9118303ba9b22249dec6713934f7479bfe636ccf4e4460fb8224fb442a4c6f91a84e36624fc
6
+ metadata.gz: 03a8d5b35ea9d2055e9a33cd398dff7d96213780cc29e0b3b00c7b5798ebcd8b81f0473b30fde60ad99e8601d63ea896a849d04eae5b90c8d3365672f7a63ad5
7
+ data.tar.gz: c36223c99112741cbbe201278a882143477e9d11d427bf93aa8a5a7b2a4e6dc1b17ff01e4760abfa643f79367ac4f4de9c63d6603d8b01199c9060a32d867412
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Nanoc-latexmk
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/nanoc-latexmk.svg)](https://badge.fury.io/rb/nanoc-latexmk)
4
+
3
5
  [Nanoc](https://nanoc.ws/) filter to compile `.tex` files to pdf using the `latexmk` command. Supports both `pdflatex` and `xelatex`.
4
6
 
5
7
  ## System requirements
@@ -3,6 +3,7 @@
3
3
  require 'tmpdir'
4
4
 
5
5
  module Nanoc::Latexmk::Filters
6
+
6
7
  class LatexmkFilter < Nanoc::Filter
7
8
  identifier :latexmk
8
9
 
@@ -11,11 +12,11 @@ module Nanoc::Latexmk::Filters
11
12
  TMPFILE_NAME = 'nanoc-latexmk.tex'
12
13
 
13
14
  ENGINES = {
14
- pdflatex: { cmd: %w[pdflatex], param: '-pdf' },
15
- xelatex: { cmd: %w[xelatex], param: '-xelatex' }
15
+ pdflatex: '-pdf',
16
+ xelatex: '-xelatex'
16
17
  }.freeze
17
18
 
18
- LATEX_PARAMS = %w[-interaction=nonstopmode -halt-on-error].freeze
19
+ LATEX_PARAMS = %w[-interaction=nonstopmode -halt-on-error -file-line-error].freeze
19
20
 
20
21
  DEFAULT_PARAMS = {
21
22
  engine: :pdflatex,
@@ -27,13 +28,11 @@ module Nanoc::Latexmk::Filters
27
28
  params = DEFAULT_PARAMS.merge(params)
28
29
 
29
30
  raise 'Unknown Engine' unless ENGINES.key? params[:engine].to_sym
30
- engine = ENGINES[params[:engine].to_sym]
31
-
32
- latex_command = engine[:cmd]
33
31
 
34
- latex_command += params[:command_params]
32
+ latex_params = []
33
+ latex_params += params[:command_params]
35
34
 
36
- latex_command << if params[:shell_escape]
35
+ latex_params << if params[:shell_escape]
37
36
  '-shell-escape'
38
37
  else
39
38
  '-no-shell-escape'
@@ -44,15 +43,14 @@ module Nanoc::Latexmk::Filters
44
43
  f.write(content)
45
44
  f.flush
46
45
 
47
- latexmk_command = ['latexmk',
48
- engine[:param],
49
- "-latex=\"#{latex_command.join(' ')}\"",
50
- "-output-directory=#{dir}",
51
- f.path]
46
+ latexmk_command = ['latexmk', ENGINES[params[:engine].to_sym]] \
47
+ + latex_params.map { |p| '-latexoption=' + p } \
48
+ + ["-output-directory=#{dir}", f.path ]
49
+
50
+ puts "Running latexmk command: #{latexmk_command}"
52
51
 
53
52
  raise 'Build Error' unless system(*latexmk_command)
54
53
  system('mv', f.path.sub('.tex', '.pdf'), output_filename)
55
-
56
54
  end
57
55
  end
58
56
  end
@@ -3,7 +3,7 @@ module Nanoc
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 0
6
+ PATCH = 1
7
7
  BUILD = nil
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.homepage = 'https://github.com/rien/nanoc-latexmk'
10
10
  s.summary = 'Latexmk filter for nanoc.'
11
11
  s.description = 'Nanoc filter to convert latex files to pdf using latexmk'
12
+ s.license = 'Unlicense'
12
13
  s.files = `git ls-files`.split("\n")
13
14
  s.require_path = 'lib'
14
15
  end
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'byebug'
5
+ require 'timeout'
3
6
 
4
7
  describe Nanoc::Latexmk::Filters::LatexmkFilter do
5
8
  before(:each) do
@@ -20,5 +23,25 @@ describe Nanoc::Latexmk::Filters::LatexmkFilter do
20
23
  result = File.read @filter.output_filename
21
24
  expect(result.slice(0, @pdf_magic_bytes.length)).to eql(@pdf_magic_bytes)
22
25
  end
26
+
27
+ it 'compile to pdf using xelatex' do
28
+ expect(@filter.run(@input, engine: :xelatex)).to be_truthy
29
+
30
+ result = File.read @filter.output_filename
31
+ expect(result.slice(0, @pdf_magic_bytes.length)).to eql(@pdf_magic_bytes)
32
+ end
33
+
34
+ it 'crash without user interaction' do
35
+ @broken_input = <<~HEREDOC
36
+ \\documentclass{article}
37
+ \\begin{document}
38
+ \\foobar
39
+ \\end{document}
40
+ HEREDOC
41
+
42
+ Timeout::timeout(1) do
43
+ expect { @filter.run(@broken_input) }.to raise_error('Build Error')
44
+ end
45
+ end
23
46
  end
24
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-latexmk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rien Maertens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-23 00:00:00.000000000 Z
11
+ date: 2017-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Nanoc filter to convert latex files to pdf using latexmk
14
14
  email:
@@ -33,7 +33,8 @@ files:
33
33
  - spec/filters/latexmk_spec.rb
34
34
  - spec/spec_helper.rb
35
35
  homepage: https://github.com/rien/nanoc-latexmk
36
- licenses: []
36
+ licenses:
37
+ - Unlicense
37
38
  metadata: {}
38
39
  post_install_message:
39
40
  rdoc_options: []