Warning, /education/cantor/thirdparty/discount-2.2.6-patched/mkd-functions.3 is written in an unsupported language. File is not indexed.

0001 .\"
0002 .Dd January 18, 2008
0003 .Dt MKD_FUNCTIONS 3
0004 .Os Mastodon
0005 .Sh NAME
0006 .Nm mkd_functions 
0007 .Nd access and process Markdown documents.
0008 .Sh LIBRARY
0009 Markdown 
0010 .Pq libmarkdown , -lmarkdown
0011 .Sh SYNOPSIS
0012 .Fd #include <mkdio.h>
0013 .Ft int
0014 .Fn mkd_compile "MMIOT *document" "int flags"
0015 .Ft int
0016 .Fn mkd_css "MMIOT *document" "char **doc"
0017 .Ft int
0018 .Fn mkd_generatecss  "MMIOT *document" "FILE *output"
0019 .Ft int
0020 .Fn mkd_document "MMIOT *document" "char **doc"
0021 .Ft int
0022 .Fn mkd_generatehtml  "MMIOT *document" "FILE *output"
0023 .Ft int
0024 .Fn mkd_xhtmlpage "MMIOT *document" "int flags" "FILE *output"
0025 .Ft int
0026 .Fn mkd_toc "MMIOT *document" "char **doc"
0027 .Ft void
0028 .Fn mkd_generatetoc "MMIOT *document" "FILE *output"
0029 .Ft void
0030 .Fn mkd_cleanup "MMIOT*"
0031 .Ft char*
0032 .Fn mkd_doc_title "MMIOT*"
0033 .Ft char*
0034 .Fn mkd_doc_author "MMIOT*"
0035 .Ft char*
0036 .Fn mkd_doc_date "MMIOT*"
0037 .Sh DESCRIPTION
0038 .Pp
0039 The
0040 .Nm markdown
0041 format supported in this implementation includes
0042 Pandoc-style header and inline 
0043 .Ar \<style\>
0044 blocks, and the standard
0045 .Xr markdown 3
0046 functions do not provide access to
0047 the data provided by either of those extensions.
0048 These functions give you access to that data, plus
0049 they provide a finer-grained way of converting
0050 .Em Markdown 
0051 documents into HTML.
0052 .Pp
0053 Given a
0054 .Ar MMIOT*
0055 generated by
0056 .Fn mkd_in
0057 or
0058 .Fn mkd_string ,
0059 .Fn mkd_compile
0060 compiles the document into
0061 .Em \<style\> ,
0062 .Em Pandoc ,
0063 and
0064 .Em html
0065 sections.
0066 .Pp
0067 Once compiled, the document can be examined and written
0068 by the
0069 .Fn mkd_css ,
0070 .Fn mkd_document ,
0071 .Fn mkd_generatecss ,
0072 .Fn mkd_generatehtml ,
0073 .Fn mkd_generatetoc ,
0074 .Fn mkd_toc ,
0075 .Fn mkd_xhtmlpage ,
0076 .Fn mkd_doc_title ,
0077 .Fn mkd_doc_author ,
0078 and
0079 .Fn mkd_doc_date
0080 functions.
0081 .Pp
0082 .Fn mkd_css
0083 allocates a string and populates it with any \<style\> sections
0084 provided in the document,
0085 .Fn mkd_generatecss
0086 writes any \<style\> sections to the output,
0087 .Fn mkd_document
0088 points
0089 .Ar text
0090 to the text of the document and returns the
0091 size of the document,
0092 .Fn mkd_generatehtml
0093 writes the rest of the document to the output,
0094 and 
0095 .Fn mkd_doc_title ,
0096 .Fn mkd_doc_author ,
0097 .Fn mkd_doc_date
0098 are used to read the contents of a Pandoc header,
0099 if any.
0100 .Pp
0101 .Fn mkd_xhtmlpage
0102 writes a xhtml page containing the document.  The regular set of
0103 flags can be passed.
0104 .Pp
0105 .Fn mkd_toc
0106 writes a document outline, in the form of a collection of nested
0107 lists with links to each header in the document, into a string
0108 allocated with
0109 .Fn malloc ,
0110 and returns the size.
0111 .Pp
0112 .Fn mkd_generatetoc
0113 is like
0114 .Fn mkd_toc ,
0115 except that it writes the document outline to the given
0116 .Pa FILE*
0117 argument.
0118 .Pp
0119 .Fn mkd_cleanup
0120 deletes a
0121 .Ar MMIOT*
0122 after processing is done.
0123 .Pp
0124 .Fn mkd_compile
0125 accepts the same flags that
0126 .Fn markdown
0127 and
0128 .Fn mkd_string
0129 do; 
0130 .Bl -tag -width MKD_NOSTRIKETHROUGH -compact
0131 .It Ar MKD_NOIMAGE
0132 Do not process `![]' and
0133 remove
0134 .Em \<img\>
0135 tags from the output.
0136 .It Ar MKD_NOLINKS
0137 Do not process `[]' and remove
0138 .Em \<a\>
0139 tags from the output.
0140 .It Ar MKD_NOPANTS
0141 Do not do Smartypants-style mangling of quotes, dashes, or ellipses.
0142 .It Ar MKD_TAGTEXT
0143 Process the input as if you were inside a html tag.  This means that
0144 no html tags will be generated, and 
0145 .Fn mkd_compile
0146 will attempt to escape anything that might terribly confuse a 
0147 web browser.
0148 .It Ar MKD_NO_EXT
0149 Do not process any markdown pseudo-protocols when
0150 handing
0151 .Ar [][]
0152 links.
0153 .It Ar MKD_NOHEADER
0154 Do not attempt to parse any Pandoc-style headers.
0155 .It Ar MKD_TOC
0156 Label all headers for use with the
0157 .Fn mkd_generatetoc
0158 function.
0159 .It Ar MKD_1_COMPAT
0160 MarkdownTest_1.0 compatibility flag; trim trailing spaces from the
0161 first line of code blocks and disable implicit reference links.
0162 .It Ar MKD_NOSTRIKETHROUGH
0163 Disable strikethrough support.
0164 .El
0165 .Sh RETURN VALUES
0166 The function
0167 .Fn mkd_compile
0168 returns 1 in the case of success, or 0 if the document is already compiled.
0169 The function
0170 .Fn mkd_generatecss
0171 returns the number of bytes written in the case of success, or EOF if an error
0172 occurred.  
0173 The function
0174 .Fn mkd_generatehtml
0175 returns 0 on success, \-1 on failure.
0176 .Sh SEE ALSO
0177 .Xr markdown 1 ,
0178 .Xr markdown 3 ,
0179 .Xr mkd-line 3 ,
0180 .Xr markdown 7 ,
0181 .Xr mkd-extensions 7 ,
0182 .Xr mmap 2 .
0183 .Pp
0184 http://daringfireball.net/projects/markdown/syntax
0185 .Sh BUGS
0186 Error handling is minimal at best.