polytexnic 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/polytexnic/postprocessors/html.rb +14 -17
- data/lib/polytexnic/version.rb +1 -1
- data/spec/to_html/asides_spec.rb +26 -0
- data/spec/to_html/literal_environments/math_spec.rb +31 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20eff55f552aa33edc42c9d1df10e80603e169a6
|
4
|
+
data.tar.gz: e9e75b8db8e6aa736b01c6cd4ceb3bc78c80a45c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d70789193aad48f82922538bc32f057cff70196a8236299934eb23460ab261a0abd50a7235e77495f445c02ce16962688913ca435805ea5e2389bcfcbb776f5
|
7
|
+
data.tar.gz: 5ee52faf11ef19c52424795cb56dac1e7a9f746b97ee7f88ee969f0253f9e6ce1286ce34146a9f33f9ee210ce694e80e08b128590cb9ed6388da7e8c7b4cfde6
|
@@ -195,9 +195,11 @@ module Polytexnic
|
|
195
195
|
# convention is not to indent paragraphs anyway, but we want to
|
196
196
|
# support that case for completeness (mainly because Tralics does).
|
197
197
|
next_paragraph = node.next_sibling
|
198
|
+
# Check to make sure it's a paragraph.
|
199
|
+
raise unless next_paragraph.name == 'p'
|
198
200
|
next_paragraph['noindent'] = 'true'
|
199
201
|
rescue
|
200
|
-
# We rescue nil in case the math isn't followed by
|
202
|
+
# We rescue nil in case the math isn't followed by a paragraph.
|
201
203
|
nil
|
202
204
|
end
|
203
205
|
end
|
@@ -949,6 +951,7 @@ module Polytexnic
|
|
949
951
|
@equation = 0
|
950
952
|
@figure = 0
|
951
953
|
@table = 0
|
954
|
+
@aside = 0
|
952
955
|
@cha = article? ? nil : node['id-text']
|
953
956
|
elsif node['class'] == 'section'
|
954
957
|
@sec = node['id-text']
|
@@ -960,34 +963,28 @@ module Polytexnic
|
|
960
963
|
@ssubsec = node['id-text']
|
961
964
|
label_number(@cha, @sec, @subsec, @ssubsec)
|
962
965
|
elsif node['textype'] == 'equation'
|
963
|
-
|
964
|
-
@equation = node['id-text']
|
965
|
-
else
|
966
|
-
@equation += 1
|
967
|
-
end
|
966
|
+
@equation = ref_number(node, @cha, @equation)
|
968
967
|
label_number(@cha, @equation)
|
969
968
|
elsif node['class'] == 'codelisting'
|
970
969
|
@listing = number_from_id(node['id-text'])
|
971
970
|
label_number(@cha, @listing)
|
972
971
|
elsif node['class'] == 'aside'
|
973
|
-
node['id-text']
|
972
|
+
@aside = @cha.nil? ? number_from_id(node['id-text']) : @aside + 1
|
973
|
+
label_number(@cha, @aside)
|
974
974
|
elsif node.name == 'table' && node['id-text']
|
975
|
-
|
976
|
-
@table = node['id-text']
|
977
|
-
else
|
978
|
-
@table += 1
|
979
|
-
end
|
975
|
+
@table = ref_number(node, @cha, @table)
|
980
976
|
label_number(@cha, @table)
|
981
977
|
elsif node.name == 'figure'
|
982
|
-
|
983
|
-
@figure = node['id-text']
|
984
|
-
else
|
985
|
-
@figure += 1
|
986
|
-
end
|
978
|
+
@figure = ref_number(node, @cha, @figure)
|
987
979
|
label_number(@cha, @figure)
|
988
980
|
end
|
989
981
|
end
|
990
982
|
|
983
|
+
# Returns the reference number (i.e., the 'x' in '2.x').
|
984
|
+
def ref_number(node, chapter, object)
|
985
|
+
chapter.nil? ? node['id-text'] : object + 1
|
986
|
+
end
|
987
|
+
|
991
988
|
# Extract the sequential number from the node id.
|
992
989
|
# I.e., number_from_id('2.3') -> '3'
|
993
990
|
def number_from_id(id)
|
data/lib/polytexnic/version.rb
CHANGED
data/spec/to_html/asides_spec.rb
CHANGED
@@ -50,4 +50,30 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
50
50
|
it { should include 'Cajón 1.1' }
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
describe "aside cross-references" do
|
55
|
+
let(:aside) do <<-'EOS'
|
56
|
+
\begin{aside}
|
57
|
+
\heading{Lorem ipsum.}
|
58
|
+
\label{aside:lorem}
|
59
|
+
|
60
|
+
lorem ipsum
|
61
|
+
|
62
|
+
dolor sit amet
|
63
|
+
|
64
|
+
\end{aside}
|
65
|
+
|
66
|
+
Box~\ref{aside:lorem}
|
67
|
+
EOS
|
68
|
+
end
|
69
|
+
context "in a chapter" do
|
70
|
+
let(:polytex) { '\chapter{Foo bar}' + "\n" + aside}
|
71
|
+
it { should include ">1.1<" }
|
72
|
+
end
|
73
|
+
|
74
|
+
context "in an article" do
|
75
|
+
let(:polytex) { '\section{A section}' + "\n" + aside }
|
76
|
+
it { should include ">1<" }
|
77
|
+
end
|
78
|
+
end
|
53
79
|
end
|
@@ -158,6 +158,37 @@ describe Polytexnic::Pipeline do
|
|
158
158
|
it { should resemble '<p class="noindent">ipsum' }
|
159
159
|
end
|
160
160
|
|
161
|
+
context "followed by a code listing" do
|
162
|
+
let(:polytex) do <<-'EOS'
|
163
|
+
author be technical. (If you know how to use a command line and have a favorite text editor, you are technical enough to use Softcover.)
|
164
|
+
|
165
|
+
\begin{equation}
|
166
|
+
\label{eq:maxwell}
|
167
|
+
\left.\begin{aligned}
|
168
|
+
\nabla\cdot\mathbf{E} & = \rho \\
|
169
|
+
\nabla\cdot\mathbf{B} & = 0 \\
|
170
|
+
\nabla\times\mathbf{E} & = -\dot{\mathbf{B}} \\
|
171
|
+
\nabla\times\mathbf{B} & = \mathbf{J} + \dot{\mathbf{E}}
|
172
|
+
\end{aligned}
|
173
|
+
\right\}
|
174
|
+
\quad\text{Maxwell equations}
|
175
|
+
\end{equation}
|
176
|
+
|
177
|
+
\begin{codelisting}
|
178
|
+
\label{code:eval}
|
179
|
+
\codecaption{The caption.}
|
180
|
+
%= lang:scheme
|
181
|
+
\begin{code}
|
182
|
+
;; Implements Lisp in Lisp.
|
183
|
+
;; Alan Kay called this feat "Maxwell's equations of software", because just as
|
184
|
+
\end{code}
|
185
|
+
\end{codelisting}
|
186
|
+
|
187
|
+
EOS
|
188
|
+
end
|
189
|
+
it { should_not resemble 'noindent="true"' }
|
190
|
+
end
|
191
|
+
|
161
192
|
describe "align" do
|
162
193
|
let(:equation) do <<-'EOS'
|
163
194
|
\begin{align}
|
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.1.
|
4
|
+
version: 1.1.7
|
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: 2015-07-
|
12
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|