util.lua

Sat, 11 Jul 2009 02:14:33 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 11 Jul 2009 02:14:33 +0100
changeset 6
cf40d55f8122
child 8
6dc28a66f4d9
permissions
-rw-r--r--

Add util module and move first helper function into it


-- 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