jgm / lunamark
- Source
- Commits
- Network (1)
- Issues (1)
- Downloads (1)
- Wiki (1)
- Graphs
-
Branch:
master
lunamark /
| name | age | message | |
|---|---|---|---|
| |
LICENSE | Fri Sep 11 07:20:49 -0700 2009 | |
| |
MarkdownTest_1.0.3/ | Sat Sep 12 12:43:05 -0700 2009 | |
| |
README.markdown | Tue Sep 15 22:44:22 -0700 2009 | |
| |
TODO | Mon Sep 14 19:32:13 -0700 2009 | |
| |
lunamark-0.1-1.rockspec | Tue Sep 15 23:12:22 -0700 2009 | |
| |
lunamark.lua | Sun Sep 13 23:07:57 -0700 2009 | |
| |
lunamark/ | Tue Sep 22 18:08:45 -0700 2009 | |
| |
markdown | Mon Sep 14 18:51:20 -0700 2009 | |
| |
runtests | Sat Sep 12 12:45:59 -0700 2009 |
README.markdown
Lunamark
Lunamark is a lua library for conversion between markup formats. Currently markdown is the only supported input format, and HTML and LaTeX are the only supported output formats. But lunamark's modular architecture makes it easy to add new parsers and writers. Parsers are written using a PEG grammar.
Installing
Lunamark can be installed using luarocks:
git pull http://github.com/jgm/lunamark.git
cd lunamark
luarocks make
Using
lunamark.converter(in_format, out_format, options)
returns a function from string to string. in_format is currently
limited to markdown; out_format can be html or latex.
options is a table; currently the only supported option is
modify_syntax, a function from a grammar table to a grammar
table that can ring changes on the standard markdown syntax.
require "luarocks.require"
require "lunamark"
-- read stdin
inp = io.read("*a")
-- note: these are functions:
markdown2html = lunamark.converter("markdown", "html")
markdown2latex = lunamark.converter("markdown", "latex")
-- this one changes the syntax definition:
markdown2htmlCAPS = lunamark.converter("markdown", "html",
{ modify_syntax = function(t) t.Str = t.Str / string.upper; return t end })
io.write("HTML:\n",markdown2html(inp))
io.write("-----\n")
io.write("LaTeX:\n",markdown2latex(inp))
io.write("-----\n")
io.write("HTML CAPS:\n",markdown2htmlCAPS(inp))
