lua-discount
Lua bindings for the Discount Markdown library.
Requirements
Installation
luarocks install discount
Usage
The discount module provides a single function:
discount.compile(input, ...)
Parameters
input: A string of Markdown text to be parsed...: zero or more option strings (see below)
Returns
- A table, with the following fields:
body: The Markdown document rendered as HTML.index: A HTML table of contents (if thetocoption was enabled, otherwisenil).css: All<style>elements from the document, concatenated together, ornilif no such elements were found.title: The first line from the Pandoc-style header, ornil.author: The second line from the Pandoc-style header, ornil.date: The third line from the Pandoc-style header, ornil.
Returns (on error)
nil- An error message
Example
local discount = require "discount"
local doc = assert(discount.compile("# Hello", "toc", "strict"))
io.write(doc.body, "\n\n\n", doc.index)
Options
| Option | Action |
|---|---|
| toc | Enable table of contents |
| nolinks | Disable links and disallow <a> tags |
| noimages | Disable images and disallow <img> tags |
| nopants | Disable SmartyPants |
| nohtml | Don't allow raw HTML at all |
| strict | Disable superscript and relaxed emphasis |
| tagtext | Process text inside html tags |
| noext | Disable pseudo-protocols |
| cdata | Generate code for XML (using ![CDATA[...]]) |
| nosuperscript | Disable superscript (A^B) |
| norelaxed | Emphasis happens everywhere |
| notables | Disable Markdown Extra style tables |
| nostrikethrough | Disable ~~strikethrough~~ |
| compat | Compatability with MarkdownTest_1.0 |
| autolink | Turn URLs into links, even without enclosing angle brackets |
| safelink | Paranoid check for link protocol |
| noheader | Disable Pandoc style headers |
| tabstop | Expand tabs to 4 spaces |
| nodivquote | Disable >%class% blocks |
| noalphalist | Disable alphabetic lists |
| nodlist | Disable definition lists |
| extrafootnote | Enable Markdown Extra style footnotes |
| nostyle | Don't extract <style> blocks |
| nodldiscount | Disable Discount style definition lists |
| dlextra | Enable Markdown Extra style definition lists |
| fencedcode | Enable fenced code blocks |
| idanchor | Use id= anchors for TOC links |
| githubtags | Allow dash and underscore in element names |
| urlencodedanchor | URL encode non-identifier chars instead of replacing with dots |
| latex | Handle embedded LaTeX escapes |
| embed | Equivalent to combining nolinks, noimages and tagtext |