parsers/textile.lua

Tue, 14 Jul 2009 02:06:33 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 14 Jul 2009 02:06:33 +0100
changeset 12
4c759312950b
parent 0
textile.lua@b40ca010c49c
permissions
-rwxr-xr-x

Update to modularise a little, and prepare for a system-wide installation support

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