soldout_markdown(3) parse markdown document

Other Alias

markdown

SYNOPSIS

In markdown.h

Fd #define MKD_CELL_ALIGN_DEFAULT Fd #define MKD_CELL_ALIGN_LEFT Fd #define MKD_CELL_ALIGN_RIGHT Fd #define MKD_CELL_ALIGN_CENTER Fd #define MKD_CELL_ALIGN_MASK Fd #define MKD_CELL_HEAD Fd #define MKD_LIST_ORDERED Fd #define MKD_LI_BLOCK Ft void Fo markdown Fa struct buf *ob Fa struct buf *ib Fa const struct mkd_renderer *rndr Fc

DESCRIPTION

The Fn markdown function parses the input buffer Fa ib and renders it into the output buffer Fa ob ; Fa rndr is a pointer to the renderer structure.

Function pointers in Vt struct mkd_renderer can be NULL A null block-level callback will make the corresponding block disappear from the output, as if the callback was an empty function. A null span-level callback will cause the corresponding element to be treated as normal characters, copied verbatim to the output. Moreover, span-level callbacks return an integer, which tells whether the renderer accepts to render the item (non-zero return value) or whether it should be copied verbatim (zero return value).

The first argument of a renderer function is always the output buffer, where the function is supposed to write its output. The last argument of a renderer function is always a private pointer, which is opaque member of Vt struct mkd_renderer . libsoldout itself never does nothing with this data.

emph_chars is a zero-terminated string which contains the set of characters that trigger emphasis. In regular markdown, emphasis is only triggered by `_' and `*' , but in some extensions it might be useful to add other characters to this list. The character that triggered the emphasis is then passed to emphasis , double_emphasis and triple_emphasis function callbacks through the parameter c

The normal_text callback should perform whatever escape is needed to have the output looking like the input data.

libsoldout supports PHP-Markdown-like tables. It uses the following flags: MKD_CELL_ALIGN_DEFAULT MKD_CELL_ALIGN_LEFT MKD_CELL_ALIGN_RIGHT MKD_CELL_ALIGN_CENTER MKD_CELL_ALIGN_MASK MKD_CELL_HEAD in these function callbacks: table_cell and table_row

MKD_LIST_ORDERED MKD_LI_BLOCK are used as flags in these function callbacks: list and listitem

Types

Vt enum mkd_autolink
type of autolink:

MKDA_NOT_AUTOLINK
used internally when it is not an autolink.
MKDA_NORMAL
normal http/https/ftp link.
MKDA_EXPLICIT_EMAIL
e-mail link with explicit mailto.
MKDA_IMPLICIT_EMAIL
e-mail link without mailto.

Vt struct mkd_renderer
consists of the following fields:

Document level callbacks

prolog
a pointer to a Ft void Fo function Fa struct buf *ob Fa void *opaque Fc
epilog
a pointer to a Ft void Fo function Fa struct buf *ob Fa void *opaque Fc

Block level callbacks (NULL skips the block )

blockcode
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa void *opaque Fc
blockquote
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa void *opaque Fc
blockhtml
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa void *opaque Fc
header
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa int level Fa void *opaque Fc
hrule
a pointer to a Ft void Fo function Fa struct buf *ob Fa void *opaque Fc
list
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa int flags Fa void *opaque Fc
listitem
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa int flags Fa void *opaque Fc
paragraph
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa void *opaque Fc
table
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *head_row Fa struct buf *rows Fa void *opaque Fc
table_cell
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa int flags Fa void *opaque Fc
table_row
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *cells Fa int flags Fa void *opaque Fc

Span level callbacks (NULL or return 0 prints the span verbatim )

autolink
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *link Fa enum mkd_autolink type Fa void *opaque Fc
codespan
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *text Fa void *opaque Fc
emphasis
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *text Fa char c Fa void *opaque Fc
double_emphasis
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *text Fa char c Fa void *opaque Fc
triple_emphasis
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *text Fa char c Fa void *opaque Fc
image
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *link Fa struct buf *title Fa struct buf *alt Fa void *opaque Fc
linebreak
a pointer to a Ft int Fo function Fa struct buf *ob Fa void *opaque Fc
link
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *link Fa struct buf *title Fa struct buf *content Fa void *opaque Fc
raw_html_tag
a pointer to a Ft int Fo function Fa struct buf *ob Fa struct buf *tag Fa void *opaque Fc

Low level callbacks (NULL copies input directly into the output )

entity
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *entity Fa void *opaque Fc
normal_text
a pointer to a Ft void Fo function Fa struct buf *ob Fa struct buf *text Fa void *opaque Fc

Renderer data

Vt int max_work_stack
prevent arbitrary deep recursion.
Vt const char * emph_chars
chars that trigger emphasis rendering.
Vt void * opaque
opaque data send to every rendering callback.

RETURN VALUES

The Fn markdown function does not return a value.

AUTHORS

An -nosplit The soldout library was written by An Natasha Qo Kerensikova Qc Porte Aq Mt [email protected] . Manual page was originally written by An Massimo Manghi Aq Mt [email protected] , and rewritten to mdoc format by An Svyatoslav Mishyn Aq Mt [email protected] .