polytexnic 0.8.4 → 0.9.0

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: 1423a3dd422cb364805b81b3d1b895ca1fc90aa6
4
- data.tar.gz: fb5ac1f61afa117520566b9aafb1812994551cf0
3
+ metadata.gz: 74e29c2ae1ffea2e625b8aa215e4d13c26a00bb5
4
+ data.tar.gz: 4ec37eb99576de122d97e6101b7533a627dcd98c
5
5
  SHA512:
6
- metadata.gz: c3f00576f1295d4cbf3cbfbe747bf4a2eace81c013045ce124e25a4939d445ee5457f32f2c6a3eb2aa84a5650915c655f9a6af8345b9c2e37d7765bef4f71d5c
7
- data.tar.gz: 383d565f5bb1dd3257281a8f69da2321f9506db71c4901e496726ad32ad6686c50944c2d4faa9e8a995dd03a366141799f1bbadb67f899a9d50a9e5c7c30c93a
6
+ metadata.gz: bbeef507a3e651e40927185278dc54b7de2490bfe01da8cc125b24259f055d7db871f1f30fbb7c56af1dc13018a9a42abf0ffc19e16aad01c9df14b4494216c9
7
+ data.tar.gz: 2ab78e4d8307416c9f07ec5754ddaa3ee16465729df93a64f66c163948b1e88556d2c1ffbb299e398684b520dec64ce90ffc13e3aecc3c032c4fd5e478a4e925
@@ -34,12 +34,17 @@ module Polytexnic
34
34
 
35
35
  attr_accessor :literal_cache, :code_cache, :polytex, :xml, :html,
36
36
  :math_label_cache, :highlight_cache, :maketitle_elements,
37
- :custom_commands
37
+ :custom_commands, :language_labels
38
38
 
39
39
  def initialize(source, options = {})
40
40
  @literal_cache = options[:literal_cache] || {}
41
41
  @code_cache = {}
42
42
  @maketitle_elements = {}
43
+ @language_labels = if (labels = options[:language_labels]).nil?
44
+ default_language_labels
45
+ else
46
+ default_language_labels.merge(labels)
47
+ end
43
48
  @highlight_cache_filename = '.highlight_cache'
44
49
  if File.exist?(@highlight_cache_filename)
45
50
  content = File.read(@highlight_cache_filename)
@@ -70,8 +75,9 @@ module Polytexnic
70
75
  end
71
76
 
72
77
  preprocess(:html)
78
+ puts "\nafter preprocess:\n#{@xml}" if debug?
73
79
  postprocess(:html)
74
- puts @html if debug?
80
+ puts "\nafter postprocess:\n#{@html}" if debug?
75
81
 
76
82
  if profiling?
77
83
  result = RubyProf.stop
@@ -89,6 +95,15 @@ module Polytexnic
89
95
 
90
96
  private
91
97
 
98
+ # Returns the default labels for 'Chapter', 'Figure', etc.
99
+ def default_language_labels
100
+ {"chapter"=>{"word"=>"Chapter", "order"=>"standard"},
101
+ "section"=>"Section", "table"=>"Table", "figure"=>"Figure",
102
+ "fig"=>"Fig", "aside"=>"Box", "listing"=>"Listing",
103
+ "equation"=>"Equation", "eq"=>"Eq", "frontmatter"=>"Frontmatter",
104
+ "contents"=>"Contents"}
105
+ end
106
+
92
107
  def markdown?
93
108
  @source_format == :markdown || @source_format == :md
94
109
  end
@@ -9,7 +9,8 @@ module Polytexnic
9
9
  # Matches the line for code inclusion.
10
10
  # %= <</path/to/code.ext
11
11
  CODE_INCLUSION_REGEX = /^\s*%=\s+<<\s*\( # opening
12
- \s*([^\s]+) # path to file
12
+ \s*([^\s]+?) # path to file
13
+ (?:\[(.+?)\])? # optional section name
13
14
  (?:,\s*lang:\s*(\w+))? # optional lang
14
15
  (,\s*options:\s*.*)? # optional options
15
16
  \s*\) # closing paren
@@ -80,21 +81,12 @@ module Polytexnic
80
81
  # to
81
82
  # %= lang:rb
82
83
  # \begin{code}
83
- # <content of file.rb>
84
+ # <content of file or section.rb>
84
85
  # \end{code}
85
86
  # and then prepend the code to the current `lines` array.
