polytexnic 0.8.2 → 0.8.3

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: 93f94c2e4866339d2cea4731e55fa4963774d985
4
- data.tar.gz: f15a6846bd39ba6d567d40cf6060910698640d38
3
+ metadata.gz: 8e73721e69c72ece6549257bb3c30295b6892992
4
+ data.tar.gz: 4a6936bfdc80f5d203a261c37acf351214d6b4b0
5
5
  SHA512:
6
- metadata.gz: bca25d2db6b2d84918031fe1dfe32da9dd929eefffc892654486930d554bc631da22910d662026796892b64f4b8e86cfb44d67786f29b14bde312bd34d933860
7
- data.tar.gz: 332fc4c67051c89e0c3854a4d02a4d60314f5b0ff28f77c7647b520ef30a236c17a8dcc9d085cad3512fd59864f6ca48b3ca2d9023fecaeb97b110eb9b8d3967
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) && !line.match(/^```\s*$/) do
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")
@@ -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 = File.join('latex_styles', 'softcover.sty')
176
- if File.exist?(softcover_sty)
177
- regex = '{code}{Verbatim}{(.*)}'
178
- styles = File.read(softcover_sty).scan(/#{regex}/).flatten.first
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
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
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
- @highlight_cache = MessagePack.unpack(content) unless content.empty?
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.2
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-05 00:00:00.000000000 Z
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