polytexnic 1.6.4 → 1.7.1

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
  SHA256:
3
- metadata.gz: 6d7799a38185640239ca691d3139570d4abbb14a35fbf9c900946bff62cc41eb
4
- data.tar.gz: 513c2c37e46535fd6abdd66448f6593daee2329be52c4768146205d74c0f17e6
3
+ metadata.gz: 57e941e13dd5f01d451a691ddfe12b2c0aec374936b6d3ab7b3e87bbb40b0155
4
+ data.tar.gz: 8713119cd89cb0a3ed59c89fe75fef408b4e529b511759605fe10f37906e59bb
5
5
  SHA512:
6
- metadata.gz: 79102ce8772b68e4a4d25a3b7ff3db533f06fff37804ba87ec347a5be785d5a290731232aa94849b17e725080f84863b1108a218550e70fffea224b2163993e4
7
- data.tar.gz: 4f0dc0d6b4d507bdab09071011f3168043d27627fdbe030d6ad2046531d8a6b544284f7aede474d6c13dd0bd4a91b02a77bc7c4427348eebed0669e56d0f9987
6
+ metadata.gz: 9745a0ed12d9980abd3155373e12a8d34547346d75685a0c2e3ae2489a6a774e9e5804ad57eeebb545bc4a8bfe267704a069fc86995585cfa9907d4f78f96e8b
7
+ data.tar.gz: 2fa3da2933f7a818ffcb4e7ba34737b422ea26e4362fbf3263f0c2c3a57f986bc189b6af0b873e4f5ee5429bd0f22e6972b5af8656e546cf533c09e9b157fa81
data/Gemfile CHANGED
@@ -22,6 +22,6 @@ group :test do
22
22
  end
23
23
 
24
24
  group :development do
25
- gem 'guard-rspec'
25
+ gem 'guard-rspec', require: false
26
26
  gem 'rake'
27
27
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polytexnic (1.6.4)
4
+ polytexnic (1.7.1)
5
5
  json (~> 2.3.0)
6
6
  kramdown (>= 2.0, < 3.0)
7
7
  msgpack (~> 1.2.0)
@@ -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.4.4)
26
+ diff-lcs (1.5.0)
27
27
  docile (1.1.5)
28
- ffi (1.15.0)
29
- formatador (0.2.5)
28
+ ffi (1.15.5)
29
+ formatador (1.1.0)
30
30
  growl (1.0.3)
31
- guard (2.16.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.9.12)
37
+ pry (>= 0.13.0)
38
38
  shellany (~> 0.0)
39
39
  thor (>= 0.18.1)
40
40
  guard-compat (1.2.1)
@@ -45,18 +45,18 @@ GEM
45
45
  json (2.3.1)
46
46
  kramdown (2.3.1)
47
47
  rexml
48
- listen (3.5.1)
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.3.1)
53
+ mime-types (3.4.1)
54
54
  mime-types-data (~> 3.2015)
55
- mime-types-data (3.2021.0225)
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.11.3-x86_64-darwin)
59
+ nokogiri (1.13.2-x86_64-darwin)
60
60
  racc (~> 1.4)
61
61
  notiffany (0.1.3)
62
62
  nenv (~> 0.1)
@@ -64,10 +64,10 @@ GEM
64
64
  pry (0.14.1)
65
65
  coderay (~> 1.1)
66
66
  method_source (~> 1.0)
67
- pygments.rb (2.2.0)
68
- racc (1.5.2)
69
- rake (13.0.3)
70
- rb-fsevent (0.10.4)
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)
@@ -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.13
110
+ 2.2.17
data/Guardfile CHANGED
@@ -1,15 +1,10 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
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
@@ -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
- node.inner_html = '&thinsp;'
795
+ # &#8201; replaces &thinsp;, which stopped working for some reason.
796
+ # Weirdly, it still works in the corresponding test.
797
+ node.inner_html = '&#8201;'
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,8 +279,16 @@ 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!('\begin{longtable}', '\begin{tabular}')
283
- output.gsub!('\end{longtable}', '\end{tabular}')
282
+ output.gsub!(/\\begin\{longtable\}(\{.*?\})\n\s*((?:\\caption|\\label).*?)\\\\$/) do
283
+ "\\begin{table}\n#{$2}\n\\begin{tabular}#{$1}"
284
+ end
285
+ output.gsub!(/\\begin\{longtable\}(\{.*?\})/) do
286
+ "\\begin{table}\n\\begin{tabular}#{$1}"
287
+ end
288
+ output.gsub!(/((?:\\caption|\\label).*?$)\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}}"
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.6.4"
2
+ VERSION = "1.7.1"
3
3
  end
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", "table"=>"Table", "figure"=>"Figure",
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
@@ -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,91 @@ describe 'Polytexnic::Pipeline#to_html' do
194
178
 
