vimdeck-without-ascii-art 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +138 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/bin/vimdeck +110 -0
- data/bin/vimdeck-without-ascii-art +110 -0
- data/img/demo1.png +0 -0
- data/img/demo2.png +0 -0
- data/img/demo3.png +0 -0
- data/img/demo4.png +0 -0
- data/img/vim.png +0 -0
- data/lib/templates/script.vim.erb +40 -0
- data/lib/vimdeck.rb +255 -0
- data/presentation/script.vim +67 -0
- data/presentation/slide001.md +92 -0
- data/presentation/slide002.md +106 -0
- data/presentation/slide003.md +90 -0
- data/presentation/slide004.md +90 -0
- data/presentation/slide005.md +91 -0
- data/presentation/slide006.md +91 -0
- data/presentation/slide007.md +91 -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 +97 -0
- data/presentation/slide015.md +95 -0
- data/presentation/slide016.md +95 -0
- data/presentation/slide017.md +95 -0
- data/presentation/slide018.md +95 -0
- data/presentation/slide019.md +87 -0
- data/slides.md +233 -0
- data/vimdeck-without-ascii-art.gemspec +25 -0
- data/vimdeck.gemspec +25 -0
- metadata +110 -0
data/img/demo1.png
ADDED
Binary file
|
data/img/demo2.png
ADDED
Binary file
|
data/img/demo3.png
ADDED
Binary file
|
data/img/demo4.png
ADDED
Binary file
|
data/img/vim.png
ADDED
Binary file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
set nonumber
|
2
|
+
set nofoldenable
|
3
|
+
if exists('+relativenumber')
|
4
|
+
set norelativenumber
|
5
|
+
end
|
6
|
+
set hidden
|
7
|
+
<% if @options[:no_filetype] %>
|
8
|
+
argdo set filetype=txt
|
9
|
+
set filetype=txt
|
10
|
+
filetype off
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
noremap <PageUp> :bp<CR>
|
14
|
+
noremap <Left> :bp<CR>
|
15
|
+
<% if @options[:mouse_enabled] -%>
|
16
|
+
noremap <RightMouse> :bp<CR>
|
17
|
+
<% end -%>
|
18
|
+
noremap <PageDown> :bn<CR>
|
19
|
+
noremap <Right> :bn<CR>
|
20
|
+
<% if @options[:mouse_enabled] -%>
|
21
|
+
noremap <LeftMouse> :bn<CR>
|
22
|
+
<% end -%>
|
23
|
+
noremap Q :q<CR>
|
24
|
+
|
25
|
+
<% if @options[:mouse_enabled] -%>
|
26
|
+
set mouse=a
|
27
|
+
|
28
|
+
<% end -%>
|
29
|
+
<% @buffers.each do |buffer| -%>
|
30
|
+
b <%= buffer[:num] %>
|
31
|
+
<% if buffer[:code] -%>
|
32
|
+
<% buffer[:code].each do |code| -%>
|
33
|
+
<%= code[:start] %>,<%= code[:end] %>SyntaxInclude <%= code[:language] %>
|
34
|
+
<% end -%>
|
35
|
+
<% end -%>
|
36
|
+
<% buffer[:comments].each do |comment| -%>
|
37
|
+
call matchadd("Comment", "<%= comment %>")
|
38
|
+
<% end -%>
|
39
|
+
<% end -%>
|
40
|
+
b 1
|
data/lib/vimdeck.rb
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'artii'
|
4
|
+
require 'erb'
|
5
|
+
require 'redcarpet'
|
6
|
+
|
7
|
+
$nl = "\n"
|
8
|
+
|
9
|
+
module Vimdeck
|
10
|
+
# Helper methods for ascii art conversion
|
11
|
+
class Ascii
|
12
|
+
def self.header(text, type)
|
13
|
+
if font_name = Vimdeck::Slideshow.options[:header_font]
|
14
|
+
begin
|
15
|
+
font = Artii::Base.new :font => font_name
|
16
|
+
rescue
|
17
|
+
raise "Incorrect figlet font name"
|
18
|
+
end
|
19
|
+
else
|
20
|
+
if type == "large"
|
21
|
+
font = Artii::Base.new :font => 'slant'
|
22
|
+
else
|
23
|
+
font = Artii::Base.new :font => 'smslant'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
font.asciify(text)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.image(img)
|
31
|
+
# a = AsciiArt.new(img)
|
32
|
+
# a.to_ascii_art width: 30
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Custom Redcarpet renderer handles headers and images
|
37
|
+
# Code blocks are ignored by the renderer because they have to be
|
38
|
+
# measured for the vimscript, so parsing of the fenced code blocks
|
39
|
+
# happens in the slideshow generator itself
|
40
|
+
class Render < Redcarpet::Render::Base
|
41
|
+
# Methods where the first argument is the text content
|
42
|
+
[
|
43
|
+
# block-level calls
|
44
|
+
:block_quote,
|
45
|
+
:block_html, :list_item,
|
46
|
+
|
47
|
+
# span-level calls
|
48
|
+
:autolink,
|
49
|
+
:underline, :raw_html,
|
50
|
+
:strikethrough,
|
51
|
+
:superscript,
|
52
|
+
|
53
|
+
# footnotes
|
54
|
+
:footnotes, :footnote_def, :footnote_ref,
|
55
|
+
|
56
|
+
# low level rendering
|
57
|
+
:entity, :normal_text
|
58
|
+
].each do |method|
|
59
|
+
define_method method do |*args|
|
60
|
+
args.first
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def code_span(text)
|
65
|
+
return "`#{text}`"
|
66
|
+
end
|
67
|
+
|
68
|
+
def emphasis(text)
|
69
|
+
return "*#{text}*"
|
70
|
+
end
|
71
|
+
|
72
|
+
def double_emphasis(text)
|
73
|
+
return "**#{text}**"
|
74
|
+
end
|
75
|
+
|
76
|
+
def triple_emphasis(text)
|
77
|
+
return "***#{text}***"
|
78
|
+
end
|
79
|
+
|
80
|
+
def list(content, type)
|
81
|
+
if type == :unordered
|
82
|
+
"<!~#{content}~!>#{$nl}#{$nl}"
|
83
|
+
else
|
84
|
+
"<@~#{content}~@>#{$nl}#{$nl}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def header(title, level)
|
89
|
+
margin = Vimdeck::Slideshow.options[:header_margin]
|
90
|
+
linebreak = margin ? "#{$nl}" * margin : "#{$nl}"
|
91
|
+
if !Vimdeck::Slideshow.options[:no_ascii]
|
92
|
+
case level
|
93
|
+
when 1
|
94
|
+
heading = Vimdeck::Ascii.header(title, "large")
|
95
|
+
if Vimdeck::Slideshow.options[:no_indent]
|
96
|
+
heading = " " + heading.gsub( /\r\n?|\n/, "#{$nl} " ) + linebreak
|
97
|
+
else
|
98
|
+
heading + linebreak
|
99
|
+
end
|
100
|
+
when 2
|
101
|
+
heading = Vimdeck::Ascii.header(title, "small")
|
102
|
+
if Vimdeck::Slideshow.options[:no_indent]
|
103
|
+
heading = " " + heading.gsub( /\r\n?|\n/, "#{$nl} " ) + linebreak
|
104
|
+
else
|
105
|
+
heading + linebreak
|
106
|
+
end
|
107
|
+
end
|
108
|
+
else
|
109
|
+
title + "#{$nl}#{$nl}"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def link(link, title, content)
|
114
|
+
content
|
115
|
+
end
|
116
|
+
|
117
|
+
def paragraph(text)
|
118
|
+
text + "#{$nl}#{$nl}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def block_code(code, language)
|
122
|
+
"```#{language}#{$nl}#{code}#{$nl}```"
|
123
|
+
end
|
124
|
+
|
125
|
+
def image(image, title, alt_text)
|
126
|
+
# Vimdeck::Ascii.image(image)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class Slideshow
|
131
|
+
@options = {}
|
132
|
+
|
133
|
+
def self.options
|
134
|
+
@options
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.slide_padding
|
138
|
+
@options[:no_indent] ? "" : " "
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.script_template
|
142
|
+
template = ERB.new(File.read(File.dirname(__FILE__) + "/templates/script.vim.erb"), nil, '-')
|
143
|
+
template.result(binding)
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.generate(filename, options)
|
147
|
+
@options = options
|
148
|
+
extension = options[:no_filetype] ? ".txt" : ".md"
|
149
|
+
if options[:dos_newlines]
|
150
|
+
$nl = "\r\n"
|
151
|
+
end
|
152
|
+
slides = File.read(filename)
|
153
|
+
|
154
|
+
renderer = Redcarpet::Markdown.new(Vimdeck::Render, :fenced_code_blocks => true)
|
155
|
+
Dir.mkdir("presentation") unless File.exists?("presentation")
|
156
|
+
@buffers = []
|
157
|
+
|
158
|
+
# Slide separator is 3 newlines
|
159
|
+
slides = slides.split(/(?:\r\n?|\n)(?:\r\n?|\n)(?:\r\n?|\n)/)
|
160
|
+
i = 0
|
161
|
+
slides.each do |slide|
|
162
|
+
# Pad file names with zeros. e.g. slide001.md, slide023.md, etc.
|
163
|
+
slide_num = "%03d" % (i+1)
|
164
|
+
slide = renderer.render(slide)
|
165
|
+
|
166
|
+
regex = /\<\@\~(.*?)\~\@\>/m
|
167
|
+
match = slide.match(regex)
|
168
|
+
while match && match[1] && match.post_match do
|
169
|
+
list = match[1].split(/\r\n?|\n/)
|
170
|
+
j = 0
|
171
|
+
list = list.map do |li|
|
172
|
+
j += 1
|
173
|
+
"#{j}. #{li}"
|
174
|
+
end
|
175
|
+
slide.sub!(regex, list.join($nl))
|
176
|
+
match = match.post_match.match(regex)
|
177
|
+
end
|
178
|
+
|
179
|
+
regex = /\<\!\~(.*?)\~\!\>/m
|
180
|
+
match = slide.match(regex)
|
181
|
+
while match && match[1] && match.post_match do
|
182
|
+
list = match[1].split(/\r\n?|\n/)
|
183
|
+
list = list.map do |li|
|
184
|
+
"\u2022 #{li}"
|
185
|
+
end
|
186
|
+
slide.sub!(regex, list.join($nl))
|
187
|
+
match = match.post_match.match(regex)
|
188
|
+
end
|
189
|
+
|
190
|
+
# buffer gets stashed into @buffers array for script template
|
191
|
+
# needs to track things like the buffer number, code highlighting
|
192
|
+
# and focus/unfocus stuff
|
193
|
+
buffer = {:num => i + 1}
|
194
|
+
code_height = 0
|
195
|
+
code = nil
|
196
|
+
code = slide.match( /```([^\r\n]*)(\r\n?|\n).*(\r\n?|\n)```/m )
|
197
|
+
if code
|
198
|
+
buffer[:code] = []
|
199
|
+
code_hash = { :language => code[1] }
|
200
|
+
code_height = code[0].split(/\r\n?|\n/).length - 2
|
201
|
+
code = code[0].gsub( /```[^\r\n]*(\r\n?|\n)/, '' ).gsub( /(\r\n?|\n)```/, '' )
|
202
|
+
slide = slide.gsub( /```[^\r\n]*(\r\n?|\n)/, '' ).gsub( /(\r\n?|\n)```/, '' )
|
203
|
+
|
204
|
+
if code_height > 0
|
205
|
+
start = slide.index(code)
|
206
|
+
start = slide[0..start].split(/\r\n?|\n/).length
|
207
|
+
code_hash[:end] = code_height + start - 1
|
208
|
+
code_hash[:start] = start
|
209
|
+
end
|
210
|
+
buffer[:code] << code_hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Prepending each line with slide_padding
|
214
|
+
# Removing trailing spaces
|
215
|
+
# Add newlines at end of the file to hide the slide identifier
|
216
|
+
slide = slide_padding + slide.gsub( /\r\n?|\n/, "#{$nl}#{slide_padding}" ).gsub( / *$/, "" ) + ($nl * 80) + "slide #{slide_num}"
|
217
|
+
|
218
|
+
# Buffers comments refers to items that need to be less focused/"unhighlighted"
|
219
|
+
# We add a regex to the vimscript for each slide with "comments"
|
220
|
+
# We use the hidden slide identifier to differentiate between slides
|
221
|
+
regex = /\{\~(.*?)\~\}/m
|
222
|
+
match = slide.match(regex)
|
223
|
+
buffer[:comments] = []
|
224
|
+
while match && match[1] && match.post_match do
|
225
|
+
slide.sub!(regex, match[1])
|
226
|
+
pattern = match[1] + "||(||_.*slide #{slide_num}||)||@="
|
227
|
+
buffer[:comments] << pattern.gsub(/\r\n?|\n/, "||n").gsub(/\[/, "||[").gsub(/\]/, "||]").gsub(/\|/, "\\").gsub(/\"/, "\\\"")
|
228
|
+
match = match.post_match.match(regex)
|
229
|
+
end
|
230
|
+
|
231
|
+
File.open("presentation/slide#{slide_num}#{extension}", "w") do |file|
|
232
|
+
file.write("#{slide}#{$nl}")
|
233
|
+
end
|
234
|
+
|
235
|
+
@buffers << buffer
|
236
|
+
i += 1
|
237
|
+
end
|
238
|
+
|
239
|
+
File.open("presentation/script.vim", "w") do |file|
|
240
|
+
file.write script_template
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def self.open
|
245
|
+
extension = @options[:no_filetype] ? ".txt" : ".md"
|
246
|
+
editor = options[:editor] || "vim"
|
247
|
+
exec "#{editor} presentation/*#{extension} -S presentation/script.vim"
|
248
|
+
end
|
249
|
+
|
250
|
+
def self.start(filename, options)
|
251
|
+
generate(filename, options)
|
252
|
+
open
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
set nonumber
|
2
|
+
set nofoldenable
|
3
|
+
if exists('+relativenumber')
|
4
|
+
set norelativenumber
|
5
|
+
end
|
6
|
+
set hidden
|
7
|
+
|
8
|
+
|
9
|
+
noremap <PageUp> :bp<CR>
|
10
|
+
noremap <Left> :bp<CR>
|
11
|
+
noremap <PageDown> :bn<CR>
|
12
|
+
noremap <Right> :bn<CR>
|
13
|
+
noremap Q :q<CR>
|
14
|
+
|
15
|
+
b 1
|
16
|
+
b 2
|
17
|
+
b 3
|
18
|
+
b 4
|
19
|
+
b 5
|
20
|
+
call matchadd("Comment", "\\n • Second\\n • Third\\(\\_.*slide 005\\)\\@=")
|
21
|
+
b 6
|
22
|
+
call matchadd("Comment", "• First\\(\\_.*slide 006\\)\\@=")
|
23
|
+
call matchadd("Comment", "\\n • Third\\(\\_.*slide 006\\)\\@=")
|
24
|
+
b 7
|
25
|
+
call matchadd("Comment", "• First\\n • Second\\(\\_.*slide 007\\)\\@=")
|
26
|
+
b 8
|
27
|
+
6,17SyntaxInclude ruby
|
28
|
+
b 9
|
29
|
+
6,17SyntaxInclude ruby
|
30
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def can\\n highlight = \\(\\_.*slide 009\\)\\@=")
|
31
|
+
call matchadd("Comment", "\\n end\\n end\\n end\\(\\_.*slide 009\\)\\@=")
|
32
|
+
b 10
|
33
|
+
6,17SyntaxInclude ruby
|
34
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def\\(\\_.*slide 010\\)\\@=")
|
35
|
+
call matchadd("Comment", "highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 010\\)\\@=")
|
36
|
+
b 11
|
37
|
+
6,17SyntaxInclude ruby
|
38
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def can\\(\\_.*slide 011\\)\\@=")
|
39
|
+
call matchadd("Comment", "= \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 011\\)\\@=")
|
40
|
+
b 12
|
41
|
+
6,17SyntaxInclude ruby
|
42
|
+
call matchadd("Comment", "module\\(\\_.*slide 012\\)\\@=")
|
43
|
+
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 012\\)\\@=")
|
44
|
+
b 13
|
45
|
+
6,17SyntaxInclude ruby
|
46
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def slide\\(\\_.*slide 013\\)\\@=")
|
47
|
+
call matchadd("Comment", "end\\n\\n def can\\n highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 013\\)\\@=")
|
48
|
+
b 14
|
49
|
+
6,17SyntaxInclude ruby
|
50
|
+
call matchadd("Comment", "module Parts\\n class foo\\n def\\(\\_.*slide 014\\)\\@=")
|
51
|
+
call matchadd("Comment", "\"of a\"\\n end\\n\\n def can\\n highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 014\\)\\@=")
|
52
|
+
b 15
|
53
|
+
6,16SyntaxInclude javascript
|
54
|
+
b 16
|
55
|
+
6,16SyntaxInclude javascript
|
56
|
+
call matchadd("Comment", "(function( window, $, undefined ) {\\n $( '.hello' ).on( 'click', function sayHello() {\\(\\_.*slide 016\\)\\@=")
|
57
|
+
call matchadd("Comment", "\\n });\\n })( window, jQuery );\\(\\_.*slide 016\\)\\@=")
|
58
|
+
b 17
|
59
|
+
6,16SyntaxInclude javascript
|
60
|
+
call matchadd("Comment", "<body>\\(\\_.*slide 017\\)\\@=")
|
61
|
+
call matchadd("Comment", "</body>\\(\\_.*slide 017\\)\\@=")
|
62
|
+
b 18
|
63
|
+
6,16SyntaxInclude javascript
|
64
|
+
call matchadd("Comment", "(function( window, $, undefined ) {\\n $( '.hello' ).on( 'click', function sayHello() {\\(\\_.*slide 018\\)\\@=")
|
65
|
+
call matchadd("Comment", "\\n });\\n })( window, jQuery );\\n\\n <body>\\n <a href=\"#\" class=\"hello\">Hello!</a>\\n </body>\\(\\_.*slide 018\\)\\@=")
|
66
|
+
b 19
|
67
|
+
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 001
|