|
Since I just uploaded a bunch of new modules based upon LPeg, I thought I
would mentioned them all in one announcement instead of a bunch of
announcements as they're somewhat releated.
First off, there's org.conman.parsers.ip 1.0.2, which fixes a bug related
to parsing IPv6 addresses.
And now, the new modules:
org.conman.parsers.ip-text
Parses IPv4 and IPv6 addresses, but returns the address as
text (instead of binary in network byte order as
org.conman.parsers.ip does).
org.conman.parsers.url.url
Parses URLs, just like it says in the label.
org.conman.parsers.url.gopher
Parses "gopher:" URLs. These are different enough from the
standard URL to warrant its own module.
org.conman.parsers.url.tel
Parses "tel:" URIs. Addmittedly this is a niche URI type,
but I tend to work with them a lot so they get their own
module.
org.conman.prsers.url.sip
Parses "sip:" URIs. Again, a niche URI type that I tend to
work with a lot so I included this as well.
The URL parsing modules can be combinded (since they're pretty much LPeg
expressions) much like:
local gopher = require "org.conman.parsers.url.gopher"
local sip = require "org.conman.parsers.url.sip"
local tel = require "org.conman.parsers.url.tel"
local url = require "org.conman.parsers.url.url"
url = "" + sip + tel.tel + url -- [1]
a = url:match "gopher://example.com/"
b = url:match "sip:+1-(555)-555-1212;ext=1234@example.net ;user=phone"
c = url:match "tel:+1-(555)-555-1212;ext=1234"
d = url:match "http://www.example.com/path/to/ref?_one_=1&two=two&three= "alpha&three=beta#fragtarget1
e = url:match "ftp://anon:fred%40example.com@example.net/public/files "
f = url:match "mailto:fred@example.com?subject=What%27s%20up%3F"
All are available via LuaRocks [2].
-spc
[1] The org.conman.parsers.url.tel module returns a table and not an
LPeg _expression_ because most of it is reused in the
org.conman.parsers.sip module, due that you can embed tel: URIs in a
sip: URI.
[2] Except there is no LuaRocks for "org.conman.parsers.url". I'm not
sure if you can have a LuaRocks made up of *just* dependencies and
no actual code. I don't want to push things.