Files
discount/markdown.3
T
David Parsons 9397c0a5c7 Redo toc.c to add the new function mkd_toc(), which writes the
generate toc to a string.   Documented in `markdown.3`
and `mkd-functions.3`, requires a new file (`Csio.c`) that has
functions for writing to a Cstring, requires that some of the
internal functions in `generate.c` be exposed (and renaed to
`__mkd_`*function* to reduce namespace collisions.

The new functions in Csio (particularly `Csprintf()` should make
it easier to convert many of the other "we print to a `FILE*` and
you need to lump it" functions into a pair of "print to a string"
and "print to a file" functions.
2009-02-27 16:47:02 -08:00

127 lines
2.5 KiB
Plaintext

.\"
.Dd December 20, 2007
.Dt MARKDOWN 3
.Os Mastodon
.Sh NAME
.Nm markdown
.Nd process Markdown documents
.Sh LIBRARY
Markdown
.Pq libmarkdown , -lmarkdown
.Sh SYNOPSIS
.Fd #include <mkdio.h>
.Ft MMIOT
.Fn *mkd_in "FILE *input"
.Ft MMIOT
.Fn *mkd_string "char *string" "int size"
.Ft int
.Fn markdown "MMIOT *doc" "FILE *output" "int flags"
.Ft int
.Fn mkd_text "char *string" "int size" "FILE *output" "int flags"
.Sh DESCRIPTION
These functions
convert
.Em Markdown
documents and strings into HTML.
.Fn markdown
processes an entire document, while
.Fn mkd_text
processes a single string.
.Pp
The
.Fn markdown
function expects to recieve a preprocessed text from the
.Fn mkd_in
or
.Fn mkd_string
functions, while
.Fn mkd_text
treats your input text as a single paragraph of markup.
.Pp
To process a file, you pass a FILE* to
.Fn mkd_in ,
and if it returns a nonzero value you pass that in to
.Fn markdown ,
which then writes the converted document to the specified
.Em FILE* .
If your input has already been written into a string (generated
input or a file opened
with
.Xr mmap 2 )
you can feed that string to
.Fn mkd_string
and pass its return value to
.Fn markdown.
.Pp
.Fn Markdown
and
.Fn mkd_text
accept the following flag values (or-ed together if needed)
to restrict how they process their input:
.Bl -tag -width MKD_NOIMAGE -compact
.It Ar MKD_NOIMAGE
Do not process `![]' and
remove
.Em \<img\>
tags from the output.
.It Ar MKD_NOLINKS
Do not process `[]' and remove
.Em \<a\>
tags from the output.
.It Ar MKD_NOPANTS
Do not do Smartypants-style mangling of quotes, dashes, or ellipses.
.It Ar MKD_STRICT
Disable superscript and relaxed emphasis processing (if they are configured;
otherwise it's a no-op.)
.It Ar MKD_QUOT
Expand
.Ar \&"
to \&&quot;.
.It Ar MKD_NOHEADER
Do not attempt to parse any Pandoc-style headers.
.It Ar MKD_TABSTOP
When reading documents, expand tabs to
.Em 4
spaces instead of whatever
.Nm
was originally configured for.
.It Ar MKD_TOC
Label all headers for use with the
.Fn mkd_generatetoc
and
.Fn mkd_toc
functions.
.El
.Sh RETURN VALUES
The functions
.Fn markdown
and
.Fn mkd_text
return 0 on success, 1 on failure.
The
.Fn mkd_in
and
.Fn mkd_string
functions return a MMIOT* on success, null on failure.
.Sh SEE ALSO
.Xr markdown 1 ,
.Xr mkd-functions 3 ,
.Xr markdown 7 ,
.Xr mkd-extensions 7 ,
.Xr mmap 2 .
.Pp
http://daringfireball.net/projects/markdown/syntax
.Sh BUGS
Error handling is minimal at best.
.Pp
The
.Ar MMIOT
created by
.Fn mkd_text
and
.Fn mkd_string
is deleted by the
.Nm
function.