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 +4 -4
- data/lib/polytexnic/postprocessors/html.rb +17 -15
- data/lib/polytexnic/version.rb +1 -1
- data/spec/articles_spec.rb +2 -2
- data/spec/to_html/chapters_and_sections_spec.rb +10 -8
- data/spec/to_html/footnote_spec.rb +54 -79
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18ed75afaa6f86f72c3b3c93a58b98de889e61d6375e7b7cd7ab338bdaae4eb5
|
4
|
+
data.tar.gz: 9d163095bab205273f9198d89ca931d1bb69a74faac6be586a38549a10e11d08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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('
|
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'] = '
|
355
|
-
|
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
|
-
|
358
|
-
|
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
|
data/lib/polytexnic/version.rb
CHANGED
data/spec/articles_spec.rb
CHANGED
@@ -79,7 +79,7 @@ $ subl .gemrc
|
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "footnote" do
|
82
|
-
it { should include '<
|
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
|
-
|
330
|
-
|
331
|
-
|
332
|
-
<div id="cha-
|
333
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
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"><sup>*</sup></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"><sup>*</sup></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"><sup>†</sup></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
|
+
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-
|
12
|
+
date: 2018-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|