polytexnic 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.pull_requests/1389652617 +0 -0
- data/lib/polytexnic/preprocessors/polytex.rb +5 -1
- data/lib/polytexnic/utils.rb +11 -4
- data/lib/polytexnic/version.rb +1 -1
- data/lib/polytexnic.rb +5 -1
- data/spec/markdown_to_polytex_spec.rb +22 -2
- 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: 8e73721e69c72ece6549257bb3c30295b6892992
|
4
|
+
data.tar.gz: 4a6936bfdc80f5d203a261c37acf351214d6b4b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e498b2a6d0c5cb8f4ab9d682541c34ea29aef319ff539516f94bc1b2508edd99f6c3a5e0298c453ce6ea4f781ee5743a16aa5d8385c1b9d6e71ed3b752fac45
|
7
|
+
data.tar.gz: 336b3755b1cbbd435310dce8285cac31b17120f7ff4425288cf093cc96bf660912a298dae4585ad310b20a378eee084d50b44aaa9305c13bc463d72dbf0f8f25
|
File without changes
|
@@ -216,10 +216,14 @@ module Polytexnic
|
|
216
216
|
output << key
|
217
217
|
output << line
|
218
218
|
elsif line =~ /^```(\w*)(,\s*options:.*)?$/ # highlighted fences
|
219
|
+
count = 1
|
219
220
|
language = $1.empty? ? 'text' : $1
|
220
221
|
options = $2
|
221
222
|
code = []
|
222
|
-
while (line = lines.shift)
|
223
|
+
while (line = lines.shift) do
|
224
|
+
count += 1 if line =~ /^```.+$/
|
225
|
+
count -= 1 if line.match(/^```\s*$/)
|
226
|
+
break if count.zero?
|
223
227
|
code << line
|
224
228
|
end
|
225
229
|
code = code.join("\n")
|
data/lib/polytexnic/utils.rb
CHANGED
@@ -171,11 +171,18 @@ module Polytexnic
|
|
171
171
|
# includes a required override of the default commandchars.
|
172
172
|
# Since the substitution is only important in the context of a PDF book,
|
173
173
|
# it only gets made if there's a style in the 'softcover.sty' file.
|
174
|
+
# We also support custom overrides in 'custom_pdf.sty'.
|
174
175
|
def add_font_info(string)
|
175
|
-
softcover_sty
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
softcover_sty = File.join('latex_styles', 'softcover.sty')
|
177
|
+
custom_pdf_sty = File.join('latex_styles', 'custom_pdf.sty')
|
178
|
+
regex = '{code}{Verbatim}{(.*)}'
|
179
|
+
styles = nil
|
180
|
+
[softcover_sty, custom_pdf_sty].reverse.each do |filename|
|
181
|
+
if File.exist?(filename)
|
182
|
+
styles ||= File.read(filename).scan(/#{regex}/).flatten.first
|
183
|
+
end
|
184
|
+
end
|
185
|
+
unless styles.nil?
|
179
186
|
string.gsub!("\\begin{Verbatim}[",
|
180
187
|
"\\begin{Verbatim}[#{styles},")
|
181
188
|
end
|
data/lib/polytexnic/version.rb
CHANGED
data/lib/polytexnic.rb
CHANGED
@@ -44,7 +44,11 @@ module Polytexnic
|
|
44
44
|
if File.exist?(@highlight_cache_filename)
|
45
45
|
content = File.read(@highlight_cache_filename)
|
46
46
|
.force_encoding('ASCII-8BIT')
|
47
|
-
|
47
|
+
begin
|
48
|
+
@highlight_cache = MessagePack.unpack(content) unless content.empty?
|
49
|
+
rescue MessagePack::UnpackError
|
50
|
+
FileUtils.rm @highlight_cache_filename
|
51
|
+
end
|
48
52
|
end
|
49
53
|
@highlight_cache ||= {}
|
50
54
|
@math_label_cache = {}
|
@@ -492,8 +492,6 @@ lorem
|
|
492
492
|
it { should resemble output }
|
493
493
|
end
|
494
494
|
|
495
|
-
|
496
|
-
|
497
495
|
context "with a code listing from Urbit that broke" do
|
498
496
|
let(:source) do <<-'EOS'
|
499
497
|
```text
|
@@ -506,6 +504,28 @@ foo
|
|
506
504
|
end
|
507
505
|
it { should_not include "\\begin{code}\n'Foo \n"}
|
508
506
|
end
|
507
|
+
|
508
|
+
context "with nested fencing" do
|
509
|
+
let(:source) do <<-'EOS'
|
510
|
+
```text
|
511
|
+
```ruby, options: "hl_lines": [1, 2], "linenos": true
|
512
|
+
def hello; puts 'hello'; end
|
513
|
+
```
|
514
|
+
```
|
515
|
+
EOS
|
516
|
+
end
|
517
|
+
|
518
|
+
let(:output) do <<-'EOS'
|
519
|
+
%= lang:text
|
520
|
+
\begin{code}
|
521
|
+
```ruby, options: "hl_lines": [1, 2], "linenos": true
|
522
|
+
def hello; puts 'hello'; end
|
523
|
+
```
|
524
|
+
\end{code}
|
525
|
+
EOS
|
526
|
+
end
|
527
|
+
it { should resemble output }
|
528
|
+
end
|
509
529
|
end
|
510
530
|
end
|
511
531
|
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
|
+
version: 0.8.3
|
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-01
|
12
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- .pull_requests/1388430185
|
204
204
|
- .pull_requests/1388440664
|
205
205
|
- .pull_requests/1388802190
|
206
|
+
- .pull_requests/1389652617
|
206
207
|
- .rspec
|
207
208
|
- Gemfile
|
208
209
|
- Guardfile
|