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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/lib/octopress-codefence.rb +58 -52
- data/lib/octopress-codefence/version.rb +2 -2
- data/octopress-codefence.gemspec +4 -1
- metadata +33 -6
- data/.rspec +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9972ada98f5f0fe17581ba4ada1aa4561250a6b8
|
4
|
+
data.tar.gz: be614c779b644172ea332eda3b4a44fe2d147f68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7a8afccc518ea2c3bf5b1042ac814cc16dbf2a87b13f16cade3214b0d269a34cc4dd1d024854363d81393ba3eb206ae9298d0fb02ec451939886160f3dcf70
|
7
|
+
data.tar.gz: 7e3b406e7e1c66aca04bd04ec98f35bac5ba0ca49e0270c9cd501b030182fbabb310e50292311d4901f84d0195f38699ef042be0daeb5f382142e25a69269f72
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/octopress-codefence.rb
CHANGED
@@ -1,69 +1,75 @@
|
|
1
1
|
require 'octopress-codefence/version'
|
2
2
|
require 'octopress-code-highlighter'
|
3
|
-
require '
|
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
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
46
|
+
def get_options(markup)
|
47
|
+
defaults = { escape: true }
|
48
|
+
clean_markup = CodeHighlighter.clean_markup(markup)
|
44
49
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
data/octopress-codefence.gemspec
CHANGED
@@ -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 '
|
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.
|
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-
|
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:
|
28
|
+
name: octopress-hooks
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
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: '
|
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