vimdeck 0.2.7 → 0.2.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecfcbef00057585172595461eb3a2b60b69331f7
4
- data.tar.gz: c21d7b0e63853a5c6329ba06d0cda463a390cf6a
3
+ metadata.gz: b1928c2614e2144900d0176c064d1a749ad1edbd
4
+ data.tar.gz: 4b081ef26e29bbaa53143f25a94e9eca3ddf7152
5
5
  SHA512:
6
- metadata.gz: 5d3b4acc152f6e68449a14357e46130bf55cab1071cbf36e41e4cd12b5d163de60b9f4b876ae889db49323e55ccfcd0a8174495e2a3c33ea6ebbfa3fc0c21a20
7
- data.tar.gz: 67b5cd7a406a5dc6e34027d606de33e30261a7bfffe33626470a2e4d2aa9af59e1b4ad1c3c7bff1852a3ee8b82a5f80d0eac2181b8801cec094a4e8c7632769e
6
+ metadata.gz: c80c2fdbe180753d2ed06b845cc68cada53776fc95c7c6bfae7636e4c2233a42e6a9dac14b45c6a05eafe93255dbbc9b26b057499282aba8b3c0907e4a10e382
7
+ data.tar.gz: bd14cc85cece40b02268d301ebec04b9e91ea4b3eef2c5f780a9b18df092c0588c018293945cb18b5885a8dfe50517fa1118279d444c8d8b36d9c1793e3ca0bf
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
data/bin/vimdeck CHANGED
@@ -16,6 +16,7 @@
16
16
  #> --header-margin, -m bottom margin for headers. default: 1
17
17
  #> --header-font, -h specify header font (http://www.figlet.org/fontdb.cgi)
18
18
  #> foregoes the ability to have small and large headers
19
+ #> --editor, -e specify editor to use (e.g., vim, mvim)
19
20
 
20
21
  require "optparse"
21
22
  if ENV["VIMDECK_DEBUG"]
@@ -64,6 +65,18 @@ opt_parser = OptionParser.new do |opt|
64
65
  opt.on("-m", "--header-margin NUMBER", Numeric) do |option|
65
66
  options[:header_margin] = option
66
67
  end
68
+
69
+ opt.on("-d", "--dos-newlines") do
70
+ options[:dos_newlines] = true
71
+ end
72
+
73
+ opt.on("-e", "--editor EDITOR", String) do |option|
74
+ if option == "vim" || option == "mvim"
75
+ options[:editor] = option
76
+ else
77
+ raise "Not a valid editor: #{option}"
78
+ end
79
+ end
67
80
  end
68
81
 
69
82
  opt_parser.parse!
data/lib/vimdeck.rb CHANGED
@@ -5,6 +5,8 @@ require 'asciiart'
5
5
  require 'erb'
6
6
  require 'redcarpet'
7
7
 
8
+ $nl = "\n"
9
+
8
10
  module Vimdeck
9
11
  # Helper methods for ascii art conversion
10
12
  class Ascii
@@ -78,34 +80,34 @@ module Vimdeck
78
80
 
79
81
  def list(content, type)
80
82
  if type == :unordered
81
- "<!~#{content}~!>\n\n"
83
+ "<!~#{content}~!>#{$nl}#{$nl}"
82
84
  else
83
- "<@~#{content}~@>\n\n"
85
+ "<@~#{content}~@>#{$nl}#{$nl}"
84
86
  end
85
87
  end
86
88
 
87
89
  def header(title, level)
88
90
  margin = Vimdeck::Slideshow.options[:header_margin]
89
- linebreak = margin ? "\n" * margin : "\n"
91
+ linebreak = margin ? "#{$nl}" * margin : "#{$nl}"
90
92
  if !Vimdeck::Slideshow.options[:no_ascii]
91
93
  case level
92
94
  when 1
93
95
  heading = Vimdeck::Ascii.header(title, "large")
94
96
  if Vimdeck::Slideshow.options[:no_indent]
95
- heading = " " + heading.gsub( /\n/, "\n " ) + linebreak
97
+ heading = " " + heading.gsub( /\r\n?|\n/, "#{$nl} " ) + linebreak
96
98
  else
97
99
  heading + linebreak
98
100
  end
99
101
  when 2
100
102
  heading = Vimdeck::Ascii.header(title, "small")
101
103
  if Vimdeck::Slideshow.options[:no_indent]
