polytexnic 1.2.7 → 1.2.8

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: df4becd6bd2c3dd71b711267c5c8815f96143f1b
4
- data.tar.gz: 1570629ee0a00d61123414ac038ef5e175c08b54
3
+ metadata.gz: 236a393d1952c7817f2caff587fe407222875cb4
4
+ data.tar.gz: 1b19fd05f87d6e1e7eacedd9b379ebe5dbdd7ed4
5
5
  SHA512:
6
- metadata.gz: 1e36d512f856f48fa2c20c56641bd342161aee1caf09f83addd22758643b4199747950dd540ebb3ed5c154c1d8937ccb3f88f72a76f897a686964ff8a3d0e633
7
- data.tar.gz: ec2a4fd5d5923b02373091cc7ec3018a5561706c1d8f7df63563f3bb7d7bfa31fdc6943775ac2db4c6282df545e419921fbfc43237192b4520503958c0dcbe9f
6
+ metadata.gz: c0676b6b6a055287399ddabd56d081c5c3540765698c4098428458c438d8260760b0abaf5ae689c5acf5b477d034b949102f0b217844d637ebc27eeff53aa825
7
+ data.tar.gz: 2baadf8881a2dfcab3e925a82a0cf9453732e8853338b5e6b67c0e3525d47a2ae3d8d57a24152302048afce0f0e1d61a414653c4c23ec0efc2eb7ff6a9d08d8f
@@ -53,6 +53,7 @@ module Polytexnic
53
53
  mainmatter(doc)
54
54
  footnotes(doc)
55
55
  table_of_contents(doc)
56
+ add_noindent(doc)
56
57
  convert_to_html(doc)
57
58
  end
58
59
 
@@ -698,7 +699,7 @@ module Polytexnic
698
699
  # Converts filesystem path (\filepath) to the proper tag.
699
700
  def filepath(doc)
700
701
  doc.xpath('//filepath').each do |node|
701
- node.name = 'span'
702
+ node.name = 'code'
702
703
  node['class'] = 'filepath'
703
704
  end
704
705
  end
@@ -860,7 +861,7 @@ module Polytexnic
860
861
  def restore_inline_verbatim(doc)
861
862
  doc.xpath('//inlineverbatim').each do |node|
862
863
  node.content = literal_cache[node.content]
863
- node.name = 'span'
864
+ node.name = 'code'
864
865
  node['class'] = 'inline_verbatim'
865
866
  end
866
867
  end
@@ -1356,6 +1357,28 @@ module Polytexnic
1356
1357
  html << open << link.to_xhtml << '</li>'
1357
1358
  end
1358
1359
 
1360
+ # Adds a noindent class where appropriate.
1361
+ # The purpose is to give the designer the option to indent all paragraphs but the first
1362
+ # one after the beginning of a chapter or section. The method is to add a "noindent" class
1363
+ # in the first paragraph after each division (chapter, section, etc.).
1364
+ def add_noindent(doc)
1365
+ divisions = %w[chapter section subsection subsubsection]
1366
+ divisions += divisions.map { |division| "#{division}-star"}
1367
+ divisions.each do |type|
1368
+ doc.css("div.#{type}").each do |node|
1369
+ if (first_paragraph = node.at_css('p'))
1370
+ if first_paragraph['class'] == 'noindent'
1371
+ next
1372
+ elsif first_paragraph['class'].nil?
1373
+ first_paragraph['class'] = 'noindent'
1374
+ else
1375
+ first_paragraph['class'] += ' noindent'
1376
+ end
1377
+ end
1378
+ end
1379
+ end
1380
+ end
1381
+
1359
1382
  # Cleans a node by removing all the given attributes.
1360
1383
  def clean_node(node, attributes)
1361
1384
  [*attributes].each { |a| node.remove_attribute a }
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.2.7"
2
+ VERSION = "1.2.8"
3
3
  end
@@ -1,5 +1,5 @@
1
1
 
2
- <p>This is inline verbatim text: <span class="inline_verbatim">\LaTeX and a literal $</span>.<span class="intersentencespace"></span> This is non-inline verbatim text:
2
+ <p>This is inline verbatim text: <code class="inline_verbatim">\LaTeX and a literal $</code>.<span class="intersentencespace"></span> This is non-inline verbatim text:
3
3
  </p><pre class="verbatim"> % \begin{verbatim}
