octopress-code-highlighter 4.2.3 → 4.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4164dd0c2e141d03bee935546f650601d2c0e5cb
4
- data.tar.gz: a83c9099f0d9dd79ea224d86afcff2abeddd32e9
3
+ metadata.gz: c6e9892e2d81b5eb3511df94f71f76a1df7890c2
4
+ data.tar.gz: ce7e0c23bf5ccf87692c2359258e795e71d8864d
5
5
  SHA512:
6
- metadata.gz: 1fe0c512294344643b66ef52113fdc17b1ce6626542f3957dc343a064be574babbbfbe73a46a19652815612d9cef8c6c5eedbf07ea2fdb2959a5366fdf1975c5
7
- data.tar.gz: 488ba51111b20a62d1c9b4869b2101f67ae46995e61a3f13488b34391dfb2f2012fe819c2090511b00849da4004a2526d9563c261a76c0c71ef3c855679f5ee6
6
+ metadata.gz: 865e32859e2e7bc1cd36b74993e37d64ed5fc49fca1dfb9159da6aec1c054ca6374f6f91ecd3968466c0d3e7a3c5ead761d09e615c1cfbf54cc99530c43350cf
7
+ data.tar.gz: 9b16907de093ec56ef18c8c98ef0a98f3ed71f42075bff49d77b12c9067cc94ef00e467b5b0a92475013243e23892e4ccdb2c984c5457b233c0b731e61eb83d5
data/CHANGELOG.md CHANGED
@@ -1,78 +1,83 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.2.3 - 2015-05-18
4
+ - New: Now works with Jekyll 3 and Jekyll Hooks.
5
+ - Fix: Cache reads and writes do not trigger Jekyll watcher.
6
+ - Fix: Cache fingerprinting improvement.
7
+
3
8
  ## 4.2.3 - 2014-07-08
4
- - Fixed: Code ranges now work on ruby 1.9.3
9
+ - Fixed: Code ranges now work on ruby 1.9.3
5
10
 
6
11
  ## 4.2.2 - 2014-07-07
7
- - Fixed: Closing spans aren't wrapped to a newline.
12
+ - Fixed: Closing spans aren't wrapped to a newline.
8
13
 
9
14
  ## 4.2.1 - 2014-06-29
10
- - Improved support for new Pygments.rb.
15
+ - Improved support for new Pygments.rb.
11
16
 
12
17
  ## 4.2.0 - 2014-06-28
13
- - New: Add classnames on code figure: `class:"example classnames"`.
18
+ - New: Add classnames on code figure: `class:"example classnames"`.
14
19
 
15
20
  ## 4.1.0 - 2014-06-27
16
- - Added support for setting PHP's startinline option (now defaults to true).
21
+ - Added support for setting PHP's startinline option (now defaults to true).
17
22
 
18
23
  ## 4.0.3 - 2014-06-26
19
- - Fixed: Improved escaping characters for Liquid.
24
+ - Fixed: Improved escaping characters for Liquid.
20
25
 
21
26
  ## 4.0.2
22
- - Fixed: end of range now works properly.
27
+ - Fixed: end of range now works properly.
23
28
 
24
29
  ## 4.0.1
25
- - Changed `get_range` method to `select_lines` which returns a code partial when `start`, `end` or `range` options are defined.
30
+ - Changed `get_range` method to `select_lines` which returns a code partial when `start`, `end` or `range` options are defined.
26
31
 
27
32
  ## 4.0.0
28
- - Removed stylesheets. Now use gem octopress-solarized for stylesheets.
29
- - Removed dependency on Octopress Ink.
33
+ - Removed stylesheets. Now use gem octopress-solarized for stylesheets.
34
+ - Removed dependency on Octopress Ink.
30
35
 
31
36
  ## 3.1.0
32
- - Updated stylesheets to be Sass 3.3 compatible.
37
+ - Updated stylesheets to be Sass 3.3 compatible.
33
38
 
34
39
  ## 3.0.1
35
- - Changed name of cache dir to .code-highlighter-cache.
40
+ - Changed name of cache dir to .code-highlighter-cache.
36
41
 
37
42
  ## 3.0.0
38
- - Changed name to octopress-code-highlighter.
39
- - Now supporting both Pygments.rb and Rouge for highlighting.
43
+ - Changed name to octopress-code-highlighter.
44
+ - Now supporting both Pygments.rb and Rouge for highlighting.
40
45
 
41
46
  ## 2.0.1
42
- - Updated Octopress Ink version, added a simple demo project.
47
+ - Updated Octopress Ink version, added a simple demo project.
43
48
 
44
49
  ## 2.0.1
