octopress-codefence 1.4.3 → 1.4.4

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: 31389d6206eeb0e184e5afdafe06235497f42744
4
- data.tar.gz: e2393cb5737626a4671513a266f29d4c37863350
3
+ metadata.gz: 9972ada98f5f0fe17581ba4ada1aa4561250a6b8
4
+ data.tar.gz: be614c779b644172ea332eda3b4a44fe2d147f68
5
5
  SHA512:
6
- metadata.gz: a825431f236a0304836c5fe51b342f2d1702e4be62969995f1ce895f383d4e4d9797dbb01f55f084826ce0bf10eec0ae49b833b880c947a5518e2c4afd93fa33
7
- data.tar.gz: 854a01a502c5dc07701e70413ca9c741ec5235dc42f1914609e3f92cb7049f9e21ab58a0462e3b0555e8804f71b3a2113de4fd5efdd311f509d460df3e518b1c
6
+ metadata.gz: 1d7a8afccc518ea2c3bf5b1042ac814cc16dbf2a87b13f16cade3214b0d269a34cc4dd1d024854363d81393ba3eb206ae9298d0fb02ec451939886160f3dcf70
7
+ data.tar.gz: 7e3b406e7e1c66aca04bd04ec98f35bac5ba0ca49e0270c9cd501b030182fbabb310e50292311d4901f84d0195f38699ef042be0daeb5f382142e25a69269f72
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  _site
21
21
  .sass-cache
22
22
  .code-highlighter-cache
23
+ site
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
- script: cd test && ruby test.rb
5
+ script: cd test && bundle exec clash
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.4 - 2014-07-27
4
+ - Now using octopress-hooks instead of jekyll-page-hooks.
5
+
3
6
  ## 1.4.3 - 2014-06-29
4
7
  - Updated to latest octopress-code-highlighter gem. Relaxed dependencies.
5
8
 
@@ -1,69 +1,75 @@
1
1
  require 'octopress-codefence/version'
2
2
  require 'octopress-code-highlighter'
3
- require 'jekyll-page-hooks'
4
-
5
- module Jekyll
6
- class Codefence < PageHooks
7
- def pre_render(page)
8
- page.content = Octopress::Codefence.new(page.content, page.ext, page.site.config['code_aliases']).render
9
- end
10
- end
11
- end
3
+ require 'octopress-hooks'
12
4
 
13
5
  module Octopress
14
- class Codefence
15
- AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i
16
- LangCaption = /([^\s]+)\s*(.+)?/i
6
+ module Codefence
7
+ class PageHook < Hooks::Page
8
+ def pre_render(page)
9
+ page.content = Codefence::Highlighter.new(page.content, page.ext, page.site.config['code_aliases']).render
10
+ end
11
+ end
17
12
 
18
- def initialize(input, ext=nil, aliases=nil)
19
- @input = input
20
- @ext = ext
21
- @aliases = aliases
13
+ class PostHook < Hooks::Post
14
+ def pre_render(post)
15
+ post.content = Codefence::Highlighter.new(post.content, post.ext, post.site.config['code_aliases']).render
16
+ end
22
17
  end
23
-
24
- def render
25
- @input.encode!("UTF-8")
26
- @input.gsub /^`{3}(.+?)`{3}/m do
27
- str = $1.to_s
28
- str.gsub /([^\n]+)?\n(.+?)\Z/m do
29
- markup = $1 || ''
30
- code = $2.to_s
31
- begin
32
- get_code(code, get_options(markup))
33
- rescue => e
34
- markup = "```#{markup}"
35
- CodeHighlighter.highlight_failed(e, "```[language] [title] [url] [link text] [linenos:false] [start:#] [mark:#,#-#]\ncode\n```", markup, code)
18
+
19
+ class Highlighter
20
+ AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i
21
+ LangCaption = /([^\s]+)\s*(.+)?/i
22
+
23
+ def initialize(input, ext=nil, aliases=nil)
24
+ @input = input
25
+ @ext = ext
26
+ @aliases = aliases
27
+ end
28
+
29
+ def render
30
+ @input.encode!("UTF-8")
31
+ @input.gsub /^`{3}(.+?)`{3}/m do
32
+ str = $1.to_s
33
+ str.gsub /([^\n]+)?\n(.+?)\Z/m do
34
+ markup = $1 || ''
35
+ code = $2.to_s
36
+ begin
37
+ get_code(code, get_options(markup))
38
+ rescue => e
39
+ markup = "```#{markup}"
40
+ CodeHighlighter.highlight_failed(e, "```[language] [title] [url] [link text] [linenos:false] [start:#] [mark:#,#-#]\ncode\n```", markup, code)
41
+ end
36
42
  end