195
179
  describe "table environments" do
196
180
 
181
+ context "longtable" do
182
+
183
+ context "with caption on top" do
184
+
185
+ let(:polytex) do <<-'EOS'
186
+
187
+ \begin{longtable}{cc}
188
+ \caption{Test caption.\label{table:longtable}}\\
189
+ HTTP request & URL \\
190
+ GET & /users \\
191
+ GET & /users/1
192
+ \end{longtable}
193
+
194
+ Table~\ref{table:longtable}
195
+
196
+ EOS
197
+ end
198
+
199
+ let(:output) do <<-'EOS'
200
+ <div id="table-longtable" data-tralics-id="uid1" data-number="1" class="table">
201
+ <table class="tabular">
202
+ <tr><td class="align_center">HTTP request</td>
203
+ <td class="align_center">URL</td>
204
+ </tr><tr><td class="align_center">GET</td>
205
+ <td class="align_center">/users</td>
206
+ </tr><tr><td class="align_center">GET</td>
207
+ <td class="align_center">/users/1</td>
208
+ </tr></table>
209
+ <div class="caption">
210
+ <span class="header">Table 1: </span>
211
+ <span class="description">Test caption.
212
+ </span>
213
+ </div>
214
+ </div>
215
+ <p>
216
+ <a href="#table-longtable" class="hyperref">Table <span class="ref">1</span></a>
217
+ </p>
218
+ EOS
219
+ end
220
+
221
+ it { should resemble output }
222
+ end
223
+
224
+ context "with caption on bottom" do
225
+
226
+ let(:polytex) do <<-'EOS'
227
+
228
+ \begin{longtable}{cc}
229
+ HTTP request & URL \\
230
+ GET & /users \\
231
+ GET & /users/1
232
+ \caption{Test caption.\label{table:longtable}}
233
+ \end{longtable}
234
+
235
+ Table~\ref{table:longtable}
236
+
237
+ EOS
238
+ end
239
+
240
+ let(:output) do <<-'EOS'
241
+ <div id="table-longtable" data-tralics-id="uid1" data-number="1" class="table">
242
+ <table class="tabular">
243
+ <tr><td class="align_center">HTTP request</td>
244
+ <td class="align_center">URL</td>
245
+ </tr><tr><td class="align_center">GET</td>
246
+ <td class="align_center">/users</td>
247
+ </tr><tr><td class="align_center">GET</td>
248
+ <td class="align_center">/users/1</td>
249
+ </tr></table>
250
+ <div class="caption">
251
+ <span class="header">Table 1: </span>
252
+ <span class="description">Test caption.
253
+ </span>
254
+ </div>
255
+ </div>
256
+ <p>
257
+ <a href="#table-longtable" class="hyperref">Table <span class="ref">1</span></a>
258
+ </p>
259
+ EOS
260
+ end
261
+
262
+ it { should resemble output }
263
+ end
264
+ end
265
+
197
266
  context "with a label and a cross-reference" do
198
267
  let(:polytex) do <<-'EOS'
199
268
  \begin{table}
@@ -352,4 +421,4 @@ describe 'Polytexnic::Pipeline#to_html' do
352
421
 
353
422
  end
354
423
  end
355
- end
424
+ end
@@ -149,11 +149,20 @@ end
149
149
 
150
150
  describe "hyperref links" do
151
151
  let(:polytex) do <<-'EOS'
152
- Chapter~\ref{cha:foo}
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(:output) { '\hyperref[cha:foo]{Chapter~\ref{cha:foo}' }
156
- it { should resemble output }
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.6.4
4
+ version: 1.7.1
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: 2021-05-01 00:00:00.000000000 Z
12
+ date: 2022-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -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.2
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