45
- - Updated Octopress Ink version, added a simple demo project.
50
+ - Updated Octopress Ink version, added a simple demo project.
46
51
 
47
52
  ## 2.0.0
48
- - Added support for Octopress Ink
53
+ - Added support for Octopress Ink
49
54
 
50
55
  ## 1.3.1
51
- - Fixed: line numbers now start at 1 instead of zero.
52
- - Changed: `escape` option defaults to false.
56
+ - Fixed: line numbers now start at 1 instead of zero.
57
+ - Changed: `escape` option defaults to false.
53
58
 
54
59
  ## 1.3.0
55
- - Added `escape` option which wraps code in {% raw %} tags to escape liquid. Defaults to true.
60
+ - Added `escape` option which wraps code in {% raw %} tags to escape liquid. Defaults to true.
56
61
 
57
62
  ## 1.2.3
58
- - Fixed: figcaptions now work when specifying a title.
63
+ - Fixed: figcaptions now work when specifying a title.
59
64
 
60
65
  ## 1.2.2
61
- - Now you can call Pygments.read_cache directly.
62
- - Added an option to specify a label on cache files.
63
- - Simplified caching methods.
66
+ - Now you can call Pygments.read_cache directly.
67
+ - Added an option to specify a label on cache files.
68
+ - Simplified caching methods.
64
69
 
65
70
  ## 1.2.1
66
- - Fix: No longer overwriting options with `nil` in parse_markup
71
+ - Fix: No longer overwriting options with `nil` in parse_markup
67
72
 
68
73
  ## 1.2.0
69
- - Added method for users to specify lexer aliases
70
- - Removed default aliases:
71
- - ru, yml, coffee - now handled by Pygments correctly
72
- - pl, m - match multiple languages, enforcing an alias is inappropriate
74
+ - Added method for users to specify lexer aliases
75
+ - Removed default aliases:
76
+ - ru, yml, coffee - now handled by Pygments correctly
77
+ - pl, m - match multiple languages, enforcing an alias is inappropriate
73
78
 
74
79
  ## 1.1.0
75
- - Boring bug fixes
80
+ - Boring bug fixes
76
81
 
77
82
  ## 1.0.0
78
- - Initial release
83
+ - Initial release
@@ -7,9 +7,13 @@ require 'colorator'
7
7
  begin require 'octopress'
8
8
  rescue LoadError; end
9
9
 
10
+ require 'octopress-code-highlighter/hooks'
11
+
10
12
  begin require 'octopress-ink'
11
13
  rescue LoadError; end
12
14
 
15
+ require 'octopress-code-highlighter/cache'
16
+
13
17
  module Octopress
14
18
  module CodeHighlighter
15
19
  DEFAULTS = {
@@ -19,7 +23,8 @@ module Octopress
19
23
  start: 1
20
24
  }
21
25
 
22
- autoload :Cache, 'octopress-code-highlighter/cache'
26
+ CODE_CACHE_DIR = '.code-highlighter-cache'
27
+
23
28
  autoload :OptionsParser, 'octopress-code-highlighter/options_parser'
24
29
  autoload :Renderer, 'octopress-code-highlighter/renderer'
25
30
 
@@ -67,4 +72,3 @@ module Octopress
67
72
  end
68
73
  end
69
74
  end
70
-
@@ -1,30 +1,51 @@
1
+ require 'find'
2
+
1
3
  module Octopress
2
4
  module CodeHighlighter
3
- class Cache
4
- CODE_CACHE_DIR = '.code-highlighter-cache'
5
-
6
- class << self
7
- def read_cache(code, options)
8
- cache_label = options[:cache_label] || options[:lang] || ''
9
- path = get_cache_path(CODE_CACHE_DIR, cache_label, options.to_s + code)
10
- File.exist?(path) ? File.read(path) : nil unless path.nil?
11
- end
5
+ module Cache
6
+ extend self
7
+
8
+ @cached_files = []
9
+ @write_cache = {}
10
+
11
+ def read_cache(code, options)
12
+ cache_label = options[:cache_label] || options[:lang] || ''
13
+ path = get_cache_path(CODE_CACHE_DIR, cache_label, options.to_s + code)
14
+ @cached_files << path
15
+ File.exist?(path) ? File.read(path) : nil unless path.nil?
16
+ end
17
+
18
+ def write_to_cache(contents, code, options)
19
+ FileUtils.mkdir_p(CODE_CACHE_DIR) unless File.directory?(CODE_CACHE_DIR)
20
+ cache_label = options[:cache_label] || options[:lang] || ''
21
+ path = get_cache_path(CODE_CACHE_DIR, cache_label, options.to_s + code)
22
+ @write_cache[path] = contents
23
+ end
12
24
 
