aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/slides_utils.lua
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2014-10-29 20:36:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-29 20:36:05 -0700
commit07dada770b0af4955031806f0c1b8016fa49b65e (patch)
tree5e22f46bf4c612326222a778763ad91d57ed6497 /resources/slides_utils.lua
parent7a6184fdf717a1da0c6e1e37b942b17fdaa236d3 (diff)
break transitions into separate file
BUG=skia: TBR= NOTRY=True Review URL: https://codereview.chromium.org/692543004
Diffstat (limited to 'resources/slides_utils.lua')
-rw-r--r--resources/slides_utils.lua57
1 files changed, 35 insertions, 22 deletions
diff --git a/resources/slides_utils.lua b/resources/slides_utils.lua
index 29c0c7176c..a0b42b4425 100644
--- a/resources/slides_utils.lua
+++ b/resources/slides_utils.lua
@@ -29,30 +29,11 @@ function count_hypens(s)
return string.len(s) - string.len(leftover)
end
-function parse_file(file)
- local slides = {}
- local block = {}
-
- for line in file:lines() do
- local s = trim_ws(line)
- if #s == 0 then -- done with a block
- if #block > 0 then
- slides[#slides + 1] = block
- block = {}
- end
- else
- local n = count_hypens(s)
- block[#block + 1] = {
- indent = n,
- text = trim_ws(s:sub(n + 1, -1))
- }
- end
- end
- return slides
-end
-
function pretty_print_slide(slide)
io.write("{\n")
+ if slide.transition then
+ io.write(" transition = \"", slide.transition, "\",\n")
+ end
for i = 1, #slide do
local node = slide[i]
for j = 0, node.indent do
@@ -73,3 +54,35 @@ function pretty_print_slides(slides)
io.write("}\n")
end
+function parse_transition_type(s)
+ return s:match("^<%s*transition%s*=%s*(%a+)%s*>$")
+end
+
+function parse_file(file)
+ local slides = {}
+ local block = {}
+
+ for line in file:lines() do
+ local s = trim_ws(line)
+ if #s == 0 then -- done with a block
+ if #block > 0 then
+ slides[#slides + 1] = block
+ block = {}
+ end
+ else
+ local transition_type = parse_transition_type(s)
+ if transition_type then
+ block["transition"] = transition_type
+ else
+ local n = count_hypens(s)
+ block[#block + 1] = {
+ indent = n,
+ text = trim_ws(s:sub(n + 1, -1))
+ }
+ end
+ end
+ end
+-- pretty_print_slides(slides)
+ return slides
+end
+