4
4
  % This is verbatim text.
5
5
  % \end{verbatim}</pre>
@@ -32,7 +32,7 @@ describe 'Polytexnic::Pipeline#to_html' do
32
32
  <span class="number">Box 1.1.</span>
33
33
  <span class="description">Lorem ipsum.</span>
34
34
  </div>
35
- <p>lorem ipsum</p>
35
+ <p class="noindent">lorem ipsum</p>
36
36
  <p>dolor sit amet</p>
37
37
  </div>
38
38
  <p><a href="#aside-lorem" class="hyperref">Box <span class="ref">1.1</span></a></p>
@@ -202,7 +202,7 @@ describe 'Polytexnic::Pipeline#to_html' do
202
202
  <h2><a href="#foo_baz" class="heading">Foo: baz</a></h2>
203
203
  <div class="subsection-star">
204
204
  <h3><a class="heading">Bar</a></h3>
205
- <p>Lorem ipsum</p>
205
+ <p class="noindent">Lorem ipsum</p>
206
206
  </div>
207
207
  </div>
208
208
  <div id="cid1" data-tralics-id="cid1" class="section" data-number="1">
@@ -233,7 +233,7 @@ describe 'Polytexnic::Pipeline#to_html' do
233
233
  should resemble <<-'EOS'
234
234
  <div id="cha-foo_bar" data-tralics-id="cid1" class="chapter" data-number="1">
235
235
  <h1><a href="#cha-foo_bar" class="heading"><span class="number">Chapter 1 </span>Foo</a></h1>
236
- <p><a href="#cha-foo_bar" class="hyperref">Chapter <span class="ref">1</span></a>
236
+ <p class="noindent"><a href="#cha-foo_bar" class="hyperref">Chapter <span class="ref">1</span></a>
237
237
  and
238
238
  <a href="#cha-foo_baz" class="hyperref">Chapter <span class="ref">2</span></a>
239
239
  </p>
@@ -241,7 +241,7 @@ describe 'Polytexnic::Pipeline#to_html' do
241
241
 
242
242
  <div id="cha-foo_baz" data-tralics-id="cid2" class="chapter" data-number="2">
243
243
  <h1><a href="#cha-foo_baz" class="heading"><span class="number">Chapter 2 </span>Baz</a></h1>
244
- <p><a href="#cha-foo_baz" class="hyperref">Chapter <span class="ref">2</span></a>
244
+ <p class="noindent"><a href="#cha-foo_baz" class="hyperref">Chapter <span class="ref">2</span></a>
245
245
  and
246
246
  <a href="#cha-foo_bar" class="hyperref">Chapter <span class="ref">1</span></a>
247
247
  </p>
@@ -270,13 +270,13 @@ describe 'Polytexnic::Pipeline#to_html' do
270
270
  it do
271
271
  should resemble <<-'EOS'
272
272
  <div id="sec-foo" data-tralics-id="cid1" class="section" data-number="1"><h2><a href="#sec-foo" class="heading"><span class="number">1 </span>Foo</a></h2>
273
- <p>
273
+ <p class="noindent">
274
274
  <a href="#sec-bar" class="hyperref">Section <span class="ref">1.1</span></a>
275
275
  and
276
276
  <a href="#sec-baz" class="hyperref">Section <span class="ref">1.1.1</span></a>
277
277
  </p>
278
278
  <div id="sec-bar" data-tralics-id="uid1" class="subsection" data-number="1.1"><h3><a href="#sec-bar" class="heading"><span class="number">1.1 </span>Bar</a></h3>
279
- <p><a href="#sec-foo" class="hyperref">Section <span class="ref">1</span></a>
279
+ <p class="noindent"><a href="#sec-foo" class="hyperref">Section <span class="ref">1</span></a>
280
280
  </p>
281
281
  <div id="sec-baz" data-tralics-id="uid2" class="subsubsection" data-number="1.1.1">
282
282
  <h4><a href="#sec-baz" class="heading">Baz</a></h4>
@@ -298,7 +298,7 @@ describe 'Polytexnic::Pipeline#to_html' do
298
298
  should resemble <<-'EOS'
299
299
  <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1">
300
300
  <h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo</a></h1>
