downr 0.0.5 → 0.0.6
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.
- data/.gitignore +1 -1
- data/downr.gemspec +1 -1
- data/lib/downr.rb +4 -2
- data/lib/downr/engine.rb +6 -0
- data/lib/downr/markdown.rb +1 -2
- data/lib/downr/railtie.rb +2 -3
- data/lib/downr/render.rb +20 -9
- data/lib/downr/version.rb +2 -1
- data/lib/generators/templates/downr.rb +5 -0
- data/spec/lib/downr/render_spec.rb +1 -1
- metadata +4 -3
data/.gitignore
CHANGED
data/downr.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Downr::VERSION
|
9
9
|
spec.authors = ["David Rivera"]
|
10
10
|
spec.email = ["david.r.rivera193@gmail.com"]
|
11
|
-
spec.summary = %q{
|
11
|
+
spec.summary = %q{Rails friendly Github Falvored Markdown}
|
12
12
|
spec.description = %q{Wrapper for RedCarpet, adding syntax highlighting, emojis etc.}
|
13
13
|
spec.homepage = "https://github.com/davidrivera/Downr"
|
14
14
|
spec.license = "MIT"
|
data/lib/downr.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
if defined?(::Rails)
|
4
4
|
require 'downr/action_view/helpers'
|
5
5
|
require 'downr/railtie'
|
6
|
+
require 'downr/engine'
|
6
7
|
end
|
7
8
|
|
8
9
|
# Namespace for classes and modules that handle markdown parsing
|
@@ -10,12 +11,13 @@ module Downr
|
|
10
11
|
|
11
12
|
autoload :Pygmentize, 'pygmentize'
|
12
13
|
autoload :Redcarpet, 'redcarpet'
|
14
|
+
autoload :RailsEmoji, 'rails_emoji'
|
13
15
|
autoload :Render, 'downr/render'
|
14
16
|
autoload :Configuration, 'downr/configuration'
|
15
17
|
autoload :Markdown, 'downr/markdown'
|
16
18
|
|
17
|
-
# @attr
|
18
|
-
# @attr
|
19
|
+
# @attr Configuration configuration the configuration used for initializing the parser
|
20
|
+
# @attr Markdown markdown the markdown object created from the configuration
|
19
21
|
class << self
|
20
22
|
attr_accessor :configuration, :markdown
|
21
23
|
end
|
data/lib/downr/engine.rb
ADDED
data/lib/downr/markdown.rb
CHANGED
data/lib/downr/railtie.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Downr
|
2
2
|
|
3
|
-
##
|
4
3
|
# Lets us tie up a Rails view helper
|
5
|
-
|
4
|
+
class Railtie < ::Rails::Railtie
|
6
5
|
initializer "downr.configure_view_controller" do |app|
|
7
6
|
ActiveSupport.on_load :action_view do
|
8
7
|
ActionView::Base.send :include, Helpers
|
9
8
|
end
|
10
9
|
end
|
11
|
-
|
10
|
+
end
|
12
11
|
end
|
data/lib/downr/render.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
module Downr
|
2
|
+
|
2
3
|
# This class wraps both pygmentize and
|
3
4
|
# RailsEmoji gems to create a custom renderer
|
4
5
|
class Render < Redcarpet::Render::HTML
|
5
6
|
|
7
|
+
# will override the postprocess method to
|
8
|
+
# perform SmartyPants replacements once
|
9
|
+
# the rendering is complete.
|
10
|
+
include Redcarpet::Render::SmartyPants
|
11
|
+
|
6
12
|
# Initializes the Render object
|
7
13
|
#
|
8
14
|
# @option opts [Boolean] :pygmentize Code colors
|
@@ -13,6 +19,9 @@ module Downr
|
|
13
19
|
super
|
14
20
|
end
|
15
21
|
|
22
|
+
|
23
|
+
# Block-level calls
|
24
|
+
|
16
25
|
# Hook for Redcarpet render
|
17
26
|
#
|
18
27
|
# @param [String] code the code snippet to parse
|
@@ -21,23 +30,25 @@ module Downr
|
|
21
30
|
# @return [String] html
|
22
31
|
def block_code(code, language)
|
23
32
|
if(@options[:pygmentize])
|
24
|
-
pygmentize(code, language)
|
25
|
-
else
|
26
|
-
return code
|
33
|
+
return pygmentize(code, language)
|
27
34
|
end
|
35
|
+
|
36
|
+
code
|
28
37
|
end
|
29
38
|
|
39
|
+
# Pre/post-process
|
40
|
+
|
30
41
|
# Hook for Redcarpet render
|
31
42
|
#
|
32
|
-
# @param [String]
|
43
|
+
# @param [String] full_document the complete doc
|
33
44
|
#
|
34
45
|
# @return [String] html
|
35
|
-
def
|
46
|
+
def postprocess(full_document)
|
36
47
|
if(@options[:emojify])
|
37
|
-
return emojify(
|
38
|
-
else
|
39
|
-
return text
|
48
|
+
return emojify(full_document)
|
40
49
|
end
|
50
|
+
|
51
|
+
full_document
|
41
52
|
end
|
42
53
|
|
43
54
|
private
|
@@ -77,7 +88,7 @@ module Downr
|
|
77
88
|
def emojify(content)
|
78
89
|
content.to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match|
|
79
90
|
RailsEmoji.render match, size: '20x20'
|
80
|
-
end
|
91
|
+
end
|
81
92
|
end
|
82
93
|
|
83
94
|
#Uses Pygmentize to color code
|
data/lib/downr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: downr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/downr.rb
|
159
159
|
- lib/downr/action_view/helpers.rb
|
160
160
|
- lib/downr/configuration.rb
|
161
|
+
- lib/downr/engine.rb
|
161
162
|
- lib/downr/markdown.rb
|
162
163
|
- lib/downr/railtie.rb
|
163
164
|
- lib/downr/render.rb
|
@@ -195,7 +196,7 @@ rubyforge_project:
|
|
195
196
|
rubygems_version: 1.8.23
|
196
197
|
signing_key:
|
197
198
|
specification_version: 3
|
198
|
-
summary:
|
199
|
+
summary: Rails friendly Github Falvored Markdown
|
199
200
|
test_files:
|
200
201
|
- spec/lib/downr/action_view/helpers_spec.rb
|
201
202
|
- spec/lib/downr/configuration_spec.rb
|