jekyll-prism-plugin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +20 -0
- data/README.md +74 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/jekyll-prism-plugin.rb +47 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 25fcb2271e77f82188c836af8733ff8611bc52fd
|
4
|
+
data.tar.gz: 8424d49e0a21164b87ddffdb5c6225e3999bca47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d0e2241cc2667e29e5c615403497ba21abc0b385a3d1b83cd531523ced0fc4174a867af2af99ddf93d1699681b57a2db54b03060a801ae4b9312e5cd404d75c
|
7
|
+
data.tar.gz: 0ada8c78e3ab941371a69b672d4ed8d614cf5db349dbf4fd4fbafed45a08b784d33c326eac1c7c7fa25db64cd0a0d04852bb9c8d5529cbbf596e1ecb899dbb20
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.1"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.1.4)
|
5
|
+
i18n (~> 0.6, >= 0.6.9)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.6)
|
11
|
+
builder (3.2.2)
|
12
|
+
descendants_tracker (0.0.4)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
+
docile (1.1.3)
|
15
|
+
faraday (0.9.0)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
17
|
+
git (1.2.6)
|
18
|
+
github_api (0.11.3)
|
19
|
+
addressable (~> 2.3)
|
20
|
+
descendants_tracker (~> 0.0.1)
|
21
|
+
faraday (~> 0.8, < 0.10)
|
22
|
+
hashie (>= 1.2)
|
23
|
+
multi_json (>= 1.7.5, < 2.0)
|
24
|
+
nokogiri (~> 1.6.0)
|
25
|
+
oauth2
|
26
|
+
hashie (3.0.0)
|
27
|
+
highline (1.6.21)
|
28
|
+
i18n (0.6.11)
|
29
|
+
jeweler (2.0.1)
|
30
|
+
builder
|
31
|
+
bundler (>= 1.0)
|
32
|
+
git (>= 1.2.5)
|
33
|
+
github_api
|
34
|
+
highline (>= 1.6.15)
|
35
|
+
nokogiri (>= 1.5.10)
|
36
|
+
rake
|
37
|
+
rdoc
|
38
|
+
json (1.8.1)
|
39
|
+
jwt (1.0.0)
|
40
|
+
mini_portile (0.6.0)
|
41
|
+
minitest (5.4.0)
|
42
|
+
multi_json (1.10.1)
|
43
|
+
multi_xml (0.5.5)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nokogiri (1.6.2.1)
|
46
|
+
mini_portile (= 0.6.0)
|
47
|
+
oauth2 (0.9.4)
|
48
|
+
faraday (>= 0.8, < 0.10)
|
49
|
+
jwt (~> 1.0)
|
50
|
+
multi_json (~> 1.3)
|
51
|
+
multi_xml (~> 0.5)
|
52
|
+
rack (~> 1.2)
|
53
|
+
rack (1.5.2)
|
54
|
+
rake (10.3.2)
|
55
|
+
rdoc (3.12.2)
|
56
|
+
json (~> 1.4)
|
57
|
+
shoulda (3.5.0)
|
58
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
59
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
60
|
+
shoulda-context (1.2.1)
|
61
|
+
shoulda-matchers (2.6.1)
|
62
|
+
activesupport (>= 3.0.0)
|
63
|
+
simplecov (0.8.2)
|
64
|
+
docile (~> 1.1.0)
|
65
|
+
multi_json
|
66
|
+
simplecov-html (~> 0.8.0)
|
67
|
+
simplecov-html (0.8.0)
|
68
|
+
thread_safe (0.3.4)
|
69
|
+
tzinfo (1.2.1)
|
70
|
+
thread_safe (~> 0.1)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
bundler (~> 1.0)
|
77
|
+
jeweler (~> 2.0.1)
|
78
|
+
rdoc (~> 3.12)
|
79
|
+
shoulda
|
80
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Tom Janssens
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Jekyll Prism Plugin
|
2
|
+
|
3
|
+
[![Gittip](http://img.shields.io/gittip/gmurphey.svg)](https://www.gittip.com/gmurphey/)
|
4
|
+
|
5
|
+
|
6
|
+
The Jekyll Prism plugin is a replacement for native Pygments syntax highlighting in [Jekyll](http://github.com/mojombo/jekyll/). It uses the [Prism Syntax Highlighter](http://prismjs.com/).
|
7
|
+
|
8
|
+
## The Setup
|
9
|
+
|
10
|
+
The Prism plugin is very easy to install and start using.
|
11
|
+
|
12
|
+
Copy `prism.rb` to your plugins folder and setup your layouts to use the [Prism JavaScript and styles](http://prismjs.com/download.html).
|
13
|
+
|
14
|
+
``` html
|
15
|
+
<html>
|
16
|
+
<head>
|
17
|
+
<link href="prism.css" rel="stylesheet" type="text/css">
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
...
|
21
|
+
<!-- after all your content -->
|
22
|
+
<script src="prism.js"></script>
|
23
|
+
</body>
|
24
|
+
</html>
|
25
|
+
```
|
26
|
+
|
27
|
+
## Getting Started
|
28
|
+
|
29
|
+
Much of my work on the plugin is based on the Jekyll's native `highlight` tag, and it's used much the same way.
|
30
|
+
|
31
|
+
For a plain, old vanilla experience (like you see on this page), the syntax is pretty straightforward.
|
32
|
+
|
33
|
+
``` html
|
34
|
+
... content ...
|
35
|
+
{% prism javascript %}
|
36
|
+
var obj = { 'foo': true, 'bar': false };
|
37
|
+
|
38
|
+
for (key in obj) {
|
39
|
+
console.log(obj[key]);
|
40
|
+
}
|
41
|
+
{% endprism %}
|
42
|
+
... more content ...
|
43
|
+
```
|
44
|
+
|
45
|
+
Like Jekyll's `highlight`, the Prism plugin also can highlight lines using `linenos`. The value can be a comma-separated list or a range (1, 3-7).
|
46
|
+
|
47
|
+
*Note:* you need to include line highlighting in your Prism download for this to work.
|
48
|
+
|
49
|
+
``` html
|
50
|
+
... content ...
|
51
|
+
{% prism javascript linenos=1,4 %}
|
52
|
+
var obj = { 'foo': true, 'bar': false };
|
53
|
+
|
54
|
+
for (key in obj) {
|
55
|
+
console.log(obj[key]);
|
56
|
+
}
|
57
|
+
{% endprism %}
|
58
|
+
... more content ...
|
59
|
+
```
|
60
|
+
|
61
|
+
And for something Prism doesn't offer out of the box, declaring `linenos` without a value will highlight all lines.
|
62
|
+
|
63
|
+
``` html
|
64
|
+
... content ...
|
65
|
+
{% prism javascript linenos %}
|
66
|
+
var obj = { 'foo': true, 'bar': false };
|
67
|
+
|
68
|
+
for (key in obj) {
|
69
|
+
console.log(obj[key]);
|
70
|
+
}
|
71
|
+
{% endprism %}
|
72
|
+
... more content ...
|
73
|
+
```
|
74
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "jekyll-prism-plugin"
|
18
|
+
gem.homepage = "http://github.com/tomjanssens/jekyll-prism-plugin"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = ""
|
21
|
+
gem.description = ""
|
22
|
+
gem.email = "tom@janssens.me"
|
23
|
+
gem.authors = ["Tom Janssens"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rdoc/task'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "jekyll-prism-plugin #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
class PrismBlock < Liquid::Block
|
4
|
+
include Liquid::StandardFilters
|
5
|
+
|
6
|
+
OPTIONS_SYNTAX = %r{^([a-zA-Z0-9.+#-]+)((\s+\w+(=[0-9,-]+)?)*)$}
|
7
|
+
|
8
|
+
def initialize(tag_name, markup, tokens)
|
9
|
+
super
|
10
|
+
if markup.strip =~ OPTIONS_SYNTAX
|
11
|
+
@lang = $1
|
12
|
+
if defined?($2) && $2 != ''
|
13
|
+
tmp_options = {}
|
14
|
+
$2.split.each do |opt|
|
15
|
+
key, value = opt.split('=')
|
16
|
+
if value.nil?
|
17
|
+
value = true
|
18
|
+
end
|
19
|
+
tmp_options[key] = value
|
20
|
+
end
|
21
|
+
@options = tmp_options
|
22
|
+
else
|
23
|
+
@options = { "linenos" => "" }
|
24
|
+
end
|
25
|
+
else
|
26
|
+
raise SyntaxError.new("Syntax Error in 'prism' - Valid syntax: prism <lang> [linenos(='1-5')]")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def render(context)
|
31
|
+
code = h(super).strip
|
32
|
+
|
33
|
+
if @options["linenos"] == true
|
34
|
+
@options["linenos"] = "1-#{code.lines.count}"
|
35
|
+
end
|
36
|
+
|
37
|
+
<<-HTML
|
38
|
+
<div>
|
39
|
+
<pre data-line='#{@options["linenos"]}'><code class='language-#{@lang}'>#{code}</code></pre>
|
40
|
+
</div>
|
41
|
+
HTML
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
Liquid::Template.register_tag('prism', Jekyll::PrismBlock)
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-prism-plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Janssens
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: shoulda
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ''
|
84
|
+
email: tom@janssens.me
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
files:
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- VERSION
|
97
|
+
- lib/jekyll-prism-plugin.rb
|
98
|
+
homepage: http://github.com/tomjanssens/jekyll-prism-plugin
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.2.2
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: ''
|
122
|
+
test_files: []
|