102
- heading = " " + heading.gsub( /\n/, "\n " ) + linebreak
104
+ heading = " " + heading.gsub( /\r\n?|\n/, "#{$nl} " ) + linebreak
103
105
  else
104
106
  heading + linebreak
105
107
  end
106
108
  end
107
109
  else
108
- title + "\n\n"
110
+ title + "#{$nl}#{$nl}"
109
111
  end
110
112
  end
111
113
 
@@ -114,11 +116,11 @@ module Vimdeck
114
116
  end
115
117
 
116
118
  def paragraph(text)
117
- text + "\n\n"
119
+ text + "#{$nl}#{$nl}"
118
120
  end
119
121
 
120
122
  def block_code(code, language)
121
- "```#{language}\n#{code}\n```"
123
+ "```#{language}#{$nl}#{code}#{$nl}```"
122
124
  end
123
125
 
124
126
  def image(image, title, alt_text)
@@ -145,6 +147,9 @@ module Vimdeck
145
147
  def self.generate(filename, options)
146
148
  @options = options
147
149
  extension = options[:no_filetype] ? ".txt" : ".md"
150
+ if options[:dos_newlines]
151
+ $nl = "\r\n"
152
+ end
148
153
  slides = File.read(filename)
149
154
 
150
155
  renderer = Redcarpet::Markdown.new(Vimdeck::Render, :fenced_code_blocks => true)
@@ -152,7 +157,7 @@ module Vimdeck
152
157
  @buffers = []
153
158
 
154
159
  # Slide separator is 3 newlines
155
- slides = slides.split("\n\n\n")
160
+ slides = slides.split(/(?:\r\n?|\n)(?:\r\n?|\n)(?:\r\n?|\n)/)
156
161
  i = 0
157
162
  slides.each do |slide|
158
163
  # Pad file names with zeros. e.g. slide001.md, slide023.md, etc.
@@ -162,24 +167,24 @@ module Vimdeck
162
167
  regex = /\<\@\~(.*?)\~\@\>/m
163
168
  match = slide.match(regex)
164
169
  while match && match[1] && match.post_match do
165
- list = match[1].split("\n")
170
+ list = match[1].split(/\r\n?|\n/)
166
171
  j = 0
167
172
  list = list.map do |li|
168
173
  j += 1
169
174
  "#{j}. #{li}"
170
175
  end
171
- slide.sub!(regex, list.join("\n"))
176
+ slide.sub!(regex, list.join($nl))
172
177
  match = match.post_match.match(regex)
173
178
  end
174
179
 
175
180
  regex = /\<\!\~(.*?)\~\!\>/m
176
181
  match = slide.match(regex)
177
182
  while match && match[1] && match.post_match do
178
- list = match[1].split("\n")
183
+ list = match[1].split(/\r\n?|\n/)
179
184
  list = list.map do |li|
180
185
  "\u2022 #{li}"
181
186
  end
182
- slide.sub!(regex, list.join("\n"))
187
+ slide.sub!(regex, list.join($nl))
183
188
  match = match.post_match.match(regex)
184
189
  end
185
190
 
@@ -189,17 +194,17 @@ module Vimdeck
189
194
  buffer = {:num => i + 1}
190
195
  code_height = 0
191
196
  code = nil
192
- code = slide.match( /```([^\n]*)\n.*\n```/m )
197
+ code = slide.match( /```([^\r\n]*)(\r\n?|\n).*(\r\n?|\n)```/m )
193
198
  if code
194
199
  buffer[:code] = []
195
200
  code_hash = { :language => code[1] }
196
- code_height = code[0].split("\n").length - 2
197
- code = code[0].gsub( /```[^\n]*\n/, '' ).gsub( /\n```/, '' )
198
- slide = slide.gsub( /```[^\n]*\n/, '' ).gsub( /\n```/, '' )
201
+ code_height = code[0].split(/\r\n?|\n/).length - 2
202
+ code = code[0].gsub( /```[^\r\n]*(\r\n?|\n)/, '' ).gsub( /(\r\n?|\n)```/, '' )
203
+ slide = slide.gsub( /```[^\r\n]*(\r\n?|\n)/, '' ).gsub( /(\r\n?|\n)```/, '' )
199
204
 
200
205
  if code_height > 0
201
206
  start = slide.index(code)
202
- start = slide[0..start].split("\n").length
207
+ start = slide[0..start].split(/\r\n?|\n/).length
203
208
  code_hash[:end] = code_height + start - 1
204
209
  code_hash[:start] = start
