Warning, /education/cantor/thirdparty/discount-2.2.6-patched/Plan9/markdown.2 is written in an unsupported language. File is not indexed.
0001 .TH MARKDOWN 2 0002 .SH NAME 0003 mkd_in, mkd_string, markdown, mkd_compile, mkd_css, mkd_generatecss, 0004 mkd_document, mkd_generatehtml, mkd_xhtmlpage, mkd_toc, mkd_generatetoc, 0005 mkd_cleanup, mkd_doc_title, mkd_doc_author, mkd_doc_date, mkd_line, 0006 mkd_generateline \- convert Markdown text to HTML 0007 .SH SYNOPSIS 0008 .ta \w'MMIOT* 'u 0009 .B #include <mkdio.h> 0010 .PP 0011 .B 0012 MMIOT* mkd_in(FILE *input, int flags) 0013 .PP 0014 .B 0015 MMIOT* mkd_string(char *buf, int size, int flags) 0016 .PP 0017 .B 0018 int markdown(MMIOT *doc, FILE *output, int flags) 0019 .PP 0020 .B 0021 int mkd_compile(MMIOT *document, int flags) 0022 .PP 0023 .B 0024 int mkd_css(MMIOT *document, char **doc) 0025 .PP 0026 .B 0027 int mkd_generatecss(MMIOT *document, FILE *output) 0028 .PP 0029 .B 0030 int mkd_document(MMIOT *document, char **doc) 0031 .PP 0032 .B 0033 int mkd_generatehtml(MMIOT *document, FILE *output) 0034 .PP 0035 .B 0036 int mkd_xhtmlpage(MMIOT *document, int flags, FILE *output) 0037 .PP 0038 .B 0039 int mkd_toc(MMIOT *document, char **doc) 0040 .PP 0041 .B 0042 int mkd_generatetoc(MMIOT *document, FILE *output) 0043 .PP 0044 .B 0045 void mkd_cleanup(MMIOT*); 0046 .PP 0047 .B 0048 char* mkd_doc_title(MMIOT*) 0049 .PP 0050 .B 0051 char* mkd_doc_author(MMIOT*) 0052 .PP 0053 .B 0054 char* mkd_doc_date(MMIOT*) 0055 .PP 0056 .B 0057 int mkd_line(char *string, int size, char **doc, int flags) 0058 .PP 0059 .B 0060 int mkd_generateline(char *string, int size, FILE *output, int flags) 0061 .PD 0062 .PP 0063 .SH DESCRIPTION 0064 These functions convert 0065 .IR Markdown (6) 0066 text into 0067 .SM HTML 0068 markup. 0069 .PP 0070 .I Mkd_in 0071 reads the text referenced by pointer to 0072 .B FILE 0073 .I input 0074 and returns a pointer to an 0075 .B MMIOT 0076 structure of the form expected by 0077 .I markdown 0078 and the other converters. 0079 .I Mkd_string 0080 accepts one 0081 .I string 0082 and returns a pointer to 0083 .BR MMIOT . 0084 .PP 0085 After such preparation, 0086 .I markdown 0087 converts 0088 .I doc 0089 and writes the result to 0090 .IR output , 0091 while 0092 .I mkd_compile 0093 transforms 0094 .I document 0095 in-place. 0096 .PP 0097 One or more of the following 0098 .I flags 0099 (combined with 0100 .BR OR ) 0101 control 0102 .IR markdown 's 0103 processing of 0104 .IR doc : 0105 .TF MKD_NOIMAGE 0106 .TP 0107 .B MKD_NOIMAGE 0108 Do not process 0109 .B ![] 0110 and remove 0111 .B <img> 0112 tags from the output. 0113 .TP 0114 .B MKD_NOLINKS 0115 Do not process 0116 .B [] 0117 and remove 0118 .B <a> 0119 tags from the output. 0120 .TP 0121 .B MKD_NOPANTS 0122 Suppress Smartypants-style replacement of quotes, dashes, or ellipses. 0123 .TP 0124 .B MKD_STRICT 0125 Disable superscript and relaxed emphasis processing. 0126 .TP 0127 .B MKD_TAGTEXT 0128 Process as inside an 0129 .SM HTML 0130 tag: no 0131 .BR <em> , 0132 no 0133 .BR <bold> , 0134 no 0135 .SM HTML 0136 or 0137 .B [] 0138 expansion. 0139 .TP 0140 .B MKD_NO_EXT 0141 Don't process pseudo-protocols (in 0142 .IR markdown (6)). 0143 .TP 0144 .B MKD_CDATA 0145 Generate code for 0146 .SM XML 0147 .B ![CDATA[...]] 0148 element. 0149 .TP 0150 .B MKD_NOHEADER 0151 Don't process Pandoc-style headers. 0152 .TP 0153 .B MKD_TABSTOP 0154 When reading documents, expand tabs to 4 spaces, overriding any compile-time configuration. 0155 .TP 0156 .B MKD_TOC 0157 Label headings for use with the 0158 .I mkd_generatetoc 0159 and 0160 .I mkd_toc 0161 functions. 0162 .TP 0163 .B MKD_1_COMPAT 0164 MarkdownTest_1.0 compatibility. Trim trailing spaces from first line of code blocks and disable implicit reference links (in 0165 .IR markdown (6)). 0166 .TP 0167 .B MKD_AUTOLINK 0168 Greedy 0169 .SM URL 0170 generation. When set, any 0171 .SM URL 0172 is converted to a hyperlink, even those not encased in 0173 .BR <> . 0174 .TP 0175 .B MKD_SAFELINK 0176 Don't make hyperlinks from 0177 .B [][] 0178 links that have unknown 0179 .SM URL 0180 protocol types. 0181 .TP 0182 .B MKD_NOTABLES 0183 Do not process the syntax extension for tables (in 0184 .IR markdown (6)). 0185 .TP 0186 .B MKD_EMBED 0187 All of 0188 .BR MKD_NOLINKS , 0189 .BR MKD_NOIMAGE , 0190 and 0191 .BR MKD_TAGTEXT . 0192 .PD 0193 .PP 0194 This implementation supports 0195 Pandoc-style 0196 headers and inline 0197 .SM CSS 0198 .B <style> 0199 blocks, but 0200 .I markdown 0201 does not access the data provided by these extensions. 0202 The following functions do, and allow other manipulations. 0203 .PP 0204 Given a pointer to 0205 .B MMIOT 0206 prepared by 0207 .I mkd_in 0208 or 0209 .IR mkd_string , 0210 .I mkd_compile 0211 compiles the 0212 .I document 0213 into 0214 .BR <style> , 0215 Pandoc, and 0216 .SM HTML 0217 sections. It accepts the 0218 .I flags 0219 described for 0220 .IR markdown , 0221 above. 0222 .PP 0223 Once compiled, the document particulars can be read and written: 0224 .PP 0225 .I Mkd_css 0226 allocates a string and populates it with any 0227 .B <style> 0228 sections from the document. 0229 .I Mkd_generatecss 0230 writes any 0231 .B <style> 0232 sections to 0233 .IR output . 0234 .PP 0235 .I Mkd_document 0236 points 0237 .I doc 0238 to the 0239 .B MMIOT 0240 .IR document , 0241 returning 0242 .IR document 's 0243 size. 0244 .PP 0245 .I Mkd_generatehtml 0246 writes the rest of the 0247 .I document 0248 to the 0249 .IR output . 0250 .PP 0251 .IR Mkd_doc_title , 0252 .IR mkd_doc_author , 0253 and 0254 .I mkd_doc_date 0255 read the contents of any Pandoc header. 0256 .PP 0257 .I Mkd_xhtmlpage 0258 writes an 0259 .SM XHTML 0260 page representation of the document. 0261 It accepts the 0262 .I flags 0263 described for 0264 .IR markdown , 0265 above. 0266 .PP 0267 .I Mkd_toc 0268 .IR malloc s 0269 a buffer into which it writes an outline, in the form of a 0270 .B <ul> 0271 element populated with 0272 .BR <li> s 0273 each containing a link to successive headings in the 0274 .IR document . 0275 It returns the size of that string. 0276 .I Mkd_generatetoc 0277 is similar, 0278 but writes the outline to the 0279 .I output 0280 referenced by a pointer to 0281 .BR FILE . 0282 .PP 0283 .I Mkd_cleanup 0284 deletes a processed 0285 .BR MMIOT . 0286 .PP 0287 The last two functions convert a single line of markdown source, for example a page title or a signature. 0288 .I Mkd_line 0289 allocates a buffer into which it writes an 0290 .SM HTML 0291 fragment representation of the 0292 .IR string . 0293 .I Mkd_generateline 0294 writes the result to 0295 .IR output . 0296 .SH SOURCE 0297 .B /sys/src/cmd/discount 0298 .SH SEE ALSO 0299 .IR markdown (1), 0300 .IR markdown (6) 0301 .SH DIAGNOSTICS 0302 The 0303 .I mkd_in 0304 and 0305 .I mkd_string 0306 functions return a pointer to 0307 .B MMIOT 0308 on success, null on failure. 0309 .IR Markdown , 0310 .IR mkd_compile , 0311 .IR mkd_style , 0312 and 0313 .I mkd_generatehtml 0314 return 0315 .B 0 0316 on success, 0317 .B -1 0318 otherwise. 0319 .SH BUGS 0320 Error handling is minimal at best. 0321 .PP 0322 The 0323 .B MMIOT 0324 created by 0325 .I mkd_string 0326 is deleted by the 0327 .I markdown 0328 function. 0329 .PP 0330 This is an 0331 .SM APE 0332 library.