Scroll to navigation

MARKDOWN(3) Library Functions Manual MARKDOWN(3)

NAME

markdownprocess Markdown documents

LIBRARY

Markdown (libmarkdown, -lmarkdown)

SYNOPSIS

#include <mkdio.h>

MMIOT
*mkd_in(FILE *input, mkd_flag_t *flags);

MMIOT
*mkd_string(char *string, int size, mkd_flag_t *flags);

int
markdown(MMIOT *doc, FILE *output, mkd_flag_t *flags);

DESCRIPTION

These functions convert Markdown documents and strings into HTML. () processes an entire document, while () processes a single string.

To process a file, you pass a FILE* to (), and if it returns a nonzero value you pass that in to markdown(), which then writes the converted document to the specified . If your input has already been written into a string (generated input or a file opened with mmap(2)) you can feed that string to () and pass its return value to ()

() holds the flag values in an opaque flag blob that you need to initialize and populate before using:

mkd_flag_t* ()
creates a mkd_flag_t structure and returns a pointer to it.
(mkd_flag_t *)
deletes a mkd_flag_t structure when you are finished with it.
mkd_flag_t* (mkd_flag_t*)
Makes a copy of a flag blob and returns a pointer to it.
(mkd_flag_t *, int)
tells you if a specific flag is set
(mkd_flag_t *, int)
Sets a specified flag
(mkd_flag_t *, int)
Clears a specified flag

The following flags are currently accepted:

MKD_NOLINKS
don't do link processing, block <a> tags
MKD_NOIMAGE
don't do image processing, block <img>
MKD_NOPANTS
don't run smartypants()
MKD_NOHTML
don't allow raw html through AT ALL
MKD_NORMAL_LISTITEM
disable github-style checkbox lists
MKD_TAGTEXT
process text inside an html tag
MKD_NO_EXT
don't allow pseudo-protocols
MKD_EXPLICITLIST
don't combine numbered/bulletted lists
MKD_CDATA
generate code for xml ![CDATA[...]]
MKD_NOSUPERSCRIPT
no A^B
MKD_STRICT
conform to Markdown standard as implemented in Markdown.pl
MKD_NOTABLES
disallow tables
MKD_NOSTRIKETHROUGH
forbid ~~strikethrough~~
MKD_1_COMPAT
compatibility with MarkdownTest_1.0
MKD_TOC
do table-of-contents processing
MKD_AUTOLINK
make http://foo.com link even without <>s
MKD_NOHEADER
don't process header blocks
MKD_TABSTOP
expand tabs to 4 spaces
MKD_SAFELINK
paranoid check for link protocol
MKD_NODIVQUOTE
forbid >%class% blocks
MKD_NOALPHALIST
forbid alphabetic lists
MKD_EXTRA_FOOTNOTE
enable markdown extra-style footnotes
MKD_NOSTYLE
don't extract <style> blocks
MKD_DLDISCOUNT
enable discount-style definition lists
MKD_DLEXTRA
enable extra-style definition lists
MKD_FENCEDCODE
enabled fenced code blocks
MKD_IDANCHOR
use id= anchors for TOC links
MKD_GITHUBTAGS
allow dash and underscore in element names
MKD_URLENCODEDANCHOR
urlencode non-identifier chars instead of replacing with dots
MKD_LATEX
handle embedded LaTeX escapes
MKD_ALT_AS_TITLE
use alt text as the title if no title is listed
MKD_EXTENDED_ATTR
allow extended attribute suffixes

RETURN VALUES

markdown() returns 0 on success, 1 on failure. The mkd_in() and mkd_string() functions return a MMIOT* on success, null on failure.

SEE ALSO

markdown(1), mkd-callbacks(3), mkd-functions(3), mkd-line(3), markdown(7), mkd-extensions(7), mmap(2).

http://daringfireball.net/projects/markdown/syntax

BUGS

Error handling is minimal at best.

The MMIOT created by mkd_string() is deleted by the markdown function.

December 20, 2007 Mastodon