86
- filename, custom_language, highlight_options = $1, $2, $3
87
- extension_array = File.extname(filename).scan(/\.(.*)/).first
88
- lang_from_extension = extension_array.nil? ? nil : extension_array[0]
89
- if File.exist?(filename)
90
- language = custom_language || lang_from_extension || 'text'
91
- code = ["%= lang:#{language}#{highlight_options}"]
92
- code << '\begin{code}'
93
- code.concat(File.read(filename).split("\n"))
94
- code << '\end{code}'
95
- lines.unshift(*code)
96
- else
97
- lines.unshift("\\verb+ERROR: File '#{filename}' does not exist+")
87
+ filename, sectionname, custom_language, highlight_options = $1, $2, $3, $4
88
+ if filename
89
+ lines.unshift(*include_code(filename, sectionname, custom_language, highlight_options))
98
90
  end
99
91
  elsif line.begin_literal?
100
92
  in_verbatim = true
@@ -168,6 +160,34 @@ module Polytexnic
168
160
  end
169
161
  end
170
162
 
163
+ # Returns the marked up file or section to be included,
164
+ # or an error message if file or section does not exist.
165
+ def include_code(filename, sectionname, custom_language, highlight_options)
166
+ reader = (sectionname ? IncludedSectionReader : IncludedFileReader).new
167
+ lang = "#{code_language(filename, custom_language)}#{highlight_options}"
168
+ code = ["%= lang:#{lang}"]
169
+ code << '\begin{code}'
170
+ code.concat(reader.read(filename, sectionname))
171
+ code << '\end{code}'
172
+
173
+ rescue FileNotFound => e
174
+ code_error("File '#{e.message}' does not exist")
175
+ rescue SectionNotFound => e
176
+ msg = e.message
177
+ err = "Could not find section header '#{msg}' in file '#{filename}'"
178
+ code_error(err)
179
+ end
180
+
181
+ def code_error(details)
182
+ "\\verb+ERROR: #{details}+"
183
+ end
184
+
185
+ def code_language(filename, custom_language)
186
+ extension_array = File.extname(filename).scan(/\.(.*)/).first
187
+ lang_from_extension = extension_array.nil? ? nil : extension_array[0]
188
+ language = custom_language || lang_from_extension || 'text'
189
+ end
190
+
171
191
  # Returns a permanent salt for the syntax highlighting cache.
172
192
  def code_salt
173
193
  'fbbc13ed4a51e27608037365e1d27a5f992b6339'
@@ -229,8 +249,17 @@ module Polytexnic
229
249
  # For completeness, we handle the case where the author neglects to
230
250
  # use the nonbreak space ~.
231
251
  def hyperrefs(string)
