parsers/textile.lua

Tue, 14 Jul 2009 02:07:18 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 14 Jul 2009 02:07:18 +0100
changeset 13
39add8e7fa99
parent 12
4c759312950b
permissions
-rwxr-xr-x

Add initial jorvick utility to manage posts and build the site

module("textile", package.seeall)


return function (textile)
	if not textile then
		error("textile: nil data!");
	end
	textile = textile:gsub("_(.-)_", "<em>%1</em>"):gsub("%*(.-)%*", "<b>%1</b>");
	textile = textile:gsub("h(%d+)%. ([^\r\n]+)", "<h%1>%2</h%1>");
	textile = textile:gsub("p%. ([^\r\n]+)", "<p>%1</p>");
	textile = textile:gsub("p%((%w+)%)%. ([^\r\n]+)", "<p class='%1'>%2</p>");
	textile = textile:gsub("[\r\n](.-)[\r\n]", "<p>%1</p>");
	return textile;
end

mercurial