octopress-pygments 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -0
- data/lib/octopress-pygments.rb +4 -0
- data/lib/octopress-pygments/cache.rb +9 -10
- data/lib/octopress-pygments/renderer.rb +4 -3
- data/lib/octopress-pygments/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTUwM2Q0N2ExNDAwNzE4OGQzYzUzNjQ5ZmRhMWY5MWQ2YzkzZWY4Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjcwZjkwMzQ5ZjU1NDAzZjVkN2QxY2ZlZThlNzFlNmVkZmY3YjAwNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODU4NGZiZmVmZTk3ZTA0ZmFlYmFjNTI1NDFiYzY0MzcxY2VhZTU0ZTdiZTVl
|
10
|
+
NDU1ODU3YWI2NzBjOWExOGRmYzcxOGEzMTYzOTM4YjljYmVkNDA1NmJkOGU4
|
11
|
+
ZGNmMWExMWI1MWNmMDg2OTg3ZjA3NmQ5YjVkMjE5ZDZkN2RhOGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGY4ODEwMmVhN2EzOWNhNDAyMTZhMDdiZWEwODAwYmM1MTk3NmZiMmYxMjcx
|
14
|
+
YTYxNDgzZGYzOTg0NDg1NzI3ODYyMGI1ZTQzZTAzODBkMTM2OTYyMjQ2OWIw
|
15
|
+
ZDAxZjU2ZGM5YzIwMDM3NDZmOTc2MjA5YWU2ZTE4N2QzYzMxZDI=
|
data/CHANGELOG.md
CHANGED
data/lib/octopress-pygments.rb
CHANGED
@@ -17,6 +17,10 @@ module Octopress
|
|
17
17
|
Renderer.new(code, options).highlight
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.read_cache(code, options={})
|
21
|
+
Cache.read_cache(code, options)
|
22
|
+
end
|
23
|
+
|
20
24
|
def self.parse_markup(input, defaults={})
|
21
25
|
OptionsParser.new(input).parse_markup(defaults)
|
22
26
|
end
|
@@ -4,25 +4,24 @@ module Octopress
|
|
4
4
|
PYGMENTS_CACHE_DIR = '.pygments-cache'
|
5
5
|
|
6
6
|
class << self
|
7
|
-
def
|
8
|
-
|
9
|
-
|
7
|
+
def read_cache(code, options)
|
8
|
+
cache_label = options[:cache_label] || options[:lang] || ''
|
9
|
+
path = get_cache_path(PYGMENTS_CACHE_DIR, cache_label, options.to_s + code)
|
10
|
+
File.exist?(path) ? File.read(path) : nil unless path.nil?
|
10
11
|
end
|
11
12
|
|
12
13
|
def write_to_cache(contents, options)
|
13
14
|
FileUtils.mkdir_p(PYGMENTS_CACHE_DIR) unless File.directory?(PYGMENTS_CACHE_DIR)
|
14
|
-
|
15
|
+
cache_label = options[:cache_label] || options[:lang] || ''
|
16
|
+
path = get_cache_path(PYGMENTS_CACHE_DIR, cache_label, options.to_s + contents)
|
15
17
|
File.open(path, 'w') do |f|
|
16
18
|
f.print(contents)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def get_cache_path(dir, name, str)
|
25
|
-
File.join(dir, "#{name}-#{Digest::MD5.hexdigest(str)}.html")
|
22
|
+
def get_cache_path(dir, label, str)
|
23
|
+
label += '-' unless label === ''
|
24
|
+
File.join(dir, "#{label}#{Digest::MD5.hexdigest(str)}.html")
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
@@ -13,8 +13,9 @@ module Octopress
|
|
13
13
|
|
14
14
|
def highlight
|
15
15
|
@options[:title] ||= ' ' if @options[:url]
|
16
|
-
cache = Cache.
|
17
|
-
|
16
|
+
if cache = Cache.read_cache(code, @options)
|
17
|
+
cache
|
18
|
+
else
|
18
19
|
if @lang == 'plain'
|
19
20
|
rendered_code = code.to_s.gsub('<','<')
|
20
21
|
else
|
@@ -24,8 +25,8 @@ module Octopress
|
|
24
25
|
title = captionize(@options[:title], @options[:url], @options[:link_text]) if @options[:title]
|
25
26
|
rendered_code = "<figure class='code'>#{title}#{rendered_code}</figure>"
|
26
27
|
Cache.write_to_cache(rendered_code, @options) unless @options[:no_cache]
|
28
|
+
rendered_code
|
27
29
|
end
|
28
|
-
cache || rendered_code
|
29
30
|
end
|
30
31
|
|
31
32
|
def determine_lang(lang)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-pygments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pygments.rb
|