markdown_render 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/markdown_render/cli.rb +13 -4
- data/lib/markdown_render/parse.rb +3 -6
- data/lib/markdown_render/version.rb +1 -1
- data/markdown_render.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77f5064185d1c90e9045bdaab797ded4b87d573e
|
4
|
+
data.tar.gz: ecabf2aedcc75a5a70d870cb8fd57b263f29bb64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80096e0b7a3ee8cf80aab5dcb84730fa1fe6178825d6ddf6fba7573ed7f8f74ecb0f9c63b61c30301d1f11d19a413f52b7905980ed21ce0c19d8f17b5ce2cc1b
|
7
|
+
data.tar.gz: 96b31430f7bd5a0cf44c7986caf31a16e1dec491ea62b2840f7b230b297ed7782abb66bb0b20417e02df49a361aa7ac663bb84d0ff0dd0b8b8ecff3e48679e24
|
data/lib/markdown_render/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mercenary'
|
2
|
+
require 'colorize'
|
2
3
|
require 'markdown_render'
|
3
4
|
|
4
5
|
Mercenary.program(:markdown_render) do |p|
|
@@ -21,8 +22,16 @@ Mercenary.program(:markdown_render) do |p|
|
|
21
22
|
raise 'No Markdown file given.' if file.nil?
|
22
23
|
raise 'Markdown file given does not exist.' unless File.exist?(file)
|
23
24
|
|
25
|
+
# find the theme
|
26
|
+
theme_file = Dir['*theme.css'].first || 'nothing'
|
27
|
+
begin
|
28
|
+
theme = File.read(theme_file)
|
29
|
+
rescue Errno::ENOENT
|
30
|
+
theme = ''
|
31
|
+
end
|
32
|
+
|
24
33
|
# parse the markdown
|
25
|
-
parser = Markdown::Parse.new(processor)
|
34
|
+
parser = Markdown::Parse.new(processor, theme)
|
26
35
|
html = parser.to_document File.read(file)
|
27
36
|
md_filename = file.split('.').first + '.html'
|
28
37
|
File.open(md_filename, 'w') do |file|
|
@@ -30,9 +39,9 @@ Mercenary.program(:markdown_render) do |p|
|
|
30
39
|
end
|
31
40
|
|
32
41
|
# some friendly output
|
33
|
-
|
34
|
-
puts "
|
35
|
-
puts "processor: #{processor}"
|
42
|
+
puts "#{file.green} => #{md_filename.green}"
|
43
|
+
puts "using #{theme_file.split('.').first.blue} as a theme"
|
44
|
+
puts "markdown processor: #{processor.to_s.red}"
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
@@ -6,8 +6,9 @@ module Markdown
|
|
6
6
|
# - redcarpet
|
7
7
|
# - maruku
|
8
8
|
# - rdiscount
|
9
|
-
def initialize(parser)
|
9
|
+
def initialize(parser, theme = '')
|
10
10
|
@parser = parser
|
11
|
+
@theme = theme
|
11
12
|
end
|
12
13
|
|
13
14
|
# takes markdown and returns html (as a string)
|
@@ -58,13 +59,9 @@ module Markdown
|
|
58
59
|
TEXT
|
59
60
|
|
60
61
|
def to_document(content)
|
61
|
-
theme_file = Dir['*theme.css'].first || 'nothing'
|
62
|
-
theme_fail = !File.exist?(theme_file)
|
63
|
-
theme = File.read(theme_file) unless theme_fail
|
64
|
-
|
65
62
|
html = to_html(content)
|
66
63
|
html = HTML.gsub('{{content}}', html)
|
67
|
-
html.gsub('{{theme}}', theme)
|
64
|
+
html.gsub('{{theme}}', @theme)
|
68
65
|
end
|
69
66
|
end
|
70
67
|
end
|
data/markdown_render.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency "redcarpet"
|
24
24
|
spec.add_runtime_dependency "rdiscount"
|
25
25
|
spec.add_runtime_dependency "github-markdown"
|
26
|
+
spec.add_runtime_dependency "colorize"
|
26
27
|
|
27
28
|
spec.add_development_dependency "bundler", "~> 1.6"
|
28
29
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Herrick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: colorize
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: bundler
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|