Skip to content

Commit f86a6a0

Browse files
committed
Fixing ordered and unordered lists
1 parent 787b7c8 commit f86a6a0

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

lib/vimdeck.rb

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Render < Redcarpet::Render::Base
3333
[
3434
# block-level calls
3535
:block_quote,
36-
:block_html, :list, :list_item,
36+
:block_html, :list_item,
3737

3838
# span-level calls
3939
:autolink, :codespan, :double_emphasis,
@@ -52,6 +52,14 @@ class Render < Redcarpet::Render::Base
5252
end
5353
end
5454

55+
def list(content, type)
56+
if type == :unordered
57+
"<!~#{content}~!>"
58+
else
59+
"<@~#{content}~@>"
60+
end
61+
end
62+
5563
def header(title, level)
5664
case level
5765
when 1
@@ -104,6 +112,30 @@ def self.generate(filename)
104112
slide_num = "%03d" % (i+1)
105113
slide = renderer.render(slide)
106114

115+
regex = /\<\@\~(.*)\~\@\>/m
116+
match = slide.match(regex)
117+
while match && match[1] && match.post_match do
118+
list = match[1].split("\n")
119+
j = 0
120+
list = list.map do |li|
121+
j += 1
122+
"#{j}. #{li}"
123+
end
124+
slide.sub!(regex, list.join("\n"))
125+
match = match.post_match.match(regex)
126+
end
127+
128+
regex = /\<\!\~(.*)\~\!\>/m
129+
match = slide.match(regex)
130+
while match && match[1] && match.post_match do
131+
list = match[1].split("\n")
132+
list = list.map do |li|
133+
"\u2022 #{li}"
134+
end
135+
slide.sub!(regex, list.join("\n"))
136+
match = match.post_match.match(regex)
137+
end
138+
107139
# buffer gets stashed into @buffers array for script template
108140
# needs to track things like the buffer number, code highlighting
109141
# and focus/unfocus stuff

slides.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717

1818
# BULLETS
1919

20-
• First
21-
{~• Second
20+
• First{~
21+
• Second
2222
• Third~}
2323

2424

2525
# BULLETS
2626

2727
{~• First~}
28-
• Second
29-
{~• Third~}
28+
• Second{~
29+
• Third~}
3030

3131

3232
# BULLETS

0 commit comments

Comments
 (0)