| SOLDOUT_MARKDOWN(3) | Library Functions Manual | SOLDOUT_MARKDOWN(3) |
soldout_markdown,
markdown — parse markdown
document
#include
<markdown.h>
#define MKD_CELL_ALIGN_DEFAULT
#define MKD_CELL_ALIGN_LEFT
#define MKD_CELL_ALIGN_RIGHT
#define MKD_CELL_ALIGN_CENTER
#define MKD_CELL_ALIGN_MASK
#define MKD_CELL_HEAD
#define MKD_LIST_ORDERED
#define MKD_LI_BLOCK
void
markdown(struct buf *ob,
struct buf *ib, const struct
mkd_renderer *rndr);
The
markdown()
function parses the input buffer ib and renders it
into the output buffer ob; rndr
is a pointer to the renderer structure.
Function pointers in 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 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.
function(struct
buf *ob, void *opaque);function(struct buf
*ob, void *opaque);NULL skips the
block)function(struct buf
*ob, struct buf *text,
void *opaque);function(struct buf
*ob, struct buf *text,
void *opaque);function(struct buf
*ob, struct buf *text,
void *opaque);function(struct buf
*ob, struct buf *text,
int level, void
*opaque);function(struct buf
*ob, void *opaque);function(struct buf
*ob, struct buf *text,
int flags, void
*opaque);function(struct buf
*ob, struct buf *text,
int flags, void
*opaque);function(struct buf
*ob, struct buf *text,
void *opaque);function(struct buf
*ob, struct buf *head_row,
struct buf *rows, void
*opaque);function(struct buf
*ob, struct buf *text,
int flags, void
*opaque);function(struct buf
*ob, struct buf *cells,
int flags, void
*opaque);NULL or return 0 prints the
span verbatim)function(struct buf
*ob, struct buf *link,
enum mkd_autolink type, void
*opaque);function(struct buf
*ob, struct buf *text,
void *opaque);function(struct buf
*ob, struct buf *text,
char c, void
*opaque);function(struct buf
*ob, struct buf *text,
char c, void
*opaque);function(struct buf
*ob, struct buf *text,
char c, void
*opaque);function(struct buf
*ob, struct buf *link,
struct buf *title, struct
buf *alt, void *opaque);function(struct buf
*ob, void *opaque);function(struct buf
*ob, struct buf *link,
struct buf *title, struct
buf *content, void *opaque);function(struct buf
*ob, struct buf *tag,
void *opaque);NULL copies input directly into
the output)function(struct buf
*ob, struct buf *entity,
void *opaque);function(struct buf
*ob, struct buf *text,
void *opaque);The markdown() function does not return a
value.
The soldout library was written by
Natasha "Kerensikova" Porte
<natacha@instinctive.eu>.
Manual page was originally written by Massimo Manghi
<mxmanghi@apache.org>,
and rewritten to mdoc format by Svyatoslav Mishyn
<juef@openmailbox.org>.
| May 30, 2016 | Debian |