softcover 0.7.5 → 0.7.6

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: 642f6e9fa8e34595d1d5811f2d843b072b78db25
4
- data.tar.gz: 6d62ef63616c5fc96aaae8510a7460a2ab9f758c
3
+ metadata.gz: a83ba9f61643640f01082c09127c294477feef73
4
+ data.tar.gz: a12fcfb63d60b4df9d323e8353d7439ebac6a0aa
5
5
  SHA512:
6
- metadata.gz: ce330e42045af1b357e2816dcacb521905b6b698113eb482e5cbbb81464f258c12e29e605c76e2d0ebf9350aa330968db11522055d8ec30c88a6a1caefb4657f
7
- data.tar.gz: dd2401d92cff7c84c7468c0ce7801adc001ede05815dd43fbfc0835572a3b738531a7a7bcefa196cf753a7b64e5408d1584857d6bbc4987163d0434e782e9d92
6
+ metadata.gz: 05bac2e39591b47a03eb6d53844e2d677c31a77cc273af9e51bb30105be2d55a7192362d066fc088b38c5afc96cff9c2fbe87667f705251e8a9fd7df4de3732b
7
+ data.tar.gz: b395d5d2bfe447838c9031cc7444a42541c41670e482b08af20476f5cb1784112e3bb25e2517827ad265df3c0f9d97cbff02777b30734aeef6f9d1f6f3ab15d8
@@ -42,40 +42,21 @@ module Softcover
42
42
  write_pygments_file(:latex)
43
43
  copy_polytexnic_sty
44
44
 
45
- if options[:'find-overfull']
46
- tmp_name = book_filename.sub('.tex', '.tmp.tex')
47
- # The way we do things, code listings show up as "Overfull", but
48
- # they're actually fine, so filter them out.
49
- filter_out_listings = "grep -v 3.22281pt"
50
- # Because each chapter typically lives in a separate file, it's
51
- # hard to correlate Overfull line numbers with lines in the source,
52
- # so we use grep's -A flag to provide some context instead. Authors
53
- # can then use their text editors' search function to find the
54
- # corresponding place in the text.
55
- show_context = 'grep -A 3 "Overfull \\\\\\\\hbox"'
56
- cmd = "xelatex #{tmp_name} | #{filter_out_listings} | #{show_context}"
57
- silence_stream(STDERR) { execute cmd }
58
- return
59
- end
60
-
61
- tmp_filename = Softcover::Utils.tmpify(manifest, book_filename)
62
- build_pdf = "#{xelatex} #{tmp_filename}"
63
- # Run the command twice (to guarantee up-to-date cross-references)
64
- # unless explicitly overriden.
65
45
  # Renaming the PDF in the command is necessary because `execute`
66
46
  # below uses `exec` (except in tests, where it breaks). Since `exec`
67
47
  # causes the Ruby process to end, any Ruby code after `exec`
68
48
  # is ignored.
69
49
  # (The reason for using `exec` is so that LaTeX errors get emitted to
70
50
  # the screen rather than just hanging the process.)
71
- pdf_cmd = options[:once] ? build_pdf : "#{build_pdf} ; #{build_pdf}"
72
- cmd = "#{pdf_cmd} ; #{rename_pdf(basename)}"
51
+ cmd = "#{pdf_cmd(book_filename, options)} ; #{rename_pdf(basename)}"
73
52
  # Here we use `system` when making a preview because the preview command
74
53
  # needs to run after the main PDF build.
75
54
  if options[:quiet] || options[:silent]
76
55
  silence_stream(STDERR) do
77
56
  silence { options[:preview] ? system(cmd) : execute(cmd) }
78
57
  end
58
+ elsif options[:'find-overfull']
59
+ silence_stream(STDERR) { execute(cmd) }
79
60
  else
80
61
  options[:preview] ? system(cmd) : execute(cmd)
81
62
  end
@@ -92,6 +73,35 @@ module Softcover
92
73
  @xelatex ||= executable(filename, message)
93
74
  end
94
75
 
76
+ # Returns the command to build the PDF (once).
77
+ def build_pdf(book_filename, options={})
78
+ tmp_filename = Softcover::Utils.tmpify(manifest, book_filename)
79
+ "#{xelatex} #{tmp_filename} #{options[:filters]}"
80
+ end
81
+
82
+ # Returns the full command to build the PDF.
83
+ def pdf_cmd(book_filename, options={})
84
+ if options[:once]
85
+ build_pdf(book_filename)
86
+ elsif options[:'find-overfull']
87
+ # The way we do things, code listings show up as "Overfull", but
88
+ # they're actually fine, so filter them out.
89
+ filter_out_listings = "grep -v 3.22281pt"
90
+ # Because each chapter typically lives in a separate file, it's
91
+ # hard to correlate Overfull line numbers with lines in the source,
92
+ # so we use grep's -A flag to provide some context instead. Authors
93
+ # can then use their text editors' search function to find the
94
+ # corresponding place in the text.
95
+ show_context = 'grep -A 3 "Overfull \\\\\\\\hbox"'
96
+ build_pdf(book_filename,
97
+ filters: "| #{filter_out_listings} | #{show_context}" )
98
+ else
99
+ # Run the command twice (to guarantee up-to-date cross-references).
100
+ cmd = build_pdf(book_filename)
101
+ "#{cmd} ; #{cmd}"
102
+ end
103
+ end
104
+
95
105
  # Returns the command to rename the temp PDF.
96
106
  # The purpose is to match the original filename.
97
107
  # For example, foo_bar.tex should produce foo_bar.pdf.
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softcover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl