util.lua

changeset 6
cf40d55f8122
child 8
6dc28a66f4d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util.lua	Sat Jul 11 02:14:33 2009 +0100
@@ -0,0 +1,9 @@
+
+-- Takes "Why I like fish" and returns "why-i-like-fish"
+function make_short_title(long_title)
+	local short_title = long_title:gsub("%W+", "-"):lower():sub(1,45)
+	if #long_title:gsub("%W+", "-") > 45 then
+		short_title = short_title:gsub("%-%w+$", "");
+	end
+	return short_title;
+end

mercurial