jekyll_prism 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/.gitignore +5 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +26 -0
- data/Rakefile +19 -0
- data/jekyll_prism.gemspec +24 -0
- data/lib/jekyll_prism.rb +52 -0
- data/spec/jekyll_prism_spec.rb +63 -0
- data/spec/spec_helper.rb +11 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52bde94c89b72d5e0c538efb49ee9b193e54e2f1
|
4
|
+
data.tar.gz: c859569ae41af20eb77ca7961104693c40979020
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10ee21bd18edb491e80533ef660bdb4bae5519529d038f7aeb5a09901087471471324b8b98531d690a5d40c75f687c41a3353b0756a5c0139844b33c3ef72ae6
|
7
|
+
data.tar.gz: f4990a9b06b8e2de22b90537be2c594f8f1aa89b49aa84ece3e9574512eb9111cab92ec76125a1d09e311cb320199a7ef403e86053800dea73f4a6585a7f076f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- 2.1.0
|
5
|
+
- 2.0.0
|
6
|
+
- 1.9.3
|
7
|
+
notifications:
|
8
|
+
email: false
|
9
|
+
irc:
|
10
|
+
template:
|
11
|
+
- '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
|
12
|
+
channels:
|
13
|
+
secure: aMgtnnMk2L9qiuolkyEOQt3PFIArubiL7Aq6MX0TL56eLWYop+Q5g76pLY87FaohFv3tynE469toWwMPoC06f/QmcupsheHBty1BUhfx29ZRhGLAwRb0zAQfUx9qRL6/XA1awDpErkHeQmXBu6f/rR8LtNejuQdlPGRHUok7Pxg=
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Les Aker
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
jekyll_prism
|
2
|
+
=========
|
3
|
+
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/jekyll_prism.svg)](https://rubygems.org/gems/jekyll_prism)
|
5
|
+
[![Dependency Status](https://img.shields.io/gemnasium/akerl/jekyll_prism.svg)](https://gemnasium.com/akerl/jekyll_prism)
|
6
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/akerl/jekyll_prism.svg)](https://codeclimate.com/github/akerl/jekyll_prism)
|
7
|
+
[![Coverage Status](https://img.shields.io/coveralls/akerl/jekyll_prism.svg)](https://coveralls.io/r/akerl/jekyll_prism)
|
8
|
+
[![Build Status](https://img.shields.io/travis/akerl/jekyll_prism.svg)](https://travis-ci.org/akerl/jekyll_prism)
|
9
|
+
[![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
|
10
|
+
|
11
|
+
Jekyll plugin to add support for [prism.js](http://prismjs.com/).
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
This adds `code` blocks and tags for syntax hilighting.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
1. Add 'jekyll_prism' to the `gems` array in your \_config.yml
|
20
|
+
2. Add the prism.js and prism.css files to your site, as described [on prism's site](http://prismjs.com/download.html)
|
21
|
+
* Note: the code tag uses the File Highlight plugin. If you don't include that, the tags won't work
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
jekyll_prism is released under the MIT License. See the bundled LICENSE file for details.
|
26
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
desc 'Run tests'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
desc 'Run Rubocop on the gem'
|
9
|
+
Rubocop::RakeTask.new(:rubocop) do |task|
|
10
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
11
|
+
task.fail_on_error = true
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Run travis-lint on .travis.yml'
|
15
|
+
task :travislint do
|
16
|
+
print 'There is an issue with your .travis.yml' unless system('travis-lint')
|
17
|
+
end
|
18
|
+
|
19
|
+
task default: [:spec, :travislint, :rubocop, :build, :install]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'jekyll_prism'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
5
|
+
|
6
|
+
s.summary = ''
|
7
|
+
s.description = ""
|
8
|
+
s.authors = ['Les Aker']
|
9
|
+
s.email = 'me@lesaker.org'
|
10
|
+
s.homepage = 'https://github.com/akerl/jekyll_prism'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split
|
14
|
+
s.test_files = `git ls-files spec/*`.split
|
15
|
+
|
16
|
+
s.add_dependency 'liquid', '~> 2.6.1'
|
17
|
+
|
18
|
+
s.add_development_dependency 'rubocop', '~> 0.19.0'
|
19
|
+
s.add_development_dependency 'travis-lint', '~> 1.8.0'
|
20
|
+
s.add_development_dependency 'rake', '~> 10.1.1'
|
21
|
+
s.add_development_dependency 'coveralls', '~> 0.7.0'
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.14.1'
|
23
|
+
s.add_development_dependency 'fuubar', '~> 1.3.2'
|
24
|
+
end
|
data/lib/jekyll_prism.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'liquid'
|
2
|
+
|
3
|
+
##
|
4
|
+
# Extend Jekyll to provide Prism helper blocks and tags
|
5
|
+
module Jekyll
|
6
|
+
##
|
7
|
+
# Block object for Prism hilighting
|
8
|
+
class CodeBlock < Liquid::Block
|
9
|
+
include Liquid::StandardFilters
|
10
|
+
|
11
|
+
def initialize(a, args, b)
|
12
|
+
super
|
13
|
+
options = args.split
|
14
|
+
@lang, @linenos = options.shift 2
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def render(_)
|
19
|
+
code = h(super).strip
|
20
|
+
|
21
|
+
linenos = @linenos == 'all' ? "1-#{code.lines.count}" : @linenos
|
22
|
+
linestring = linenos.nil? ? '' : %Q( data-line="#{linenos}")
|
23
|
+
langstring = @lang.nil? ? '' : %Q( class="language-#{@lang}")
|
24
|
+
|
25
|
+
<<-OUTPUT
|
26
|
+
<pre#{linestring}><code#{langstring}>
|
27
|
+
#{code}
|
28
|
+
</code></pre>
|
29
|
+
OUTPUT
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Tag object for Prism hilighting
|
35
|
+
class CodeTag < Liquid::Tag
|
36
|
+
def initialize(_, args, _)
|
37
|
+
super
|
38
|
+
options = args.split
|
39
|
+
@file, @lang, @linenos = options.shift 3
|
40
|
+
end
|
41
|
+
|
42
|
+
def render(_)
|
43
|
+
linestring = @linenos.nil? ? '' : %Q( data-line="#{@linenos}")
|
44
|
+
langstring = @lang.nil? ? '' : %Q( class="language-#{@lang}")
|
45
|
+
|
46
|
+
%Q(<pre data-src="#{@file}"#{langstring}#{linestring}></pre>)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Liquid::Template.register_tag('code', Jekyll::CodeBlock)
|
52
|
+
Liquid::Template.register_tag('ext_code', Jekyll::CodeTag)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
##
|
4
|
+
# Helper to save keystrokes
|
5
|
+
def test_template(input, output)
|
6
|
+
expect(Liquid::Template.parse(input).render).to eql output
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Jekyll::CodeBlock do
|
10
|
+
it 'renders code blocks' do
|
11
|
+
code = '{% code %}foobar{% endcode %}'
|
12
|
+
result = "<pre><code>\nfoobar\n</code></pre>\n"
|
13
|
+
test_template code, result
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'accepts a language parameter' do
|
17
|
+
code = '{% code ruby %}foobar{% endcode %}'
|
18
|
+
result = "<pre><code class=\"language-ruby\">\nfoobar\n</code></pre>\n"
|
19
|
+
test_template code, result
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'accepts a linenos parameter' do
|
23
|
+
it 'as line numbers' do
|
24
|
+
code = '{% code ruby 1,3-5,10 %}foobar{% endcode %}'
|
25
|
+
result = "<pre data-line=\"1,3-5,10\"><code class=\"language-ruby\">
|
26
|
+
foobar
|
27
|
+
</code></pre>\n"
|
28
|
+
test_template code, result
|
29
|
+
end
|
30
|
+
it 'as an "all" parameter' do
|
31
|
+
code = "{% code ruby all %}foo\nbar\nbaz{% endcode %}"
|
32
|
+
result = "<pre data-line=\"1-3\"><code class=\"language-ruby\">
|
33
|
+
foo
|
34
|
+
bar
|
35
|
+
baz
|
36
|
+
</code></pre>\n"
|
37
|
+
test_template code, result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe Jekyll::CodeTag do
|
43
|
+
it 'renders external code objects' do
|
44
|
+
code = '{% ext_code sekrit.rb %}'
|
45
|
+
result = '<pre data-src="sekrit.rb"></pre>'
|
46
|
+
test_template code, result
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'accepts a language parameter' do
|
50
|
+
code = '{% ext_code sekrit.rb ruby %}'
|
51
|
+
result = '<pre data-src="sekrit.rb" class="language-ruby"></pre>'
|
52
|
+
test_template code, result
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'accepts a linenos parameter' do
|
56
|
+
it 'as line numbers' do
|
57
|
+
code = '{% ext_code sekrit.rb ruby 1,3-5,10 %}'
|
58
|
+
result = '<pre data-src="sekrit.rb" ' \
|
59
|
+
'class="language-ruby" data-line="1,3-5,10"></pre>'
|
60
|
+
test_template code, result
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_prism
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Les Aker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: liquid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.6.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.6.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.19.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.19.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: travis-lint
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.8.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.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 10.1.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 10.1.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.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.7.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.14.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.14.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fuubar
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.3.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.3.2
|
111
|
+
description: ''
|
112
|
+
email: me@lesaker.org
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- .rubocop.yml
|
120
|
+
- .travis.yml
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- jekyll_prism.gemspec
|
126
|
+
- lib/jekyll_prism.rb
|
127
|
+
- spec/jekyll_prism_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: https://github.com/akerl/jekyll_prism
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.0.14
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: ''
|
153
|
+
test_files:
|
154
|
+
- spec/jekyll_prism_spec.rb
|
155
|
+
- spec/spec_helper.rb
|