polytexnic 1.4.1 → 1.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 108b5d52a86e428593bd9766ba50872d1d193b150c2b86e11109e46227da3a0c
4
- data.tar.gz: 81f9315acbabac0371dba57454fe6300b9bb68295ff50a4cedb389a540eb5e83
3
+ metadata.gz: 18ed75afaa6f86f72c3b3c93a58b98de889e61d6375e7b7cd7ab338bdaae4eb5
4
+ data.tar.gz: 9d163095bab205273f9198d89ca931d1bb69a74faac6be586a38549a10e11d08
5
5
  SHA512:
6
- metadata.gz: 959279eb8d2cee9b6a3e96c4dd2aae2bef345bfcd19aeabbd44cc6c329b8d8bab7d088defdf380adbac0d2cc27b5264bbca6bcc82d4bf3c9405728c0215ca0b2
7
- data.tar.gz: 3967ceb9642092e93c1da72e0a6100ecb333ca8631d5b2ca2d138f375213de1f4ddc368afb621ba51c3a136057a2664de7231330c0bb01f0ed7a01130e525350
6
+ metadata.gz: 8c53d66257b3f6a4b607508fc4a043eb253844a3980e43c24823867651f4bee92d51a9a2d553eaba0a6d3da93e39147d22c1c8b46dc2b76767dc8780779f423c
7
+ data.tar.gz: d9453ea5eafc5b9819a011e7355bc309391f320a45bd83c53bb797c361204fd38914967b25d3e74058ab2c7bf8cc442d39cfeb91a119d0a543eb7f5f846d474c
@@ -31,7 +31,6 @@ module Polytexnic
31
31
  headings(doc)
32
32
  sout(doc)
33
33
  kode(doc)
34
- # return '2'
35
34
  coloredtext(doc)
36
35
  filepath(doc)
37
36
  backslash_break(doc)
@@ -46,20 +45,17 @@ module Polytexnic
46
45
  codelistings(doc)
47
46
  asides(doc)
48
47
  make_cross_references(doc)
49
- # return '3'
50
48
  hrefs(doc)
51
49
  graphics_and_figures(doc)
52
50
  images_and_imageboxes(doc)
53
51
  tables(doc)
54
52
  math(doc)
55
53
  frontmatter(doc)
56
- # return '4'
57
54
  mainmatter(doc)
58
55
  footnotes(doc)
59
56
  table_of_contents(doc)
60
57
  add_noindent(doc)
61
58
  convert_to_html(doc)
62
- # return '5'
63
59
  end
64
60
 
65
61
  private
@@ -339,23 +335,29 @@ module Polytexnic
339
335
  # Returns a list of footnotes ready for placement.
340
336
  def footnotes_list(footnotes, chapter_number)
341
337
  doc = footnotes.values[0][0].document
342
- # For symbolic footnotes, we want to suppress numbers, which can be
343
- # done in CSS, but it doesn't work in many EPUB & MOBI readers.
344
- # As a kludge, we switch to ul in this case, which looks nicer.
345
- list_type = footnote_symbols? ? 'ul' : 'ol'
346
- footnotes_node = Nokogiri::XML::Node.new(list_type, doc)
338
+ footnotes_node = Nokogiri::XML::Node.new('div', doc)
347
339
  footnotes_node['class'] = 'footnotes'
348
340
  footnotes_node['class'] += ' nonumbers' if footnote_symbols?
349
341
  footnotes[chapter_number].each_with_index do |footnote, i|
350
342
  n = i + 1
351
- note = Nokogiri::XML::Node.new('li', doc)
343
+ note = Nokogiri::XML::Node.new('div', doc)
352
344
  note['id'] = footnote_id(chapter_number, n)
345
+ note['class'] = 'footnote'
353
346
  reflink = Nokogiri::XML::Node.new('a', doc)
354
- reflink['class'] = 'arrow'
355
- reflink.content = "↑"
347
+ reflink['class'] = 'footnote-link'
348
+ if footnote_symbols?
349
+ reflink.content = "<sup>#{fnsymbol(i)}</sup>"
350
+ else
351
+ reflink.content = "#{n}."
352
+ end
356
353
  reflink['href'] = footnote_ref_href(chapter_number, n)
357
- html = "#{footnote.inner_html} #{reflink.to_xhtml}"
358
- html = "<sup>#{fnsymbol(i)}</sup> #{html}" if footnote_symbols?
354
+ if (first_paragraph = footnote.css('p').first)
355
+ first_paragraph.inner_html = reflink.to_xhtml + ' ' +
356
+ first_paragraph.inner_html
357
+ html = footnote.inner_html
358
+ else
359
+ html = "#{reflink.to_xhtml} #{footnote.inner_html}"
360
+ end
359
361
  note.inner_html = html