232
- linked_item = "(Chapter|Section|Table|Box|Figure|Fig\.|Listing" +
233
- "|Equation|Eq\.)"
252
+ chapter = language_labels["chapter"]["word"]
253
+ section = language_labels["section"]
254
+ table = language_labels["table"]
255
+ box = language_labels["aside"]
256
+ figure = language_labels["figure"]
257
+ fig = language_labels["fig"]
258
+ listing = language_labels["listing"]
259
+ equation = language_labels["equation"]
260
+ eq = language_labels["eq"]
261
+ linked_item = "(#{chapter}|#{section}|#{table}|#{box}|#{figure}" +
262
+ "|#{fig}\.|#{listing}|#{equation}|#{eq}\.)"
234
263
  ref = /(?:#{linked_item}(~| ))*(\\(?:eq)*ref){(.*?)}/i
235
264
  string.gsub!(ref) do
236
265
  "\\hyperref[#{$4}]{#{$1}#{$2}#{$3}{#{$4}}}"
@@ -245,7 +274,7 @@ module Polytexnic
245
274
  # pipeline intact.
246
275
  def cache_unicode(string)
247
276
  non_ascii_unicode = /([^\x00-\x7F]+)/
248
- string.gsub(non_ascii_unicode) do
277
+ string.gsub!(non_ascii_unicode) do
249
278
  key = digest($1)
250
279
  literal_cache[key] = $1
251
280
  xmlelement('unicode') { key }
@@ -259,6 +288,57 @@ module Polytexnic
259
288
  literal_type
260
289
  end
261
290
  end
291
+
292
+
293
+ class FileNotFound < Exception; end;
294
+ class IncludedFileReader
295
+ def read(filename, _)
296
+ raise(FileNotFound, filename) unless File.exist?(filename)
297
+ File.read(filename).split("\n")
298
+ end
299
+ end
300
+
301
+ class SectionNotFound < Exception; end;
302
+ class IncludedSectionReader < IncludedFileReader
303
+ attr_reader :lines, :sectionname
304
+
305
+ def read(filename, sectionname)
306
+ @lines = super
307
+ @sectionname = sectionname
308
+
309
+ raise(SectionNotFound, section_begin_text) unless exist?
310
+ lines.slice(index_of_first_line, length)
311
+ end
312
+
313
+ private
314
+ def exist?
315
+ !!index_of_section_begin
316
+ end
317
+
318
+ def index_of_section_begin
319
+ @section_begin_i ||= lines.index(section_begin_text)
320
+ end
321
+
322
+ def index_of_first_line
323
+ @first_line_i ||= index_of_section_begin + 1
324
+ end
325
+
326
+ def length
327
+ lines.slice(index_of_first_line, lines.size).index(section_end_text)
328
+ end
329
+
330
+ def marker
331
+ '#//'
332
+ end
333
+
334
+ def section_begin_text
335
+ "#{marker} begin #{sectionname}"
336
+ end
337
+
338
+ def section_end_text
339
+ "#{marker} end"
340
+ end
341
+ end
262
342
  end
263
343
  end
264
344
 
@@ -310,4 +390,4 @@ class String
310
390
  Regexp.escape(s)
311
391
  end.join('|')
312
392
  end
313
- end
393
+ end
@@ -28,16 +28,16 @@ module Polytexnic
28
28
  sout(doc)
29
29
  kode(doc)
30
30
  filepath(doc)
31
- codelistings(doc)
32
31
  backslash_break(doc)
33
32
  spaces(doc)
34
- asides(doc)
35
33
  center(doc)
36
34
  title(doc)
37
35
  doc = smart_single_quotes(doc)
38
36
  tex_logos(doc)
39
37
  restore_literal(doc)
40
38
  restore_inline_verbatim(doc)
39
+ codelistings(doc)
40
+ asides(doc)
41
41
  make_cross_references(doc)
42
42
  hrefs(doc)
43
43
  graphics_and_figures(doc)
@@ -765,10 +765,7 @@ module Polytexnic
765
765
  # Add number span
766
766
  if (head = node.css('h1 a, h2 a, h3 a').first)
767
767
  el = doc.create_element 'span'
768
- number = node['data-number']
769
- is_section = number.match(/\./)
770
- prefix = (@cha.nil? || is_section) ? '' : "#{chaptername} "
771
- el.content = prefix + node['data-number'] + ' '
768
+ el.content = section_label(node)
772
769
  el['class'] = 'number'
773
770
  chapter_name = head.children.first
774
771
  if chapter_name.nil?
@@ -805,13 +802,32 @@ module Polytexnic
805
802
  end
806
803
  end
807
804
 
805
+ # Returns the section label for the node; e.g., "Chapter 2".
806
+ def section_label(node)
807
+ number = node['data-number']
808
+ if chapter?(node)
809
+ label = if language_labels["chapter"]["order"] == "reverse"
810
+ number + ' ' + chaptername
811
+ else
812
+ chaptername + ' ' + number
813
+ end
814
+ else
815
+ label = number
816
+ end
817
+ label + ' '
818
+ end
819
+
820
+ # Returns true if the node represents a chapter.
821
+ def chapter?(node)
822
+ is_section = node['data-number'].match(/\./)
823
+ !(@cha.nil? || is_section)
824
+ end
825
+
808
826
  # Returns the name to use for chapters.
809
827
  # The default is 'Chapter', of course, but this can be overriden
810
- # using '\renewcommand', especially in books other than Engilsh.
828
+ # using 'language_labels', especially in books other than English.
811
829
  def chaptername
812
- name_regex = /\\renewcommand\{\\chaptername\}\{(.*?)\}/
813
- name = custom_commands.scan(name_regex).flatten.last
814
- name || 'Chapter'
830
+ language_labels["chapter"]["word"]
815
831
  end
816
832
 
817
833
  # Returns the formatted number appropriate for the node.
@@ -967,7 +983,7 @@ module Polytexnic
967
983
  # Adds a caption to a node.
968
984
  # This works for figures and tables (at the least).
969
985
  def add_caption(node, options={})
970
- name = options[:name].to_s.capitalize
986
+ name = language_labels[options[:name].to_s]
971
987
  doc = node.document
972
988
  full_caption = Nokogiri::XML::Node.new('div', doc)
973
989
  full_caption['class'] = 'caption'
@@ -1123,7 +1139,8 @@ module Polytexnic
1123
1139
  def table_of_contents(doc)
1124
1140
  toc = doc.at_css('tableofcontents')
1125
1141
  return if toc.nil?
1126
- toc.add_previous_sibling('<h1 class="contents">Contents</h1>')
1142
+ label = language_labels["contents"]
1143
+ toc.add_previous_sibling(%(<h1 class="contents">#{label}</h1>))
1127
1144
  toc.name = 'div'
1128
1145
  toc['id'] = 'table_of_contents'
1129
1146
  toc.remove_attribute 'depth'
@@ -34,6 +34,7 @@ module Polytexnic
34
34
  convert_longtable(output)
35
35
  mark_environments(output)
36
36
  make_tabular_alignment_cache(output)
37
+ cache_unicode(output)
37
38
  end
38
39
  end
39
40
 
@@ -43,7 +44,7 @@ module Polytexnic
43
44
  # The result is a document that can safely be transformed using
44
45
  # global substitutions.
45
46
  def clean_document(polytex)
46
- doc = cache_unicode(cache_literal(add_commands(polytex)))
47
+ doc = cache_literal(add_commands(polytex))
47
48
  inline_verbatim(doc)
48
49
  cache_hrefs(doc)
49
50
  remove_comments(doc)
@@ -3,16 +3,30 @@ module Polytexnic
3
3
  module Latex
4
4
 
5
5
  def to_processed_latex
6
- @polytex = polish_tables(process_asides(clean_latex_document))
6
+ @polytex = convert_gifs(
7
+ polish_tables(
8
+ process_asides(clean_latex_document)))
7
9
  end
8
10
 
9
11
  # Returns LaTeX with hashed versions of literal environments.
10
12
  # Literal environments are hashed and passed through the pipeline
11
- # so that we can process things like refs to hyperrefs using gsubs.
13
+ # so that we can process things like refs and hyperrefs using gsubs.
12
14
  def clean_latex_document
13
15
  cache_literal(@polytex, :latex)
14
16
  end
15
17
 
18
+ # Convert GIFs to PNGs.
19
+ # Unfortunately, xelatex doesn't support GIFs. This converts the included
20
+ # filenames to use '.png' in place of '.gif'. When used with the Softcover
21
+ # system, the correct PNG files are automatically created on the fly.
22
+ def convert_gifs(text)
23
+ text.tap do
24
+ text.gsub!(/\\(includegraphics|image|imagebox)\{(.*)\.gif\}/) do
25
+ "\\#{$1}{#{$2}.png}"
26
+ end
27
+ end
28
+ end
29
+
16
30
  def polish_tables(text)
17
31
  text.tap do
18
32
  text.gsub!(/^\s*(\\begin\{table\})/) do
@@ -95,7 +95,7 @@ module Polytexnic
95
95
  # the commands with 'xmlelt' aren't even valid LaTeX; they're actually
96
96
  # pseudo-LaTeX that has special meaning to the Tralics processor.
97
97
  def tralics_commands
98
- <<-'EOS'
98
+ base_commands = <<-'EOS'
99
99
  % Commands specific to Tralics
100
100
  \def\hyperref[#1]#2{\xmlelt{a}{\XMLaddatt{target}{#1}#2}}
101
101
  \newcommand{\heading}[1]{\xmlelt{heading}{#1}}
@@ -110,14 +110,14 @@ module Polytexnic
110
110
  % Ignore some other commands.
111
111
  \newcommand{\includepdf}[1]{}
112
112
  \newcommand{\newunicodechar}[2]{fdsfdas}
113
-
114
-
115
- % Code listings
116
- \usepackage{amsthm}
117
- \theoremstyle{definition}
118
- \newtheorem{codelisting}{Listing}[chapter]
119
- \newtheorem{aside}{Box}[chapter]
120
113
  EOS
114
+ custom_commands = <<-EOS
115
+ \\usepackage{amsthm}
116
+ \\theoremstyle{definition}
117
+ \\newtheorem{codelisting}{#{language_labels["listing"]}}[chapter]
118
+ \\newtheorem{aside}{#{language_labels["aside"]}}[chapter]
119
+ EOS
120
+ [base_commands, custom_commands].join("\n")
121
121
  end
122
122
 
123
123
  # Highlights source code.
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.8.4"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -3,9 +3,10 @@ require 'spec_helper'
3
3
 
4
4
  describe 'Polytexnic::Pipeline#to_html' do
5
5
 
6
- subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html }
6
+ let(:pipeline) { Polytexnic::Pipeline.new(polytex) }
7
+ subject(:processed_text) { pipeline.to_html }
7
8
 
8
- describe "code listings" do
9
+ describe "aside boxes" do
9
10
  let(:polytex) do <<-'EOS'
10
11
  \chapter{Foo bar}
11
12
 
@@ -38,5 +39,15 @@ describe 'Polytexnic::Pipeline#to_html' do
38
39
  </div>
39
40
  EOS
40
41
  end
42
+
43
+ context "with a custom language label" do
44
+ before do
45
+ pipeline.stub(:language_labels).
46
+ and_return({ "chapter" => { "word" => "Chapter",
47
+ "order" => "standard" },
48
+ "aside" => "Cajón" })
49
+ end
50
+ it { should include 'Cajón 1.1' }
51
+ end
41
52
  end
42
53
  end
@@ -38,9 +38,12 @@ describe 'Polytexnic::Pipeline#to_html' do
38
38
  end
39
39
 
40
40
  context "with an alternate to 'Chapter'" do
41
- before do
42
- pipeline.stub(:custom_commands).
43
- and_return('\renewcommand{\chaptername}{Chapitre}')
41
+ let(:language_labels) do
42
+ { "chapter" => {"word" => "fejezet",
43
+ "order" => "reverse"} }
44
+ end
45
+ let(:pipeline) do
46
+ Polytexnic::Pipeline.new(polytex, language_labels: language_labels)
44
47
  end
45
48
  let(:polytex) do <<-'EOS'
46
49
  \chapter{Foo \emph{bar}}
@@ -49,13 +52,58 @@ describe 'Polytexnic::Pipeline#to_html' do
49
52
  end
50
53
  let(:output) do <<-'EOS'
51
54
  <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1">
52
- <h1><a href="#cha-foo" class="heading"><span class="number">Chapitre 1 </span>Foo <em>bar</em></a></h1>
55
+ <h1><a href="#cha-foo" class="heading"><span class="number">1 fejezet </span>Foo <em>bar</em></a></h1>
53
56
  </div>
54
57
  EOS
55
58
  end
59
+
56
60
  it { should resemble output }
57
- end
58
61
 
62
+ context "chapter, etc., linking" do
63
+ let(:language_labels) do
64
+ { "chapter" => {"word" => "Capítulo",
65
+ "order" => "standard"},
66
+ "section" => "Sección",
67
+ "table" => "Tabla",
68
+ "aside" => "Caja",
69
+ "figure" => "Figura",
70
+ "fig" => "Fig",
71
+ "listing" => "Listado",
72
+ "equation" => "Ecuación",
73
+ "eq" => "Ec",
74
+ }
75
+ end
76
+ let(:polytex) do <<-'EOS'
77
+ \chapter{Foo}
78
+ \label{cha:foo}
79
+
80
+ Capítulo~\ref{cha:foo}
81
+ Sección~\ref{sec:bar}
82
+ Tabla~\ref{table:bar}
83
+ Caja~\ref{aside:bar}
84
+ Figura~\ref{fig:bar}
85
+ Fig.~\ref{fig:bar}
86
+ Listado~\ref{code:bar}
87
+ Ecuación~\ref{eq:bar}
88
+ Ec.~\ref{eq:bar}
89
+ EOS
90
+ end
91
+ let(:capitulo) { 'Cap<span class="unicode">í</span>tulo' }
92
+ let(:seccion) { 'Secci<span class="unicode">ó</span>n' }
93
+ let(:ecuacion) { 'Ecuaci<span class="unicode">ó</span>n' }
94
+
95
+ it { should include %(class="hyperref">#{capitulo}) }
96
+ it { should include %(class="hyperref">#{seccion}) }
97
+ it { should include %(class="hyperref">Tabla) }
98
+ it { should include %(class="hyperref">Figura) }
99
+ it { should include %(class="hyperref">Fig.) }
100
+ it { should include %(class="hyperref">Caja) }
101
+ it { should include %(class="hyperref">Listado) }
102
+ it { should include %(class="hyperref">#{ecuacion}) }
103
+ it { should include %(class="hyperref">Ec.) }
104
+
105
+ end
106
+ end
59
107
  end
60
108
 
61
109
  describe '\section' do
@@ -3,7 +3,8 @@ require 'spec_helper'
3
3
 
4
4
  describe 'Polytexnic::Pipeline#to_html' do
5
5
 
6
- subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html }
6
+ let(:pipeline) { Polytexnic::Pipeline.new(polytex) }
7
+ subject(:processed_text) { pipeline.to_html }
7
8
 
8
9
  describe "code listings" do
9
10
  let(:polytex) do <<-'EOS'
@@ -44,6 +45,17 @@ $ subl .gemrc
44
45
  EOS
45
46
  end
46
47
 
48
+ context "with a custom language label" do
49
+ before do
50
+ pipeline.stub(:language_labels).
51
+ and_return({ "chapter" => { "word" => "Chapter",
52
+ "order" => "standard" },
53
+ "listing" => "Código" })
54
+ end
55
+ it { should include 'Código' }
56
+ end
57
+
58
+
47
59
  context "with an empty caption" do
48
60
  let(:polytex) do <<-'EOS'
49
61
  \chapter{Foo bar}
@@ -167,6 +167,42 @@ describe Polytexnic::Pipeline do
167
167
  it { should_not include '<p></p>' }
168
168
  end
169
169
 
170
+ context "with a section" do
171
+ let(:polytex) do <<-'EOS'
172
+ %= <<(spec/to_html/literal_environments/code_spec.rb[section_z])
173
+ EOS
174
+ end
175
+ let(:output) do <<-'EOS'
176
+ <div class="code">
177
+ <div class="highlight">
178
+ <pre>
179
+ <span class="s2">"This is section_z; it's used by a test."</span>
180
+ <span class="s2">"Section Z is your friend."</span>
181
+ </pre>
182
+ </div>
183
+ EOS
184
+ end
185
+ it { should resemble output }
186
+ it { should_not include '<span class="c1">#// begin section_z</span>' }
187
+ it { should_not include '<span class="c1">#// end</span>' }
188
+
189
+ context "that does not exist" do
190
+ let(:polytex) do <<-'EOS'
191
+ %= <<(spec/to_html/literal_environments/code_spec.rb[section_that_does_not_exist])
192
+ EOS
193
+ end
194
+ let(:output) do <<-'EOS'
195
+ <p>
196
+ <span class="inline_verbatim">
197
+ ERROR: Could not find section header '#// begin section_that_does_not_exist' in file 'spec/to_html/literal_environments/code_spec.rb'
198
+ </span>
199
+ </p>
200
+ EOS
201
+ end
202
+ it { should resemble output }
203
+ end
204
+ end
205
+
170
206
  context "with a custom language override" do
171
207
  let(:polytex) do <<-'EOS'
172
208
  %= <<(polytexnic_commands.sty, lang: tex)
@@ -203,4 +239,19 @@ describe Polytexnic::Pipeline do
203
239
  it { should include "ERROR: File 'foobar.rb' does not exist" }
204
240
  end
205
241
  end
206
- end
242
+ end
243
+
244
+
245
+ ###################################################
246
+ 'The following lines are used to test code sections'
247
+
248
+ #// begin section_a
249
+ "This is the code inside of section_a."
250
+ "Sections begin with a line containing only '#// begin section_name' and end with '#// end'"
251
+ "You many divide a file into multiple sections and include them individually in your book."
252
+ #// end
253
+
254
+ #// begin section_z
255
+ "This is section_z; it's used by a test."
256
+ "Section Z is your friend."
257
+ #// end
@@ -204,5 +204,18 @@ end
204
204
 
205
205
  it { should resemble output }
206
206
  end
207
+
208
+ describe "images with GIFs" do
209
+ let(:polytex) do <<-'EOS'
210
+ \includegraphics{foo.gif}
211
+ \image{bar.gif}
212
+ \imagebox{baz.gif}
213
+ EOS
214
+ end
215
+
216
+ it { should include '\includegraphics{foo.png}' }
217
+ it { should include '\image{bar.png}' }
218
+ it { should include '\imagebox{baz.png}' }
219
+ end
207
220
  end
208
221
  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: 0.8.4
4
+ version: 0.9.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: 2014-02-07 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri