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

0
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 module("textile", package.seeall)
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 return function (textile)
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 if not textile then
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 error("textile: nil data!");
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 end
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 textile = textile:gsub("_(.-)_", "<em>%1</em>"):gsub("%*(.-)%*", "<b>%1</b>");
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 textile = textile:gsub("h(%d+)%. ([^\r\n]+)", "<h%1>%2</h%1>");
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 textile = textile:gsub("p%. ([^\r\n]+)", "<p>%1</p>");
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 textile = textile:gsub("p%((%w+)%)%. ([^\r\n]+)", "<p class='%1'>%2</p>");
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 textile = textile:gsub("[\r\n](.-)[\r\n]", "<p>%1</p>");
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 return textile;
b40ca010c49c Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 end

mercurial