markdown-scaffold 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +47 -0
- data/Rakefile +2 -0
- data/lib/markdown-scaffold.rb +45 -0
- data/lib/markdown-scaffold/templates/html_with_pygments.rb +12 -0
- data/lib/markdown-scaffold/templates/pygments.css +288 -0
- data/lib/markdown-scaffold/templates/ruby_python.rb +2 -0
- data/lib/markdown-scaffold/version.rb +5 -0
- data/markdown-scaffold.gemspec +21 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Shun Matsumoto
|
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,47 @@
|
|
1
|
+
# Markdown::Scaffold
|
2
|
+
|
3
|
+
Scaffold for Markdown.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# For Markdown
|
11
|
+
gem 'markdown-scaffold', :group => :development
|
12
|
+
gem 'redcarpet'
|
13
|
+
gem "pygments.rb" # => 0.2.3
|
14
|
+
gem "rubypython", "0.5.1" # For Heroku
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
bundle
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Generate
|
24
|
+
|
25
|
+
```
|
26
|
+
rails g markdown:scaffold
|
27
|
+
----------
|
28
|
+
create app/assets/stylesheets/pygments.css
|
29
|
+
create app/models/html_with_pygments.rb
|
30
|
+
insert app/controllers/application_controller.rb
|
31
|
+
create config/initializers/ruby_python.rb
|
32
|
+
----------
|
33
|
+
```
|
34
|
+
|
35
|
+
View
|
36
|
+
|
37
|
+
```erb
|
38
|
+
<%= raw show_markdown( markdown_text ) %>
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "markdown-scaffold/version"
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
module Markdown
|
6
|
+
module Generators
|
7
|
+
class ScaffoldGenerator < ::Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path("../markdown-scaffold", __FILE__)
|
10
|
+
desc "This generator scaffold for Markdown"
|
11
|
+
|
12
|
+
#-------------------#
|
13
|
+
# generate_scaffold #
|
14
|
+
#-------------------#
|
15
|
+
def generate_scaffold
|
16
|
+
# stylesheets/pygments.css
|
17
|
+
copy_file( "templates/pygments.css", "app/assets/stylesheets/pygments.css" )
|
18
|
+
|
19
|
+
# models/html_with_pygments.rb
|
20
|
+
copy_file( "templates/html_with_pygments.rb", "app/models/html_with_pygments.rb" )
|
21
|
+
|
22
|
+
# controllers/application_controller.rb
|
23
|
+
content = "\n"
|
24
|
+
content += " #---------------#\n"
|
25
|
+
content += " # show_markdown #\n"
|
26
|
+
content += " #---------------#\n"
|
27
|
+
content += " # Markdown変換\n"
|
28
|
+
content += " def show_markdown( text )\n"
|
29
|
+
content += " html_render = HtmlWithPygments.new( hard_wrap: true, filter_html: true )\n"
|
30
|
+
content += " markdown = Redcarpet::Markdown.new( html_render, autolink: true, fenced_code_blocks: true, space_after_headers: true )\n"
|
31
|
+
content += "\n"
|
32
|
+
content += " return markdown.render( text )\n"
|
33
|
+
content += " end\n"
|
34
|
+
content += "\n"
|
35
|
+
content += " helper_method :show_markdown\n"
|
36
|
+
|
37
|
+
insert_into_file( "app/controllers/application_controller.rb", content.force_encoding('ASCII-8BIT'), after: "private\n" )
|
38
|
+
|
39
|
+
# initializers/ruby_python.rb
|
40
|
+
copy_file( "templates/ruby_python.rb", "config/initializers/ruby_python.rb" )
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
class HtmlWithPygments < Redcarpet::Render::HTML
|
3
|
+
|
4
|
+
#------------#
|
5
|
+
# block_code #
|
6
|
+
#------------#
|
7
|
+
# コードハイライト
|
8
|
+
def block_code( code, language )
|
9
|
+
Pygments.highlight( code, lexer: language, options: { encoding: 'utf-8' } )
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,288 @@
|
|
1
|
+
.highlight {
|
2
|
+
background: #fff;
|
3
|
+
}
|
4
|
+
|
5
|
+
.highlight .c {
|
6
|
+
color: #998;
|
7
|
+
font-style: italic;
|
8
|
+
}
|
9
|
+
|
10
|
+
.highlight .err {
|
11
|
+
color: #a61717;
|
12
|
+
background-color: #e3d2d2;
|
13
|
+
}
|
14
|
+
|
15
|
+
.highlight .k {
|
16
|
+
font-weight: bold;
|
17
|
+
}
|
18
|
+
|
19
|
+
.highlight .o {
|
20
|
+
font-weight: bold;
|
21
|
+
}
|
22
|
+
|
23
|
+
.highlight .cm {
|
24
|
+
color: #998;
|
25
|
+
font-style: italic;
|
26
|
+
}
|
27
|
+
|
28
|
+
.highlight .cp {
|
29
|
+
color: #999;
|
30
|
+
font-weight: bold;
|
31
|
+
}
|
32
|
+
|
33
|
+
.highlight .c1 {
|
34
|
+
color: #998;
|
35
|
+
font-style: italic;
|
36
|
+
}
|
37
|
+
|
38
|
+
.highlight .cs {
|
39
|
+
color: #999;
|
40
|
+
font-weight: bold;
|
41
|
+
font-style: italic;
|
42
|
+
}
|
43
|
+
|
44
|
+
.highlight .gd {
|
45
|
+
color: #000;
|
46
|
+
background-color: #fdd;
|
47
|
+
}
|
48
|
+
|
49
|
+
.highlight .gd .x {
|
50
|
+
color: #000;
|
51
|
+
background-color: #faa;
|
52
|
+
}
|
53
|
+
|
54
|
+
.highlight .ge {
|
55
|
+
font-style: italic;
|
56
|
+
}
|
57
|
+
|
58
|
+
.highlight .gr {
|
59
|
+
color: #a00;
|
60
|
+
}
|
61
|
+
|
62
|
+
.highlight .gh {
|
63
|
+
color: #999;
|
64
|
+
}
|
65
|
+
|
66
|
+
.highlight .gi {
|
67
|
+
color: #000;
|
68
|
+
background-color: #dfd;
|
69
|
+
}
|
70
|
+
|
71
|
+
.highlight .gi .x {
|
72
|
+
color: #000;
|
73
|
+
background-color: #afa;
|
74
|
+
}
|
75
|
+
|
76
|
+
.highlight .go {
|
77
|
+
color: #888;
|
78
|
+
}
|
79
|
+
|
80
|
+
.highlight .gp {
|
81
|
+
color: #555;
|
82
|
+
}
|
83
|
+
|
84
|
+
.highlight .gs {
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
.highlight .gu {
|
89
|
+
color: #800080;
|
90
|
+
font-weight: bold;
|
91
|
+
}
|
92
|
+
|
93
|
+
.highlight .gt {
|
94
|
+
color: #a00;
|
95
|
+
}
|
96
|
+
|
97
|
+
.highlight .kc {
|
98
|
+
font-weight: bold;
|
99
|
+
}
|
100
|
+
|
101
|
+
.highlight .kd {
|
102
|
+
font-weight: bold;
|
103
|
+
}
|
104
|
+
|
105
|
+
.highlight .kn {
|
106
|
+
font-weight: bold;
|
107
|
+
}
|
108
|
+
|
109
|
+
.highlight .kp {
|
110
|
+
font-weight: bold;
|
111
|
+
}
|
112
|
+
|
113
|
+
.highlight .kr {
|
114
|
+
font-weight: bold;
|
115
|
+
}
|
116
|
+
|
117
|
+
.highlight .kt {
|
118
|
+
color: #458;
|
119
|
+
font-weight: bold;
|
120
|
+
}
|
121
|
+
|
122
|
+
.highlight .m {
|
123
|
+
color: #099;
|
124
|
+
}
|
125
|
+
|
126
|
+
.highlight .s {
|
127
|
+
color: #d14;
|
128
|
+
}
|
129
|
+
|
130
|
+
.highlight .na {
|
131
|
+
color: #008080;
|
132
|
+
}
|
133
|
+
|
134
|
+
.highlight .nb {
|
135
|
+
color: #0086B3;
|
136
|
+
}
|
137
|
+
|
138
|
+
.highlight .nc {
|
139
|
+
color: #458;
|
140
|
+
font-weight: bold;
|
141
|
+
}
|
142
|
+
|
143
|
+
.highlight .no {
|
144
|
+
color: #008080;
|
145
|
+
}
|
146
|
+
|
147
|
+
.highlight .ni {
|
148
|
+
color: #800080;
|
149
|
+
}
|
150
|
+
|
151
|
+
.highlight .ne {
|
152
|
+
color: #900;
|
153
|
+
font-weight: bold;
|
154
|
+
}
|
155
|
+
|
156
|
+
.highlight .nf {
|
157
|
+
color: #900;
|
158
|
+
font-weight: bold;
|
159
|
+
}
|
160
|
+
|
161
|
+
.highlight .nn {
|
162
|
+
color: #555;
|
163
|
+
}
|
164
|
+
|
165
|
+
.highlight .nt {
|
166
|
+
color: #000080;
|
167
|
+
}
|
168
|
+
|
169
|
+
.highlight .nv {
|
170
|
+
color: #008080;
|
171
|
+
}
|
172
|
+
|
173
|
+
.highlight .ow {
|
174
|
+
font-weight: bold;
|
175
|
+
}
|
176
|
+
|
177
|
+
.highlight .w {
|
178
|
+
color: #bbb;
|
179
|
+
}
|
180
|
+
|
181
|
+
.highlight .mf {
|
182
|
+
color: #099;
|
183
|
+
}
|
184
|
+
|
185
|
+
.highlight .mh {
|
186
|
+
color: #099;
|
187
|
+
}
|
188
|
+
|
189
|
+
.highlight .mi {
|
190
|
+
color: #099;
|
191
|
+
}
|
192
|
+
|
193
|
+
.highlight .mo {
|
194
|
+
color: #099;
|
195
|
+
}
|
196
|
+
|
197
|
+
.highlight .sb {
|
198
|
+
color: #d14;
|
199
|
+
}
|
200
|
+
|
201
|
+
.highlight .sc {
|
202
|
+
color: #d14;
|
203
|
+
}
|
204
|
+
|
205
|
+
.highlight .sd {
|
206
|
+
color: #d14;
|
207
|
+
}
|
208
|
+
|
209
|
+
.highlight .s2 {
|
210
|
+
color: #d14;
|
211
|
+
}
|
212
|
+
|
213
|
+
.highlight .se {
|
214
|
+
color: #d14;
|
215
|
+
}
|
216
|
+
|
217
|
+
.highlight .sh {
|
218
|
+
color: #d14;
|
219
|
+
}
|
220
|
+
|
221
|
+
.highlight .si {
|
222
|
+
color: #d14;
|
223
|
+
}
|
224
|
+
|
225
|
+
.highlight .sx {
|
226
|
+
color: #d14;
|
227
|
+
}
|
228
|
+
|
229
|
+
.highlight .sr {
|
230
|
+
color: #009926;
|
231
|
+
}
|
232
|
+
|
233
|
+
.highlight .s1 {
|
234
|
+
color: #d14;
|
235
|
+
}
|
236
|
+
|
237
|
+
.highlight .ss {
|
238
|
+
color: #990073;
|
239
|
+
}
|
240
|
+
|
241
|
+
.highlight .bp {
|
242
|
+
color: #999;
|
243
|
+
}
|
244
|
+
|
245
|
+
.highlight .vc {
|
246
|
+
color: #008080;
|
247
|
+
}
|
248
|
+
|
249
|
+
.highlight .vg {
|
250
|
+
color: #008080;
|
251
|
+
}
|
252
|
+
|
253
|
+
.highlight .vi {
|
254
|
+
color: #008080;
|
255
|
+
}
|
256
|
+
|
257
|
+
.highlight .il {
|
258
|
+
color: #099;
|
259
|
+
}
|
260
|
+
|
261
|
+
.type-csharp .highlight .k {
|
262
|
+
color: #00F;
|
263
|
+
}
|
264
|
+
|
265
|
+
.type-csharp .highlight .kt {
|
266
|
+
color: #00F;
|
267
|
+
}
|
268
|
+
|
269
|
+
.type-csharp .highlight .nf {
|
270
|
+
color: #000;
|
271
|
+
font-weight: normal;
|
272
|
+
}
|
273
|
+
|
274
|
+
.type-csharp .highlight .nc {
|
275
|
+
color: #2B91AF;
|
276
|
+
}
|
277
|
+
|
278
|
+
.type-csharp .highlight .nn {
|
279
|
+
color: #000;
|
280
|
+
}
|
281
|
+
|
282
|
+
.type-csharp .highlight .s {
|
283
|
+
color: #A31515;
|
284
|
+
}
|
285
|
+
|
286
|
+
.type-csharp .highlight .sc {
|
287
|
+
color: #A31515;
|
288
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/markdown-scaffold/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Shun Matsumoto"]
|
6
|
+
gem.email = ["shun.matsumoto@pixta.co.jp"]
|
7
|
+
gem.description = %q{Scaffold for Markdown.}
|
8
|
+
gem.summary = %q{Markdown Scaffold}
|
9
|
+
gem.homepage = "https://github.com/shu0115/markdown-scaffold"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "markdown-scaffold"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Markdown::Scaffold::VERSION
|
17
|
+
|
18
|
+
# gem.add_dependency "redcarpet"
|
19
|
+
# gem.add_dependency "pygments.rb"
|
20
|
+
# gem.add_dependency "rubypython", "0.5.1"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: markdown-scaffold
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Shun Matsumoto
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-27 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Scaffold for Markdown.
|
15
|
+
email:
|
16
|
+
- shun.matsumoto@pixta.co.jp
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/markdown-scaffold.rb
|
27
|
+
- lib/markdown-scaffold/templates/html_with_pygments.rb
|
28
|
+
- lib/markdown-scaffold/templates/pygments.css
|
29
|
+
- lib/markdown-scaffold/templates/ruby_python.rb
|
30
|
+
- lib/markdown-scaffold/version.rb
|
31
|
+
- markdown-scaffold.gemspec
|
32
|
+
homepage: https://github.com/shu0115/markdown-scaffold
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.23
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Markdown Scaffold
|
56
|
+
test_files: []
|