github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jgm / lunamark

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 6
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (1)
  • Downloads (1)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (1)
    • 0.1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Lua library for conversion between markup formats — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Newline after <blockquote> tag 
jgm (author)
Tue Sep 22 18:08:45 -0700 2009
commit  bd4be96fe01bd135e7222e7905ef802cab540dbe
tree    886fee67a08bc18587c0902828ef578d96456a5d
parent  841bb64decb4a2570567f57f1c697bca0dbbd4a3
lunamark /
name age
history
message
file LICENSE Fri Sep 11 07:20:49 -0700 2009 Added LICENSE, updated rockspec. [jgm]
directory MarkdownTest_1.0.3/ Sat Sep 12 12:43:05 -0700 2009 Added markdown test suite. [jgm]
file README.markdown Tue Sep 15 22:44:22 -0700 2009 Updated README [John MacFarlane]
file TODO Mon Sep 14 19:32:13 -0700 2009 Updated TODO [jgm]
file lunamark-0.1-1.rockspec Tue Sep 15 23:12:22 -0700 2009 Updated rockspec [John MacFarlane]
file lunamark.lua Sun Sep 13 23:07:57 -0700 2009 Put into more hierarchical modules [John MacFarlane]
directory lunamark/ Tue Sep 22 18:08:45 -0700 2009 Newline after <blockquote> tag [jgm]
file markdown Mon Sep 14 18:51:20 -0700 2009 More efficient way of adding \n\n to end of input. [jgm]
file runtests Sat Sep 12 12:45:59 -0700 2009 Added runtests script. [jgm]
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))
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server