205
210
  end
@@ -209,7 +214,7 @@ module Vimdeck
209
214
  # Prepending each line with slide_padding
210
215
  # Removing trailing spaces
211
216
  # Add newlines at end of the file to hide the slide identifier
212
- slide = slide_padding + slide.gsub( /\n/, "\n#{slide_padding}" ).gsub( / *$/, "" ) + ("\n" * 80) + "slide #{slide_num}"
217
+ slide = slide_padding + slide.gsub( /\r\n?|\n/, "#{$nl}#{slide_padding}" ).gsub( / *$/, "" ) + ($nl * 80) + "slide #{slide_num}"
213
218
 
214
219
  # Buffers comments refers to items that need to be less focused/"unhighlighted"
215
220
  # We add a regex to the vimscript for each slide with "comments"
@@ -220,12 +225,12 @@ module Vimdeck
220
225
  while match && match[1] && match.post_match do
221
226
  slide.sub!(regex, match[1])
222
227
  pattern = match[1] + "||(||_.*slide #{slide_num}||)||@="
223
- buffer[:comments] << pattern.gsub(/\n/, "||n").gsub(/\[/, "||[").gsub(/\]/, "||]").gsub(/\|/, "\\").gsub(/\"/, "\\\"")
228
+ buffer[:comments] << pattern.gsub(/\r\n?|\n/, "||n").gsub(/\[/, "||[").gsub(/\]/, "||]").gsub(/\|/, "\\").gsub(/\"/, "\\\"")
224
229
  match = match.post_match.match(regex)
225
230
  end
226
231
 
227
232
  File.open("presentation/slide#{slide_num}#{extension}", "w") do |file|
228
- file.write(slide + "\n")
233
+ file.write("#{slide}#{$nl}")
229
234
  end
230
235
 
231
236
  @buffers << buffer
@@ -239,7 +244,8 @@ module Vimdeck
239
244
 
240
245
  def self.open
241
246
  extension = @options[:no_filetype] ? ".txt" : ".md"
242
- exec "vim presentation/*#{extension} -S presentation/script.vim"
247
+ editor = options[:editor] || "vim"
248
+ exec "#{editor} presentation/*#{extension} -S presentation/script.vim"
243
249
  end
244
250
 
245
251
  def self.start(filename, options)
@@ -13,54 +13,4 @@ noremap Q :q<CR>
13
13
 
14
14
  b 1
15
15
  b 2
16
- b 3
17
- b 4
18
- b 5
19
- call matchadd("Comment", "\\n • Second\\n • Third\\(\\_.*slide 005\\)\\@=")
20
- b 6
21
- call matchadd("Comment", "• First\\(\\_.*slide 006\\)\\@=")
22
- call matchadd("Comment", "\\n • Third\\(\\_.*slide 006\\)\\@=")
23
- b 7
24
- call matchadd("Comment", "• First\\n • Second\\(\\_.*slide 007\\)\\@=")
25
- b 8
26
- 6,17SyntaxInclude ruby
27
- b 9
28
- 6,17SyntaxInclude ruby
29
- call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def can\\n highlight = \\(\\_.*slide 009\\)\\@=")
30
- call matchadd("Comment", "\\n end\\n end\\n end\\(\\_.*slide 009\\)\\@=")
31
- b 10
32
- 6,17SyntaxInclude ruby
33
- call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def\\(\\_.*slide 010\\)\\@=")
34
- call matchadd("Comment", "highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 010\\)\\@=")
35
- b 11
36
- 6,17SyntaxInclude ruby
37
- call matchadd("Comment", "module Parts\\n class foo\\n def slide\\n \"of a\"\\n end\\n\\n def can\\(\\_.*slide 011\\)\\@=")
38
- call matchadd("Comment", "= \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 011\\)\\@=")
39
- b 12
40
- 6,17SyntaxInclude ruby
41
- call matchadd("Comment", "module\\(\\_.*slide 012\\)\\@=")
42
- 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\\)\\@=")
43
- b 13
44
- 6,17SyntaxInclude ruby
45
- call matchadd("Comment", "module Parts\\n class foo\\n def slide\\(\\_.*slide 013\\)\\@=")
46
- call matchadd("Comment", "end\\n\\n def can\\n highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 013\\)\\@=")
47
- b 14
48
- 6,17SyntaxInclude ruby
49
- call matchadd("Comment", "module Parts\\n class foo\\n def\\(\\_.*slide 014\\)\\@=")
50
- call matchadd("Comment", "\"of a\"\\n end\\n\\n def can\\n highlight = \"vimdeck\"\\n end\\n end\\n end\\(\\_.*slide 014\\)\\@=")
51
- b 15
52
- 6,16SyntaxInclude javascript
53
- b 16
54
- 6,16SyntaxInclude javascript
55
- call matchadd("Comment", "(function( window, $, undefined ) {\\n $( '.hello' ).on( 'click', function sayHello() {\\(\\_.*slide 016\\)\\@=")
56
- call matchadd("Comment", "\\n });\\n })( window, jQuery );\\(\\_.*slide 016\\)\\@=")
57
- b 17
58
- 6,16SyntaxInclude javascript
59
- call matchadd("Comment", "<body>\\(\\_.*slide 017\\)\\@=")
60
- call matchadd("Comment", "</body>\\(\\_.*slide 017\\)\\@=")
61
- b 18
62
- 6,16SyntaxInclude javascript
63
- call matchadd("Comment", "(function( window, $, undefined ) {\\n $( '.hello' ).on( 'click', function sayHello() {\\(\\_.*slide 018\\)\\@=")
64
- call matchadd("Comment", "\\n });\\n })( window, jQuery );\\n\\n <body>\\n <a href=\"#\" class=\"hello\">Hello!</a>\\n </body>\\(\\_.*slide 018\\)\\@=")
65
- b 19
66
16
  b 1
