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

Side by Side Diff: resources/slides_utils.lua

Issue 697923002: add code-style for slides (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « resources/slides_content2.lua ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function tostr(t) 1 function tostr(t)
2 local str = "" 2 local str = ""
3 for k, v in next, t do 3 for k, v in next, t do
4 if #str > 0 then 4 if #str > 0 then
5 str = str .. ", " 5 str = str .. ", "
6 end 6 end
7 if type(k) == "number" then 7 if type(k) == "number" then
8 str = str .. "[" .. k .. "] = " 8 str = str .. "[" .. k .. "] = "
9 else 9 else
10 str = str .. tostring(k) .. " = " 10 str = str .. tostring(k) .. " = "
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 for i = 1, #slides do 51 for i = 1, #slides do
52 pretty_print_slide(slides[i]) 52 pretty_print_slide(slides[i])
53 end 53 end
54 io.write("}\n") 54 io.write("}\n")
55 end 55 end
56 56
57 function parse_transition_type(s) 57 function parse_transition_type(s)
58 return s:match("^<%s*transition%s*=%s*(%a+)%s*>$") 58 return s:match("^<%s*transition%s*=%s*(%a+)%s*>$")
59 end 59 end
60 60
61 function parse_blockstyle_type(s)
62 return s:match("^<%s*blockstyle%s*=%s*(%a+)%s*>$")
63 end
64
61 function parse_file(file) 65 function parse_file(file)
62 local slides = {} 66 local slides = {}
63 local block = {} 67 local block = {}
64 68
65 for line in file:lines() do 69 for line in file:lines() do
66 local s = trim_ws(line) 70 local s = trim_ws(line)
67 if #s == 0 then -- done with a block 71 if #s == 0 then -- done with a block
68 if #block > 0 then 72 if #block > 0 then
69 slides[#slides + 1] = block 73 slides[#slides + 1] = block
70 block = {} 74 block = {}
71 end 75 end
72 else 76 else
73 local transition_type = parse_transition_type(s) 77 local transition_type = parse_transition_type(s)
78 local blockstyle = parse_blockstyle_type(s)
74 if transition_type then 79 if transition_type then
75 block["transition"] = transition_type 80 block["transition"] = transition_type
81 elseif blockstyle then
82 block["blockstyle"] = blockstyle
76 else 83 else
77 local n = count_hypens(s) 84 if block.blockstyle == "code" then
78 block[#block + 1] = { 85 block[#block + 1] = { text = line }
79 indent = n, 86 else
80 text = trim_ws(s:sub(n + 1, -1)) 87 local n = count_hypens(s)
81 } 88 block[#block + 1] = {
89 indent = n,
90 text = trim_ws(s:sub(n + 1, -1))
91 }
92 end
82 end 93 end
83 end 94 end
84 end 95 end
85 -- pretty_print_slides(slides) 96 -- pretty_print_slides(slides)
86 return slides 97 return slides
87 end 98 end
88 99
OLDNEW
« no previous file with comments | « resources/slides_content2.lua ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698