13
- def write_to_cache(contents, options)
14
- FileUtils.mkdir_p(CODE_CACHE_DIR) unless File.directory?(CODE_CACHE_DIR)
15
- cache_label = options[:cache_label] || options[:lang] || ''
16
- path = get_cache_path(CODE_CACHE_DIR, cache_label, options.to_s + contents)
25
+ def get_cache_path(dir, label, str)
26
+ label += '-' unless label === ''
27
+ File.join(dir, ".#{label}#{Digest::MD5.hexdigest(str)}.html")
28
+ end
29
+
30
+ def write
31
+ @write_cache.each do |path, contents|
32
+ @cached_files << path
17
33
  File.open(path, 'w') do |f|
18
34
  f.print(contents)
19
35
  end
20
36
  end
37
+ @write_cache = {}
38
+ end
21
39
 
22
- def get_cache_path(dir, label, str)
23
- label += '-' unless label === ''
24
- File.join(dir, "#{label}#{Digest::MD5.hexdigest(str)}.html")
40
+ def clean
41
+ remove = Find.find(CODE_CACHE_DIR).to_a.reject do |file|
42
+ @cached_files.include?(file) || File.directory?(file)
25
43
  end
44
+
45
+ @cached_files = []
46
+
47
+ FileUtils.rm remove
26
48
  end
27
49
  end
28
50
  end
29
51
  end
30
-
@@ -0,0 +1,18 @@
1
+ module Octopress
2
+ module CodeHighlighter
3
+ if defined?(Jekyll::Hooks)
4
+ Jekyll::Hooks.register :site, :post_write do |site|
5
+ Octopress::CodeHighlighter::Cache.write
6
+ Octopress::CodeHighlighter::Cache.clean
7
+ end
8
+ else
9
+ require 'octopress-hooks'
10
+ class SiteHook < Octopress::Hooks::Site
11
+ def post_write(site)
12
+ Octopress::CodeHighlighter::Cache.write
13
+ Octopress::CodeHighlighter::Cache.clean
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -51,7 +51,7 @@ module Octopress
51
51
  end
52
52
  rendered_code = "<figure class='#{classnames}'>#{caption}#{rendered_code}</figure>"
53
53
  rendered_code = "{% raw %}#{rendered_code}{% endraw %}" if options[:escape]
54
- Cache.write_to_cache(rendered_code, options) unless options[:no_cache]
54
+ Cache.write_to_cache(rendered_code, code, options) unless options[:no_cache]
55
55
  rendered_code
56
56
  end
57
57
  end
@@ -1,6 +1,6 @@
1
1
  module Octopress
2
2
  module CodeHighlighter
3
- VERSION = "4.2.3"
3
+ VERSION = "4.2.4"
4
4
  end
5
5
  end
6
6
 
@@ -8,14 +8,13 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Octopress::CodeHighlighter::VERSION
9
9
  gem.authors = ["Brandon Mathis"]
10
10
  gem.email = ["brandon@imathis.com"]
11
- gem.description = %q{Octopress's core plugin for rendering nice code blocks}
12
11
  gem.summary = %q{Octopress's core plugin for rendering nice code blocks}
13
12
  gem.homepage = "https://github.com/octopress/code-highlighter"
14
13
  gem.license = "MIT"
15
14
 
16
15
  gem.add_runtime_dependency 'colorator', '~> 0.1'
16
+ gem.add_runtime_dependency 'octopress-hooks'
17
17
 
18
- gem.add_development_dependency 'pry-debugger'
19
18
  gem.add_development_dependency 'rake'
20
19
  gem.add_development_dependency 'rspec'
21
20
  gem.add_development_dependency 'rouge', '~> 1.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-code-highlighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-08 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorator
@@ -25,13 +25,13 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: pry-debugger
28
+ name: octopress-hooks
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.3'
83
- description: Octopress's core plugin for rendering nice code blocks
83
+ description:
84
84
  email:
85
85
  - brandon@imathis.com
86
86
  executables: []
@@ -97,6 +97,7 @@ files:
97
97
  - Rakefile
98
98
  - lib/octopress-code-highlighter.rb
99
99
  - lib/octopress-code-highlighter/cache.rb
100
+ - lib/octopress-code-highlighter/hooks.rb
100
101
  - lib/octopress-code-highlighter/options_parser.rb
101
102
  - lib/octopress-code-highlighter/renderer.rb
102
103
  - lib/octopress-code-highlighter/version.rb
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  requirements: []
125
126
  rubyforge_project:
126
- rubygems_version: 2.2.2
127
+ rubygems_version: 2.4.6
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Octopress's core plugin for rendering nice code blocks