@@ -1,92 +1,91 @@
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
1
+ _____ ___ __ ___
2
+ / ___// (_)___/ /__ < /
3
+ \__ \/ / / __ / _ \ / /
4
+ ___/ / / / /_/ / __/ / /
5
+ /____/_/_/\__,_/\___/ /_/
6
+
7
+ has some
8
+ really important
9
+ information
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
+ slide 001
@@ -1,106 +1,89 @@
1
- _ ________ ___ ____ ____ ________ _______ __
2
- | | / / _/ |/ / / __ \/ __ \/ ____/ //_/ ___// /
3
- | | / // // /|_/ / / /_/ / / / / / / ,< \__ \/ /
4
- | |/ // // / / / / _, _/ /_/ / /___/ /| |___/ /_/
5
- |___/___/_/ /_/ /_/ |_|\____/\____/_/ |_/____(_)
6
-
7
- +------------------------------+
8
- | ..:. |
9
- | ~+~========~+~.:=========: |
10
- | =o=oooooo=~~~~~+=oooooooo~ |
11
- | .+oooooo~~~~~~~=oooooo+.. |
12
- | .oooooo=~~~~~+ooooo=+:. |
13
- | :ooooo==~~~+ooooo=+~~:. |
14
- | .:~~=ooooo=++ooooo=+~~~~~~:. |
15
- |.:~~~=oooooooooooo+~~~~~~~~~~.|
16
- | :~oooooooooo==~~~~~~~~~. |
17
- | ooooooooo+++~~~~~~~:.. |
18
- | ooooooo+~~+~~+=++==~++: |
19
- | =ooo=+~~~++~~=+~+=..o+. |
20
- | .=oo+~ .~+=~~o+.+o= =+~ |
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
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
- slide 002
1
+ _____ ___ __ ___
2
+ / ___// (_)___/ /__ |__ \
3
+ \__ \/ / / __ / _ \ __/ /
4
+ ___/ / / / /_/ / __/ / __/
5
+ /____/_/_/\__,_/\___/ /____/
6
+
7
+ Is less important
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
+ slide 002
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimdeck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Benziger
@@ -76,23 +76,6 @@ files:
76
76
  - presentation/script.vim
77
77
  - presentation/slide001.md
78
78
  - presentation/slide002.md
79
- - presentation/slide003.md
80
- - presentation/slide004.md
81
- - presentation/slide005.md
82
- - presentation/slide006.md
83
- - presentation/slide007.md
84
- - presentation/slide008.md
85
- - presentation/slide009.md
86
- - presentation/slide010.md
87
- - presentation/slide011.md
88
- - presentation/slide012.md
89
- - presentation/slide013.md
90
- - presentation/slide014.md
91
- - presentation/slide015.md
92
- - presentation/slide016.md
93
- - presentation/slide017.md
94
- - presentation/slide018.md
95
- - presentation/slide019.md
96
79
  - slides.md
97
80
  - vimdeck.gemspec
98
81
  homepage: http://github.com/tybenz/vimdeck