vimdeck 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -4
- data/VERSION +1 -1
- data/bin/vimdeck +1 -1
- data/lib/templates/script.vim.erb +2 -0
- data/lib/vimdeck.rb +141 -93
- data/presentation/script.vim +111 -0
- data/presentation/slide001.md +92 -0
- data/presentation/slide002.md +105 -0
- data/presentation/slide003.md +89 -0
- data/presentation/slide004.md +90 -0
- data/presentation/slide005.md +90 -0
- data/presentation/slide006.md +90 -0
- data/presentation/slide007.md +97 -0
- data/presentation/slide008.md +97 -0
- data/presentation/slide009.md +97 -0
- data/presentation/slide010.md +97 -0
- data/presentation/slide011.md +97 -0
- data/presentation/slide012.md +97 -0
- data/presentation/slide013.md +97 -0
- data/presentation/slide014.md +87 -0
- data/vimdeck-0.0.9.gem +0 -0
- data/vimdeck.gemspec +1 -0
- metadata +34 -1
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
The MIT License (MIT)
|
3
|
+
|
4
|
+
Copyright (c) [year] [fullname]
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
8
|
+
the Software without restriction, including without limitation the rights to
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
10
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
11
|
+
subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
19
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
20
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
21
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
#
|
1
|
+
# Vimdeck
|
2
2
|
|
3
3
|
VIM as a presentation tool
|
4
4
|
|
5
5
|
|
6
|
+
## News
|
7
|
+
|
8
|
+
Vimdeck now uses [redcarpet](http://github.com/vmg/redcarpet) to parse and render markdown!
|
9
|
+
|
10
|
+
I've cleaned up the code significantly. So those of you who like more features in Vimdeck
|
11
|
+
can fork and pull-request your buns off.
|
12
|
+
|
13
|
+
|
6
14
|
## Installation
|
7
15
|
|
8
16
|
Install the vim plugin [SyntaxRange](https://github.com/vim-scripts/SyntaxRange).
|
@@ -25,6 +33,7 @@ Vimdeck will also provide a script file that will set up keybindings for you.
|
|
25
33
|
|
26
34
|
- PageUp/Left go backwards
|
27
35
|
- PageDown/Right go forward
|
36
|
+
- Q closes presentation
|
28
37
|
|
29
38
|
|
30
39
|
## A Note about VIM
|
@@ -56,8 +65,8 @@ Example:
|
|
56
65
|
Is less important
|
57
66
|
```
|
58
67
|
|
59
|
-
Vimdeck
|
60
|
-
It uses a very small subset of markdown. List of items supported:
|
68
|
+
Vimdeck uses redcarpet to parse its markdown and implements a custom renderer
|
69
|
+
for things like ascii art. It uses a very small subset of markdown. List of items supported:
|
61
70
|
|
62
71
|
- h1s
|
63
72
|
- h2s
|
@@ -73,7 +82,22 @@ Fenced code blocks look like this:
|
|
73
82
|
this.is = 'code'
|
74
83
|
```
|
75
84
|
|
76
|
-
|
85
|
+
## Highlighting Syntax
|
86
|
+
|
87
|
+
Vimdeck also supports "highlighting" parts of a slide. This is an experimental feature and needs more testing.
|
88
|
+
|
89
|
+
Use `{~ unimportant_text_here ~}` to "unhighlight" portions of a slide:
|
90
|
+
|
91
|
+
# Slide Title
|
92
|
+
|
93
|
+
{~- Unimportant bullet~}
|
94
|
+
- Important bullet
|
95
|
+
{~- Really unimportant bullet~}
|
96
|
+
|
97
|
+
This allows you to create multiple versions of the same slide but with different parts highlighted.
|
98
|
+
Which is something I like to use often when presenting code snippets.
|
99
|
+
|
100
|
+
## Why Ruby?
|
77
101
|
|
78
102
|
Additionally, I want to point out that I realize that it's odd to have a VIM-based tool
|
79
103
|
and not write it as a VIM script. Ruby was my language of choice only because the ascii art dependencies
|
@@ -97,3 +121,10 @@ Vimdeck will also augment its vimscript to provide syntax highlighting
|
|
97
121
|
|
98
122
|
Images are even converted to ascii art!
|
99
123
|
![](img/demo4.png)
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
---------------------
|
129
|
+
|
130
|
+
Made by [tybenz](http://github.com/tybenz): [tybenz.com](http://tybenz.com) // [@tybenz](http://twitter.com/tybenz)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/bin/vimdeck
CHANGED
data/lib/vimdeck.rb
CHANGED
@@ -1,120 +1,168 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
require 'artii'
|
2
4
|
require 'asciiart'
|
3
5
|
require 'erb'
|
6
|
+
require 'redcarpet'
|
4
7
|
|
5
8
|
module Vimdeck
|
6
|
-
|
9
|
+
# Helper methods for ascii art conversion
|
10
|
+
class Ascii
|
11
|
+
def self.header(text, type)
|
12
|
+
if type == "large"
|
13
|
+
font = Artii::Base.new :font => 'slant'
|
14
|
+
else
|
15
|
+
font = Artii::Base.new :font => 'smslant'
|
16
|
+
end
|
7
17
|
|
8
|
-
|
9
|
-
if type == "large"
|
10
|
-
font = Artii::Base.new :font => 'slant'
|
11
|
-
else
|
12
|
-
font = Artii::Base.new :font => 'smslant'
|
18
|
+
font.asciify(text)
|
13
19
|
end
|
14
20
|
|
15
|
-
|
21
|
+
def self.image(img)
|
22
|
+
a = AsciiArt.new(img)
|
23
|
+
a.to_ascii_art width: 30
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
# Custom Redcarpet renderer handles headers and images
|
28
|
+
# Code blocks are ignored by the renderer because they have to be
|
29
|
+
# measured for the vimscript, so parsing of the fenced code blocks
|
30
|
+
# happens in the slideshow generator itself
|
31
|
+
class Render < Redcarpet::Render::Base
|
32
|
+
# Methods where the first argument is the text content
|
33
|
+
[
|
34
|
+
# block-level calls
|
35
|
+
:block_quote,
|
36
|
+
:block_html, :list, :list_item,
|
37
|
+
|
38
|
+
# span-level calls
|
39
|
+
:autolink, :codespan, :double_emphasis,
|
40
|
+
:emphasis, :underline, :raw_html,
|
41
|
+
:triple_emphasis, :strikethrough,
|
42
|
+
:superscript,
|
43
|
+
|
44
|
+
# footnotes
|
45
|
+
:footnotes, :footnote_def, :footnote_ref,
|
46
|
+
|
47
|
+
# low level rendering
|
48
|
+
:entity, :normal_text
|
49
|
+
].each do |method|
|
50
|
+
define_method method do |*args|
|
51
|
+
args.first
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def header(title, level)
|
56
|
+
case level
|
57
|
+
when 1
|
58
|
+
Vimdeck::Ascii.header(title, "large") + "\n"
|
59
|
+
|
60
|
+
when 2
|
61
|
+
Vimdeck::Ascii.header(title, "small") + "\n"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def link(link, title, content)
|
66
|
+
content
|
67
|
+
end
|
68
|
+
|
69
|
+
def paragraph(text)
|
70
|
+
text + "\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
def block_code(code, language)
|
74
|
+
"```#{language}\n#{code}\n```"
|
75
|
+
end
|
22
76
|
|
23
|
-
|
24
|
-
|
77
|
+
def image(image, title, alt_text)
|
78
|
+
Vimdeck::Ascii.image(image)
|
79
|
+
end
|
25
80
|
end
|
26
81
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
82
|
+
class Slideshow
|
83
|
+
def self.slide_padding
|
84
|
+
" "
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.script_template
|
88
|
+
template = ERB.new(File.read(File.dirname(__FILE__) + "/templates/script.vim.erb"))
|
89
|
+
template.result(binding)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.generate(filename)
|
93
|
+
slides = File.read(filename)
|
94
|
+
|
95
|
+
renderer = Redcarpet::Markdown.new(Vimdeck::Render, :fenced_code_blocks => true)
|
96
|
+
Dir.mkdir("presentation") unless File.exists?("presentation")
|
97
|
+
@buffers = []
|
98
|
+
|
99
|
+
# Slide separator is 3 newlines
|
100
|
+
slides = slides.split("\n\n\n")
|
101
|
+
i = 0
|
102
|
+
slides.each do |slide|
|
103
|
+
# Pad file names with zeros. e.g. slide001.md, slide023.md, etc.
|
104
|
+
slide_num = "%03d" % (i+1)
|
105
|
+
slide = renderer.render(slide)
|
106
|
+
|
107
|
+
# buffer gets stashed into @buffers array for script template
|
108
|
+
# needs to track things like the buffer number, code highlighting
|
109
|
+
# and focus/unfocus stuff
|
110
|
+
buffer = {:num => i + 1}
|
111
|
+
code_height = 0
|
112
|
+
code = nil
|
113
|
+
code = slide.match( /```([^\n]*)\n.*\n```/m )
|
114
|
+
if code
|
115
|
+
buffer[:code] = { :language => code[1] }
|
116
|
+
code_height = code[0].split("\n").length - 2
|
117
|
+
code = code[0].gsub( /```[^\n]*\n/, '' ).gsub( /\n```/, '' )
|
118
|
+
slide = slide.gsub( /```[^\n]*\n/, '' ).gsub( /\n```/, '' )
|
119
|
+
|
120
|
+
if code_height > 0
|
121
|
+
start = slide.index(code)
|
122
|
+
start = slide[0..start].split("\n").length
|
123
|
+
buffer[:code][:end] = code_height + start - 1
|
124
|
+
buffer[:code][:start] = start
|
58
125
|
end
|
59
126
|
end
|
60
|
-
end
|
61
127
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
buffer[:
|
128
|
+
# Prepending each line with slide_padding
|
129
|
+
# Removing trailing spaces
|
130
|
+
# Add newlines at end of the file to hide the slide identifier
|
131
|
+
slide = slide_padding + slide.gsub( /\n/, "\n#{slide_padding}" ).gsub( / *$/, "" ) + ("\n" * 80) + "slide #{i+1}"
|
132
|
+
|
133
|
+
# Buffers comments refers to items that need to be less focused/"unhighlighted"
|
134
|
+
# We add a regex to the vimscript for each slide with "comments"
|
135
|
+
# We use the hidden slide identifier to differentiate between slides
|
136
|
+
regex = /\{\~(.*?)\~\}/m
|
137
|
+
match = slide.match(regex)
|
138
|
+
buffer[:comments] = []
|
139
|
+
while match && match[1] && match.post_match do
|
140
|
+
slide.sub!(regex, match[1])
|
141
|
+
pattern = match[1] + "||(||_.*slide #{i+1}||)||@="
|
142
|
+
buffer[:comments] << pattern.gsub(/\n/, "||n").gsub(/\[/, "||[").gsub(/\]/, "||]").gsub(/\|/, "\\").gsub(/\"/, "\\\"")
|
143
|
+
match = match.post_match.match(regex)
|
77
144
|
end
|
78
|
-
end
|
79
145
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
spaces = " "
|
84
|
-
slide = slide.gsub( /\n/, "\n#{spaces}" )
|
85
|
-
slide = spaces + slide
|
86
|
-
slide = slide.gsub( / *\n/, "\n" ).gsub( / *$/, '' )
|
87
|
-
|
88
|
-
regex = /\{\~(.*?)\~\}/m
|
89
|
-
match = slide.match(regex)
|
90
|
-
buffer[:comments] = []
|
91
|
-
while match && match[1] && match.post_match do
|
92
|
-
slide.sub!(regex, match[1])
|
93
|
-
pattern = match[1] + "||(||_.*slide #{i+1}||)||@="
|
94
|
-
buffer[:comments] << pattern.gsub(/\n/, "||n").gsub(/\[/, "||[").gsub(/\]/, "||]").gsub(/\|/, "\\").gsub(/\"/, "\\\"")
|
95
|
-
match = match.post_match.match(regex)
|
96
|
-
end
|
97
|
-
|
98
|
-
filenum = "%03d" % (i+1)
|
146
|
+
File.open("presentation/slide#{slide_num}.md", "w") do |file|
|
147
|
+
file.write slide
|
148
|
+
end
|
99
149
|
|
100
|
-
|
101
|
-
|
150
|
+
@buffers << buffer
|
151
|
+
i += 1
|
102
152
|
end
|
103
153
|
|
104
|
-
|
154
|
+
File.open("presentation/script.vim", "w") do |file|
|
155
|
+
file.write script_template
|
156
|
+
end
|
105
157
|
end
|
106
158
|
|
107
|
-
|
108
|
-
|
159
|
+
def self.open
|
160
|
+
exec 'vim presentation/*.md -S presentation/script.vim'
|
109
161
|
end
|
110
|
-
end
|
111
162
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
def self.slideshow(file)
|
117
|
-
create_slides(file)
|
118
|
-
open_vim
|
163
|
+
def self.start(filename)
|
164
|
+
generate(filename)
|
165
|
+
open
|
166
|
+
end
|
119
167
|
end
|
120
168
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
set nonumber
|
2
|
+
noremap <PageUp> :bp<CR>
|
3
|
+
noremap <Left> :bp<CR>
|
4
|
+
noremap <PageDown> :bn<CR>
|
5
|
+
noremap <Right> :bn<CR>
|
6
|
+
noremap Q :q<CR>
|
7
|
+
|
8
|
+
|
9
|
+
b 1
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
b 2
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
b 3
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
b 4
|
22
|
+
|
23
|
+
|
24
|
+
call matchadd("Comment", "• Second\\n • Third\\(\\_.*slide 4\\)\\@=")
|
25
|
+
|
26
|
+
|
27
|
+
b 5
|
28
|
+
|
29
|
+
|
30
|
+
call matchadd("Comment", "• First\\(\\_.*slide 5\\)\\@=")
|
31
|
+
|
32
|
+
call matchadd("Comment", "• Third\\(\\_.*slide 5\\)\\@=")
|
33
|
+
|
34
|
+
|
35
|
+
b 6
|
36
|
+
|
37
|
+
|
38
|
+
call matchadd("Comment", "• First\\n • Second\\(\\_.*slide 6\\)\\@=")
|
39
|
+
|
40
|
+
|
41
|
+
b 7
|
42
|
+
|
43
|
+
6,17SyntaxInclude ruby
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
b 8
|
48
|
+
|
49
|
+
6,17SyntaxInclude ruby
|
50
|
+
|
51
|
+
|
52
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def can\\n highlight = \\(\\_.*slide 8\\)\\@=")
|
53
|
+
|
54
|
+
call matchadd("Comment", "\\n end\\n end\\n end\\(\\_.*slide 8\\)\\@=")
|
55
|
+
|
56
|
+
|
57
|
+
b 9
|
58
|
+
|
59
|
+
6,17SyntaxInclude ruby
|
60
|
+
|
61
|
+
|
62
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def\\(\\_.*slide 9\\)\\@=")
|
63
|
+
|
64
|
+
call matchadd("Comment", "highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 9\\)\\@=")
|
65
|
+
|
66
|
+
|
67
|
+
b 10
|
68
|
+
|
69
|
+
6,17SyntaxInclude ruby
|
70
|
+
|
71
|
+
|
72
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def can\\(\\_.*slide 10\\)\\@=")
|
73
|
+
|
74
|
+
call matchadd("Comment", "= \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 10\\)\\@=")
|
75
|
+
|
76
|
+
|
77
|
+
b 11
|
78
|
+
|
79
|
+
6,17SyntaxInclude ruby
|
80
|
+
|
81
|
+
|
82
|
+
call matchadd("Comment", "module\\(\\_.*slide 11\\)\\@=")
|
83
|
+
|
84
|
+
call matchadd("Comment", "class foo\\n def slide\\n \"of a\"\\n end\\n\\n def can\\n highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 11\\)\\@=")
|
85
|
+
|
86
|
+
|
87
|
+
b 12
|
88
|
+
|
89
|
+
6,17SyntaxInclude ruby
|
90
|
+
|
91
|
+
|
92
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\(\\_.*slide 12\\)\\@=")
|
93
|
+
|
94
|
+
call matchadd("Comment", "end\\n\\n def can\\n highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 12\\)\\@=")
|
95
|
+
|
96
|
+
|
97
|
+
b 13
|
98
|
+
|
99
|
+
6,17SyntaxInclude ruby
|
100
|
+
|
101
|
+
|
102
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def\\(\\_.*slide 13\\)\\@=")
|
103
|
+
|
104
|
+
call matchadd("Comment", "\"of a\"\\n end\\n\\n def can\\n highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 13\\)\\@=")
|
105
|
+
|
106
|
+
|
107
|
+
b 14
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
b 1
|
@@ -0,0 +1,92 @@
|
|
1
|
+
_ ________ _______ ______________ __
|
2
|
+
| | / / _/ |/ / __ \/ ____/ ____/ //_/
|
3
|
+
| | / // // /|_/ / / / / __/ / / / ,<
|
4
|
+
| |/ // // / / / /_/ / /___/ /___/ /| |
|
5
|
+
|___/___/_/ /_/_____/_____/\____/_/ |_|
|
6
|
+
|
7
|
+
___ __ _____ ____ ___ _ ______________ __ _______
|
8
|
+
/ _ \/ / / / _ \/ __/ / _ | | /| / / __/ __/ __ \/ |/ / __/
|
9
|
+
/ ___/ /_/ / , _/ _/ / __ | |/ |/ / _/_\ \/ /_/ / /|_/ / _/
|
10
|
+
/_/ \____/_/|_/___/ /_/ |_|__/|__/___/___/\____/_/ /_/___/
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
slide 1
|