polytexnic 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +37 -0
  3. data/.pull_requests/1371777257 +0 -0
  4. data/.pull_requests/1371927975 +0 -0
  5. data/.pull_requests/1372804345 +0 -0
  6. data/.pull_requests/1374784075 +0 -0
  7. data/.pull_requests/1375304853 +0 -0
  8. data/.pull_requests/1375408308 +0 -0
  9. data/.pull_requests/1375409462 +0 -0
  10. data/.pull_requests/1375410668 +0 -0
  11. data/.pull_requests/1375472132 +0 -0
  12. data/.pull_requests/1375485496 +0 -0
  13. data/.pull_requests/1375487548 +0 -0
  14. data/.pull_requests/1375492835 +0 -0
  15. data/.pull_requests/1375497765 +0 -0
  16. data/.pull_requests/1375559547 +0 -0
  17. data/.pull_requests/1375589063 +0 -0
  18. data/.pull_requests/1375841786 +0 -0
  19. data/.pull_requests/1376352634 +0 -0
  20. data/.pull_requests/1376353299 +0 -0
  21. data/.pull_requests/1376449284 +0 -0
  22. data/.pull_requests/1376452696 +0 -0
  23. data/.pull_requests/1376454166 +0 -0
  24. data/.pull_requests/1376532291 +0 -0
  25. data/.pull_requests/1376625487 +0 -0
  26. data/.pull_requests/1376690108 +0 -0
  27. data/.pull_requests/1376699046 +0 -0
  28. data/.pull_requests/1376707642 +0 -0
  29. data/.pull_requests/1377230284 +0 -0
  30. data/.pull_requests/1379118478 +0 -0
  31. data/.pull_requests/1379123150 +0 -0
  32. data/.pull_requests/1380221847 +0 -0
  33. data/.pull_requests/1380589654 +0 -0
  34. data/.pull_requests/1380673142 +0 -0
  35. data/.pull_requests/1380850800 +0 -0
  36. data/.pull_requests/1381001264 +0 -0
  37. data/.pull_requests/1381005204 +0 -0
  38. data/.pull_requests/1381103022 +0 -0
  39. data/.pull_requests/1381252832 +0 -0
  40. data/.pull_requests/1381276624 +0 -0
  41. data/.pull_requests/1381344234 +0 -0
  42. data/.pull_requests/1381385297 +0 -0
  43. data/.pull_requests/1381427498 +0 -0
  44. data/.pull_requests/1381429761 +0 -0
  45. data/.pull_requests/1381873684 +0 -0
  46. data/.pull_requests/1382045490 +0 -0
  47. data/.pull_requests/1382056384 +0 -0
  48. data/.pull_requests/1382405223 +0 -0
  49. data/.pull_requests/1382478400 +0 -0
  50. data/.pull_requests/1382479780 +0 -0
  51. data/.pull_requests/1382485483 +0 -0
  52. data/.pull_requests/1382569911 +0 -0
  53. data/.pull_requests/1382646199 +0 -0
  54. data/.pull_requests/1382649778 +0 -0
  55. data/.pull_requests/1382660987 +0 -0
  56. data/.pull_requests/1382743927 +0 -0
  57. data/.pull_requests/1382840347 +0 -0
  58. data/.pull_requests/1383077676 +0 -0
  59. data/.pull_requests/1383086948 +0 -0
  60. data/.pull_requests/1383161978 +0 -0
  61. data/.pull_requests/1383263695 +0 -0
  62. data/.pull_requests/1383274008 +0 -0
  63. data/.pull_requests/1383327328 +0 -0
  64. data/.rspec +2 -0
  65. data/.ruby-gemset +1 -0
  66. data/.ruby-version +1 -0
  67. data/Gemfile +15 -0
  68. data/Guardfile +15 -0
  69. data/LICENSE.txt +22 -0
  70. data/README.md +21 -0
  71. data/Rakefile +2 -0
  72. data/lib/polytexnic/literal.rb +299 -0
  73. data/lib/polytexnic/postprocessor.rb +28 -0
  74. data/lib/polytexnic/postprocessors/html.rb +1139 -0
  75. data/lib/polytexnic/postprocessors/latex.rb +18 -0
  76. data/lib/polytexnic/postprocessors/polytex.rb +44 -0
  77. data/lib/polytexnic/preprocessor.rb +23 -0
  78. data/lib/polytexnic/preprocessors/html.rb +349 -0
  79. data/lib/polytexnic/preprocessors/latex.rb +43 -0
  80. data/lib/polytexnic/preprocessors/polytex.rb +127 -0
  81. data/lib/polytexnic/utils.rb +176 -0
  82. data/lib/polytexnic/version.rb +3 -0
  83. data/lib/polytexnic.rb +92 -0
  84. data/notes/pandoc.md +41 -0
  85. data/polytexnic.gemspec +28 -0
  86. data/polytexnic_commands.sty +5 -0
  87. data/precompiled_binaries/tralics +0 -0
  88. data/spec/fixtures/code_listing.tex +14 -0
  89. data/spec/fixtures/figures.tex +8 -0
  90. data/spec/fixtures/inline_math.html +4 -0
  91. data/spec/fixtures/inline_math.tex +3 -0
  92. data/spec/fixtures/math_environments.html +50 -0
  93. data/spec/fixtures/math_environments.tex +56 -0
  94. data/spec/fixtures/section_xrefs.tex +9 -0
  95. data/spec/fixtures/sidebar.tex +10 -0
  96. data/spec/fixtures/tables.tex +8 -0
  97. data/spec/fixtures/verbatim_environments.html +11 -0
  98. data/spec/fixtures/verbatim_environments.tex +13 -0
  99. data/spec/integration_spec.rb +34 -0
  100. data/spec/markdown_to_polytex_spec.rb +192 -0
  101. data/spec/resemble_matcher_spec.rb +69 -0
  102. data/spec/spec_helper.rb +38 -0
  103. data/spec/support/resemble_matcher.rb +100 -0
  104. data/spec/to_html/asides_spec.rb +42 -0
  105. data/spec/to_html/chapters_and_sections_spec.rb +268 -0
  106. data/spec/to_html/characters_and_punctuation_spec.rb +138 -0
  107. data/spec/to_html/codelistings_spec.rb +70 -0
  108. data/spec/to_html/core_spec.rb +227 -0
  109. data/spec/to_html/eqref_spec.rb +32 -0
  110. data/spec/to_html/footnote_spec.rb +164 -0
  111. data/spec/to_html/graphics_and_figures_spec.rb +358 -0
  112. data/spec/to_html/lists_spec.rb +103 -0
  113. data/spec/to_html/literal_environments/code_spec.rb +141 -0
  114. data/spec/to_html/literal_environments/math_spec.rb +255 -0
  115. data/spec/to_html/literal_environments/unicode_spec.rb +12 -0
  116. data/spec/to_html/literal_environments/verbatim_spec.rb +168 -0
  117. data/spec/to_html/quotations_and_verse_spec.rb +86 -0
  118. data/spec/to_html/table_of_contents_spec.rb +93 -0
  119. data/spec/to_html/table_spec.rb +269 -0
  120. data/spec/to_html/text_formatting_spec.rb +50 -0
  121. data/spec/to_latex_spec.rb +197 -0
  122. data/tasks/bin/ruby_tests +41 -0
  123. data/tasks/run_tests_with_both_rubies.rake +5 -0
  124. data/tmp/.gitkeep +0 -0
  125. metadata +286 -0