37
43
  end
38
44
  end
39
- end
40
45
 
41
- def get_options(markup)
42
- defaults = { escape: true }
43
- clean_markup = CodeHighlighter.clean_markup(markup)
46
+ def get_options(markup)
47
+ defaults = { escape: true }
48
+ clean_markup = CodeHighlighter.clean_markup(markup)
44
49
 
45
- if clean_markup =~ AllOptions
46
- defaults = {
47
- lang: $1,
48
- title: $2,
49
- url: $3,
50
- link_text: $4,
51
- }
52
- elsif clean_markup =~ LangCaption
53
- defaults = {
54
- lang: $1,
55
- title: $2
56
- }
50
+ if clean_markup =~ AllOptions
51
+ defaults = {
52
+ lang: $1,
53
+ title: $2,
54
+ url: $3,
55
+ link_text: $4,
56
+ }
57
+ elsif clean_markup =~ LangCaption
58
+ defaults = {
59
+ lang: $1,
60
+ title: $2
61
+ }
62
+ end
63
+ CodeHighlighter.parse_markup(markup, defaults)
57
64
  end
58
- CodeHighlighter.parse_markup(markup, defaults)
59
- end
60
65
 
61
66
 
62
- def get_code(code, options)
63
- options[:aliases] = @aliases || {}
64
- code = CodeHighlighter.highlight(code, options)
65
- code = "<notextile>#{code}</notextile>" if !@ext.nil? and @ext.match(/textile/)
66
- code
67
+ def get_code(code, options)
68
+ options[:aliases] = @aliases || {}
69
+ code = CodeHighlighter.highlight(code, options)
70
+ code = "<notextile>#{code}</notextile>" if !@ext.nil? and @ext.match(/textile/)
71
+ code
72
+ end
67
73
  end
68
74
  end
69
75
  end
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
- class Codefence
3
- VERSION = "1.4.3"
2
+ module Codefence
3
+ VERSION = "1.4.4"
4
4
  end
5
5
  end
@@ -14,7 +14,10 @@ Gem::Specification.new do |gem|
14
14
  gem.license = "MIT"
15
15
 
16
16
  gem.add_runtime_dependency 'octopress-code-highlighter', '~> 4.2'
17
- gem.add_runtime_dependency 'jekyll-page-hooks', '~> 1.1'
17
+ gem.add_runtime_dependency 'octopress-hooks', '~> 2.1'
18
+
19
+ gem.add_development_dependency 'clash'
20
+ gem.add_development_dependency 'jekyll'
18
21
 
19
22
  gem.files = `git ls-files`.split($/).reject {|f| f =~ /^test\// }
20
23
  gem.require_paths = ["lib"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-codefence
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.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-06-29 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-code-highlighter
@@ -25,19 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: jekyll-page-hooks
28
+ name: octopress-hooks
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '2.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.1'
40
+ version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: clash
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jekyll
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  description: Generate beautiful code snippets with advanced features on any Jekyll
42
70
  site.
43
71
  email:
@@ -47,7 +75,6 @@ extensions: []
47
75
  extra_rdoc_files: []
48
76
  files:
49
77
  - ".gitignore"
50
- - ".rspec"
51
78
  - ".travis.yml"
52
79
  - CHANGELOG.md
53
80
  - Gemfile
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress