Perform line unfolding default tip

Fri, 29 Mar 2013 15:01:47 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 29 Mar 2013 15:01:47 +0000
changeset 3
c16d25785df1
parent 2
19d109c1625f

Perform line unfolding

ical.lua file | annotate | diff | comparison | revisions
--- a/ical.lua	Wed Mar 14 12:22:21 2012 +0000
+++ b/ical.lua	Fri Mar 29 15:01:47 2013 +0000
@@ -6,7 +6,11 @@
 	local k,v = line:match("^(%w+):(.*)$");
 	local curr_event = ical[#ical];
 	if k and v then
+		curr_event._last_key = k;
 		curr_event[k] = v;
+	elseif line:sub(1,1) == " " then
+		curr_event[curr_event._last_key] = curr_event[curr_event._last_key]..line:sub(2);
+		return;
 	end
 	
 	if k == "DTSTAMP" then
@@ -23,6 +27,7 @@
 	local line_num = 0;
 	
 	-- Parse
+	local hold_buffer;
 	for line in data:gmatch("(.-)[\r\n]+") do
 		line_num = line_num + 1;
 		if line:match("^BEGIN:") then
@@ -35,7 +40,7 @@
 			end
 			table.remove(stack);
 		elseif handler[stack[#stack]] then
-			handler[stack[#stack]](ical, line);
+			handler[stack[#stack]](ical, (hold_buffer or "")..line);
 		end
 	end
 	

mercurial