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

asb / lua-discount

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

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (3)
    • 1.2.10.1
    • 1.2.10
    • 1.2.7
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 binding to the discount C implementation of the Markdown text-to-html markup system — Read more

  cancel

http://asbradbury.org/projects/lua-discount/

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

This URL has Read+Write access

build toc.c 
asb (author)
Thu Feb 19 11:41:33 -0800 2009
commit  01331fcedb5401a1368c3f32475022488e37dbae
tree    b7873ed27a7a3a95fbb927502072ea8c41f0603b
parent  0ff51469cf91a551f1e1e1908566ebfc0094a5d9
lua-discount /
name age
history
message
file LICENSE Loading commit data...
file Makefile
file README.mkd
file amalloc.h
file bench.lua
file config.h
file cstring.h
file docheader.c
file dumptree.c
file generate.c
file ldiscount.c
file lua-discount-dev-1.rockspec
file markdown.c
file markdown.h
file mkdio.c
file mkdio.h
file resource.c
file test_discount.lua
file toc.c
README.mkd

lua-discount

A binding to Discount, a fast C implementation of the Markdown text to HTML markup system. Discount passes the Markdown test suite.

Project links

  • Home
  • Download
  • Documentation
  • Source

Release history

  • lua-discount-1.3.1 (unreleased)
    • update to updstream Discount 1.3.1
    • new language extensions: class blocks, superscripts and alphabetic ordered lists.
    • support the "toc" option for table of contents generation - headers will include an id attribute.
    • support the "strict" option, to disable relaxed emphasis and superscripts.
  • lua-discount-1.2.10.1 (2008-09-22)
    • Windows is now a supported platform (thanks to contributions from Tim Channon)
  • lua-discount-1.2.10 (2008-09-03)
    • update to upstream Discount 1.2.10
    • support the "nohtml" option, to disable embedded html.
    • compile to use relaxed emphasis, meaning underscores don't count when they're in the middle of a word.
    • add some tests
    • include results of a simple benchmark in the readme
  • lua-discount-1.2.7 (2008-08-03)
    • first public release

See also

  • Discount
  • Markdown syntax
  • markdown.lua

Performance

Thanks to the underlying Discount implementation, lua-discount is incredibly fast. Benchmarking markdown.lua 0.32 against lua-discount 1.2.10 by parsing the Markdown syntax document 100 times gives the following result (all figures are in seconds):

                   user     system      total       real
lua-discount   0.170000   0.000000   0.170000   0.177374
markdown.lua  48.530000   0.000000  48.530000  48.524910

Usage

Note that require("discount") returns a single function, which you are responsible for giving a suitable name. Example:

discount = require("discount")

local markdown_string = [[
  # Demonstration
  This is a demonstration of lua-discount. Passing the options `"nolinks"` 
  disables links such as [this](http://example.com).
  ]]

  local html_string = discount(markdown_string, "nolinks")

The discount function takes as its first argument the Markdown string to convert, and for its subsequent arguments takes any combination of the following strings as options:

="nolinks"=

do not allow `<a` or expand Markdown links.

="noimages"=

do not allow `<img` or expand Markdown images.

="nopants"=

disable [SmartyPants](http://daringfireball.net/projects/smartypants/) 
processing.

="nohtml"=

disallow embedded html by replacing all `<` with `&lt;`.

="strict"=

disable relaxed emphasis and superscripts.

="tagtext"=

don't expand `*` or `_` when used for emphasis.

="noext"=

do not process 
[pseudo-protocols](http://www.pell.portland.or.us/~orc/Code/discount/#pseudo)

="cdata"=

generate output suitable for use as data in an XML document.

="toc"=

generate table-of-contents headers - each generated `<h1>`, `<h2>`, etc 
will include an `id` attribute.

="embed"=

equivalent to specifying `"nolinks"`, `"noimages"` and `"tagtext"`.

License and acknowledgements

lua-discount is distributed under a BSD-style license.

Thanks to Tim Channon for Windows support.

This product includes software developed by David Loren Parsons.

Contact

Author: A.S. Bradbury
Email: asb@asbradbury.org
Homepage: http://asbradbury.org/

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