markdown_render 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/markdown +3 -0
- data/lib/markdown_render/cli.rb +38 -0
- data/lib/markdown_render/parse.rb +70 -0
- data/lib/markdown_render/version.rb +3 -0
- data/lib/markdown_render.rb +3 -0
- data/markdown_render.gemspec +30 -0
- data/spec/parse_spec.rb +18 -0
- data/spec/spec_helper.rb +7 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c4f437c50b9187d34e092c5312938d691fe7027f
|
4
|
+
data.tar.gz: 4799ddf9af782163ead915bf5e789ae0b4a2ec16
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a91c6b401b6ffb3bdac6a643329e31223d360b4a4b4d164c3635db6c93e255334a805215af7eb8a0921703bc62562a3ff8972f8728d7fe8593b3011770cd1b1
|
7
|
+
data.tar.gz: b7f9d72ea50e2179d0ae6cc2520b7348932dc31c8c23ef15df88f0d89c6502399e73de80f8cb99815af89313b31b806c5c179447569741fb0aec0cd6df65eafc
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jesse Herrick
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MarkdownRender
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'markdown_render'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install markdown_render
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/markdown_render/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/markdown
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'mercenary'
|
2
|
+
require 'markdown_render'
|
3
|
+
|
4
|
+
Mercenary.program(:markdown_render) do |p|
|
5
|
+
p.version Markdown::VERSION
|
6
|
+
p.description 'A simple, themed Markdown processor.'
|
7
|
+
p.syntax 'markdown <command> [options]'
|
8
|
+
|
9
|
+
p.command(:build) do |c|
|
10
|
+
c.syntax 'build <file> [options]'
|
11
|
+
c.description 'Process the Markdown and write it to a file.'
|
12
|
+
|
13
|
+
# c.option 'theme', '-t THEME_NAME', '--theme THEME_NAME', 'Pass a theme to the processor.'
|
14
|
+
c.option 'processor', '-p PROCESSOR', '--processor PROCESSOR', 'Specify a Markdown processor.'
|
15
|
+
|
16
|
+
c.action do |args, options|
|
17
|
+
file = args.shift
|
18
|
+
processor = (options['processor'] || :kramdown).downcase
|
19
|
+
|
20
|
+
# check that a markdown file is given and exists
|
21
|
+
raise 'No Markdown file given.' if file.nil?
|
22
|
+
raise 'Markdown file given does not exist.' unless File.exist?(file)
|
23
|
+
|
24
|
+
# parse the markdown
|
25
|
+
parser = Markdown::Parse.new(processor)
|
26
|
+
html = parser.to_document File.read(file)
|
27
|
+
md_filename = file.split('.').first + '.html'
|
28
|
+
File.open(md_filename, 'w') do |file|
|
29
|
+
file.write html
|
30
|
+
end
|
31
|
+
|
32
|
+
# some friendly output
|
33
|
+
print "#{file} => #{md_filename}"
|
34
|
+
puts " using #{Dir['*theme.css'].first || 'nothing'} as a theme"
|
35
|
+
puts "processor: #{processor}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# converter class for markdown
|
2
|
+
module Markdown
|
3
|
+
class Parse
|
4
|
+
# parser - markdown processor
|
5
|
+
# - kramdown
|
6
|
+
# - redcarpet
|
7
|
+
# - maruku
|
8
|
+
# - rdiscount
|
9
|
+
def initialize(parser)
|
10
|
+
@parser = parser
|
11
|
+
end
|
12
|
+
|
13
|
+
# takes markdown and returns html (as a string)
|
14
|
+
#
|
15
|
+
# content - markdown content
|
16
|
+
def to_html(content)
|
17
|
+
case @parser
|
18
|
+
when :kramdown, 'kramdown'
|
19
|
+
require 'kramdown'
|
20
|
+
Kramdown::Document.new(content).to_html
|
21
|
+
when :redcarpet, 'redcarpet'
|
22
|
+
require 'redcarpet'
|
23
|
+
markdown = Redcarpet::Markdown.new(
|
24
|
+
Redcarpet::Render::HTML,
|
25
|
+
smart: true,
|
26
|
+
no_intra_emphasis: true,
|
27
|
+
fenced_code_blocks: true,
|
28
|
+
autolink: true,
|
29
|
+
tables: true,
|
30
|
+
with_toc_data: true
|
31
|
+
)
|
32
|
+
|
33
|
+
# add smartypants support
|
34
|
+
Redcarpet::Render::SmartyPants.render markdown.render(content)
|
35
|
+
when :rdiscount, 'rdiscount'
|
36
|
+
require 'rdiscount'
|
37
|
+
RDiscount.new(content).to_html
|
38
|
+
when :gfm, :github, :github_markdown, 'gfm', 'github_markdown'
|
39
|
+
require 'github/markdown'
|
40
|
+
GitHub::Markdown.render(content)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
HTML = <<-TEXT
|
45
|
+
<!DOCTYPE html>
|
46
|
+
<html>
|
47
|
+
<head>
|
48
|
+
<title>Document</title>
|
49
|
+
<style>
|
50
|
+
{{theme}}
|
51
|
+
</style>
|
52
|
+
</head>
|
53
|
+
|
54
|
+
<body>
|
55
|
+
{{content}}
|
56
|
+
</body>
|
57
|
+
</html>
|
58
|
+
TEXT
|
59
|
+
|
60
|
+
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
|
+
html = to_html(content)
|
66
|
+
html = HTML.gsub('{{content}}', html)
|
67
|
+
html.gsub('{{theme}}', theme) unless theme_fail
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'markdown_render/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "markdown_render"
|
8
|
+
spec.version = Markdown::VERSION
|
9
|
+
spec.authors = ["Jesse Herrick"]
|
10
|
+
spec.email = ["jessegrantherrick@gmail.com"]
|
11
|
+
spec.summary = %q{A themed markdown processor.}
|
12
|
+
# spec.description = ""
|
13
|
+
spec.homepage = "https://github.com/JesseHerrick/markdown_render"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "mercenary"
|
22
|
+
spec.add_runtime_dependency "kramdown"
|
23
|
+
spec.add_runtime_dependency "redcarpet"
|
24
|
+
spec.add_runtime_dependency "rdiscount"
|
25
|
+
spec.add_runtime_dependency "github-markdown"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
end
|
data/spec/parse_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Markdown do
|
4
|
+
before do
|
5
|
+
@processors = [:kramdown, :redcarpet, :rdiscount, :gfm]
|
6
|
+
|
7
|
+
def all_processors
|
8
|
+
@processors.each do |processor|
|
9
|
+
yield Markdown.new(processor)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
it 'should work with all markdown processors' do
|
14
|
+
all_processors do |p|
|
15
|
+
expect(p).to respond_to(:to_html)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: markdown_render
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jesse Herrick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mercenary
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kramdown
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: redcarpet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdiscount
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: github-markdown
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- jessegrantherrick@gmail.com
|
128
|
+
executables:
|
129
|
+
- markdown
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- bin/markdown
|
140
|
+
- lib/markdown_render.rb
|
141
|
+
- lib/markdown_render/cli.rb
|
142
|
+
- lib/markdown_render/parse.rb
|
143
|
+
- lib/markdown_render/version.rb
|
144
|
+
- markdown_render.gemspec
|
145
|
+
- spec/parse_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
homepage: https://github.com/JesseHerrick/markdown_render
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.2.2
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: A themed markdown processor.
|
171
|
+
test_files:
|
172
|
+
- spec/parse_spec.rb
|
173
|
+
- spec/spec_helper.rb
|