gmd 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,36 +1,36 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
- <%= Gmd.layout_meta_tags %>
5
- <%= Gmd.load_common(:header) %>
6
- <style>
7
- body {background-color:#f8f8f8;font-family:Helvetica;}
8
- h1,h2,h3,h4,h5,h6{border:0;}
9
- h1{font-size:170%;border-top:4px solid #aaa;padding-top:.5em;margin-top:1.5em;}
10
- h1:first-child{margin-top:0;padding-top:.25em;border-top:none;}
11
- h2{font-size:150%;margin-top:1.5em;border-top:4px solid #e0e0e0;padding-top:.5em;}
12
- h3{margin-top:1em;}
13
- p{margin:1em 0;line-height:1.5em;}
14
- ul{margin:1em 0 1em 2em;}
15
- ol{margin:1em 0 1em 2em;}
16
- ul li{margin-top:.5em;margin-bottom:.5em;}
17
- ul ul,ul ol,ol ol,ol ul,{margin-top:0;margin-bottom:0;}
18
- blockquote{margin:1em 0;border-left:5px solid #ddd;padding-left:.6em;color:#555;}
19
- dt{font-weight:bold;margin-left:1em;}
20
- dd{margin-left:2em;margin-bottom:1em;}
21
- table{margin:1em 0;}
22
- table th{border-bottom:1px solid #bbb;padding:.2em 1em;}
23
- table td{border-bottom:1px solid #ddd;padding:.2em 1em;}
24
- pre{margin:1em 0;font-size:12px;background-color:#f8f8ff;border:1px solid #dedede;padding:.5em;line-height:1.5em;color:#444;overflow:auto;}
25
- pre code{padding:0;font-size:12px;background-color:#f8f8ff;border:none;}
26
- code{font-size:12px;background-color:#f8f8ff;color:#444;padding:0 .2em;border:1px solid #dedede;}
27
- a{color:#4183c4;text-decoration:none;}
28
- a:hover{text-decoration:underline;}
29
- a code,a:link code,a:visited code{color:#4183c4;}
30
- img{max-width:100%;}
31
- </style>
32
- </head>
33
- <body>
34
- <%= yield %>
35
- </body>
36
- </html>
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
+ <%= Gmd.layout_meta_tags %>
5
+ <%= Gmd.load_common(:header) %>
6
+ <style>
7
+ body {background-color:#f8f8f8;font-family:Helvetica;}
8
+ h1,h2,h3,h4,h5,h6{border:0;}
9
+ h1{font-size:170%;border-top:4px solid #aaa;padding-top:.5em;margin-top:1.5em;}
10
+ h1:first-child{margin-top:0;padding-top:.25em;border-top:none;}
11
+ h2{font-size:150%;margin-top:1.5em;border-top:4px solid #e0e0e0;padding-top:.5em;}
12
+ h3{margin-top:1em;}
13
+ p{margin:1em 0;line-height:1.5em;}
14
+ ul{margin:1em 0 1em 2em;}
15
+ ol{margin:1em 0 1em 2em;}
16
+ ul li{margin-top:.5em;margin-bottom:.5em;}
17
+ ul ul,ul ol,ol ol,ol ul,{margin-top:0;margin-bottom:0;}
18
+ blockquote{margin:1em 0;border-left:5px solid #ddd;padding-left:.6em;color:#555;}
19
+ dt{font-weight:bold;margin-left:1em;}
20
+ dd{margin-left:2em;margin-bottom:1em;}
21
+ table{margin:1em 0;}
22
+ table th{border-bottom:1px solid #bbb;padding:.2em 1em;}
23
+ table td{border-bottom:1px solid #ddd;padding:.2em 1em;}
24
+ pre{margin:1em 0;font-size:12px;background-color:#f8f8ff;border:1px solid #dedede;padding:.5em;line-height:1.5em;color:#444;overflow:auto;}
25
+ pre code{padding:0;font-size:12px;background-color:#f8f8ff;border:none;}
26
+ code{font-size:12px;background-color:#f8f8ff;color:#444;padding:0 .2em;border:1px solid #dedede;}
27
+ a{color:#4183c4;text-decoration:none;}
28
+ a:hover{text-decoration:underline;}
29
+ a code,a:link code,a:visited code{color:#4183c4;}
30
+ img{max-width:100%;}
31
+ </style>
32
+ </head>
33
+ <body>
34
+ <%= yield %>
35
+ </body>
36
+ </html>
data/lib/gmd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Gmd
2
- VERSION = "1.2.0"
3
- end
1
+ module Gmd
2
+ VERSION = "1.2.1"
3
+ end
data/lib/gmd.rb CHANGED
@@ -1,75 +1,79 @@
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
- "#{file}.html.erb",
13
- "#{file}/layout.html.erb",
14
- "layout/#{file}",
15
- "layout/#{file}.html.erb",
16
- "layouts/#{file}",
17
- "layouts/#{file}.html.erb",
18
- "layouts/#{file}/layout.html.erb",
19
- "~/.gmd/#{file}",
20
- "~/.gmd/#{file}.html.erb",
21
- "~/.gmd/#{file}/layout.html.erb",
22
- File.join(default_layouts_dir, file),
23
- File.join(default_layouts_dir, file + ".html.erb"),
24
- File.join(default_layouts_dir, file + "/layout.html.erb"),
25
- "~/.tilt/#{file}",
26
- "/etc/tilt/#{file}"
27
- ]
28
- end
29
-
30
- def choose_file_from_paths(paths)
31
- paths.map { |p| File.expand_path(p) }.find { |p| File.file?(p) }
32
- end
33
-
34
- def default_layouts_dir
35
- File.dirname(__FILE__) + "/gmd/templates/layouts"
36
- end
37
-
38
- def default_layout
39
- default_layouts_dir + "/default/layout.html.erb"
40
- end
41
-
42
- def layout_meta_tags
43
- <<-METATAGS
44
- <meta name="generator" content="gmd #{Gmd::VERSION}">
45
- METATAGS
46
- end
47
-
48
- # Used to load files from templates/common/ dir
49
- def load_common(file)
50
- paths = [
51
- File.dirname(__FILE__) + "/gmd/templates/common/#{file}",
52
- File.dirname(__FILE__) + "/gmd/templates/common/#{file}.html.erb",
53
- File.dirname(__FILE__) + "/gmd/templates/common/#{file}.erb"
54
- ]
55
- filepath = choose_file_from_paths(paths)
56
- raise "Unable to find file: #{file}" unless filepath
57
- Tilt.new(filepath).render.force_encoding("UTF-8")
58
- end
59
-
60
- def escape_markdown(str)
61
- symbols = "\\`*_{}[]()#+-.!".split('')
62
- symbols.each { |s| str.gsub!(s, "\\" + s) }
63
- str
64
- end
65
-
66
- def fix_latex(str)
67
- inline_exp = /(([^\$]\${1}[^\$].*?[^\$]?\${1}[^\$]))/
68
- multline_exp = /((\\begin\{(\w+?)\}.+?\\end\{\3\})|(\$\$.+?\$\$))/m
69
- str.gsub!(multline_exp) { |s| escape_markdown($1) }
70
- str.gsub!(inline_exp) { |s| escape_markdown($1) }
71
- str
72
- end
73
-
74
- end
75
- end
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
+ "#{file}.html.erb",
13
+ "#{file}/layout.html.erb",
14
+ "layout/#{file}",
15
+ "layout/#{file}.html.erb",
16
+ "layouts/#{file}",
17
+ "layouts/#{file}.html.erb",
18
+ "layouts/#{file}/layout.html.erb",
19
+ "~/.gmd/#{file}",
20
+ "~/.gmd/#{file}.html.erb",
21
+ "~/.gmd/#{file}/layout.html.erb",
22
+ File.join(default_layouts_dir, file),
23
+ File.join(default_layouts_dir, file + ".html.erb"),
24
+ File.join(default_layouts_dir, file + "/layout.html.erb"),
25
+ "~/.tilt/#{file}",
26
+ "/etc/tilt/#{file}"
27
+ ]
28
+ end
29
+
30
+ def choose_file_from_paths(paths)
31
+ paths.map { |p| File.expand_path(p) }.find { |p| File.file?(p) }
32
+ end
33
+
34
+ def default_layouts_dir
35
+ File.dirname(__FILE__) + "/gmd/templates/layouts"
36
+ end
37
+
38
+ def default_layout
39
+ default_layouts_dir + "/default/layout.html.erb"
40
+ end
41
+
42
+ def layout_meta_tags
43
+ <<-METATAGS
44
+ <meta name="generator" content="gmd #{Gmd::VERSION}">
45
+ METATAGS
46
+ end
47
+
48
+ # Used to load files from templates/common/ dir
49
+ def load_common(file)
50
+ paths = [
51
+ File.dirname(__FILE__) + "/gmd/templates/common/#{file}",
52
+ File.dirname(__FILE__) + "/gmd/templates/common/#{file}.html.erb",
53
+ File.dirname(__FILE__) + "/gmd/templates/common/#{file}.erb"
54
+ ]
55
+ filepath = choose_file_from_paths(paths)
56
+ raise "Unable to find file: #{file}" unless filepath
57
+ Tilt.new(filepath).render(self, locals).force_encoding("UTF-8")
58
+ end
59
+
60
+ def escape_markdown(str)
61
+ symbols = "\\`*_{}[]()#+-.!".split('')
62
+ symbols.each { |s| str.gsub!(s, "\\" + s) }
63
+ str
64
+ end
65
+
66
+ def fix_latex(str)
67
+ inline_exp = /(([^\$]\${1}[^\$].*?[^\$]?\${1}[^\$]))/
68
+ multline_exp = /((\\begin\{(\w+?)\}.+?\\end\{\3\})|(\$\$.+?\$\$))/m
69
+ str.gsub!(multline_exp) { |s| escape_markdown($1) }
70
+ str.gsub!(inline_exp) { |s| escape_markdown($1) }
71
+ str
72
+ end
73
+
74
+ def locals
75
+ @locals ||= {}
76
+ end
77
+
78
+ end
79
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-20 00:00:00.000000000Z
12
+ date: 2012-01-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redcarpet
16
- requirement: &74326440 !ruby/object:Gem::Requirement
16
+ requirement: &30064788 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *74326440
24
+ version_requirements: *30064788
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: tilt
27
- requirement: &74326130 !ruby/object:Gem::Requirement
27
+ requirement: &30101388 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *74326130
35
+ version_requirements: *30101388
36
36
  description: gmd is a small command-line utility to easily generate fancy HTML from
37
37
  Markdown.
38
38
  email:
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project: gmd
81
- rubygems_version: 1.8.12
81
+ rubygems_version: 1.8.10
82
82
  signing_key:
83
83
  specification_version: 3
84
84
  summary: gmd is a small command-line utility to easily generate fancy HTML from Markdown.