downr 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/downr/render.rb +11 -10
- data/lib/downr/version.rb +1 -1
- data/spec/lib/downr/render_spec.rb +3 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Downr
|
2
|
-
[![Build Status](https://travis-ci.org/davidrivera/Downr.svg?branch=master)](https://travis-ci.org/davidrivera/Downr) [![Code Climate](https://codeclimate.com/github/davidrivera/Downr.png)](https://codeclimate.com/github/davidrivera/Downr) [![Gem Version](https://badge.fury.io/rb/downr.svg)](http://badge.fury.io/rb/downr) [![Dependency Status](https://gemnasium.com/davidrivera/Downr.svg)](https://gemnasium.com/davidrivera/Downr)
|
2
|
+
[![Build Status](https://travis-ci.org/davidrivera/Downr.svg?branch=master)](https://travis-ci.org/davidrivera/Downr) [![Code Climate](https://codeclimate.com/github/davidrivera/Downr.png)](https://codeclimate.com/github/davidrivera/Downr) [![Inline docs](http://inch-pages.github.io/github/davidrivera/Downr.png)](http://inch-pages.github.io/github/davidrivera/Downr) [![Gem Version](https://badge.fury.io/rb/downr.svg)](http://badge.fury.io/rb/downr) [![Dependency Status](https://gemnasium.com/davidrivera/Downr.svg)](https://gemnasium.com/davidrivera/Downr)
|
3
3
|
|
4
4
|
Downr is an easy to use rails wrapper around a couple of different notable gems
|
5
5
|
* [Redcarpet](https://github.com/vmg/redcarpet)
|
data/lib/downr/render.rb
CHANGED
@@ -7,9 +7,10 @@ module Downr
|
|
7
7
|
#
|
8
8
|
# @option opts [Boolean] :pygmentize Code colors
|
9
9
|
# @option opts [Boolean] :emojify Icons
|
10
|
-
def
|
11
|
-
opt = clean_options
|
10
|
+
def initialize(opt)
|
11
|
+
opt = clean_options(opt)
|
12
12
|
@options = opt
|
13
|
+
super
|
13
14
|
end
|
14
15
|
|
15
16
|
# Hook for Redcarpet render
|
@@ -19,7 +20,7 @@ module Downr
|
|
19
20
|
#
|
20
21
|
# @return [String] html
|
21
22
|
def block_code(code, language)
|
22
|
-
if(@options
|
23
|
+
if(@options[:pygmentize])
|
23
24
|
pygmentize(code, language)
|
24
25
|
else
|
25
26
|
return code
|
@@ -32,7 +33,7 @@ module Downr
|
|
32
33
|
#
|
33
34
|
# @return [String] html
|
34
35
|
def paragraph(text)
|
35
|
-
if(@options
|
36
|
+
if(@options[:emojify])
|
36
37
|
return emojify(text)
|
37
38
|
else
|
38
39
|
return text
|
@@ -51,19 +52,19 @@ module Downr
|
|
51
52
|
def clean_options opts
|
52
53
|
a = {}
|
53
54
|
|
54
|
-
if(opts.has_key?(pygmentize))
|
55
|
-
a[:pygmentize] = opts
|
55
|
+
if(opts.has_key?(:pygmentize))
|
56
|
+
a[:pygmentize] = opts[:pygmentize]
|
56
57
|
else
|
57
58
|
a[:pygmentize] = false
|
58
59
|
end
|
59
60
|
|
60
|
-
if(opts.has_key?(emojify))
|
61
|
-
a[:emojify] = opts
|
61
|
+
if(opts.has_key?(:emojify))
|
62
|
+
a[:emojify] = opts[:emojify]
|
62
63
|
else
|
63
64
|
a[:emojify] = false
|
64
65
|
end
|
65
66
|
|
66
|
-
return
|
67
|
+
return a
|
67
68
|
end
|
68
69
|
|
69
70
|
# Uses RailsEmoji to insert icons
|
@@ -92,4 +93,4 @@ module Downr
|
|
92
93
|
Pygmentize.process(code, language)
|
93
94
|
end
|
94
95
|
end
|
95
|
-
end
|
96
|
+
end
|
data/lib/downr/version.rb
CHANGED