polytexnic 0.6.7 → 0.6.8

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: 90967a11604447f1c48b3016f4f7dde1f082fdd6
4
- data.tar.gz: 5567505edfd23e041e228a835ab1b07ea60d752b
3
+ metadata.gz: de6a446d78432685757904722522835e26505704
4
+ data.tar.gz: 3a39439ee2a40bcf52f9ca967332feaa65af4941
5
5
  SHA512:
6
- metadata.gz: 18b33ec18fc3a248ddc7d60b4b2fe6492bcc7a01b5dca944683989290e9dcc49c48d570a601c3c250d455330807f2930187eb235b875fc18092e5ac745502ff5
7
- data.tar.gz: b748f0a571d6a60f389fd5b99691f2bed3b620bfe18a52e7f14fb2af31e61f524e49066ff6ffbd5be65dce310bcae0cc371c223009675183915e0713a2df395a
6
+ metadata.gz: a587872ddd1612030e5e3ccbe006daa6cf0782a07762e496858f05b556d62db003a0cec403f3239b66baa19fc533e4b44ef1b164ce1a38727142f64d6ad78661
7
+ data.tar.gz: 982fd0d2bcf7d04e92b69a06f805e58cf5dd321a793bb3c7eee8e8e6eb061f0a999499705ab840083b82b925d4fcb2ddb84caef0d65b1ca568a5f41ae9f991b1
File without changes
@@ -29,7 +29,7 @@ module Polytexnic
29
29
  cleaned_markdown = cache_code_environments
30
30
  puts cleaned_markdown if debug?
31
31
  cleaned_markdown.tap do |markdown|
32
- convert_code_inclusion(markdown)
32
+ convert_code_inclusion(markdown, cache)
33
33
  cache_latex_literal(markdown, cache)
34
34
  cache_raw_latex(markdown, cache)
35
35
  puts markdown if debug?
@@ -40,20 +40,20 @@ module Polytexnic
40
40
  lh = 'chapter,section,subsection,subsubsection,paragraph,subparagraph'
41
41
  kramdown = Kramdown::Document.new(cleaned_markdown, latex_headers: lh)
42
42
  @source = kramdown.to_latex.tap do |polytex|
43
+ remove_comments(polytex)
43
44
  convert_tt(polytex)
44
45
  restore_math(polytex, math_cache)
45
- restore_inclusion(polytex)
46
- restore_raw_latex(polytex, cache)
46
+ restore_hashed_content(polytex, cache)
47
47
  end
48
48
  end
49
49
 
50
50
  # Adds support for <<(path/to/code) inclusion.
51
- # Yes, this is a bit of a hack, but it works.
52
- def convert_code_inclusion(text)
53
- text.gsub!(/^\s*<<(\(.*?\))/) { "<!-- inclusion= <<#{$1}-->" }
54
- end
55
- def restore_inclusion(text)
56
- text.gsub!(/% <!-- inclusion= (.*?)-->/) { "%= #{$1}" }
51
+ def convert_code_inclusion(text, cache)
52
+ text.gsub!(/^\s*(<<\(.*?\))/) do
53
+ key = digest($1)
54
+ cache[key] = "%= #{$1}" # reduce to a previously solved case
55
+ key
56
+ end
57
57
  end
58
58
 
59
59
  # Caches literal LaTeX environments.
@@ -101,11 +101,11 @@ module Polytexnic
101
101
  end
102
102
  end
103
103
 
104
- # Restores raw LaTeX from the cache
105
- def restore_raw_latex(text, cache)
104
+ # Restores raw code from the cache
105
+ def restore_hashed_content(text, cache)
106
106
  cache.each do |key, value|
107
107
  # Because of the way backslashes get interpolated, we need to add
108
- # some extra ones to cover all the cases.
108
+ # some extra ones to cover all the cases of hashed LaTeX.
109
109
  text.gsub!(key, value.gsub(/\\/, '\\\\\\'))
110
110
  end
111
111
  end
@@ -151,6 +151,14 @@ module Polytexnic
151
151
  output.join("\n")
152
152
  end
153
153
 
154
+ # # Removes comments.
155
+ # # The main reason for doing this is so that commented-out cached objects,
156
+ # # such as '% <hash of a code sample>', get removed.
157
+ # # Code like '%= lang:ruby' gets preserved.
158
+ # def strip_comments(text)
159
+ # text.gsub!(/^%.*$/, '')
160
+ # end
161
+
154
162
  # Converts {tt ...} to \kode{...}
155
163
  # This effectively converts `inline code`, which kramdown sets as
156
164
  # {\tt inline code}, to PolyTeX's native \kode command, which in
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.8"
3
3
  end
@@ -185,7 +185,7 @@ bar
185
185
  it { should resemble source }
186
186
  end
187
187
 
188
- context "a codelisting environment, including a nested command." do
188
+ context "a codelisting environment, including a nested command" do
189
189
  let(:source) do <<-'EOS'
190
190
  \begin{codelisting}
191
191
  \codecaption{Lorem \emph{ipsum}.}
@@ -202,6 +202,24 @@ def foo; "bar"; end
202
202
  it { should resemble '\end{codelisting}' }
203
203
  end
204
204
 
205
+ context "a commented-out codelisting" do
206
+ let(:source) do <<-'EOS'
207
+ %= foo:bar
208
+ <!--
209
+ \begin{codelisting}
210
+ \codecaption{Lorem \emph{ipsum}.}
211
+ \label{code:lorem}
212
+ ```ruby
213
+ def foo; "bar"; end
214
+ ```
215
+ \end{codelisting}
216
+ -->
217
+ EOS
218
+ end
219
+ it { should include '%= foo:bar' }
220
+ it { should_not resemble '\begin{codelisting}' }
221
+ end
222
+
205
223
  context "code inclusion inside codelisting" do
206
224
  let(:source) do <<-'EOS'
207
225
  \begin{codelisting}
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.6.7
4
+ version: 0.6.8
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: 2013-11-27 00:00:00.000000000 Z
12
+ date: 2013-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -168,6 +168,7 @@ files:
168
168
  - .pull_requests/1384800466
169
169
  - .pull_requests/1384811507
170
170
  - .pull_requests/1385061501
171
+ - .pull_requests/1385598040
171
172
  - .rspec
172
173
  - .ruby-gemset
173
174
  - .ruby-version