LuaPOD - Parsing POD files using Lua


Introduction
POD
Basic Operation
Using LuaPOD
Getting LuaPOD
Contact
License


Introduction

Plain Old Documentation, or just POD, is a simple documentation format used mainly among users of the Perl programming language. Most part of Perl's related documentation is written using POD.

Despite POD have been designed in a way a POD file could be read without the help of a formatting tool, most of time the POD file is translated to a language like HTML or TeX.

LuaPOD is a tool that allows to translate a POD file into HTML using Lua and the LPeg library.

POD

LuaPOD is based on the POD specification available at http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlpodspec.pod, however, there are some differences between the specification and the LuaPOD implementation:

The resolution of L codes depends of a base url that should be supplied.

If you want to know more about POD, a good place to go is http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlpod.pod.

Basic Operation

LuaPOD uses LPeg, a new pattern-matching library for Lua that is based on Parsing Expression Grammars (PEGs).

LuaPOD has a PEG grammar describing the expected general structure of a POD file, but this grammar will not deal with formatting codes. Because of this, LuaPOD parsers a POD file in two steps.

In a general way, each production of the PEG grammar has an associated function, which does some actions and calls a function responsible by the output. The output function by turn will call, if the POD formatting codes are being currently applied, the parsing function to resolve the formatting codes appropriately.

The functions responsible to deal with each formatting code are described in the table tags and should not be difficult to modify them.

As formatting codes can be nested, each time the parsing function is called it tries to find a set of characters indicating the beginning or the ending of a formatting code. If it finds a sequence indicating a beginning, the correspondent sequence will be saved in the table formatTable. If a ending sequence is found, it is checked if it matches the last formatting code opened. In the end, all formatting codes which were not matched will be closed.

Using LuaPOD

To use LuaPOD inside your Lua program, the first thing to do is require ("pod"). After this, you can use the functions parser and parserToBuffer, which are described below:

If the structure of the POD file is not according LuaPOD's PEG grammar, the output file will be empty.

Getting LuaPOD

As LPeg is not part of the standard Lua distribution, you should download and install LPeg before start using LuaPOD. Follow this link to downlaod LPeg.

Click here to download LuaPOD from LuaForge.

You can also get LuaPOD from Google Code typing the following command line:

svn checkout http://luapod.googlecode.com/svn/trunk/ luapod

Contact

LuaPOD was developed by Sérgio Medeiros and is free software. If you have any comments or doubts, please send me an e-mail (smedeiros at inf dot puc-rio dot br).

License

Copyright © 2007 Sérgio Medeiros.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.