301
- <p><a href="#cha-bar" class="hyperref">Chapter <span class="undefined_ref">cha:bar</span></a>
301
+ <p class="noindent"><a href="#cha-bar" class="hyperref">Chapter <span class="undefined_ref">cha:bar</span></a>
302
302
  </p>
303
303
  </div>
304
304
  EOS
@@ -324,13 +324,13 @@ describe 'Polytexnic::Pipeline#to_html' do
324
324
  should resemble <<-'EOS'
325
325
  <div id="frontmatter" data-number="0">
326
326
  <div class="chapter-star" id="foo"><h1><a href="#foo" class="heading">Foo</a></h1>
327
- <p>Lorem ipsum.<sup id="cha-0_footnote-ref-1" class="footnote"><a href="#cha-0_footnote-1">1</a></sup></p>
327
+ <p class="noindent">Lorem ipsum.<sup id="cha-0_footnote-ref-1" class="footnote"><a href="#cha-0_footnote-1">1</a></sup></p>
328
328
  </div></div>
329
329
  <div id="cha-0_footnotes">
330
330
  <ol class="footnotes"><li id="cha-0_footnote-1">Foo bar. <a class="arrow" href="#cha-0_footnote-ref-1">↑</a></li>
331
331
  </ol></div>
332
332
  <div id="cha-bar" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 1 </span>Bar</a></h1>
333
- <p><a href="#cha-bar" class="hyperref">Chapter <span class="ref">1</span></a>
333
+ <p class="noindent"><a href="#cha-bar" class="hyperref">Chapter <span class="ref">1</span></a>
334
334
  </p></div>
335
335
  EOS
336
336
  end
@@ -31,7 +31,7 @@ $ subl .gemrc
31
31
  <span class="number">Listing 1.1:</span>
32
32
  <span class="description">Creating a <code class="tt">gem</code> configuration file.<span class="intersentencespace"></span>
33
33
  <span class="break"></span>
34
- <span class="filepath">path/to/file</span>
34
+ <code class="filepath">path/to/file</code>
35
35
  </span>
36
36
  </div>
37
37
  <div class="code">
@@ -40,7 +40,7 @@ $ subl .gemrc
40
40
  </div>
41
41
  </div>
42
42
  </div>
43
- <p><a href="#code-create_gemrc" class="hyperref">Listing <span class="ref">1.1</span></a></p>
43
+ <p class="noindent"><a href="#code-create_gemrc" class="hyperref">Listing <span class="ref">1.1</span></a></p>
44
44
  </div>
45
45
  EOS
46
46
  end
@@ -28,7 +28,7 @@ describe 'Polytexnic::Pipeline#to_html' do
28
28
  </div>
29
29
  <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1">
30
30
  <h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
31
- <p>Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
31
+ <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
32
32
  </div>
33
33
  <div id="cha-1_footnotes">
34
34
  <ol class="footnotes">
@@ -39,7 +39,7 @@ describe 'Polytexnic::Pipeline#to_html' do
39
39
  </div>
40
40
  <div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2">
41
41
  <h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
42
- <p>Dolor sit amet.</p>
42
+ <p class="noindent">Dolor sit amet.</p>
43
43
  </div>
44
44
  EOS
45
45
  end
@@ -74,7 +74,7 @@ describe 'Polytexnic::Pipeline#to_html' do
74
74
  </div>
75
75
  <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1">
76
76
  <h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
77
- <p>Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
77
+ <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
78
78
  </div>
79
79
  <div id="cha-1_footnotes">
80
80
  <ol class="footnotes">
@@ -85,7 +85,7 @@ describe 'Polytexnic::Pipeline#to_html' do
85
85
  </div>
86
86
  <div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2">
87
87
  <h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
88
- <p>Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">1</a></sup></p>
88
+ <p class="noindent">Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">1</a></sup></p>
89
89
  <p>Hey Jude.<sup id="cha-2_footnote-ref-2" class="footnote"><a href="#cha-2_footnote-2">2</a></sup></p>
90
90
  </div>
91
91
  <div id="cha-2_footnotes">
@@ -137,7 +137,7 @@ describe 'Polytexnic::Pipeline#to_html' do
137
137
  </div>
138
138
  <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1">
139
139
  <h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
140
- <p>Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">*</a></sup></p>
140
+ <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">*</a></sup></p>
141
141
  </div>
142
142
  <div id="cha-1_footnotes">
