gmd 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +7 -0
- data/Rakefile +1 -0
- data/bin/gmd +58 -0
- data/gmd.gemspec +26 -0
- data/lib/gmd/templates/default.html.erb +74 -0
- data/lib/gmd/version.rb +3 -0
- data/lib/gmd.rb +36 -0
- metadata +78 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/gmd
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#encoding: utf-8
|
3
|
+
require 'optparse'
|
4
|
+
require 'gmd'
|
5
|
+
|
6
|
+
usage = <<USAGE
|
7
|
+
Usage: gmd <options> <file>
|
8
|
+
|
9
|
+
Options
|
10
|
+
-l, --layout=<file> Use <file> as a layout template
|
11
|
+
-o, --output=<file> Save output to <file> instead
|
12
|
+
of using source file name with
|
13
|
+
.html extenstion
|
14
|
+
|
15
|
+
-h, --help Show this help message
|
16
|
+
|
17
|
+
USAGE
|
18
|
+
|
19
|
+
script_name = File.basename($0)
|
20
|
+
layout = nil
|
21
|
+
output_file = nil
|
22
|
+
|
23
|
+
ARGV.options do |o|
|
24
|
+
o.program_name = script_name
|
25
|
+
|
26
|
+
o.on("-l", "--layout=FILE", String) do |file|
|
27
|
+
layout = Gmd::choose_file_from_paths(Gmd::get_layout_paths(file))
|
28
|
+
abort "no such layout: #{file}" if layout.nil?
|
29
|
+
end
|
30
|
+
|
31
|
+
o.on("-o", "--output=FILE", String) do |file|
|
32
|
+
output_file = file
|
33
|
+
end
|
34
|
+
|
35
|
+
o.on_tail("-h", "--help") { puts usage; exit }
|
36
|
+
|
37
|
+
o.parse!
|
38
|
+
end
|
39
|
+
|
40
|
+
file = ARGV.first
|
41
|
+
|
42
|
+
unless file
|
43
|
+
puts usage
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
layout = Gmd::default_layout unless layout
|
48
|
+
|
49
|
+
output_file = file.gsub(/\.(md|markdown)\z/, '') + '.html' unless output_file
|
50
|
+
|
51
|
+
locals = {}
|
52
|
+
|
53
|
+
# output = Tilt.new(file).render(self, locals)
|
54
|
+
# Use redcarpet here directly
|
55
|
+
output = Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(File.read(file))
|
56
|
+
output = Tilt.new(layout).render(self, locals) { output } if layout
|
57
|
+
|
58
|
+
File.open(output_file, "w") { |f| f.write(output) }
|
data/gmd.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gmd/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gmd"
|
7
|
+
s.version = Gmd::VERSION
|
8
|
+
s.authors = ["MOZGIII"]
|
9
|
+
s.email = ["mike-n@narod.ru"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{gmd is a small command-line utility to easily generate fancy HTML from Markdown.}
|
12
|
+
s.description = %q{gmd is a small command-line utility to easily generate fancy HTML from Markdown.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "gmd"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
s.add_runtime_dependency "redcarpet"
|
25
|
+
s.add_runtime_dependency "tilt"
|
26
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
4
|
+
<script src="http://yandex.st/highlightjs/6.1/highlight.min.js"></script>
|
5
|
+
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.1/styles/default.min.css">
|
6
|
+
<style>
|
7
|
+
/*
|
8
|
+
Some simple Github-like styles.
|
9
|
+
*/
|
10
|
+
body{
|
11
|
+
font-family: helvetica, arial, freesans, clean, sans-serif;
|
12
|
+
color: #333;
|
13
|
+
background-color: #fff;
|
14
|
+
border: none;
|
15
|
+
line-height: 1.5;
|
16
|
+
margin: 2em 3em;
|
17
|
+
text-align:left;
|
18
|
+
}
|
19
|
+
pre{
|
20
|
+
background-color: #eee;
|
21
|
+
padding: 10px;
|
22
|
+
-webkit-border-radius: 5px;
|
23
|
+
-moz-border-radius: 5px;
|
24
|
+
border-radius: 5px;
|
25
|
+
overflow: auto;
|
26
|
+
}
|
27
|
+
code{
|
28
|
+
background-color: #eee;
|
29
|
+
padding: 1px 3px;
|
30
|
+
-webkit-border-radius: 2px;
|
31
|
+
-moz-border-radius: 2px;
|
32
|
+
border-radius: 2px;
|
33
|
+
}
|
34
|
+
li p{
|
35
|
+
margin: 0.3em;
|
36
|
+
}
|
37
|
+
li{
|
38
|
+
list-style-type: disc;
|
39
|
+
}
|
40
|
+
a:link, a:visited{
|
41
|
+
color: #33e;
|
42
|
+
text-decoration: none;
|
43
|
+
}
|
44
|
+
a:hover{
|
45
|
+
color: #00f;
|
46
|
+
text-shadow:1px 1px 2px #ccf;
|
47
|
+
text-decoration:underline;
|
48
|
+
}
|
49
|
+
h1{
|
50
|
+
color: #999;
|
51
|
+
font-weight: bold;
|
52
|
+
}
|
53
|
+
h2{
|
54
|
+
border-bottom: 1px dotted #aaa;
|
55
|
+
margin-bottom: 1em;
|
56
|
+
color: #333;
|
57
|
+
}
|
58
|
+
h3{
|
59
|
+
color: #666;
|
60
|
+
}
|
61
|
+
.shadow{
|
62
|
+
-webkit-box-shadow:0 5px 15px #000;
|
63
|
+
-moz-box-shadow:0 5px 15px #000;
|
64
|
+
box-shadow:0 5px 15px #000;
|
65
|
+
}
|
66
|
+
</style>
|
67
|
+
<script type="text/javascript">
|
68
|
+
hljs.initHighlightingOnLoad();
|
69
|
+
</script>
|
70
|
+
</head>
|
71
|
+
<body>
|
72
|
+
<%= yield %>
|
73
|
+
</body>
|
74
|
+
</html>
|
data/lib/gmd/version.rb
ADDED
data/lib/gmd.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "gmd/version"
|
2
|
+
require "tilt"
|
3
|
+
require "redcarpet"
|
4
|
+
require "erb"
|
5
|
+
|
6
|
+
module Gmd
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def get_layout_paths(file)
|
10
|
+
[
|
11
|
+
file,
|
12
|
+
"layout/#{file}",
|
13
|
+
"layouts/#{file}",
|
14
|
+
"~/.gmd/#{file}",
|
15
|
+
File.join(defalut_layouts_dir, file),
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def choose_file_from_paths(paths)
|
20
|
+
paths.map { |p| File.expand_path(p) }.find { |p| File.exist?(p) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_layouts_dir
|
24
|
+
File.join(
|
25
|
+
File.dirname(__FILE__),
|
26
|
+
"gmd",
|
27
|
+
"templates"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_layout
|
32
|
+
default_layouts_dir + "/default.html.erb"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gmd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- MOZGIII
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-14 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: redcarpet
|
16
|
+
requirement: &82953420 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *82953420
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: tilt
|
27
|
+
requirement: &82953060 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *82953060
|
36
|
+
description: gmd is a small command-line utility to easily generate fancy HTML from
|
37
|
+
Markdown.
|
38
|
+
email:
|
39
|
+
- mike-n@narod.ru
|
40
|
+
executables:
|
41
|
+
- gmd
|
42
|
+
extensions: []
|
43
|
+
extra_rdoc_files: []
|
44
|
+
files:
|
45
|
+
- .gitignore
|
46
|
+
- Gemfile
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- bin/gmd
|
50
|
+
- gmd.gemspec
|
51
|
+
- lib/gmd.rb
|
52
|
+
- lib/gmd/templates/default.html.erb
|
53
|
+
- lib/gmd/version.rb
|
54
|
+
homepage: ''
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project: gmd
|
74
|
+
rubygems_version: 1.8.12
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: gmd is a small command-line utility to easily generate fancy HTML from Markdown.
|
78
|
+
test_files: []
|