textile.lua

Sat, 11 Jul 2009 03:37:48 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 11 Jul 2009 03:37:48 +0100
changeset 10
58f3707e44d7
parent 0
b40ca010c49c
permissions
-rwxr-xr-x

Strip trailing punctuation from short titles

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