Sat, 10 Nov 2012 04:02:30 +0000
parsers.markdown: Make module callable, to allow parsing text as a module
-- 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:gsub("%W+$", ""):gsub("^%W+", "")); end -- Config -- local conffile = ".blogrc"; for i=1,#arg do if arg[i] == "-c" or arg[i] == "--config" then table.remove(arg, i); conffile = arg[i] or conffile; table.remove(arg, i); break; end end dofile(conffile) posts_dir = posts_dir or "_posts/" layouts_dir = layouts_dir or "_layouts/" output_dir = output_dir or "./" -- - -- - -- -- Append '/' to end of posts_dir if necessary posts_dir = posts_dir:gsub("([^/])$", "%1/") -- Append '/' to end of output_dir if necessary output_dir = output_dir:gsub("([^/])$", "%1/") -- Append '/' to end of base_url if necessary base_url = base_url:gsub("([^/])$", "%1/")