polytexnic 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/polytexnic/preprocessors/html.rb +18 -11
- data/lib/polytexnic/utils.rb +3 -3
- data/lib/polytexnic/version.rb +1 -1
- data/spec/to_html/table_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 348b4c4315ac2e61f11e0a17d79c4fa0654ab3a9
|
4
|
+
data.tar.gz: a7b18141d05af5ef88e33c81fc90bf038dce71fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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
|
202
|
-
@
|
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
|
-
@
|
204
|
+
if line =~ /^\s*\\begin\{(figure|table)\}/
|
205
|
+
@in_float = true
|
206
|
+
@float_type = $1
|
206
207
|
line
|
207
|
-
elsif @
|
208
|
+
elsif @in_float && line =~ /^\s*\\begin\{center\}/
|
208
209
|
'\centering'
|
209
|
-
elsif @
|
210
|
+
elsif @in_float && line =~ /^\s*\\end\{center\}/
|
210
211
|
''
|
211
|
-
elsif @
|
212
|
-
|
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
|
data/lib/polytexnic/utils.rb
CHANGED
@@ -206,8 +206,8 @@ module Polytexnic
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
unless styles.nil?
|
209
|
-
string.gsub!("\\begin{Verbatim}[",
|
210
|
-
|
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.
|
data/lib/polytexnic/version.rb
CHANGED
data/spec/to_html/table_spec.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|