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 +4 -4
- data/.pull_requests/1385598040 +0 -0
- data/lib/polytexnic/preprocessors/polytex.rb +20 -12
- data/lib/polytexnic/version.rb +1 -1
- data/spec/markdown_to_polytex_spec.rb +19 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6a446d78432685757904722522835e26505704
|
4
|
+
data.tar.gz: 3a39439ee2a40bcf52f9ca967332feaa65af4941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
105
|
-
def
|
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
|
data/lib/polytexnic/version.rb
CHANGED
@@ -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
|
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.
|
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-
|
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
|