Git Product home page Git Product logo

lua-discount's Introduction

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

Release history

  • 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

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 processing. ="nohtml"= disallow embedded html by replacing all < with &lt;. ="tagtext"= don't expand * or _ when used for emphasis. ="noext"= do not process pseudo-protocols ="cdata"= generate output suitable for use as data in an XML document. = "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: [email protected]
Homepage: http://asbradbury.org/

lua-discount's People

Contributors

drahosp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.