mdpress 0.0.3 → 0.0.4

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.
data/bin/mdpress CHANGED
@@ -8,30 +8,18 @@ require 'tempfile'
8
8
  require 'launchy'
9
9
 
10
10
  def log(x)
11
- puts "\033[94m" + x + "\033[0m"
11
+ puts "\033[94m" + x + "\033[0m" if OPTS[:verbose]
12
12
  end
13
13
 
14
14
  def base_dir
15
15
  File.dirname(__FILE__) + "/../lib/"
16
16
  end
17
17
 
18
- opts = Trollop::options do
19
- banner <<-EOS
20
- Usage: mdpress [filename] [options]
21
- where [options] are:
22
- EOS
23
- opt :automatic, "Keeps running and automatically updates the presentation to reflect changes to markdown file."
24
- opt :stylesheet, "Specify what stylesheet to use.", :default => "default"
25
- opt :list, "List all available stylesheets."
26
- opt :run, "Run presentation (automatically compiles to a tmp directory and opens in a browser window)"
27
- end
28
-
29
- if opts[:list]
18
+ def list_available_stylesheets
30
19
  log "Available stylesheets:"
31
20
  Dir.glob(base_dir + "impress_css/*").each do |file|
32
21
  puts File.basename(file, ".css")
33
22
  end
34
- exit
35
23
  end
36
24
 
37
25
  def render
@@ -60,6 +48,12 @@ def render
60
48
  # now use those attributes and render the file
61
49
  include Redcarpet
62
50
  ImpressRenderer.init_with_attrs attrs
51
+ if File.exist?(STYLESHEET_HEAD)
52
+ ImpressRenderer.set_head(File.read(STYLESHEET_HEAD))
53
+ else
54
+ ImpressRenderer.set_head("")
55
+ end
56
+
63
57
  m = Markdown.new(ImpressRenderer, :autolink => true)
64
58
  log "rendering presentation"
65
59
  f = File.open(DIRNAME + "/index.html", "w+")
@@ -67,15 +61,34 @@ def render
67
61
  f.close
68
62
  end
69
63
 
70
- STYLESHEET = base_dir + "impress_css/#{opts[:stylesheet]}.css"
64
+ OPTS = Trollop::options do
65
+ banner <<-EOS
66
+ Usage: mdpress [filename] [options]
67
+ where [options] are:
68
+ EOS
69
+ opt :automatic, "Keeps running and automatically updates the presentation to reflect changes to markdown file."
70
+ opt :stylesheet, "Specify what stylesheet to use.", :default => "default"
71
+ opt :list, "List all available stylesheets."
72
+ opt :run, "Run presentation (automatically compiles to a tmp directory and opens in a browser window)"
73
+ opt :verbose, "Be verbose."
74
+ end
71
75
 
72
76
  raise Trollop::HelpNeeded if ARGV.empty? # show help screen
77
+
78
+ if OPTS[:list]
79
+ list_available_stylesheets
80
+ end
81
+
82
+
83
+ STYLESHEET = base_dir + "impress_css/#{OPTS[:stylesheet]}.css"
84
+ STYLESHEET_HEAD = base_dir + "impress_css/#{OPTS[:stylesheet]}.html"
85
+
73
86
  unless File.exist?(STYLESHEET)
74
- puts opts[:stylesheet] + " is not a valid stylesheet. See available stylesheets with `mdpress -l`."
87
+ puts OPTS[:stylesheet] + " is not a valid stylesheet. See available stylesheets with `mdpress -l`."
75
88
  exit
76
89
  end
77
90
 
78
- if opts[:run]
91
+ if OPTS[:run]
79
92
  file = ARGV[0]
80
93
  tmp = Tempfile.new("mdpress")
81
94
  tmp.write(File.read(file))
@@ -87,8 +100,15 @@ else
87
100
  DIRNAME = File.basename(FILENAME, File.extname(FILENAME))
88
101
  end
89
102
 
90
- log "making directory"
91
- Dir.mkdir(DIRNAME)
103
+ if File.exist?(DIRNAME)
104
+ unless File.directory?(DIRNAME)
105
+ puts "please delete the file: #{DIRNAME} before continuing."
106
+ exit
107
+ end
108
+ else
109
+ log "making directory"
110
+ Dir.mkdir(DIRNAME)
111
+ end
92
112
 
93
113
  render
94
114
 
@@ -107,10 +127,10 @@ def auto
107
127
  end
108
128
  end
109
129
 
110
- if opts[:automatic]
130
+ if OPTS[:automatic]
111
131
  log "waiting for updates..."
112
132
  auto
113
- elsif opts[:run]
133
+ elsif OPTS[:run]
114
134
  log "opening in browser."
115
135
  Launchy.open(DIRNAME + "/index.html", :application => :browser)
116
136
  else
@@ -26,6 +26,14 @@ body {
26
26
 
27
27
  .step:not(.active) { opacity: 0.0; }
28
28
 
29
+ strong {
30
+ font-weight: 800;
31
+ }
32
+
33
+ em {
34
+ font-style: italic;
35
+ }
36
+
29
37
  h1, h2 {
30
38
  //font-family: 'Raleway', serif;
31
39
  font-weight: normal;
@@ -0,0 +1,2 @@
1
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,800italic,300,400,800' rel='stylesheet' type='text/css'>
2
+
@@ -2,12 +2,17 @@ require 'redcarpet'
2
2
  class ImpressRenderer < Redcarpet::Render::HTML
3
3
  @@attrs = []
4
4
  @@current = 0
5
+ @@head = ""
5
6
 
6
7
  def self.init_with_attrs att
7
8
  @@attrs = att
8
9
  @@current = 0
9
10
  end
10
11
 
12
+ def self.set_head head
13
+ @@head = head
14
+ end
15
+
11
16
  def hrule
12
17
  # this is how we later inject attributes into pages. what an awful hack.
13
18
  @@current += 1
@@ -30,10 +35,10 @@ class ImpressRenderer < Redcarpet::Render::HTML
30
35
  <head>
31
36
  <link href="css/reset.css" rel="stylesheet" />
32
37
  <link href="css/style.css" rel="stylesheet" />
33
- <link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400' rel='stylesheet' type='text/css'>
34
38
  <!-- Code Prettifier: -->
35
39
  <link href="css/prettify.css" type="text/css" rel="stylesheet" />
36
- <script type="text/javascript" src="js/prettify.js"></script>
40
+ <script type="text/javascript" src="js/prettify.js"></script>
41
+ #{@@head}
37
42
  </head>
38
43
 
39
44
  <body onload="prettyPrint()">
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdpress
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aditya Bhargava
@@ -69,13 +69,14 @@ extensions: []
69
69
  extra_rdoc_files: []
70
70
 
71
71
  files:
72
- - lib/impress_renderer.rb
73
- - bin/mdpress
74
72
  - lib/css/prettify.css
75
73
  - lib/css/reset.css
74
+ - lib/impress_css/default.css
75
+ - lib/impress_css/default.html
76
+ - lib/impress_renderer.rb
76
77
  - lib/js/impress.js
77
78
  - lib/js/prettify.js
78
- - lib/impress_css/default.css
79
+ - bin/mdpress
79
80
  has_rdoc: true
80
81
  homepage: https://github.com/egonSchiele/mdpress
81
82
  licenses: []