highlight 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/HISTORY.md +11 -6
- data/README.md +36 -28
- data/lib/simplabs/highlight.rb +4 -3
- data/spec/boot.rb +0 -3
- metadata +6 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c0bc4a96c7be5df2f98b89e3084ce14db28fac06
|
4
|
+
data.tar.gz: af1f0d4c4e3ef8464389a5797b3ade49a2b11b8a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 31ce617e77b6327cf6c4c658c8910c97201aca00fca965d7dd7a821ffe1938030219ce57f278a0bc2c2b8604c30d2e00afeed26d476e3d73d3d0fc094f4db53d
|
7
|
+
data.tar.gz: 6c07d47a250076d105ee598793c01162b486e40fef064dfd64257648383d52505b3521314b6a285cd1a25e7e56f39c1bd475ff1965d1fe83ecca2621f70801bc
|
data/HISTORY.md
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
-
v1.1.
|
1
|
+
v1.1.5
|
2
2
|
------
|
3
3
|
|
4
|
-
*
|
4
|
+
* removed activesupport dependency
|
5
|
+
|
6
|
+
v1.1.4
|
7
|
+
------
|
8
|
+
|
9
|
+
* switched to new web API
|
10
|
+
* cleaned up internals
|
11
|
+
* fixed Rails 3 generator
|
5
12
|
|
6
13
|
v1.1.3
|
7
14
|
------
|
8
15
|
|
9
16
|
* added new supported language NASM
|
10
17
|
|
11
|
-
v1.1.
|
18
|
+
v1.1.2
|
12
19
|
------
|
13
20
|
|
14
|
-
*
|
15
|
-
* cleaned up internals
|
16
|
-
* fixed Rails 3 generator
|
21
|
+
* first gem version
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Highlight
|
2
2
|
=========
|
3
3
|
|
4
|
+
[![Build Status](https://travis-ci.org/simplabs/highlight.png)](https://travis-ci.org/simplabs/highlight)
|
5
|
+
|
4
6
|
Highlight is a simple syntax highlighting gem for Ruby and Rails. It's basically a
|
5
7
|
wrapper around the popular [http://pygments.org](http://pygments.org) highlighter that's
|
6
8
|
written in Python and supports an impressive number of languages.
|
@@ -16,34 +18,44 @@ Usage
|
|
16
18
|
|
17
19
|
Highlight can either be used standalone via
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
```ruby
|
22
|
+
require 'simplabs/highlight'
|
23
|
+
Simplabs::Highlight.highlight(:ruby, 'class Test; end')
|
24
|
+
```
|
21
25
|
|
22
26
|
or in Rails where it adds the `highlight_code` helper:
|
23
27
|
|
24
|
-
|
28
|
+
```ruby
|
29
|
+
highlight_code(language, code = nil, &block)
|
30
|
+
```
|
25
31
|
|
26
32
|
`language` may be either a Symbol or a String (see supported languages
|
27
33
|
below). The code can be passed either as a string or inside a block, e.g.:
|
28
34
|
|
29
|
-
|
35
|
+
```ruby
|
36
|
+
highlight_code(:ruby, 'class Test; end')
|
37
|
+
```
|
30
38
|
|
31
39
|
or
|
32
40
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
```ruby
|
42
|
+
highlight_code(:ruby) do
|
43
|
+
klass = 'class'
|
44
|
+
name = 'Test'
|
45
|
+
_end = 'end'
|
46
|
+
"#{klass} #{name}; #{_end}"
|
47
|
+
end
|
48
|
+
```
|
39
49
|
|
40
50
|
Since highlighting the code takes a while, all highlighted source code
|
41
51
|
should be cached, e.g.:
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
53
|
+
```ruby
|
54
|
+
<%- code = 'class Test; end' -%>
|
55
|
+
<%- cache Digest::SHA1.hexdigest(code) do -%>
|
56
|
+
<%= highlight_code(:ruby, code) -%>
|
57
|
+
<%- end -%>
|
58
|
+
```
|
47
59
|
|
48
60
|
|
49
61
|
Supported Languages
|
@@ -91,26 +103,22 @@ Installation
|
|
91
103
|
|
92
104
|
Installation is as easy as
|
93
105
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
config.gem 'highlight', :lib => 'simplabs/highlight'
|
106
|
+
```bash
|
107
|
+
gem install highlight
|
108
|
+
```
|
99
109
|
|
100
|
-
|
110
|
+
To use highlight in Rails apps, you have to define the dependency in the Gemfile:
|
101
111
|
|
102
|
-
|
112
|
+
```ruby
|
113
|
+
gem 'highlight', :require => 'simplabs/highlight'
|
114
|
+
```
|
103
115
|
|
104
116
|
Highlight also comes with a default CSS file that defines styles for the highlighted code. This CSS file can be copied to
|
105
117
|
your application's `public/stylesheets` directory via
|
106
118
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
./script/rails generate highlight_styles
|
112
|
-
|
113
|
-
for Rails 3.
|
119
|
+
```bash
|
120
|
+
./bin/rails generate highlight_styles
|
121
|
+
```
|
114
122
|
|
115
123
|
If you don't have python and pygments installed, you will need that too.
|
116
124
|
For instructions on installing pygments, refer to
|
data/lib/simplabs/highlight.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
require 'net/http'
|
3
3
|
require 'uri'
|
4
|
-
require 'active_support/core_ext/module/attribute_accessors'
|
5
4
|
require 'simplabs/highlight/pygments_wrapper'
|
6
5
|
|
7
6
|
module Simplabs
|
@@ -58,7 +57,9 @@ module Simplabs
|
|
58
57
|
#
|
59
58
|
module Highlight
|
60
59
|
|
61
|
-
|
60
|
+
class << self
|
61
|
+
attr_accessor :use_web_api
|
62
|
+
end
|
62
63
|
|
63
64
|
SUPPORTED_LANGUAGES = {
|
64
65
|
:as => ['as', 'as3', 'actionscript'],
|
@@ -149,7 +150,7 @@ module Simplabs
|
|
149
150
|
# name = 'Test'
|
150
151
|
# _end = 'end'
|
151
152
|
# "#{klass} #{name}; #{_end}"
|
152
|
-
# end
|
153
|
+
# end
|
153
154
|
#
|
154
155
|
# @raise [ArgumentError] if both the +code+ parameter and a block are given
|
155
156
|
# @raise [ArgumentError] if neither the +code+ parameter or a block are given
|
data/spec/boot.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: highlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Marco Otte-Witte
|
@@ -10,18 +9,7 @@ autorequire:
|
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
date: 2013-03-23 00:00:00.000000000 Z
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: activesupport
|
16
|
-
requirement: &70334546100500 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0.0
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: *70334546100500
|
12
|
+
dependencies: []
|
25
13
|
description: Highlight highlights code in more than 20 languages. It uses the Pygments
|
26
14
|
syntax highlighter and adds a simple Ruby API over it. It also provides helpers
|
27
15
|
for use in your Ruby on Rails views.
|
@@ -47,27 +35,25 @@ files:
|
|
47
35
|
- spec/spec_helper.rb
|
48
36
|
homepage: http://github.com/simplabs/highlight
|
49
37
|
licenses: []
|
38
|
+
metadata: {}
|
50
39
|
post_install_message:
|
51
40
|
rdoc_options: []
|
52
41
|
require_paths:
|
53
42
|
- lib
|
54
43
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
44
|
requirements:
|
57
|
-
- -
|
45
|
+
- - '>='
|
58
46
|
- !ruby/object:Gem::Version
|
59
47
|
version: '0'
|
60
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
49
|
requirements:
|
63
|
-
- -
|
50
|
+
- - '>='
|
64
51
|
- !ruby/object:Gem::Version
|
65
52
|
version: '0'
|
66
53
|
requirements: []
|
67
54
|
rubyforge_project:
|
68
|
-
rubygems_version:
|
55
|
+
rubygems_version: 2.0.2
|
69
56
|
signing_key:
|
70
57
|
specification_version: 2
|
71
58
|
summary: Syntax Higlighting plugin for Ruby on Rails
|
72
59
|
test_files: []
|
73
|
-
has_rdoc: false
|