polytexnic 1.6.3 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +20 -19
- data/Guardfile +5 -10
- data/lib/polytexnic/literal.rb +3 -1
- data/lib/polytexnic/postprocessors/html.rb +3 -1
- data/lib/polytexnic/preprocessors/html.rb +13 -3
- data/lib/polytexnic/version.rb +1 -1
- data/lib/polytexnic.rb +4 -4
- data/polytexnic.gemspec +1 -1
- data/spec/to_html/table_spec.rb +37 -17
- data/spec/to_latex_spec.rb +12 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d40834bb8a0205105739c3c347480faf14ddb63f64afeab9197e165d8b92bf5d
|
4
|
+
data.tar.gz: c8571137c2be72affefe7ff6f4b40770e1e4fc52a4c67b6b7e1ea1e0cddf45a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d2d76d36ba1dcbb41f5db7bde576cccc23c8db83886ce9146885a0abee32be8827e172fe3f5670d160d2ca29d2e0d39ecca22464cb49c7c05ad666dd72f50e9
|
7
|
+
data.tar.gz: 28688818b0a7ba361ad24c6e6cd7b807671e294cc0e8253e15b75c75bde1bfcf08e7401c258a3e1f80ccfbacf0e0dd7f338b17520bbe1f75bd00e8ee7c764379
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
polytexnic (1.
|
4
|
+
polytexnic (1.7.0)
|
5
5
|
json (~> 2.3.0)
|
6
|
-
kramdown (>=
|
6
|
+
kramdown (>= 2.0, < 3.0)
|
7
7
|
msgpack (~> 1.2.0)
|
8
8
|
nokogiri (>= 1.6.0, < 2.0)
|
9
9
|
pygments.rb (~> 2.1)
|
@@ -23,18 +23,18 @@ GEM
|
|
23
23
|
debugger2 (1.0.0.beta2)
|
24
24
|
columnize (>= 0.3.1)
|
25
25
|
debugger-linecache (~> 1.2.0)
|
26
|
-
diff-lcs (1.
|
26
|
+
diff-lcs (1.5.0)
|
27
27
|
docile (1.1.5)
|
28
|
-
ffi (1.15.
|
29
|
-
formatador (
|
28
|
+
ffi (1.15.5)
|
29
|
+
formatador (1.1.0)
|
30
30
|
growl (1.0.3)
|
31
|
-
guard (2.
|
31
|
+
guard (2.18.0)
|
32
32
|
formatador (>= 0.2.4)
|
33
33
|
listen (>= 2.7, < 4.0)
|
34
34
|
lumberjack (>= 1.0.12, < 2.0)
|
35
35
|
nenv (~> 0.1)
|
36
36
|
notiffany (~> 0.0)
|
37
|
-
pry (>= 0.
|
37
|
+
pry (>= 0.13.0)
|
38
38
|
shellany (~> 0.0)
|
39
39
|
thor (>= 0.18.1)
|
40
40
|
guard-compat (1.2.1)
|
@@ -43,36 +43,36 @@ GEM
|
|
43
43
|
guard-compat (~> 1.1)
|
44
44
|
rspec (>= 2.99.0, < 4.0)
|
45
45
|
json (2.3.1)
|
46
|
-
kramdown (2.3.
|
46
|
+
kramdown (2.3.1)
|
47
47
|
rexml
|
48
|
-
listen (3.
|
48
|
+
listen (3.7.1)
|
49
49
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
50
50
|
rb-inotify (~> 0.9, >= 0.9.10)
|
51
51
|
lumberjack (1.2.8)
|
52
52
|
method_source (1.0.0)
|
53
|
-
mime-types (3.
|
53
|
+
mime-types (3.4.1)
|
54
54
|
mime-types-data (~> 3.2015)
|
55
|
-
mime-types-data (3.
|
55
|
+
mime-types-data (3.2022.0105)
|
56
56
|
msgpack (1.2.10)
|
57
57
|
multi_json (1.15.0)
|
58
58
|
nenv (0.3.0)
|
59
|
-
nokogiri (1.
|
59
|
+
nokogiri (1.13.2-x86_64-darwin)
|
60
60
|
racc (~> 1.4)
|
61
61
|
notiffany (0.1.3)
|
62
62
|
nenv (~> 0.1)
|
63
63
|
shellany (~> 0.0)
|
64
|
-
pry (0.14.
|
64
|
+
pry (0.14.1)
|
65
65
|
coderay (~> 1.1)
|
66
66
|
method_source (~> 1.0)
|
67
|
-
pygments.rb (2.
|
68
|
-
racc (1.
|
69
|
-
rake (13.0.
|
70
|
-
rb-fsevent (0.
|
67
|
+
pygments.rb (2.3.0)
|
68
|
+
racc (1.6.0)
|
69
|
+
rake (13.0.6)
|
70
|
+
rb-fsevent (0.11.1)
|
71
71
|
rb-inotify (0.10.1)
|
72
72
|
ffi (~> 1.0)
|
73
73
|
rest-client (1.6.7)
|
74
74
|
mime-types (>= 1.16)
|
75
|
-
rexml (3.2.
|
75
|
+
rexml (3.2.5)
|
76
76
|
rspec (2.99.0)
|
77
77
|
rspec-core (~> 2.99.0)
|
78
78
|
rspec-expectations (~> 2.99.0)
|
@@ -94,6 +94,7 @@ GEM
|
|
94
94
|
|
95
95
|
PLATFORMS
|
96
96
|
x86_64-darwin-19
|
97
|
+
x86_64-darwin-20
|
97
98
|
|
98
99
|
DEPENDENCIES
|
99
100
|
coveralls
|
@@ -106,4 +107,4 @@ DEPENDENCIES
|
|
106
107
|
simplecov (~> 0.15.1)
|
107
108
|
|
108
109
|
BUNDLED WITH
|
109
|
-
2.2.
|
110
|
+
2.2.17
|
data/Guardfile
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# Feel free to open issues for suggestions and improvements
|
3
6
|
|
4
|
-
guard :rspec do
|
5
7
|
watch(%r{^spec/.+_spec\.rb$})
|
6
8
|
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
7
|
-
## Uncomment & edit below (and comment out above) to watch particular specs.
|
8
|
-
# watch(%r{^lib/(.+)\.rb$}) do
|
9
|
-
# [
|
10
|
-
# "spec/to_html/asides_spec.rb",
|
11
|
-
# "spec/to_html/codelistings_spec.rb"
|
12
|
-
# ]
|
13
|
-
# end
|
14
9
|
watch('spec/spec_helper.rb') { "spec" }
|
15
10
|
end
|
data/lib/polytexnic/literal.rb
CHANGED
@@ -209,8 +209,10 @@ module Polytexnic
|
|
209
209
|
# For completeness, we handle the case where the author neglects to
|
210
210
|
# use the nonbreak space ~.
|
211
211
|
def hyperrefs(string)
|
212
|
+
part = language_labels["part"]
|
212
213
|
chapter = language_labels["chapter"]["word"]
|
213
214
|
section = language_labels["section"]
|
215
|
+
appendix = language_labels["appendix"]
|
214
216
|
table = language_labels["table"]
|
215
217
|
box = language_labels["aside"]
|
216
218
|
figure = language_labels["figure"]
|
@@ -218,7 +220,7 @@ module Polytexnic
|
|
218
220
|
listing = language_labels["listing"]
|
219
221
|
equation = language_labels["equation"]
|
220
222
|
eq = language_labels["eq"]
|
221
|
-
linked_item = "(#{chapter}|#{section}|#{table}|#{box}|#{figure}" +
|
223
|
+
linked_item = "(#{part}|#{chapter}|#{section}|#{appendix}|#{table}|#{box}|#{figure}" +
|
222
224
|
"|#{fig}\.|#{listing}|#{equation}|#{eq}\.)"
|
223
225
|
ref = /(?:#{linked_item}(~| ))*(\\(?:eq)*ref){(.*?)}/i
|
224
226
|
string.gsub!(ref) do
|
@@ -792,7 +792,9 @@ module Polytexnic
|
|
792
792
|
doc.xpath('//thinspace').each do |node|
|
793
793
|
node.name = 'span'
|
794
794
|
node['class'] = 'thinspace'
|
795
|
-
|
795
|
+
#   replaces  , which stopped working for some reason.
|
796
|
+
# Weirdly, it still works in the corresponding test.
|
797
|
+
node.inner_html = ' '
|
796
798
|
end
|
797
799
|
doc.xpath('//normalspace').each do |node|
|
798
800
|
node.replace(' ')
|
@@ -28,11 +28,11 @@ module Polytexnic
|
|
28
28
|
hyperrefs(output)
|
29
29
|
title_fields(output)
|
30
30
|
maketitle(output)
|
31
|
+
convert_longtable(output)
|
31
32
|
label_names(output)
|
32
33
|
image_names(output)
|
33
34
|
restore_eq_labels(output)
|
34
35
|
convert_float_centering(output)
|
35
|
-
convert_longtable(output)
|
36
36
|
mark_environments(output)
|
37
37
|
make_tabular_alignment_cache(output)
|
38
38
|
cache_unicode(output)
|
@@ -279,13 +279,23 @@ module Polytexnic
|
|
279
279
|
# input documents. The latest update includes support for the tabularx
|
280
280
|
# environment
|
281
281
|
def convert_longtable(output)
|
282
|
-
output.gsub!(
|
283
|
-
|
282
|
+
output.gsub!(/\\begin\{longtable\}(\{.*?\})\n((?:\\caption|\\label)\S*?$)/m) do
|
283
|
+
"\\begin{table}\n#{$2}\n\\begin{tabular}#{$1}"
|
284
|
+
end
|
285
|
+
output.gsub!(/\\begin\{longtable\}(\{.*?\})/m) do
|
286
|
+
"\\begin{table}\n\\begin{tabular}#{$1}"
|
287
|
+
end
|
288
|
+
output.gsub!(/((?:\\caption|\\label)\S*?$)\n\s*\\end\{longtable\}/) do
|
289
|
+
"\\end{tabular}#{$1}\n\\end{table}"
|
290
|
+
end
|
291
|
+
output.gsub!('\end{longtable}', "\\end{tabular}\n\\end{table}")
|
284
292
|
output.gsub!(/\\begin\{tabularx\}\{.*?\}\{(.*)\}/) do
|
285
293
|
alignment = $1.gsub('X', 'l') # X becomes left-justified in HTML
|
286
294
|
"\\begin{tabular}{#{alignment}}"
|
287
295
|
end
|
288
296
|
output.gsub!('\end{tabularx}', '\end{tabular}')
|
297
|
+
# puts output
|
298
|
+
# puts '+' * 50
|
289
299
|
end
|
290
300
|
|
291
301
|
# Marks environments with their types.
|
data/lib/polytexnic/version.rb
CHANGED
data/lib/polytexnic.rb
CHANGED
@@ -54,7 +54,7 @@ module Polytexnic
|
|
54
54
|
else
|
55
55
|
default_language_labels.merge(labels)
|
56
56
|
end
|
57
|
-
tempdir = 'tmp'
|
57
|
+
tempdir = 'tmp'
|
58
58
|
FileUtils.mkdir(tempdir) unless File.directory?(tempdir)
|
59
59
|
@highlight_cache_filename = File.join(tempdir, '.highlight_cache')
|
60
60
|
if File.exist?(@highlight_cache_filename)
|
@@ -109,9 +109,9 @@ module Polytexnic
|
|
109
109
|
|
110
110
|
# Returns the default labels for 'Chapter', 'Figure', etc.
|
111
111
|
def default_language_labels
|
112
|
-
{"chapter"=>{"word"=>"Chapter", "order"=>"standard"},
|
113
|
-
"section"=>"Section", "
|
114
|
-
"fig"=>"Fig", "aside"=>"Box", "listing"=>"Listing",
|
112
|
+
{"part"=>"Part","chapter"=>{"word"=>"Chapter", "order"=>"standard"},
|
113
|
+
"section"=>"Section", "appendix"=>"Appendix", "table"=>"Table",
|
114
|
+
"figure"=>"Figure", "fig"=>"Fig", "aside"=>"Box", "listing"=>"Listing",
|
115
115
|
"equation"=>"Equation", "eq"=>"Eq", "frontmatter"=>"Frontmatter",
|
116
116
|
"contents"=>"Contents"}
|
117
117
|
end
|
data/polytexnic.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_dependency 'nokogiri', '>= 1.6.0', '< 2.0'
|
22
22
|
gem.add_dependency 'pygments.rb', '~> 2.1'
|
23
23
|
gem.add_dependency 'msgpack', '~> 1.2.0'
|
24
|
-
gem.add_dependency 'kramdown', '>=
|
24
|
+
gem.add_dependency 'kramdown', '>= 2.0', '< 3.0'
|
25
25
|
gem.add_dependency 'json', '~> 2.3.0'
|
26
26
|
|
27
27
|
gem.add_development_dependency 'rspec', '~> 2.14'
|
data/spec/to_html/table_spec.rb
CHANGED
@@ -33,22 +33,6 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it { should resemble output }
|
36
|
-
|
37
|
-
context "longtable" do
|
38
|
-
|
39
|
-
let(:polytex) do <<-'EOS'
|
40
|
-
\begin{longtable}{cc}
|
41
|
-
\hline
|
42
|
-
HTTP request & URL \\
|
43
|
-
\hline
|
44
|
-
GET & /users \\
|
45
|
-
GET & /users/1
|
46
|
-
\end{longtable}
|
47
|
-
EOS
|
48
|
-
end
|
49
|
-
|
50
|
-
it { should resemble output }
|
51
|
-
end
|
52
36
|
end
|
53
37
|
|
54
38
|
context "tabularx environments" do
|
@@ -194,6 +178,42 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
194
178
|
|
195
179
|
describe "table environments" do
|
196
180
|
|
181
|
+
context "longtable" do
|
182
|
+
|
183
|
+
let(:polytex) do <<-'EOS'
|
184
|
+
|
185
|
+
\begin{longtable}{cc}
|
186
|
+
\label{table:longtable}
|
187
|
+
HTTP request & URL \\
|
188
|
+
GET & /users \\
|
189
|
+
GET & /users/1
|
190
|
+
\end{longtable}
|
191
|
+
|
192
|
+
Table~\ref{table:longtable}
|
193
|
+
|
194
|
+
EOS
|
195
|
+
end
|
196
|
+
|
197
|
+
let(:output) do <<-'EOS'
|
198
|
+
<div id="table-longtable" data-tralics-id="uid1" data-number="1" class="table">
|
199
|
+
<table class="tabular"><tr><td class="align_center">HTTP request</td>
|
200
|
+
<td class="align_center">URL</td>
|
201
|
+
</tr><tr><td class="align_center">GET</td>
|
202
|
+
<td class="align_center">/users</td>
|
203
|
+
</tr><tr><td class="align_center">GET</td>
|
204
|
+
<td class="align_center">/users/1</td>
|
205
|
+
</tr></table>
|
206
|
+
<div class="caption">
|
207
|
+
<span class="header">Table 1</span>
|
208
|
+
</div>
|
209
|
+
</div>
|
210
|
+
<p><a href="#table-longtable" class="hyperref">Table <span class="ref">1</span></a></p>
|
211
|
+
EOS
|
212
|
+
end
|
213
|
+
|
214
|
+
it { should resemble output }
|
215
|
+
end
|
216
|
+
|
197
217
|
context "with a label and a cross-reference" do
|
198
218
|
let(:polytex) do <<-'EOS'
|
199
219
|
\begin{table}
|
@@ -352,4 +372,4 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
352
372
|
|
353
373
|
end
|
354
374
|
end
|
355
|
-
end
|
375
|
+
end
|
data/spec/to_latex_spec.rb
CHANGED
@@ -149,11 +149,20 @@ end
|
|
149
149
|
|
150
150
|
describe "hyperref links" do
|
151
151
|
let(:polytex) do <<-'EOS'
|
152
|
-
|
152
|
+
Part~\ref{prt:foo}
|
153
|
+
Chapter~\ref{cha:bar}
|
154
|
+
Section~\ref{sec:baz}
|
155
|
+
Appendix~\ref{cha:quux}
|
153
156
|
EOS
|
154
157
|
end
|
155
|
-
let(:
|
156
|
-
|
158
|
+
let(:part_ref) { '\hyperref[prt:foo]{Part~\ref{prt:foo}' }
|
159
|
+
let(:chapter_ref) { '\hyperref[cha:bar]{Chapter~\ref{cha:bar}' }
|
160
|
+
let(:section_ref) { '\hyperref[sec:baz]{Section~\ref{sec:baz}' }
|
161
|
+
let(:appendix_ref) { '\hyperref[cha:quux]{Appendix~\ref{cha:quux}' }
|
162
|
+
it { should resemble part_ref }
|
163
|
+
it { should resemble chapter_ref }
|
164
|
+
it { should resemble section_ref }
|
165
|
+
it { should resemble appendix_ref }
|
157
166
|
end
|
158
167
|
|
159
168
|
describe "asides" do
|
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: 1.
|
4
|
+
version: 1.7.0
|
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:
|
12
|
+
date: 2022-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.0'
|
69
69
|
- - "<"
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '3.0'
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: '
|
78
|
+
version: '2.0'
|
79
79
|
- - "<"
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '3.0'
|
@@ -308,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
308
308
|
- !ruby/object:Gem::Version
|
309
309
|
version: '0'
|
310
310
|
requirements: []
|
311
|
-
rubygems_version: 3.1.
|
311
|
+
rubygems_version: 3.1.6
|
312
312
|
signing_key:
|
313
313
|
specification_version: 4
|
314
314
|
summary: Convert from PolyTeX & Markdown to HTML & LaTeX
|