360
362
  footnotes_node.add_child note
361
363
  end
@@ -1402,4 +1404,4 @@ module Polytexnic
1402
1404
  end
1403
1405
  end
1404
1406
  end
1405
- end
1407
+ end
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.4.1"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -79,7 +79,7 @@ $ subl .gemrc
79
79
  end
80
80
 
81
81
  describe "footnote" do
82
- it { should include '<ol class="footnotes">' }
82
+ it { should include '<div class="footnotes">' }
83
83
  describe "numbering" do
84
84
  it { should include footnote }
85
85
  end
@@ -87,4 +87,4 @@ $ subl .gemrc
87
87
  it { should include fntext }
88
88
  end
89
89
  end
90
- end
90
+ end
@@ -323,14 +323,16 @@ describe 'Polytexnic::Pipeline#to_html' do
323
323
  it do
324
324
  should resemble <<-'EOS'
325
325
  <div id="frontmatter" data-number="0">
326
- <div class="chapter-star" id="foo"><h1><a href="#foo" class="heading">Foo</a></h1>
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
- </div></div>
329
- <div id="cha-0_footnotes">
330
- <ol class="footnotes"><li id="cha-0_footnote-1">Foo bar. <a class="arrow" href="#cha-0_footnote-ref-1">↑</a></li>
331
- </ol></div>
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 class="noindent"><a href="#cha-bar" class="hyperref">Chapter <span class="ref">1</span></a>
326
+ <div class="chapter-star" id="foo"><h1><a href="#foo" class="heading">Foo</a></h1>
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
+ </div></div>
329
+
330
+ <div id="cha-0_footnotes">
331
+ <div class="footnotes">
332
+ <div id="cha-0_footnote-1" class="footnote"><a class="footnote-link" href="#cha-0_footnote-ref-1">1.</a> Foo bar.</div>
333
+ </div>
334
+ </div><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>
335
+ <p class="noindent"><a href="#cha-bar" class="hyperref">Chapter <span class="ref">1</span></a>
334
336
  </p></div>
335
337
  EOS
336
338
  end
@@ -23,24 +23,18 @@ describe 'Polytexnic::Pipeline#to_html' do
23
23
  end
24
24
 
25
25
  let(:output) do <<-'EOS'
26
- <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1">
27
- <h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
28
- </div>
29
- <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1">
30
- <h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
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
- </div>
33
- <div id="cha-1_footnotes">
34
- <ol class="footnotes">
35
- <li id="cha-1_footnote-1">
36
- Cicero <a class="arrow" href="#cha-1_footnote-ref-1">↑</a>
37
- </li>
38
- </ol>
39
- </div>
40
- <div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2">
41
- <h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
42
- <p class="noindent">Dolor sit amet.</p>
43
- </div>
26
+ <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
27
+ </div>
28
+ <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1"><h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
29
+ <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
30
+ </div>
31
+ <div id="cha-1_footnotes">
32
+ <div class="footnotes">
33
+ <div id="cha-1_footnote-1" class="footnote"><a class="footnote-link" href="#cha-1_footnote-ref-1">1.</a> Cicero</div>
34
+ </div>
35
+ </div><div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
36
+ <p class="noindent">Dolor sit amet.
37
+ </p></div>
44
38
  EOS
45
39
  end
46
40
  it { should resemble output }
@@ -69,35 +63,24 @@ describe 'Polytexnic::Pipeline#to_html' do
69
63
  end
70
64
 
71
65
  let(:output) do <<-'EOS'
