glorify 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,11 @@
1
1
  ---
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.2
5
4
  - 1.9.3
6
5
  - 2.0.0
7
6
  - ruby-head
8
- - jruby-18mode
9
7
  - jruby-19mode
10
8
  - jruby-head
11
- - rbx-18mode
12
9
  - rbx-19mode
13
10
  notifications:
14
11
  recipients:
data/README.md CHANGED
@@ -4,12 +4,17 @@
4
4
 
5
5
  Sinatra helper to parse markdown with syntax highlighting like the pros
6
6
 
7
- Renders markdown via redcarpet with syntax highlighting thanks to
8
- [pygments.rb](https://github.com/tmm1/pygments.rb).
7
+ Renders markdown via [rdoc-rouge](https://github.com/zzak/rdoc-rouge), an
8
+ [RDoc](https://github.com/rdoc/rdoc) and
9
+ [Rouge](https://github.com/jayferd/rouge) bridge.
9
10
 
10
11
  Able to use fenced code blocks like github, and includes a default pygments
11
12
  stylesheet.
12
13
 
14
+ ## Requirements
15
+
16
+ Ruby 1.9.2 or greater, also supports JRuby and Rubinius when using 1.9 modes.
17
+
13
18
  ## Installation
14
19
 
15
20
  ```bash
@@ -28,8 +33,8 @@ gem 'glorify'
28
33
 
29
34
  Sinatra::Glorify comes with a tilt template for rendering markdown.
30
35
 
31
- This allows you to override the default markdown renderer and use `redcarpet`
32
- with `pygments.rb` to highlight any code blocks within your view.
36
+ This allows you to override the default markdown renderer and use `rdoc-rouge`
37
+ to highlight any code blocks within your view.
33
38
 
34
39
  In order to do this, you will need to prefer the template class.
35
40
 
@@ -9,14 +9,13 @@ Gem::Specification.new do |s|
9
9
  s.email = ["zachary@zacharyscott.net"]
10
10
  s.homepage = "http://zacharyscott.net/glorify/"
11
11
  s.summary = %q{Sinatra helper to parse markdown with syntax highlighting like the pros}
12
- s.description = %q{Renders markdown via redcarpet with syntax highlighting thanks to pygments.rb. Able to use fenced code blocks like github, and includes a default pygments stylesheet.}
12
+ s.description = %q{Renders markdown via rdoc-rouge, an RDoc and Rouge bridge. Able to use fenced code blocks like github, and includes a default pygments stylesheet.}
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.require_paths = ["lib"]
16
16
 
17
17
  s.add_runtime_dependency "sinatra"
18
- s.add_runtime_dependency "redcarpet", "~> 2.0"
19
- s.add_runtime_dependency "pygments.rb"
18
+ s.add_runtime_dependency "rdoc-rouge"
20
19
  s.add_runtime_dependency "nokogiri"
21
20
 
22
21
  s.add_development_dependency "minitest"
@@ -1,6 +1,5 @@
1
1
  require "sinatra/base"
2
2
  require "glorify/css"
3
- require "glorify/extensions"
4
3
  require "glorify/version"
5
4
  require "glorify/renderer"
6
5
  require "glorify/template"
@@ -17,12 +16,9 @@ module Sinatra
17
16
  module Glorify
18
17
  # Sinatra extension setup to configure the application.
19
18
  #
20
- # Uses +settings.glorify_extensions+ for the Sinatra::Glorify::Renderer
21
- #
22
19
  # Also, registers the Sinatra::Glorify::Helpers and provides the pygments
23
20
  # stylesheet route using Sinatra::Glorify::Helpers.glorify_css.
24
21
  def self.registered(app)
25
- app.set :glorify_extensions, Glorify::EXTENSIONS
26
22
  app.helpers Glorify::Helpers
27
23
 
28
24
  app.get '/pygments.css' do
@@ -62,8 +62,7 @@ module Sinatra
62
62
  # For modular applications you must add <code>register
63
63
  # Sinatra::Helpers</code> to your application.
64
64
  def glorify text
65
- Redcarpet::Markdown.new(Glorify::Renderer.new,
66
- Glorify::EXTENSIONS).render(text)
65
+ Glorify::Renderer.render(text.force_encoding('UTF-8'))
67
66
  end
68
67
  end
69
68
  end
@@ -1,14 +1,7 @@
1
- require "redcarpet"
2
- require "pygments.rb"
1
+ require "rdoc/rouge"
3
2
 
4
3
  module Sinatra
5
4
  module Glorify
6
- class Renderer < Redcarpet::Render::HTML # :nodoc:
7
-
8
- def block_code(code, lang) # :nodoc:
9
- Pygments.highlight(code, :lexer => lang, :options => {:encoding => "utf-8"})
10
- end
11
-
12
- end
5
+ class Renderer < RDoc::Rouge::Renderer; end # :nodoc:
13
6
  end
14
7
  end
@@ -1,4 +1,3 @@
1
- require 'redcarpet' unless defined? Redcarpet
2
1
  require 'tilt/template'
3
2
 
4
3
  module Sinatra
@@ -6,8 +5,7 @@ module Sinatra
6
5
  # Sinatra::Glorify comes with a tilt template for rendering markdown.
7
6
  #
8
7
  # This allows you to override the default markdown renderer and use
9
- # +redcarpet+ with +pygments.rb+ to highlight any code blocks within your
10
- # view.
8
+ # +rdoc-rouge+ to highlight any code blocks within your view.
11
9
  #
12
10
  # In order to do this, you will need to prefer the template class.
13
11
  #
@@ -22,13 +20,12 @@ module Sinatra
22
20
  # end
23
21
  class Template < Tilt::Template
24
22
  def prepare # :nodoc:
25
- @engine = Redcarpet::Markdown.new(Glorify::Renderer.new,
26
- Glorify::EXTENSIONS)
23
+ @engine = Glorify::Renderer
27
24
  @output = nil
28
25
  end
29
26
 
30
27
  def evaluate(scope, locals, &block) # :nodoc:
31
- @output ||= @engine.render(data)
28
+ @output ||= @engine.render(data.force_encoding('UTF-8'))
32
29
  end
33
30
  end
34
31
  end
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module Glorify
3
3
  # Current version of Sinatra::Glorify
4
- VERSION = "0.3.2"
4
+ VERSION = "0.4.0"
5
5
  end
6
6
  end
@@ -1,8 +1,4 @@
1
- begin
2
- require_relative 'spec_helper'
3
- rescue NameError
4
- require File.expand_path('../spec_helper', __FILE__)
5
- end
1
+ require_relative 'spec_helper'
6
2
 
7
3
  describe Sinatra::Glorify do
8
4
 
@@ -11,7 +7,7 @@ describe Sinatra::Glorify do
11
7
  Tilt.prefer Sinatra::Glorify::Template
12
8
  get('/') { markdown :header }
13
9
  end
14
- expected = "<h1>a sip of glory</h1>"
10
+ expected = "<h1 id=\"label-a+sip+of+glory\">a sip of glory<span><a href=\"#label-a+sip+of+glory\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>"
15
11
  get('/')
16
12
  assert ok?
17
13
  assert_equal expected, body
@@ -22,7 +18,7 @@ describe Sinatra::Glorify do
22
18
  Tilt.prefer Sinatra::Glorify::Template
23
19
  get('/') { markdown :blocks }
24
20
  end
25
- expected = "<p><code>puts &quot;Hello, world!&quot;</code></p>"
21
+ expected = "<pre class=\"highlight text\">&quot;Hello, world!&quot;</pre>"
26
22
  get('/')
27
23
  assert ok?
28
24
  assert_equal expected, body
@@ -37,7 +33,7 @@ describe Sinatra::Glorify do
37
33
  end
38
34
  get('/')
39
35
  assert ok?
40
- refute_empty Nokogiri::HTML(body).search("//div[@class = 'highlight']/pre")
36
+ refute_empty Nokogiri::HTML(body).search("pre.highlight")
41
37
  end
42
38
 
43
39
  it "should parse with a helper" do
@@ -52,7 +48,7 @@ describe Sinatra::Glorify do
52
48
  end
53
49
  get('/')
54
50
  assert ok?
55
- refute_empty Nokogiri::HTML(body).search("//div[@class = 'highlight']/pre")
51
+ refute_empty Nokogiri::HTML(body).search("pre.highlight")
56
52
  end
57
53
 
58
54
  it "should include a valid css helper for pygments" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glorify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-03-18 00:00:00.000000000 Z
14
+ date: 2013-03-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sinatra
@@ -30,23 +30,7 @@ dependencies:
30
30
  - !ruby/object:Gem::Version
31
31
  version: '0'
32
32
  - !ruby/object:Gem::Dependency
33
- name: redcarpet
34
- requirement: !ruby/object:Gem::Requirement
35
- none: false
36
- requirements:
37
- - - ~>
38
- - !ruby/object:Gem::Version
39
- version: '2.0'
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- - !ruby/object:Gem::Dependency
49
- name: pygments.rb
33
+ name: rdoc-rouge
50
34
  requirement: !ruby/object:Gem::Requirement
51
35
  none: false
52
36
  requirements:
@@ -157,8 +141,8 @@ dependencies:
157
141
  - - '='
158
142
  - !ruby/object:Gem::Version
159
143
  version: 4.0.0
160
- description: Renders markdown via redcarpet with syntax highlighting thanks to pygments.rb.
161
- Able to use fenced code blocks like github, and includes a default pygments stylesheet.
144
+ description: Renders markdown via rdoc-rouge, an RDoc and Rouge bridge. Able to use
145
+ fenced code blocks like github, and includes a default pygments stylesheet.
162
146
  email:
163
147
  - zachary@zacharyscott.net
164
148
  executables: []
@@ -174,7 +158,6 @@ files:
174
158
  - glorify.gemspec
175
159
  - lib/glorify.rb
176
160
  - lib/glorify/css.rb
177
- - lib/glorify/extensions.rb
178
161
  - lib/glorify/helpers.rb
179
162
  - lib/glorify/renderer.rb
180
163
  - lib/glorify/template.rb
@@ -200,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
183
  version: '0'
201
184
  segments:
202
185
  - 0
203
- hash: 3769292332255854767
186
+ hash: 1006836911274585602
204
187
  required_rubygems_version: !ruby/object:Gem::Requirement
205
188
  none: false
206
189
  requirements:
@@ -209,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
192
  version: '0'
210
193
  segments:
211
194
  - 0
212
- hash: 3769292332255854767
195
+ hash: 1006836911274585602
213
196
  requirements: []
214
197
  rubyforge_project:
215
198
  rubygems_version: 1.8.23
@@ -1,12 +0,0 @@
1
- module Sinatra
2
- module Glorify
3
- # Helper for Sinatra::Glorify::Renderer default options.
4
- #
5
- # Configure in your application through +settings.glorify_extensions+
6
- EXTENSIONS = { :filter_html => true,
7
- :autolink => true,
8
- :no_intra_emphasis => true,
9
- :fenced_code_blocks => true
10
- }
11
- end
12
- end