redrug 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/red_rug.rb +48 -1
- metadata +3 -3
data/lib/red_rug.rb
CHANGED
@@ -1,13 +1,60 @@
|
|
1
1
|
require 'redcarpet'
|
2
2
|
|
3
|
+
=begin rdoc
|
4
|
+
|
5
|
+
RedRug provides a simplified interface to the functionality of the Redcarpet
|
6
|
+
gem for Markdown handling, intended to provide convenience in execution of
|
7
|
+
common tasks. At present, only HTML output is supported.
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
3
11
|
module RedRug
|
4
|
-
|
12
|
+
|
13
|
+
=begin rdoc
|
14
|
+
|
15
|
+
This method returns the version number of the RedRug gem.
|
16
|
+
|
17
|
+
=end
|
18
|
+
|
19
|
+
def self.version; '0.2.1'; end
|
20
|
+
|
21
|
+
=begin rdoc
|
22
|
+
|
23
|
+
The +markdown_string+ argument is a string containing text using Markdown
|
24
|
+
formatting recognized by Redcarpet. The method returns an HTML formatted
|
25
|
+
version of the string. It depends on the Redcarpet implementation, which adds
|
26
|
+
a newline at the end of the output string.
|
27
|
+
|
28
|
+
Example:
|
29
|
+
|
30
|
+
RedRug.to_html('#foo')
|
31
|
+
=> "<h1>foo</h1>\n"
|
32
|
+
|
33
|
+
=end
|
5
34
|
|
6
35
|
def self.to_html(markdown_string)
|
7
36
|
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
|
8
37
|
markdown.render(markdown_string)
|
9
38
|
end
|
10
39
|
|
40
|
+
=begin rdoc
|
41
|
+
|
42
|
+
The +filename+ argument is a string consisting of the name of a file, including
|
43
|
+
path information as necessary.
|
44
|
+
|
45
|
+
The +output_format+ argument is an output format supported by RedRug via +to_*+
|
46
|
+
methods, indicated in lower case letters. When no +output_format+ is
|
47
|
+
specified, it defaults to HTML.
|
48
|
+
|
49
|
+
Example, assuming a file +file.md+ containing only +#foo+ on the first line:
|
50
|
+
|
51
|
+
RedRug.from_file('/usr/home/username/file.md', 'html')
|
52
|
+
=> "<h1>foo</h1>\n"
|
53
|
+
|
54
|
+
It depends on the implementation of the +to_*+ method it calls.
|
55
|
+
|
56
|
+
=end
|
57
|
+
|
11
58
|
def self.from_file(filename, output_format='html')
|
12
59
|
case output_format
|
13
60
|
when 'html'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redrug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-09-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redcarpet
|
16
|
-
requirement: &
|
16
|
+
requirement: &5824980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *5824980
|
25
25
|
description: ! " RedRug is a wrapper for Redcarpet, intended to provide more convenient\n
|
26
26
|
\ interfaces for common Markdown parsing use cases.\n"
|
27
27
|
email: code@apotheon.net
|