@@ -0,0 +1,93 @@
1
+ # encoding=utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'Polytexnic::Pipeline#to_html' do
5
+
6
+ subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html }
7
+
8
+ describe '\chapter' do
9
+ let(:polytex) do <<-'EOS'
10
+ \tableofcontents
11
+ \chapter{Foo}
12
+ \label{cha:foo}
13
+
14
+ \section{Bar}
15
+ \label{sec:bar}
16
+
17
+ \subsection{Baz}
18
+ \label{sec:baz}
19
+
20
+ \subsubsection{Null}
21
+ \label{sec:null}
22
+
23
+ \section{Quux}
24
+ \label{sec:quux}
25
+
26
+ \chapter{Lorem}
27
+ \label{cha:lorem}
28
+
29
+ EOS
30
+ end
31
+
32
+ let(:output) do <<-'EOS'
33
+ <h1 class="contents">Contents</h1>
34
+ <div id="table_of_contents">
35
+ <ul>
36
+ <li class="chapter"><a href="#cha-foo" class="heading hyperref"><span class="number">Chapter 1 </span>Foo</a></li>
37
+ <li>
38
+ <ul>
39
+ <li class="section"><a href="#sec-bar" class="heading hyperref"><span class="number">1.1 </span>Bar</a></li>
40
+ <li>
41
+ <ul>
42
+ <li class="subsection"><a href="#sec-baz" class="heading hyperref"><span class="number">1.1.1 </span>Baz</a></li>
43
+ </ul>
44
+ </li>
45
+ <li class="section">
46
+ <a href="#sec-quux" class="heading hyperref"><span class="number">1.2 </span>Quux</a></li>
47
+ </ul>
48
+ </li>
49
+ <li class="chapter"><a href="#cha-lorem" class="heading hyperref"><span class="number">Chapter 2 </span>Lorem</a></li>
50
+ </ul>
51
+ </div>
52
+ EOS
53
+ end
54
+
55
+ it { should resemble output }
56
+
57
+ describe "HTML structure" do
58
+ subject(:toc) do
59
+ Nokogiri::HTML(processed_text).css('div#table_of_contents')
60
+ end
61
+
62
+ it { should_not be_empty }
63
+
64
+ it "should have a 'depth' attribute" do
65
+ expect(toc.first['depth']).to be_nil
66
+ end
67
+
68
+ it "should have a link to the first chapter" do
69
+ expect(toc.css('li>a')[0]['href']).to eq '#cha-foo'
70
+ end
71
+
72
+ it "should have a link to the first section" do
73
+ expect(toc.css('li>a')[1]['href']).to eq '#sec-bar'
74
+ end
75
+
76
+ it "should have a link to the first subsection" do
77
+ expect(toc.css('li>a')[2]['href']).to eq '#sec-baz'
78
+ end
79
+
80
+ it "should have a link to the second section" do
81
+ expect(toc.css('li>a')[3]['href']).to eq '#sec-quux'
82
+ end
83
+
84
+ it "should have a link to the second chapter" do
85
+ expect(toc.css('li>a')[4]['href']).to eq '#cha-lorem'
86
+ end
87
+
88
+ it "should have the right number of lists" do
89
+ expect(toc.css('ul').length).to eq 3
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,269 @@
1
+ # encoding=utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'Polytexnic::Pipeline#to_html' do
5
+
6
+ subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html }
7
+
8
+ describe "tabular environments" do
9
+
10
+ context "simple table with centered elements" do
11
+
12
+ let(:polytex) do <<-'EOS'
13
+ \begin{tabular}{cc}
14
+ \hline
15
+ HTTP request & URL \\
16
+ \hline
17
+ GET & /users \\
18
+ GET & /users/1
19
+ \end{tabular}
20
+ EOS
21
+ end
22
+
23
+ let(:output) do <<-'EOS'
24
+ <table class="tabular">
25
+ <tr class="top_border bottom_border"><td class="align_center">HTTP request</td>
26
+ <td class="align_center">URL</td>
27
+ </tr><tr><td class="align_center">GET</td>
28
+ <td class="align_center">/users</td>
29
+ </tr><tr><td class="align_center">GET</td>
30
+ <td class="align_center">/users/1</td>
31
+ </tr></table>
32
+ EOS
33
+ end
34
+
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
+ end
53
+
54
+ context "more complicated left-aligned cells with lines" do
55
+ let(:polytex) do <<-'EOS'
56
+ \begin{tabular}{|l|lll|}
57
+ \multicolumn{4}{|c|}{Cell spanning four columns} \\
58
+ HTTP request & URL & Action & Purpose \\ \hline
59
+
60
+ GET & /users & index & page to list all users \\
61
+ GET & /users/1 & show & page to show user with id 1\\
62
+ GET & /users/new & new & page to make a new user \\
63
+ POST & /users & create & create a new user \\
64
+ GET & /users/1/edit & edit & page to edit user with id 1 \\
65
+ PATCH & /users/1 & update & update user with id 1 \\
66
+ DELETE & /users/1 & destroy & delete user with id 1
67
+ \end{tabular}
68
+ EOS
69
+ end
70
+
71
+ it do
72
+ should resemble <<-'EOS'
73
+ <table class="tabular">
74
+
75
+ <tr>
76
+ <td colspan="4" class="left_border align_center right_border">Cell spanning four columns</td>
77
+ </tr>
78
+ <tr class="bottom_border">
79
+ <td class="left_border align_left right_border">HTTP request</td>
80
+ <td class="align_left">URL</td>
81
+ <td class="align_left">Action</td>
82
+ <td class="align_left right_border">Purpose</td>
83
+ </tr>
84
+ <tr>
85
+ <td class="left_border align_left right_border">GET</td>
86
+ <td class="align_left">/users</td>
87
+ <td class="align_left">index</td>
88
+ <td class="align_left right_border">page to list all users</td>
89
+ </tr>
90
+ <tr>
91
+ <td class="left_border align_left right_border">GET</td>
92
+ <td class="align_left">/users/1</td>
93
+ <td class="align_left">show</td>
94
+ <td class="align_left right_border">page to show user with id 1</td>
95
+ </tr>
96
+ <tr>
97
+ <td class="left_border align_left right_border">GET</td>
98
+ <td class="align_left">/users/new</td>
99
+ <td class="align_left">new</td>
100
+ <td class="align_left right_border">page to make a new user</td>
101
+ </tr>
102
+ <tr>
103
+ <td class="left_border align_left right_border">POST</td>
104
+ <td class="align_left">/users</td>
105
+ <td class="align_left">create</td>
106
+ <td class="align_left right_border">create a new user</td>
107
+ </tr>
108
+ <tr>
109
+ <td class="left_border align_left right_border">GET</td>
110
+ <td class="align_left">/users/1/edit</td>
111
+ <td class="align_left">edit</td>
112
+ <td class="align_left right_border">page to edit user with id 1</td>
113
+ </tr>
114
+ <tr>
115
+ <td class="left_border align_left right_border">PATCH</td>
116
+ <td class="align_left">/users/1</td>
117
+ <td class="align_left">update</td>
118
+ <td class="align_left right_border">update user with id 1</td>
119
+ </tr>
120
+ <tr>
121
+ <td class="left_border align_left right_border">DELETE</td>
122
+ <td class="align_left">/users/1</td>
123
+ <td class="align_left">destroy</td>
124
+ <td class="align_left right_border">delete user with id 1</td>
125
+ </tr>
126
+ </table>
127
+ EOS
128
+ end
129
+ end
130
+
131
+ context "table whose border used to break for some reason" do
132
+ let(:polytex) do <<-'EOS'
133
+ \begin{tabular}{l|l|ll}
134
+ DELETE & /users/1 & destroy & delete user with id 1
135
+ \end{tabular}
136
+
137
+ \begin{tabular}{|r|l|ll|}
138
+ DELETE & /users/1 & destroy & delete user with id 1
139
+ \end{tabular}
140
+ EOS
141
+ end
142
+
143
+ it do
144
+ should resemble <<-'EOS'
145
+ <table class="tabular">
146
+ <tr>
147
+ <td class="align_left right_border">DELETE</td>
148
+ <td class="align_left right_border">/users/1</td>
149
+ <td class="align_left">destroy</td>
150
+ <td class="align_left">delete user with id 1</td>
151
+ </tr>
152
+ </table>
153
+ <table class="tabular">
154
+ <tr>
155
+ <td class="left_border align_right right_border">DELETE</td>
156
+ <td class="align_left right_border">/users/1</td>
157
+ <td class="align_left">destroy</td>
158
+ <td class="align_left right_border">delete user with id 1</td>
159
+ </tr>
160
+ </table>
161
+ EOS
162
+ end
163
+ end
164
+ end
165
+
166
+ describe "table environments" do
167
+
168
+ context "with a label and a cross-reference" do
169
+ let(:polytex) do <<-'EOS'
170
+ \begin{table}
171
+ \begin{tabular}{cc}
172
+ HTTP request & URL \\
173
+ GET & /users \\
174
+ GET & /users/1
175
+ \end{tabular}
176
+ \label{table:foo}
177
+ \end{table}
178
+
179
+ Table~\ref{table:foo}
180
+ EOS
181
+ end
182
+
183
+ it do
184
+ should resemble <<-'EOS'
185
+ <div id="table-foo" data-tralics-id="uid1" data-number="1" class="table">
186
+ <table class="tabular"><tr><td class="align_center">HTTP request</td>
187
+ <td class="align_center">URL</td>
188
+ </tr><tr><td class="align_center">GET</td>
189
+ <td class="align_center">/users</td>
190
+ </tr><tr><td class="align_center">GET</td>
191
+ <td class="align_center">/users/1</td>
192
+ </tr></table>
193
+ <div class="caption">
194
+ <span class="header">Table 1</span>
195
+ </div>
196
+ </div>
197
+ <p><a href="#table-foo" class="hyperref">Table <span class="ref">1</span></a></p>
198
+ EOS
199
+ end
200
+ end
201
+
202
+ context "with a caption" do
203
+ let(:polytex) do <<-'EOS'
204
+ \begin{table}
205
+ \begin{tabular}{cc}
206
+ HTTP request & URL \\
207
+ GET & /users \\
208
+ GET & /users/1
209
+ \end{tabular}
210
+ \caption{HTTP requests.}
211
+ \end{table}
212
+ EOS
213
+ end
214
+
215
+ it do
216
+ should resemble <<-'EOS'
217
+ <div id="uid1" data-tralics-id="uid1" data-number="1" class="table">
218
+ <table class="tabular"><tr><td class="align_center">HTTP request</td>
219
+ <td class="align_center">URL</td>
220
+ </tr><tr><td class="align_center">GET</td>
221
+ <td class="align_center">/users</td>
222
+ </tr><tr><td class="align_center">GET</td>
223
+ <td class="align_center">/users/1</td>
224
+ </tr></table>
225
+ <div class="caption">
226
+ <span class="header">Table 1:</span>
227
+ <span class="description">HTTP requests.</span>
228
+ </div>
229
+ </div>
230
+ EOS
231
+ end
232
+
233
+ context "with a caption and a label" do
234
+ let(:polytex) do <<-'EOS'
235
+ \begin{table}
236
+ \begin{tabular}{cc}
237
+ HTTP request & URL \\
238
+ GET & /users \\
239
+ GET & /users/1
240
+ \end{tabular}
241
+ \caption{HTTP requests.\label{table:foo}}
242
+ \end{table}
243
+
244
+ Table~\ref{table:foo}
245
+ EOS
246
+ end
247
+
248
+ it do
249
+ should resemble <<-'EOS'
250
+ <div id="table-foo" data-tralics-id="uid1" data-number="1" class="table">
251
+ <table class="tabular"><tr><td class="align_center">HTTP request</td>
252
+ <td class="align_center">URL</td>
253
+ </tr><tr><td class="align_center">GET</td>
254
+ <td class="align_center">/users</td>
255
+ </tr><tr><td class="align_center">GET</td>
256
+ <td class="align_center">/users/1</td>
257
+ </tr></table>
258
+ <div class="caption">
259
+ <span class="header">Table 1: </span>
260
+ <span class="description">HTTP requests.</span>
261
+ </div>
262
+ </div>
263
+ <p><a href="#table-foo" class="hyperref">Table <span class="ref">1</span></a></p>
264
+ EOS
265
+ end
266
+ end
267
+ end
268
+ end
269
+ end
@@ -0,0 +1,50 @@
1
+ # encoding=utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'Polytexnic::Pipeline#to_html' do
5
+
6
+ subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html }
7
+
8
+ describe "text formatting" do
9
+
10
+ describe "italics" do
11
+ let(:polytex) { '\emph{foo bar}' }
12
+ it { should resemble '<em>foo bar</em>' }
13
+
14
+
15
+ context "multiple instances" do
16
+ let(:polytex) do
17
+ '\emph{foo bar} and also \emph{baz quux}'
18
+ end
19
+
20
+ it { should resemble '<em>foo bar</em>' }
21
+ it { should resemble '<em>baz quux</em>' }
22
+ end
23
+ end
24
+
25
+ describe "boldface" do
26
+ let(:polytex) { '\textbf{boldface}' }
27
+ it { should resemble '<strong>boldface</strong>' }
28
+ end
29
+
30
+ describe "small caps" do
31
+ let(:polytex) { '\textsc{small caps}' }
32
+ it { should resemble '<span class="sc">small caps</span>' }
33
+ end
34
+
35
+ describe "typewriter text" do
36
+ let(:polytex) { '\texttt{typewriter text}' }
37
+ it { should resemble '<span class="tt">typewriter text</span>' }
38
+ end
39
+
40
+ describe "strikeout text" do
41
+ let(:polytex) { '\sout{foo} bar' }
42
+ it { should resemble '<del>foo</del> bar' }
43
+ end
44
+
45
+ describe "custom kode command" do
46
+ let(:polytex) { '\kode{function\_name}' }
47
+ it { should resemble '<code>function_name</code>' }
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,197 @@
1
+ # encoding=utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Polytexnic::Pipeline do
5
+
6
+ before(:all) do
7
+ FileUtils.rm('.highlight_cache') if File.exist?('.highlight_cache')
8
+ end
9
+
10
+ describe '#to_latex' do
11
+ subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_latex }
12
+
13
+ describe "for vanilla LaTeX" do
14
+ let(:polytex) { '\emph{foo}' }
15
+ it { should include(polytex) }
16
+ end
17
+
18
+ describe "with source code highlighting" do
19
+ let(:polytex) do <<-'EOS'
20
+ %= lang:ruby
21
+ \begin{code}
22
+ def hello
23
+ "hello, world!"
24
+ end
25
+ \end{code}
26
+
27
+ Make a code listing as in Listing~\ref{code:hello}.
28
+
29
+ \begin{codelisting}
30
+ \label{code:hello}
31
+ \codecaption{A hello program in Ruby.}
32
+ %= lang:ruby
33
+ \begin{code}
34
+ def hello
35
+ "hello, world!"
36
+ end
37
+ \end{code}
38
+ \end{codelisting}
39
+
40
+ \noindent lorem ipsum
41
+ EOS
42
+ end
43
+
44
+ it { should resemble '\begin{framed_shaded}' + "\n" }
45
+ it { should resemble "\n" + '\end{framed_shaded}' }
46
+ it { should_not resemble "\n" + '\end{framed_shaded})' }
47
+ it { should resemble "commandchars=\\\\\\{" }
48
+ it { should resemble '\begin{Verbatim}' }
49
+ it { should resemble 'commandchars' }
50
+ it { should resemble '\end{Verbatim}' }
51
+ it { should_not resemble 'def hello' }
52
+ it { should resemble '\noindent lorem ipsum' }
53
+
54
+ describe "in the middle of a line" do
55
+ let(:polytex) { 'Use \verb+%= lang:ruby+ to highlight Ruby code' }
56
+ it { should resemble '\verb' }
57
+ it { should_not resemble '<div class="highlight">' }
58
+ end
59
+ end
60
+
61
+ context "with the metacode environment" do
62
+ let(:polytex) do <<-'EOS'
63
+ %= lang:latex
64
+ \begin{metacode}
65
+ %= lang:ruby
66
+ \begin{code}
67
+ def foo
68
+ "bar"
69
+ end
70
+ \end{code}
71
+ \end{metacode}
72
+
73
+ \noindent lorem ipsum
74
+ EOS
75
+ end
76
+
77
+ it { should resemble '\begin{framed_shaded}' + "\n" }
78
+ it { should resemble "\n" + '\end{framed_shaded}' }
79
+ it { should resemble "commandchars=\\\\\\{" }
80
+ it { should_not resemble '%= lang:ruby' }
81
+ end
82
+
83
+ describe "verbatim environments" do
84
+ let(:polytex) do <<-'EOS'
85
+ \begin{verbatim}
86
+ def foo
87
+ "bar"
88
+ end
89
+ \end{verbatim}
90
+
91
+ \begin{Verbatim}
92
+ def foo
93
+ "bar"
94
+ end
95
+ \end{Verbatim}
96
+
97
+ \begin{Verbatim}
98
+ x
99
+ \end{equation}
100
+ \end{Verbatim}
101
+ EOS
102
+ end
103
+
104
+ it { should resemble polytex }
105
+
106
+ context "containing an example of highlighted code" do
107
+ let(:polytex) do <<-'EOS'
108
+ \begin{verbatim}
109
+ %= lang:ruby
110
+ def foo
111
+ "bar"
112
+ end
113
+ \end{verbatim}
114
+ EOS
115
+ end
116
+
117
+ it { should resemble polytex }
118
+ end
119
+
120
+ context "with an equation" do
121
+ let(:polytex) do <<-'EOS'
122
+ \begin{equation}
123
+ \label{eq:x_y}
124
+ x_y
125
+ \end{equation}
126
+ EOS
127
+ end
128
+
129
+ it { should resemble polytex }
130
+ it { should_not resemble 'xmlelement' }
131
+ it { should_not resemble 'xbox' }
132
+ it "should have only one '\end{equation}'" do
133
+ n_ends = processed_text.scan(/\\end{equation}/).length
134
+ expect(n_ends).to eq 1
135
+ end
136
+ end
137
+ end
138
+
139
+ describe "hyperref links" do
140
+ let(:polytex) do <<-'EOS'
141
+ Chapter~\ref{cha:foo}
142
+ EOS
143
+ end
144
+ let(:output) { '\hyperref[cha:foo]{Chapter~\ref{cha:foo}' }
145
+ it { should resemble output }
146
+ end
147
+
148
+ describe "asides" do
149
+
150
+ context "with headings and labels" do
151
+ let(:polytex) do <<-'EOS'
152
+ \begin{aside}
153
+ \heading{Foo \emph{are} bar.}
154
+ \label{aside:foo}
155
+
156
+ lorem ipsum
157
+
158
+ \end{aside}
159
+ EOS
160
+ end
161
+
162
+ let(:output) do <<-'EOS'
163
+ \begin{shaded_aside}{Foo \emph{are} bar.}{aside:foo}
164
+
165
+ lorem ipsum
166
+
167
+ \end{shaded_aside}
168
+ EOS
169
+ end
170
+
171
+ it { should resemble output }
172
+ end
173
+ end
174
+
175
+ describe "tables" do
176
+
177
+ let(:polytex) do <<-'EOS'
178
+ \begin{table}
179
+ lorem ipsum
180
+ \end{table}
181
+ EOS
182
+ end
183
+
184
+ let(:output) do <<-'EOS'
185
+ \begin{table}
186
+ \begin{center}
187
+ \small
188
+ lorem ipsum
189
+ \end{center}
190
+ \end{table}
191
+ EOS
192
+ end
193
+
194
+ it { should resemble output }
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,41 @@
1
+ #!/bin/bash
2
+
3
+ if hash rbenv 2>/dev/null; then
4
+ eval "$(rbenv init -)"
5
+
6
+ echo "Running tests under Ruby 1.9.3"
7
+ rbenv shell 1.9.3-p194
8
+ gem install pivotal-github
9
+ bundle
10
+ rspec spec
11
+ echo "Running tests under Ruby 2.0.0"
12
+ rbenv shell 2.0.0-p0
13
+ gem instsll pivotal-github
14
+ bundle
15
+ rspec spec
16
+
17
+ rbenv shell --unset
18
+ else
19
+
20
+ # Load RVM into a shell session *as a function*
21
+ if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
22
+ # First try to load from a user install
23
+ source "$HOME/.rvm/scripts/rvm"
24
+ elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
25
+ # Then try to load from a root install
26
+ source "/usr/local/rvm/scripts/rvm"
27
+ else
28
+ printf "ERROR: An RVM installation was not found.\n"
29
+ fi
30
+
31
+ echo "Running tests under Ruby 1.9.3"
32
+ rvm use 1.9.3@polytexnic
33
+ gem install pivotal-github
34
+ bundle
35
+ rspec spec
36
+ echo "Running tests under Ruby 2.0.0"
37
+ rvm use 2.0.0@polytexnic
38
+ gem install pivotal-github
39
+ bundle
40
+ rspec spec
41
+ fi
@@ -0,0 +1,5 @@
1
+ task default: [:rubies]
2
+
3
+ task :rubies do
4
+ exit system('tasks/bin/ruby_tests')
5
+ end
data/tmp/.gitkeep ADDED
File without changes