mdpress 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Aditya Bhargava
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # mdpress
2
+
3
+ This is a tool that converts markdown files to presentations using impress.
4
+
5
+ # Example
6
+
7
+ [This presentation](http://egonschiele.github.com/mdpress/default) was created from [this markdown file](https://raw.github.com/egonSchiele/mdpress/master/examples/demo.md).
8
+
9
+ [This presentation](http://egonschiele.github.com/mdpress/impress) was created from the same markdown file and a different stylesheet using `mdpress -s [stylesheet name]`.
10
+
11
+
12
+ ## Advantages
13
+
14
+ - dead simple, works with any markdown file
15
+ - comes with a beautiful default stylesheet + more styles (more styles TBD) ... no need to write your own
16
+ - ...but you can write your own easily if you want!
17
+ - comes with [prettify](http://code.google.com/p/google-code-prettify/) integrated, does code highlighting out of the box
18
+ - has an auto-update mode; update your markdown file and mdpress will update your presentation automatically
19
+ - quick install as a ruby gem
20
+ - presentations are tiny and easy to distribute
21
+ - presentations are easy to read as a plain text file
22
+
23
+ ## Install
24
+
25
+ gem install mdpress
26
+
27
+ ## Usage
28
+
29
+ mdpress [filename.md]
30
+ mdpress [http://www.yourdomain.com/path/to/filename.md]
31
+
32
+ This creates a directory named `filename`. Start the presentation by opening up `index.html`.
33
+
34
+ ## Quickstart (writing your first presentation!)
35
+
36
+ # Chicken Chicken Chicken
37
+ ## By Chicken
38
+
39
+ ---
40
+
41
+ # Chicken
42
+ - Chicken
43
+ - Chicken Chicken
44
+
45
+ Save that as `test.md` and then use `mdpress test.md` to convert it to a presentation.
46
+ `mdpress` uses [Redcarpet](https://github.com/tanoku/redcarpet), so it can parse whatever markdown you throw at it.
47
+ We use the horizonal rule, `---`, to indicate the start of a new slide.
48
+
49
+ ### Getting Fancy: adding transformations
50
+
51
+ So far the slide transitions haven't been that exciting. Let's spice them up.
52
+ Below the `---`, type:
53
+
54
+ = data-x="1000"
55
+
56
+ And re-compile with `mdpress test.md` (you might have to delete your old presentation directory first).
57
+
58
+ Aha! Not bad! We specify transformations with `= [list of transformations]` as the first line of whatever slide we want to apply the transformation to.
59
+
60
+ We could have written
61
+
62
+ = data-x="1000" data-scale="2"
63
+
64
+ To make it scale as well as swipe.
65
+
66
+ ## Possible Attributes
67
+
68
+ - `data-x`, `data-y`, `data-z`: positioning
69
+ - `data-rotate-x`, `data-rotate-y`, 'data-rotate-z`, `data-rotate`: rotation (`data-rotate` and `data-rotate-z` are exactly the same)
70
+ - `data-scale`: scale
71
+ - `id`: used as the slide link. For example, if you use `id=intro`, you can link to that slide using `index.html#/intro`.
72
+
73
+ See [impress.js](https://github.com/bartaz/impress.js/blob/master/index.html) for a broader description of these.
74
+
75
+ Adding this syntax to Markdown feels like kind of a hack, but it's concise. I'm open to suggestions for something better.
76
+
77
+ ## Auto-update
78
+
79
+ Earlier, our workflow involved having to delete the old presentation and recompile every time we made an edit. The better choice is to use the automatic mode:
80
+
81
+ mdpress -a [filename.md]
82
+
83
+ Now, `mdpress` will keep running and check for updates to your markdown file. It will automatically recompile the presentation for you, so you can seamlessly edit your markdown and view your changes instantly.
84
+
85
+ ## Stylesheets
86
+
87
+ `mdpress` comes with a default stylesheet, plus a few more. See the full list of available stylesheets with
88
+
89
+ mdpress -l
90
+
91
+ Or specify a stylesheet to use with
92
+
93
+ mdpress -s [stylesheet]
94
+
95
+ If you make your own stylesheets, send me a pull request and I'll add them to the list! See below.
96
+
97
+ You can also create your own local theme:
98
+
99
+ 1. Use the 'lib/impress_css/' files as a model to work from.
100
+ 2. Create a folder called 'themes' in the directory where your markdown
101
+ file is. Inside it put the [yourtheme].css and [yourtheme].html files
102
+ 3. Call mdpress -s [yourtheme] and mdpress will look for the two theme
103
+ files in themes/ matching that name.
104
+
105
+ ## Running a presentation
106
+
107
+ Someone emailed you a `mdpress` presentation. Now you want to **just run it**? Sure:
108
+
109
+ mdpress -r [filename.md]
110
+
111
+ That will automatically compile the presentation and open it in a browser window.
112
+
113
+ ## Latex Support
114
+
115
+ mdpress now has Latex support through [MathJax](http://www.mathjax.org/). To build your presentation with latex support, use the `--latex` flag.
116
+
117
+ Put your latex code between a pair of `$$`'s, like this:
118
+
119
+ # Latex!
120
+ $$e^{\imath\pi} = -1$$
121
+
122
+ **Note**: you might run into conflicts between markdown and latex. For example, `_` means emphasize in markdown. So if you want subscripts, escape `_`:
123
+
124
+ $a_x$ # wrong, x will be italic
125
+ $a\_x$ # right, x will be a subscript
126
+
127
+ ## Metadata
128
+
129
+ Metadata can be set via YAML-Frontmatter. Have a look at the examples for further information. For example, if you want to set a title, put this at the top of the markdown file:
130
+
131
+ ---
132
+ title: All about chicken
133
+ ---
134
+
135
+
136
+ ## Contributing
137
+
138
+ To contribute a new stylesheet, follow these steps:
139
+
140
+ 1. Fork this repo.
141
+ 2. Place your new stylesheet in `lib/impress_css/[your stylesheet name].css`
142
+ 3. Send me a pull request!
143
+
144
+ ## Contributors
145
+
146
+ - Mte90
147
+
148
+ ## License (MIT)
149
+
150
+ Copyright (C) 2012 by Aditya Bhargava
151
+
152
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
153
+
154
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
155
+
156
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bin/mdpress CHANGED
@@ -6,6 +6,7 @@ require 'impress_renderer'
6
6
  require 'trollop'
7
7
  require 'tempfile'
8
8
  require 'launchy'
9
+ require 'yaml'
9
10
 
10
11
  THEMES_DIRNAME = './themes/'
11
12
 
@@ -43,15 +44,23 @@ def readfile file
43
44
  end
44
45
  end
45
46
 
47
+ def extract_metadata text
48
+ if md = text.match(/\A(---\s*\n.*?\n?)^(---\s*$\n?)/m)
49
+ [md.post_match, YAML.load(md[1])]
50
+ else
51
+ [text, {}]
52
+ end
53
+ end
54
+
46
55
  def render opts
47
- text = readfile(FILENAME)
56
+ text, metadata = extract_metadata(readfile(FILENAME))
48
57
  # ugly hack to get attributes for impress.js
49
58
  # TODO make this pretty
50
59
  lines = text.split("\n")
51
60
  lines.drop_while { |l| l =~ /^\s*$/ }
52
61
 
53
62
  attrs = [""]
54
-
63
+
55
64
  new_lines = []
56
65
  lines.each_with_index do |line, i|
57
66
  if line =~ /^=(.*)$/ && (i == 0 || lines[i-1] =~ /^(-\s*){3,}$/)
@@ -69,10 +78,10 @@ def render opts
69
78
  # now use those attributes and render the file
70
79
  include Redcarpet
71
80
  ImpressRenderer.init_with_attrs attrs, opts
81
+ ImpressRenderer.author= metadata['author'] if metadata['author']
82
+ ImpressRenderer.title= metadata['title'] if metadata['title']
72
83
  if File.exist?(STYLESHEET_HEAD)
73
- ImpressRenderer.set_head(File.read(STYLESHEET_HEAD))
74
- else
75
- ImpressRenderer.set_head("")
84
+ ImpressRenderer.head= File.read(STYLESHEET_HEAD)
76
85
  end
77
86
 
78
87
  m = Markdown.new(ImpressRenderer, :autolink => true, :fenced_code_blocks => true, :tables => true)
@@ -117,7 +126,7 @@ end
117
126
  if File.exist?(THEMES_DIRNAME + "#{OPTS[:stylesheet]}.css")
118
127
  STYLESHEET = THEMES_DIRNAME + "#{OPTS[:stylesheet]}.css"
119
128
  STYLESHEET_HEAD = THEMES_DIRNAME + "#{OPTS[:stylesheet]}.html"
120
- else
129
+ else
121
130
  STYLESHEET = base_dir + "impress_css/#{OPTS[:stylesheet]}.css"
122
131
  STYLESHEET_HEAD = base_dir + "impress_css/#{OPTS[:stylesheet]}.html"
123
132
  end
data/examples/code.md ADDED
@@ -0,0 +1,6 @@
1
+ # Here's some code!
2
+
3
+ def fib x
4
+ return x if x < 2
5
+ fib(x - 1) + fib(x - 2)
6
+ end
data/examples/demo.md ADDED
@@ -0,0 +1,24 @@
1
+ ---
2
+ author: Aditya Bhargava
3
+ title: All about chicken
4
+ ---
5
+ # Just because
6
+ ## my middle name
7
+
8
+ is **Pancake**,
9
+
10
+ > doesn't mean you can put syrup on me before I'm ready to come out of the oven.
11
+
12
+ mdpress++
13
+
14
+ ---
15
+ = data-x='1000'
16
+ # Let's Make Lists!
17
+
18
+ 1. Chicken
19
+ 2. *Emphasized Chicken*
20
+ 3. [Chicken Link](http://github.com/egonschiele/mdpress)
21
+
22
+ - unordered `chicken = 1`
23
+
24
+
@@ -0,0 +1,7 @@
1
+ # Hello
2
+ ## World!
3
+
4
+ ---
5
+ = data-x='1000'
6
+
7
+ # Hi, mdpress!
@@ -2,7 +2,7 @@ require 'redcarpet'
2
2
  class ImpressRenderer < Redcarpet::Render::HTML
3
3
  @@attrs = []
4
4
  @@current = 0
5
- @@head = ""
5
+ @@author, @@head, @@title = nil
6
6
 
7
7
  def self.init_with_attrs _attrs, _opts
8
8
  @@attrs = _attrs
@@ -10,10 +10,18 @@ class ImpressRenderer < Redcarpet::Render::HTML
10
10
  @@opts = _opts
11
11
  end
12
12
 
13
- def self.set_head head
13
+ def self.author= author
14
+ @@author = "<meta name=\"author\" content=\"#{author}\">"
15
+ end
16
+
17
+ def self.head= head
14
18
  @@head = head
15
19
  end
16
20
 
21
+ def self.title= title
22
+ @@title = "<title>#{title}</title>"
23
+ end
24
+
17
25
  def hrule
18
26
  # this is how we later inject attributes into pages. what an awful hack.
19
27
  @@current += 1
@@ -47,7 +55,9 @@ class ImpressRenderer < Redcarpet::Render::HTML
47
55
  %{<!DOCTYPE html>
48
56
  <html>
49
57
  <head>
58
+ #{@@title}
50
59
  <link href="css/reset.css" rel="stylesheet" />
60
+ #{@@author}
51
61
  <meta charset="utf-8" />
52
62
  <meta name="viewport" content="width=1024" />
53
63
  <meta name="apple-mobile-web-app-capable" content="yes" />
metadata CHANGED
@@ -1,87 +1,89 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mdpress
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.14
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 15
10
+ version: 0.0.15
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Aditya Bhargava
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-10-29 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-10-29 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: redcarpet
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: trollop
32
- requirement: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
33
24
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: trollop
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: launchy
48
- requirement: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
49
38
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
54
46
  type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: launchy
55
50
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: httparty
64
- requirement: !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
65
52
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
70
60
  type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: httparty
71
64
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
73
66
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :runtime
75
+ version_requirements: *id004
78
76
  description: Build impress.js presentations from markdown files.
79
77
  email: bluemangroupie@gmail.com
80
- executables:
78
+ executables:
81
79
  - mdpress
82
80
  extensions: []
81
+
83
82
  extra_rdoc_files: []
84
- files:
83
+
84
+ files:
85
+ - README.md
86
+ - LICENSE
85
87
  - lib/css/apple-touch-icon.png
86
88
  - lib/css/favicon.png
87
89
  - lib/css/highlight.css
@@ -127,29 +129,41 @@ files:
127
129
  - lib/js/highlight.pack.js
128
130
  - lib/js/impress.js
129
131
  - bin/mdpress
130
- - bin/test.md
132
+ - examples/code.md
133
+ - examples/demo.md
134
+ - examples/helloworld.md
131
135
  homepage: https://github.com/egonSchiele/mdpress
132
136
  licenses: []
137
+
133
138
  post_install_message:
134
139
  rdoc_options: []
135
- require_paths:
140
+
141
+ require_paths:
136
142
  - lib
137
- required_ruby_version: !ruby/object:Gem::Requirement
143
+ required_ruby_version: !ruby/object:Gem::Requirement
138
144
  none: false
139
- requirements:
140
- - - ! '>='
141
- - !ruby/object:Gem::Version
142
- version: '0'
143
- required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
151
+ version: "0"
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
153
  none: false
145
- requirements:
146
- - - ! '>='
147
- - !ruby/object:Gem::Version
148
- version: '0'
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 3
158
+ segments:
159
+ - 0
160
+ version: "0"
149
161
  requirements: []
162
+
150
163
  rubyforge_project:
151
164
  rubygems_version: 1.8.25
152
165
  signing_key:
153
166
  specification_version: 3
154
167
  summary: Build impress.js presentations from markdown files.
155
168
  test_files: []
169
+
data/bin/test.md DELETED
@@ -1,2 +0,0 @@
1
- # Hello
2
- World!