gmd 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in gmd.gemspec
4
- gemspec
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gmd.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -1,48 +1,48 @@
1
- gmd
2
- ===
3
-
4
-
5
- What is it?
6
- -----------
7
-
8
- gmd is a small command-line utility to easily generate fancy HTML from Markdown.
9
-
10
-
11
- Installation
12
- ------------
13
-
14
- $ [sudo] gem install gmd
15
-
16
-
17
- Usage
18
- -----
19
-
20
- $ gmd text.md
21
-
22
- Will generate HTML from the `text.md` and save it to `text.html`.
23
-
24
- $ gmd text.md -l <layout>
25
-
26
- Will generate and save HTML from the `text.md` using specified layout.
27
-
28
- Built-in layouts:
29
-
30
- + *default*
31
- + *github* - something similar to new GitHub style
32
- + *metal* - something like older GitHub style
33
-
34
- Actually, the deafult style is also (a very very old) GitHub style ;)
35
-
36
-
37
- TeX-based math
38
- --------------
39
-
40
- gmd supports TeX formulas!
41
- Just use `$ ... $` for inline math and `$$ ... $$` for display math.
42
-
43
- An inline math here: $e^{i\pi} = -1$. Awesome!
44
-
45
- $$
46
- \left( \sum_{k=1}^n a_k b_k \right)^{\!\!2} \leq
47
- \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
48
- $$
1
+ gmd
2
+ ===
3
+
4
+
5
+ What is it?
6
+ -----------
7
+
8
+ gmd is a small command-line utility to easily generate fancy HTML from Markdown.
9
+
10
+
11
+ Installation
12
+ ------------
13
+
14
+ $ [sudo] gem install gmd
15
+
16
+
17
+ Usage
18
+ -----
19
+
20
+ $ gmd text.md
21
+
22
+ Will generate HTML from the `text.md` and save it to `text.html`.
23
+
24
+ $ gmd text.md -l <layout>
25
+
26
+ Will generate and save HTML from the `text.md` using specified layout.
27
+
28
+ Built-in layouts:
29
+
30
+ + *default*
31
+ + *github* - something similar to new GitHub style
32
+ + *metal* - something like older GitHub style
33
+
34
+ Actually, the deafult style is also (a very very old) GitHub style ;)
35
+
36
+
37
+ TeX-based math
38
+ --------------
39
+
40
+ gmd supports TeX formulas!
41
+ Just use `$ ... $` for inline math and `$$ ... $$` for display math.
42
+
43
+ An inline math here: $e^{i\pi} = -1$. Awesome!
44
+
45
+ $$
46
+ \left( \sum_{k=1}^n a_k b_k \right)^{\!\!2} \leq
47
+ \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
48
+ $$
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
data/bin/gmd CHANGED
@@ -1,70 +1,72 @@
1
- #!/usr/bin/env ruby
2
- # coding: utf-8
3
- Encoding.default_external = "UTF-8"
4
- Encoding.default_internal = "UTF-8"
5
- require 'optparse'
6
- require 'gmd'
7
-
8
- usage = <<USAGE
9
- Usage: gmd <options> <file>
10
-
11
- Options
12
- -l, --layout=<file> Use <file> as a layout template
13
- -o, --output=<file> Save output to <file> instead
14
- of using source file name with
15
- .html extenstion
16
-
17
- -h, --help Show this help message
18
-
19
- USAGE
20
-
21
- script_name = File.basename($0)
22
- layout = nil
23
- output_file = nil
24
-
25
- ARGV.options do |o|
26
- o.program_name = script_name
27
-
28
- o.on("-l", "--layout=FILE", String) do |file|
29
- layout = Gmd::choose_file_from_paths(Gmd::get_layout_paths(file))
30
- abort "no such layout: #{file}" if layout.nil?
31
- end
32
-
33
- o.on("-o", "--output=FILE", String) do |file|
34
- output_file = file
35
- end
36
-
37
- o.on_tail("-h", "--help") { puts usage; exit }
38
-
39
- o.parse!
40
- end
41
-
42
- file = ARGV.first
43
-
44
- unless file
45
- puts usage
46
- exit
47
- end
48
-
49
- layout = Gmd::default_layout unless layout
50
-
51
- output_file = file.gsub(/\.(md|markdown)\z/, '') + '.html' unless output_file
52
-
53
- locals = {}
54
-
55
- # output = Tilt.new(file).render(self, locals)
56
- # Use redcarpet here directly
57
- output = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
58
- :no_intra_emphasis => true,
59
- :tables => true,
60
- :fenced_code_blocks => true,
61
- :autolink => true,
62
- :strikethrough => true,
63
- :lax_html_blocks => true,
64
- :space_after_headers => true,
65
- :superscript => false
66
- ).render(Gmd::fix_latex(File.read(file)))
67
-
68
- output = Tilt.new(layout).render(self, locals) { output } if layout
69
-
70
- File.open(output_file, "wb") { |f| f.write(output) }
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ Encoding.default_external = "UTF-8"
4
+ Encoding.default_internal = "UTF-8"
5
+ require 'optparse'
6
+ require 'gmd'
7
+
8
+ usage = <<USAGE
9
+ Usage: gmd <options> <file>
10
+
11
+ Options
12
+ -l, --layout=<file> Use <file> as a layout template
13
+ -o, --output=<file> Save output to <file> instead of using source file
14
+ name with .html extenstion
15
+
16
+ -h, --help Show this help message
17
+
18
+ USAGE
19
+
20
+ script_name = File.basename($0)
21
+ layout = nil
22
+ output_file = nil
23
+ options = {
24
+ :use_tex => false
25
+ }
26
+
27
+ ARGV.options do |o|
28
+ o.program_name = script_name
29
+
30
+ o.on("-l", "--layout=FILE", String) do |file|
31
+ layout = Gmd::choose_file_from_paths(Gmd::get_layout_paths(file))
32
+ abort "no such layout: #{file}" if layout.nil?
33
+ end
34
+
35
+ o.on("-o", "--output=FILE", String) do |file|
36
+ output_file = file
37
+ end
38
+
39
+ o.on_tail("-h", "--help") { puts usage; exit }
40
+
41
+ o.parse!
42
+ end
43
+
44
+ file = ARGV.first
45
+
46
+ unless file
47
+ puts usage
48
+ exit
49
+ end
50
+
51
+ layout = Gmd::default_layout unless layout
52
+
53
+ output_file = file.gsub(/\.(md|markdown)\z/, '') + '.html' unless output_file
54
+
55
+ Gmd::locals[:options] = options
56
+
57
+ # output = Tilt.new(file).render(self, locals)
58
+ # Use redcarpet here directly
59
+ output = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
60
+ :no_intra_emphasis => true,
61
+ :tables => true,
62
+ :fenced_code_blocks => true,
63
+ :autolink => true,
64
+ :strikethrough => true,
65
+ :lax_html_blocks => true,
66
+ :space_after_headers => true,
67
+ :superscript => false
68
+ ).render(File.read(file))
69
+
70
+ output = Tilt.new(layout).render(self, Gmd::locals) { output } if layout
71
+
72
+ File.open(output_file, "wb") { |f| f.write(output) }
data/gmd.gemspec CHANGED
@@ -1,26 +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
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
@@ -1,36 +1,38 @@
1
- <%# jQuery %>
2
- <script type="text/javascript"><%= File.read(File.dirname(__FILE__) + "/jquery/jquery-1.7.1.min.js") %></script>
3
-
4
- <%# Common highlighting %>
5
- <script type="text/javascript"><%= File.read(File.dirname(__FILE__) + "/highlight_js/highlight.pack.js") %></script>
6
- <style><%= File.read(File.dirname(__FILE__) + "/highlight_js/github.css") %></style>
7
- <script type="text/javascript">
8
- $(document).ready(function() {
9
- $('pre code').each(function(i, e) {
10
- if (e.className)
11
- hljs.highlightBlock(e, hljs.tabReplace);
12
- });
13
- });
14
- </script>
15
-
16
- <%# MathJax %>
17
- <script type="text/x-mathjax-config">
18
- MathJax.Hub.Config({
19
- jax: ["input/TeX","output/HTML-CSS"],
20
- extensions: ["tex2jax.js"],
21
- tex2jax: {
22
- element: null,
23
- inlineMath: [
24
- ['$','$']
25
- ],
26
- displayMath: [
27
- ['$$','$$']
28
- ],
29
- skipTags: ["script","noscript","style","textarea","pre","code"],
30
- processEscapes: false,
31
- processEnvironments: true,
32
- preview: "TeX"
33
- }
34
- });
35
- </script>
36
- <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
1
+ <%# jQuery %>
2
+ <script type="text/javascript"><%= File.read(File.dirname(__FILE__) + "/jquery/jquery-1.7.1.min.js") %></script>
3
+
4
+ <%# Common highlighting %>
5
+ <script type="text/javascript"><%= File.read(File.dirname(__FILE__) + "/highlight_js/highlight.pack.js") %></script>
6
+ <style><%= File.read(File.dirname(__FILE__) + "/highlight_js/github.css") %></style>
7
+ <script type="text/javascript">
8
+ $(document).ready(function() {
9
+ $('pre code').each(function(i, e) {
10
+ if (e.className)
11
+ hljs.highlightBlock(e, hljs.tabReplace);
12
+ });
13
+ });
14
+ </script>
15
+
16
+ <%# MathJax %>
17
+ <% if locals[:options][:use_tex] %>
18
+ <script type="text/x-mathjax-config">
19
+ MathJax.Hub.Config({
20
+ jax: ["input/TeX","output/HTML-CSS"],
21
+ extensions: ["tex2jax.js"],
22
+ tex2jax: {
23
+ element: null,
24
+ inlineMath: [
25
+ ['$','$']
26
+ ],
27
+ displayMath: [
28
+ ['$$','$$']
29
+ ],
30
+ skipTags: ["script","noscript","style","textarea","pre","code"],
31
+ processEscapes: false,
32
+ processEnvironments: true,
33
+ preview: "TeX"
34
+ }
35
+ });
36
+ </script>
37
+ <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
38
+ <% end %>
@@ -1,129 +1,129 @@
1
- /*
2
-
3
- github.com style (c) Vasily Polovnyov <vast@whiteants.net>
4
-
5
- */
6
-
7
- pre code {
8
- display: block; padding: 0.5em;
9
- color: #000;
10
- background: #f8f8ff
11
- }
12
-
13
- pre .comment,
14
- pre .template_comment,
15
- pre .diff .header,
16
- pre .javadoc {
17
- color: #998;
18
- font-style: italic
19
- }
20
-
21
- pre .keyword,
22
- pre .css .rule .keyword,
23
- pre .winutils,
24
- pre .javascript .title,
25
- pre .lisp .title,
26
- pre .subst {
27
- color: #000;
28
- font-weight: bold
29
- }
30
-
31
- pre .number,
32
- pre .hexcolor {
33
- color: #40a070
34
- }
35
-
36
- pre .string,
37
- pre .tag .value,
38
- pre .phpdoc,
39
- pre .tex .formula {
40
- color: #d14
41
- }
42
-
43
- pre .title,
44
- pre .id {
45
- color: #900;
46
- font-weight: bold
47
- }
48
-
49
- pre .javascript .title,
50
- pre .lisp .title,
51
- pre .subst {
52
- font-weight: normal
53
- }
54
-
55
- pre .class .title,
56
- pre .haskell .label,
57
- pre .tex .command {
58
- color: #458;
59
- font-weight: bold
60
- }
61
-
62
- pre .tag,
63
- pre .tag .title,
64
- pre .rules .property,
65
- pre .django .tag .keyword {
66
- color: #000080;
67
- font-weight: normal
68
- }
69
-
70
- pre .attribute,
71
- pre .variable,
72
- pre .instancevar,
73
- pre .lisp .body {
74
- color: #008080
75
- }
76
-
77
- pre .regexp {
78
- color: #009926
79
- }
80
-
81
- pre .class {
82
- color: #458;
83
- font-weight: bold
84
- }
85
-
86
- pre .symbol,
87
- pre .ruby .symbol .string,
88
- pre .ruby .symbol .keyword,
89
- pre .ruby .symbol .keymethods,
90
- pre .lisp .keyword,
91
- pre .tex .special,
92
- pre .input_number {
93
- color: #990073
94
- }
95
-
96
- pre .builtin,
97
- pre .built_in,
98
- pre .lisp .title {
99
- color: #0086b3
100
- }
101
-
102
- pre .preprocessor,
103
- pre .pi,
104
- pre .doctype,
105
- pre .shebang,
106
- pre .cdata {
107
- color: #999;
108
- font-weight: bold
109
- }
110
-
111
- pre .deletion {
112
- background: #fdd
113
- }
114
-
115
- pre .addition {
116
- background: #dfd
117
- }
118
-
119
- pre .diff .change {
120
- background: #0086b3
121
- }
122
-
123
- pre .chunk {
124
- color: #aaa
125
- }
126
-
127
- pre .tex .formula {
128
- opacity: 0.5;
129
- }
1
+ /*
2
+
3
+ github.com style (c) Vasily Polovnyov <vast@whiteants.net>
4
+
5
+ */
6
+
7
+ pre code {
8
+ display: block; padding: 0.5em;
9
+ color: #000;
10
+ background: #f8f8ff
11
+ }
12
+
13
+ pre .comment,
14
+ pre .template_comment,
15
+ pre .diff .header,
16
+ pre .javadoc {
17
+ color: #998;
18
+ font-style: italic
19
+ }
20
+
21
+ pre .keyword,
22
+ pre .css .rule .keyword,
23
+ pre .winutils,
24
+ pre .javascript .title,
25
+ pre .lisp .title,
26
+ pre .subst {
27
+ color: #000;
28
+ font-weight: bold
29
+ }
30
+
31
+ pre .number,
32
+ pre .hexcolor {
33
+ color: #40a070
34
+ }
35
+
36
+ pre .string,
37
+ pre .tag .value,
38
+ pre .phpdoc,
39
+ pre .tex .formula {
40
+ color: #d14
41
+ }
42
+
43
+ pre .title,
44
+ pre .id {
45
+ color: #900;
46
+ font-weight: bold
47
+ }
48
+
49
+ pre .javascript .title,
50
+ pre .lisp .title,
51
+ pre .subst {
52
+ font-weight: normal
53
+ }
54
+
55
+ pre .class .title,
56
+ pre .haskell .label,
57
+ pre .tex .command {
58
+ color: #458;
59
+ font-weight: bold
60
+ }
61
+
62
+ pre .tag,
63
+ pre .tag .title,
64
+ pre .rules .property,
65
+ pre .django .tag .keyword {
66
+ color: #000080;
67
+ font-weight: normal
68
+ }
69
+
70
+ pre .attribute,
71
+ pre .variable,
72
+ pre .instancevar,
73
+ pre .lisp .body {
74
+ color: #008080
75
+ }
76
+
77
+ pre .regexp {
78
+ color: #009926
79
+ }
80
+
81
+ pre .class {
82
+ color: #458;
83
+ font-weight: bold
84
+ }
85
+
86
+ pre .symbol,
87
+ pre .ruby .symbol .string,
88
+ pre .ruby .symbol .keyword,
89
+ pre .ruby .symbol .keymethods,
90
+ pre .lisp .keyword,
91
+ pre .tex .special,
92
+ pre .input_number {
93
+ color: #990073
94
+ }
95
+
96
+ pre .builtin,
97
+ pre .built_in,
98
+ pre .lisp .title {
99
+ color: #0086b3
100
+ }
101
+
102
+ pre .preprocessor,
103
+ pre .pi,
104
+ pre .doctype,
105
+ pre .shebang,
106
+ pre .cdata {
107
+ color: #999;
108
+ font-weight: bold
109
+ }
110
+
111
+ pre .deletion {
112
+ background: #fdd
113
+ }
114
+
115
+ pre .addition {
116
+ background: #dfd
117
+ }
118
+
119
+ pre .diff .change {
120
+ background: #0086b3
121
+ }
122
+
123
+ pre .chunk {
124
+ color: #aaa
125
+ }
126
+
127
+ pre .tex .formula {
128
+ opacity: 0.5;
129
+ }