143
143
  <ul class="footnotes nonumbers">
@@ -148,7 +148,7 @@ describe 'Polytexnic::Pipeline#to_html' do
148
148
  </div>
149
149
  <div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2">
150
150
  <h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
151
- <p>Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">*</a></sup></p>
151
+ <p class="noindent">Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">*</a></sup></p>
152
152
  <p>Hey Jude!<sup id="cha-2_footnote-ref-2" class="footnote intersentence"><a href="#cha-2_footnote-2">†</a></sup><span class="intersentencespace"></span>
153
153
  Be afraid.<span class="intersentencespace"></span></p>
154
154
  </div>
@@ -250,7 +250,7 @@ describe 'Polytexnic::Pipeline#to_html' do
250
250
  <span class="description">This is another caption.</span>
251
251
  </div>
252
252
  </div>
253
- <p>
253
+ <p class="noindent">
254
254
  <a href="#fig-baz" class="hyperref">Figure <span class="ref">2.1</span></a>
255
255
  </p>
256
256
  </div>
@@ -268,7 +268,7 @@ describe 'Polytexnic::Pipeline#to_html' do
268
268
  <span class="description">Yet another.</span>
269
269
  </div>
270
270
  </div>
271
- <p>
271
+ <p class="noindent">
272
272
  <a href="#fig-foo" class="hyperref">Figure <span class="ref">1.1</span></a>
273
273
  and
274
274
  <a href="#fig-bar" class="hyperref">Figure <span class="ref">1.2</span></a>
@@ -209,9 +209,9 @@ describe Polytexnic::Pipeline do
209
209
  end
210
210
  let(:output) do <<-'EOS'
211
211
  <p>
212
- <span class="inline_verbatim">
212
+ <code class="inline_verbatim">
213
213
  ERROR: Could not find section header '#// begin section_that_does_not_exist' in file 'spec/to_html/literal_environments/code_spec.rb'
214
- </span>
214
+ </code>
215
215
  </p>
216
216
  EOS
217
217
  end
@@ -401,9 +401,9 @@ describe Polytexnic::Pipeline do
401
401
  end
402
402
  let(:output) do <<-'EOS'
403
403
  <p>
404
- <span class="inline_verbatim">
404
+ <code class="inline_verbatim">
405
405
  ERROR: Repository 'non_existent_repo' does not exist.
406
- </span>
406
+ </code>
407
407
  </p>
408
408
  EOS
409
409
  end
@@ -434,9 +434,9 @@ describe Polytexnic::Pipeline do
434
434
  end
435
435
  let(:output) do <<-'EOS'
436
436
  <p>
437
- <span class="inline_verbatim">
437
+ <code class="inline_verbatim">
438
438
  ERROR: Tag 'non_existent_tag' does not exist.
439
- </span>
439
+ </code>
440
440
  </p>
441
441
  EOS
442
442
  end
@@ -467,9 +467,9 @@ describe Polytexnic::Pipeline do
467
467
  end
468
468
  let(:output) do <<-'EOS'
469
469
  <p>
470
- <span class="inline_verbatim">
470
+ <code class="inline_verbatim">
471
471
  ERROR: fatal: Path 'path/to/non_existent_file.rb' does not exist in 'v0.9.9'
472
- </span>
472
+ </code>
473
473
  </p>
474
474
  EOS
475
475
  end
@@ -7,8 +7,8 @@ describe Polytexnic::Pipeline do
7
7
  describe "\\verb environments" do
8
8
  let(:polytex) { '\verb+\begin{center}+ \verb-$foo-' }
9
9
  let(:output) do
10
- '<span class="inline_verbatim">\begin{center}</span>' +
11
- '<span class="inline_verbatim">$foo</span>'
10
+ '<code class="inline_verbatim">\begin{center}</code>' +
11
+ '<code class="inline_verbatim">$foo</code>'
12
12
  end
13
13
  it { should resemble output }
14
14
  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: 1.2.7
4
+ version: 1.2.8
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: 2016-12-16 00:00:00.000000000 Z
12
+ date: 2017-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  requirements: []
295
295
  rubyforge_project:
296
- rubygems_version: 2.5.1
296
+ rubygems_version: 2.4.5.1
297
297
  signing_key:
298
298
  specification_version: 4
299
299
  summary: Convert from PolyTeX & Markdown to HTML & LaTeX