polytexnic 0.7.4 → 0.7.5

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: 79efdbbf104728740b5f914246576bed48de4e7f
4
- data.tar.gz: db68bb996ee36dae5a50d11d148a99a4fb27185c
3
+ metadata.gz: 992b4e844c5cfcf319fd51187c7149f407ede674
4
+ data.tar.gz: 41d96e893e916971b0b1bc2a097edd0cc724eff1
5
5
  SHA512:
6
- metadata.gz: e2d1c109775edd3a36dedd8419e1a35c9897b64c413058e23ca5cb106619e2167a475e771bc94a4ccc59bc066a5c466888a8924826347c68b7efbeeeb9dad49a
7
- data.tar.gz: 1048adc5309ab22bab8ba836cb31017451c33ea51a70dd46e5fa15ac3cdacccfb49dd156cf876dba0ae0eba585f07fbd1e55a69e17671ab093d34530432811c9
6
+ metadata.gz: 3275186896b0e6447fc3c50b3b259cc45520c76d0f40d4fa43e27524b4d04e30ec5a8330f17d31ceec02b9377a4a0cd279ef177904a0cf06fa618d3efab30f3a
7
+ data.tar.gz: 41e7f7ab12d747692d8ebd736a5d7cac1684e627f5507ad3bb43ca28a98839dae37fc354246c1a3d5dc767a2483f6429eda87fabf5dfd3b295c35251fd4fc385
File without changes
@@ -886,10 +886,7 @@ module Polytexnic
886
886
  clean_node internal_paragraph, 'rend'
887
887
  end
888
888
  if node['file'] && node['extension']
889
- extension = node['extension']
890
- # Support PDF images in PDF documents and PNGs in HTML.
891
- extension = 'png' if extension == 'pdf'
892
- filename = "#{node['file']}.#{extension}"
889
+ filename = png_for_pdf(node['file'], node['extension'])
893
890
  alt = File.basename(node['file'])
894
891
  img = %(<img src="#{filename}" alt="#{alt}" />)
895
892
  graphic = %(<div class="graphics">#{img}</div>)
@@ -922,11 +919,28 @@ module Polytexnic
922
919
  container.name = 'div'
923
920
  container['class'] = 'graphics ' + klass
924
921
  node.name = 'img'
925
- node['src'] = node.content.gsub(underscore_digest, '_')
922
+ node['src'] = png_for_pdf(node.content.gsub(underscore_digest, '_'))
926
923
  node['alt'] = node['src'].split('.').first
927
924
  node.content = ""
928
925
  end
929
926
 
927
+ # Returns the name of an image file with PNG for PDF if necessary.
928
+ # This is to support PDF images in the raw source, which look good in
929
+ # PDF document, but need to be web-friendly in the HTML. We standardize
930
+ # on PNG for simplicity. This means that, to do something like
931
+ # \image{images/foo.pdf}
932
+ # authors need to have both foo.pdf and foo.png in their images/
933
+ # directory. In this case, foo.pdf will be used in the PDF output, while
934
+ # foo.png will automatically be used in the HTML, EPUB, & MOBI versions.
935
+ def png_for_pdf(name, extension=nil)
936
+ if extension.nil?
937
+ name.sub('.pdf', '.png')
938
+ else
939
+ ext = extension == 'pdf' ? 'png' : extension
940
+ "#{name}.#{ext}"
941
+ end
942
+ end
943
+
930
944
  # Adds a caption to a node.
931
945
  # This works for figures and tables (at the least).
932
946
  def add_caption(node, options={})
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
@@ -287,13 +287,13 @@ describe 'Polytexnic::Pipeline#to_html' do
287
287
  EOS
288
288
  end
289
289
 
290
- context "using the \\image command" do
290
+ context "using the \\image command and a PDF file image file" do
291
291
  let(:polytex) do <<-'EOS'
292
292
  \chapter{The chapter}
293
293
  \label{cha:lorem_ipsum}
294
294
 
295
295
  \begin{figure}
296
- \image{foo_bar.png}
296
+ \image{foo_bar.pdf}
297
297
  \caption{This is a caption.\label{fig:foo}}
298
298
  \end{figure}
299
299
  EOS
@@ -320,13 +320,13 @@ describe 'Polytexnic::Pipeline#to_html' do
320
320
  end
321
321
  end
322
322
 
323
- context "using the \\imagebox command" do
323
+ context "using the \\imagebox command and PDF image file" do
324
324
  let(:polytex) do <<-'EOS'
325
325
  \chapter{The chapter}
326
326
  \label{cha:lorem_ipsum}
327
327
 
328
328
  \begin{figure}
329
- \imagebox{foo_bar.png}
329
+ \imagebox{foo_bar.pdf}
330
330
  \caption{This is a caption.\label{fig:foo}}
331
331
  \end{figure}
332
332
  EOS
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polytexnic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-13 00:00:00.000000000 Z
12
+ date: 2013-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -192,6 +192,7 @@ files:
192
192
  - .pull_requests/1386184858
193
193
  - .pull_requests/1386718874
194
194
  - .pull_requests/1386936855
195
+ - .pull_requests/1387316123
195
196
  - .rspec
196
197
  - Gemfile
197
198
  - Guardfile