mkd_functions(3) access and process Markdown documents.

LIBRARY

Markdown (libmarkdown , -lmarkdown)

SYNOPSIS

Fd #include <mkdio.h> Ft int Fn mkd_compile MMIOT *document int flags Ft int Fn mkd_css MMIOT *document char **doc Ft int Fn mkd_generatecss MMIOT *document FILE *output Ft int Fn mkd_document MMIOT *document char **doc Ft int Fn mkd_generatehtml MMIOT *document FILE *output Ft int Fn mkd_xhtmlpage MMIOT *document int flags FILE *output Ft int Fn mkd_toc MMIOT *document char **doc Ft void Fn mkd_generatetoc MMIOT *document FILE *output Ft void Fn mkd_cleanup MMIOT* Ft char* Fn mkd_doc_title MMIOT* Ft char* Fn mkd_doc_author MMIOT* Ft char* Fn mkd_doc_date MMIOT*

DESCRIPTION

The markdown format supported in this implementation includes Pandoc-style header and inline <style> blocks, and the standard markdown(3) functions do not provide access to the data provided by either of those extensions. These functions give you access to that data, plus they provide a finer-grained way of converting Markdown documents into HTML.

Given a MMIOT* generated by Fn mkd_in or Fn mkd_string , Fn mkd_compile compiles the document into <style> Pandoc and html sections.

Once compiled, the document can be examined and written by the Fn mkd_css , Fn mkd_document , Fn mkd_generatecss , Fn mkd_generatehtml , Fn mkd_generatetoc , Fn mkd_toc , Fn mkd_xhtmlpage , Fn mkd_doc_title , Fn mkd_doc_author , and Fn mkd_doc_date functions.

Fn mkd_css allocates a string and populates it with any <style> sections provided in the document, Fn mkd_generatecss writes any <style> sections to the output, Fn mkd_document points text to the text of the document and returns the size of the document, Fn mkd_generatehtml writes the rest of the document to the output, and Fn mkd_doc_title , Fn mkd_doc_author , Fn mkd_doc_date are used to read the contents of a Pandoc header, if any.

Fn mkd_xhtmlpage writes a xhtml page containing the document. The regular set of flags can be passed.

Fn mkd_toc writes a document outline, in the form of a collection of nested lists with links to each header in the document, into a string allocated with Fn malloc , and returns the size.

Fn mkd_generatetoc is like Fn mkd_toc , except that it writes the document outline to the given FILE* argument.

Fn mkd_cleanup deletes a MMIOT* after processing is done.

Fn mkd_compile accepts the same flags that Fn markdown and Fn mkd_string do;

MKD_NOIMAGE
Do not process `![]' and remove <img> tags from the output.
MKD_NOLINKS
Do not process `[]' and remove <a> tags from the output.
MKD_NOPANTS
Do not do Smartypants-style mangling of quotes, dashes, or ellipses.
MKD_TAGTEXT
Process the input as if you were inside a html tag. This means that no html tags will be generated, and Fn mkd_compile will attempt to escape anything that might terribly confuse a web browser.
MKD_NO_EXT
Do not process any markdown pseudo-protocols when handing [][] links.
MKD_NOHEADER
Do not attempt to parse any Pandoc-style headers.
MKD_TOC
Label all headers for use with the Fn mkd_generatetoc function.
MKD_1_COMPAT
MarkdownTest_1.0 compatibility flag; trim trailing spaces from the first line of code blocks and disable implicit reference links.
MKD_NOSTRIKETHROUGH
Disable strikethrough support.

RETURN VALUES

The function Fn mkd_compile returns 1 in the case of success, or 0 if the document is already compiled. The function Fn mkd_generatecss returns the number of bytes written in the case of success, or EOF if an error occurred. The function Fn mkd_generatehtml returns 0 on success, -1 on failure.

BUGS

Error handling is minimal at best.