polytexnic 0.9.5 → 0.9.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: ac0f741ed9f9e9fc12fae1ece2669ea3cac6c297
4
- data.tar.gz: c9b400b7656626d7c01c62685a6afcf54cfa62d7
3
+ metadata.gz: 348b4c4315ac2e61f11e0a17d79c4fa0654ab3a9
4
+ data.tar.gz: a7b18141d05af5ef88e33c81fc90bf038dce71fa
5
5
  SHA512:
6
- metadata.gz: c08b0a2d337d40b82bf0d3dff77c2b192452c100cd1df7d306e1b1a877c11c24e103aac217d55b5a040beac93e29d7b40b1a1b5877c4ab555cb620b374b0300e
7
- data.tar.gz: 9fb84efd1b845ba40d59af9123f0e0a8cab3276901b7fa952e41df771a7153643a59edd4b3986286fa76ef44c7a34ff37392231e967aa9a8ea8f354172a37eef
6
+ metadata.gz: 13eae2112e674b2fb2c0e98ac24378461f3c62ee850e06b178d59b702f61d7a16f2b7fef62eefacf7c352401c5aefe6d5ae408d1836d32f070aa765c37848d06
7
+ data.tar.gz: 6de8e925e46fcdd10acd82a4ccc5c1d59e4cfce855992bc829e1f5a9286b1a2216f752edffd827b481c97b28eb34cea1cafa99cfe2fa265dcdb0145f1656226b
@@ -31,7 +31,7 @@ module Polytexnic
31
31
  label_names(output)
32
32
  image_names(output)
33
33
  restore_eq_labels(output)
34
- convert_figure_centering(output)
34
+ convert_float_centering(output)
35
35
  convert_longtable(output)
36
36
  mark_environments(output)
37
37
  make_tabular_alignment_cache(output)
@@ -194,22 +194,29 @@ module Polytexnic
194
194
  end
195
195
  end
196
196
 
197
- # Handles centering in figures.
197
+ # Handles centering in floats (figures and tables).
198
198
  # The way we handle generic \begin{center}...\end{center} doesn't
199
- # work in figures for some reason. Luckily, the preferred method
199
+ # work in floats for some reason. Luckily, the preferred method
200
200
  # is to use \centering anyway, so this kludge is actually better LaTeX.
201
- def convert_figure_centering(output)
202
- @in_figure = false
201
+ def convert_float_centering(output)
202
+ @in_float = false
203
203
  centered = output.split("\n").map do |line|
204
- if line =~ /^\s*\\begin\{figure\}/
205
- @in_figure = true
204
+ if line =~ /^\s*\\begin\{(figure|table)\}/
205
+ @in_float = true
206
+ @float_type = $1
206
207
  line
207
- elsif @in_figure && line =~ /^\s*\\begin\{center\}/
208
+ elsif @in_float && line =~ /^\s*\\begin\{center\}/
208
209
  '\centering'
209
- elsif @in_figure && line =~ /^\s*\\end\{center\}/
210
+ elsif @in_float && line =~ /^\s*\\end\{center\}/
210
211
  ''
211
- elsif @in_figure && line =~ /^\s*\\end\{figure\}/
212
- @in_figure = false
212
+ elsif @in_float && line =~/^\s*\\footnotesize/
213
+ # Removes \footnotesize in floats.
214
+ # This sizing is useful for tables
215
+ # in some LaTeX PDF contexts, but not in HTML,
216
+ # and it messes up the conversion.
217
+ ''
218
+ elsif @in_float && line =~ /^\s*\\end\{#{@float_type}\}/
219
+ @in_float = false
213
220
  line
214
221
  else
215
222
  line
@@ -206,8 +206,8 @@ module Polytexnic
206
206
  end
207
207
  end
208
208
  unless styles.nil?
209
- string.gsub!("\\begin{Verbatim}[",
210
- "\\begin{Verbatim}[#{styles},")
209
+ string.to_s.gsub!("\\begin{Verbatim}[",
210
+ "\\begin{Verbatim}[#{styles},")
211
211
  end
212
212
  string
213
213
  end
@@ -226,7 +226,7 @@ module Polytexnic
226
226
  # How many? I literally had to just keep adding backslashes until
227
227
  # the output was correct when running `softcover build:pdf`.
228
228
  def horrible_backslash_kludge(string)
229
- string.gsub!(/commandchars=\\\\/, 'commandchars=\\\\\\\\')
229
+ string.to_s.gsub!(/commandchars=\\\\/, 'commandchars=\\\\\\\\')
230
230
  end
231
231
 
232
232
  # Returns true if we are debugging, false otherwise.
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.6"
3
3
  end
@@ -293,6 +293,24 @@ describe 'Polytexnic::Pipeline#to_html' do
293
293
  EOS
294
294
  end
295
295
  end
296
+
297
+ context "with a table containing a centering environment" do
298
+ let(:polytex) do <<-'EOS'
299
+ \begin{table}
300
+ \footnotesize
301
+ \begin{center}
302
+ \begin{tabular}{lll}
303
+ \textbf{HTTP request} & \textbf{URL} & \textbf{Action} \\ \hline
304
+ \texttt{DELETE} & /users/1 & \kode{destroy}
305
+ \end{tabular}
306
+ \end{center}
307
+ \caption{RESTful routes provided by the Users resource.\label{table:RESTful_users}}
308
+ \end{table}
309
+ EOS
310
+ end
311
+
312
+ it { should resemble 'id="table-RESTful_users"' }
313
+ end
296
314
  end
297
315
  end
298
316
  end
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.9.5
4
+ version: 0.9.6
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: 2014-03-28 00:00:00.000000000 Z
12
+ date: 2014-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri