lunamark.writer.generic

Generic writer for lunamark. This serves as generic documentation for lunamark writers, which all export a table with the same functions defined.

New writers can simply modify the generic writer: for example,

local Xml = generic.new(options)

Xml.linebreak = "<linebreak />"

local escaped = {
     ["<" ] = "&lt;",
     [">" ] = "&gt;",
     ["&" ] = "&amp;",
     ["\"" ] = "&quot;",
     ["'" ] = "&#39;"
}

function Xml.string(s)
  return s:gsub(".",escaped)
end

new(options)

Returns a table with functions defining a generic lunamark writer, which outputs plain text with no formatting. options is an optional table with the following fields:

layout
minimize (no space between blocks)
compact (no extra blank lines between blocks)
default (blank line between blocks)

The table contains the following fields:

W.set_metadata(key, val)

Set metadata field key to val.

W.add_metadata(key, val)

Add val to an array in metadata field key.

W.get_metadata()

Return metadata table.

W.space

A space (string).

W.start_document()

Setup tasks at beginning of document.

W.stop_document()

Finalization tasks at end of document.

W.plain(s)

Plain text block (not formatted as a pragraph).

W.linebreak

A line break (string).

W.interblocksep

Line breaks to use between block elements.

W.containersep

Line breaks to use between a container (like a <div> tag) and the adjacent block element.

W.ellipsis

Ellipsis (string).

W.mdash

Em dash (string).

W.ndash

En dash (string).

W.singlequoted(s)

String in curly single quotes.

W.doublequoted(s)

String in curly double quotes.

W.string(s)

String, escaped as needed for the output format.

W.code(s)

Inline (verbatim) code.

W.image(label, src, title)

An image link with alt text label, source src, and title title.

W.paragraph(s)

A paragraph.

W.bulletlist(items,tight)

A bullet list with contents items (an array). If tight is true, returns a “tight” list (with minimal space between items).

W.orderedlist(items,tight,startnum)

An ordered list with contents items (an array). If tight is true, returns a “tight” list (with minimal space between items). If optional number startnum is present, use it as the number of the first list item.

W.inline_html(s)

Inline HTML.

W.display_html(s)

Display HTML (HTML block).

W.emphasis(s)

Emphasized text.

W.strong(s)

Strongly emphasized text.

W.blockquote(s)

Block quotation.

W.verbatim(s)

Verbatim block.

W.header(s, level)

Header level level, with text s.

W.hrule

Horizontal rule.

W.note(contents)

A footnote or endnote.

W.definitionlist(items, tight)

A definition list. items is an array of tables, each of the form { term = t, definitions = defs, tight = tight }, where t is a string and defs is an array of strings. tight is a boolean, true if it is a tight list.

W.template

A cosmo template to be used in producing a standalone document. $body is replaced with the document body, $title with the title, and so on.

lunamark

lunamark.entities

lunamark.optparser

lunamark.reader

lunamark.util

lunamark.writer

lunamark.reader.markdown

lunamark.writer.context

lunamark.writer.docbook

lunamark.writer.dzslides

lunamark.writer.generic

lunamark.writer.groff

lunamark.writer.html

lunamark.writer.html5

lunamark.writer.latex

lunamark.writer.man

lunamark.writer.tex

lunamark.writer.xml