72
- <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1">
73
- <h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
74
- </div>
75
- <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1">
76
- <h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
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
- </div>
79
- <div id="cha-1_footnotes">
80
- <ol class="footnotes">
81
- <li id="cha-1_footnote-1">
82
- Cicero <a class="arrow" href="#cha-1_footnote-ref-1">↑</a>
83
- </li>
84
- </ol>
85
- </div>
86
- <div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2">
87
- <h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
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
- <p>Hey Jude.<sup id="cha-2_footnote-ref-2" class="footnote"><a href="#cha-2_footnote-2">2</a></sup></p>
90
- </div>
91
- <div id="cha-2_footnotes">
92
- <ol class="footnotes">
93
- <li id="cha-2_footnote-1">
94
- <em>Still</em> Cicero <a class="arrow" href="#cha-2_footnote-ref-1">↑</a>
95
- </li>
96
- <li id="cha-2_footnote-2">
97
- Lennon/McCartney <a class="arrow" href="#cha-2_footnote-ref-2">↑</a>
98
- </li>
99
- </ol>
100
- </div>
66
+ <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
67
+ </div>
68
+ <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1"><h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
69
+ <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
70
+ </div>
71
+ <div id="cha-1_footnotes">
72
+ <div class="footnotes">
73
+ <div id="cha-1_footnote-1" class="footnote"><a class="footnote-link" href="#cha-1_footnote-ref-1">1.</a> Cicero</div>
74
+ </div>
75
+ </div><div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
76
+ <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>
77
+ <p>Hey Jude.<sup id="cha-2_footnote-ref-2" class="footnote"><a href="#cha-2_footnote-2">2</a></sup>
78
+ </p></div><div id="cha-2_footnotes">
79
+ <div class="footnotes">
80
+ <div id="cha-2_footnote-1" class="footnote"><a class="footnote-link" href="#cha-2_footnote-ref-1">1.</a> <em>Still</em> Cicero</div>
81
+ <div id="cha-2_footnote-2" class="footnote"><a class="footnote-link" href="#cha-2_footnote-ref-2">2.</a> Lennon/McCartney</div>
82
+ </div>
83
+ </div>
101
84
  EOS
102
85
  end
103
86
  it { should resemble output }
@@ -124,7 +107,9 @@ describe 'Polytexnic::Pipeline#to_html' do
124
107
  \chapter{Bar}
125
108
  \label{cha:bar}
126
109
 
127
- Dolor sit amet.\footnote{\emph{Still} Cicero}
110
+ Dolor sit amet.\footnote{\emph{Still} Cicero.
111
+
112
+ And Catullus.}
128
113
 
129
114
  Hey Jude!\footnote{Lennon/McCartney} Be afraid.
130
115
  \end{document}
@@ -132,36 +117,26 @@ describe 'Polytexnic::Pipeline#to_html' do
132
117
  end
133
118
 
134
119
  let(:output) do <<-'EOS'
135
- <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1">
136
- <h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
137
- </div>
138
- <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1">
139
- <h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
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
- </div>
142
- <div id="cha-1_footnotes">
143
- <ul class="footnotes nonumbers">
144
- <li id="cha-1_footnote-1">
145
- <sup>*</sup> Cicero <a class="arrow" href="#cha-1_footnote-ref-1">↑</a>
146
- </li>
147
- </ul>
148
- </div>
149
- <div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2">
150
- <h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
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
- <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
- Be afraid.<span class="intersentencespace"></span></p>
154
- </div>
155
- <div id="cha-2_footnotes">
156
- <ul class="footnotes nonumbers">
157
- <li id="cha-2_footnote-1">
158
- <sup>*</sup> <em>Still</em> Cicero <a class="arrow" href="#cha-2_footnote-ref-1">↑</a>
159
- </li>
160
- <li id="cha-2_footnote-2">
161
- <sup>†</sup> Lennon/McCartney <a class="arrow" href="#cha-2_footnote-ref-2">↑</a>
162
- </li>
163
- </ul>
164
- </div>
120
+ <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
121
+ </div>
122
+ <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1"><h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
123
+ <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">*</a></sup></p>
124
+ </div>
125
+ <div id="cha-1_footnotes">
126
+ <div class="footnotes nonumbers">
127
+ <div id="cha-1_footnote-1" class="footnote"><a class="footnote-link" href="#cha-1_footnote-ref-1">&lt;sup&gt;*&lt;/sup&gt;</a> Cicero</div>
128
+ </div>
129
+ </div><div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
130
+ <p class="noindent">Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">*</a></sup></p>
131
+ <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> Be afraid.<span class="intersentencespace"></span> </p></div>
132
+ <div id="cha-2_footnotes">
133
+ <div class="footnotes nonumbers">
134
+ <div id="cha-2_footnote-1" class="footnote"><p><a class="footnote-link" href="#cha-2_footnote-ref-1">&lt;sup&gt;*&lt;/sup&gt;</a> <em>Still</em> Cicero.</p>
135
+ <p>And Catullus.</p>
136
+ </div>
137
+ <div id="cha-2_footnote-2" class="footnote"><a class="footnote-link" href="#cha-2_footnote-ref-2">&lt;sup&gt;†&lt;/sup&gt;</a> Lennon/McCartney</div>
138
+ </div>
139
+ </div>
165
140
  EOS
166
141
  end
167
142
  it { should resemble output }
@@ -197,4 +172,4 @@ describe 'Polytexnic::Pipeline#to_html' do
197
172
  end
198
173
  it { should include 'cha-3_footnote' }
199
174
  end
200
- end
175
+ 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.4.1
4
+ version: 1.5.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: 2018-03-30 00:00:00.000000000 Z
12
+ date: 2018-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri