Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: resources/slides_utils.lua

Issue 692543004: break transitions into separate file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « resources/slides_transitions.lua ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: resources/slides_utils.lua
diff --git a/resources/slides_utils.lua b/resources/slides_utils.lua
index 29c0c7176cf6164c77461c07750a1a46ac3c7311..a0b42b4425883da30f879024902a495e2e46f03a 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
+
« no previous file with comments | « resources/slides_transitions.lua ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698