Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

332 lines
5.4 KiB

  1. .TH MARKDOWN 2
  2. .SH NAME
  3. mkd_in, mkd_string, markdown, mkd_compile, mkd_css, mkd_generatecss,
  4. mkd_document, mkd_generatehtml, mkd_xhtmlpage, mkd_toc, mkd_generatetoc,
  5. mkd_cleanup, mkd_doc_title, mkd_doc_author, mkd_doc_date, mkd_line,
  6. mkd_generateline \- convert Markdown text to HTML
  7. .SH SYNOPSIS
  8. .ta \w'MMIOT* 'u
  9. .B #include <mkdio.h>
  10. .PP
  11. .B
  12. MMIOT* mkd_in(FILE *input, int flags)
  13. .PP
  14. .B
  15. MMIOT* mkd_string(char *buf, int size, int flags)
  16. .PP
  17. .B
  18. int markdown(MMIOT *doc, FILE *output, int flags)
  19. .PP
  20. .B
  21. int mkd_compile(MMIOT *document, int flags)
  22. .PP
  23. .B
  24. int mkd_css(MMIOT *document, char **doc)
  25. .PP
  26. .B
  27. int mkd_generatecss(MMIOT *document, FILE *output)
  28. .PP
  29. .B
  30. int mkd_document(MMIOT *document, char **doc)
  31. .PP
  32. .B
  33. int mkd_generatehtml(MMIOT *document, FILE *output)
  34. .PP
  35. .B
  36. int mkd_xhtmlpage(MMIOT *document, int flags, FILE *output)
  37. .PP
  38. .B
  39. int mkd_toc(MMIOT *document, char **doc)
  40. .PP
  41. .B
  42. int mkd_generatetoc(MMIOT *document, FILE *output)
  43. .PP
  44. .B
  45. void mkd_cleanup(MMIOT*);
  46. .PP
  47. .B
  48. char* mkd_doc_title(MMIOT*)
  49. .PP
  50. .B
  51. char* mkd_doc_author(MMIOT*)
  52. .PP
  53. .B
  54. char* mkd_doc_date(MMIOT*)
  55. .PP
  56. .B
  57. int mkd_line(char *string, int size, char **doc, int flags)
  58. .PP
  59. .B
  60. int mkd_generateline(char *string, int size, FILE *output, int flags)
  61. .PD
  62. .PP
  63. .SH DESCRIPTION
  64. These functions convert
  65. .IR Markdown (6)
  66. text into
  67. .SM HTML
  68. markup.
  69. .PP
  70. .I Mkd_in
  71. reads the text referenced by pointer to
  72. .B FILE
  73. .I input
  74. and returns a pointer to an
  75. .B MMIOT
  76. structure of the form expected by
  77. .I markdown
  78. and the other converters.
  79. .I Mkd_string
  80. accepts one
  81. .I string
  82. and returns a pointer to
  83. .BR MMIOT .
  84. .PP
  85. After such preparation,
  86. .I markdown
  87. converts
  88. .I doc
  89. and writes the result to
  90. .IR output ,
  91. while
  92. .I mkd_compile
  93. transforms
  94. .I document
  95. in-place.
  96. .PP
  97. One or more of the following
  98. .I flags
  99. (combined with
  100. .BR OR )
  101. control
  102. .IR markdown 's
  103. processing of
  104. .IR doc :
  105. .TF MKD_NOIMAGE
  106. .TP
  107. .B MKD_NOIMAGE
  108. Do not process
  109. .B ![]
  110. and remove
  111. .B <img>
  112. tags from the output.
  113. .TP
  114. .B MKD_NOLINKS
  115. Do not process
  116. .B []
  117. and remove
  118. .B <a>
  119. tags from the output.
  120. .TP
  121. .B MKD_NOPANTS
  122. Suppress Smartypants-style replacement of quotes, dashes, or ellipses.
  123. .TP
  124. .B MKD_STRICT
  125. Disable superscript and relaxed emphasis processing if configured; otherwise a no-op.
  126. .TP
  127. .B MKD_TAGTEXT
  128. Process as inside an
  129. .SM HTML
  130. tag: no
  131. .BR <em> ,
  132. no
  133. .BR <bold> ,
  134. no
  135. .SM HTML
  136. or
  137. .B []
  138. expansion.
  139. .TP
  140. .B MKD_NO_EXT
  141. Don't process pseudo-protocols (in
  142. .IR markdown (6)).
  143. .TP
  144. .B MKD_CDATA
  145. Generate code for
  146. .SM XML
  147. .B ![CDATA[...]]
  148. element.
  149. .TP
  150. .B MKD_NOHEADER
  151. Don't process Pandoc-style headers.
  152. .TP
  153. .B MKD_TABSTOP
  154. When reading documents, expand tabs to 4 spaces, overriding any compile-time configuration.
  155. .TP
  156. .B MKD_TOC
  157. Label headings for use with the
  158. .I mkd_generatetoc
  159. and
  160. .I mkd_toc
  161. functions.
  162. .TP
  163. .B MKD_1_COMPAT
  164. MarkdownTest_1.0 compatibility. Trim trailing spaces from first line of code blocks and disable implicit reference links (in
  165. .IR markdown (6)).
  166. .TP
  167. .B MKD_AUTOLINK
  168. Greedy
  169. .SM URL
  170. generation. When set, any
  171. .SM URL
  172. is converted to a hyperlink, even those not encased in
  173. .BR <> .
  174. .TP
  175. .B MKD_SAFELINK
  176. Don't make hyperlinks from
  177. .B [][]
  178. links that have unknown
  179. .SM URL
  180. protocol types.
  181. .TP
  182. .B MKD_NOTABLES
  183. Do not process the syntax extension for tables (in
  184. .IR markdown (6)).
  185. .TP
  186. .B MKD_EMBED
  187. All of
  188. .BR MKD_NOLINKS ,
  189. .BR MKD_NOIMAGE ,
  190. and
  191. .BR MKD_TAGTEXT .
  192. .PD
  193. .PP
  194. This implementation supports
  195. Pandoc-style
  196. headers and inline
  197. .SM CSS
  198. .B <style>
  199. blocks, but
  200. .I markdown
  201. does not access the data provided by these extensions.
  202. The following functions do, and allow other manipulations.
  203. .PP
  204. Given a pointer to
  205. .B MMIOT
  206. prepared by
  207. .I mkd_in
  208. or
  209. .IR mkd_string ,
  210. .I mkd_compile
  211. compiles the
  212. .I document
  213. into
  214. .BR <style> ,
  215. Pandoc, and
  216. .SM HTML
  217. sections. It accepts the
  218. .I flags
  219. described for
  220. .IR markdown ,
  221. above.
  222. .PP
  223. Once compiled, the document particulars can be read and written:
  224. .PP
  225. .I Mkd_css
  226. allocates a string and populates it with any
  227. .B <style>
  228. sections from the document.
  229. .I Mkd_generatecss
  230. writes any
  231. .B <style>
  232. sections to
  233. .IR output .
  234. .PP
  235. .I Mkd_document
  236. points
  237. .I doc
  238. to the
  239. .B MMIOT
  240. .IR document ,
  241. returning
  242. .IR document 's
  243. size.
  244. .PP
  245. .I Mkd_generatehtml
  246. writes the rest of the
  247. .I document
  248. to the
  249. .IR output .
  250. .PP
  251. .IR Mkd_doc_title ,
  252. .IR mkd_doc_author ,
  253. and
  254. .I mkd_doc_date
  255. read the contents of any Pandoc header.
  256. .PP
  257. .I Mkd_xhtmlpage
  258. writes an
  259. .SM XHTML
  260. page representation of the document.
  261. It accepts the
  262. .I flags
  263. described for
  264. .IR markdown ,
  265. above.
  266. .PP
  267. .I Mkd_toc
  268. .IR malloc s
  269. a buffer into which it writes an outline, in the form of a
  270. .B <ul>
  271. element populated with
  272. .BR <li> s
  273. each containing a link to successive headings in the
  274. .IR document .
  275. It returns the size of that string.
  276. .I Mkd_generatetoc
  277. is similar,
  278. but writes the outline to the
  279. .I output
  280. referenced by a pointer to
  281. .BR FILE .
  282. .PP
  283. .I Mkd_cleanup
  284. deletes a processed
  285. .BR MMIOT .
  286. .PP
  287. The last two functions convert a single line of markdown source, for example a page title or a signature.
  288. .I Mkd_line
  289. allocates a buffer into which it writes an
  290. .SM HTML
  291. fragment representation of the
  292. .IR string .
  293. .I Mkd_generateline
  294. writes the result to
  295. .IR output .
  296. .SH SOURCE
  297. .B /sys/src/cmd/discount
  298. .SH SEE ALSO
  299. .IR markdown (1),
  300. .IR markdown (6)
  301. .SH DIAGNOSTICS
  302. The
  303. .I mkd_in
  304. and
  305. .I mkd_string
  306. functions return a pointer to
  307. .B MMIOT
  308. on success, null on failure.
  309. .IR Markdown ,
  310. .IR mkd_compile ,
  311. .IR mkd_style ,
  312. and
  313. .I mkd_generatehtml
  314. return
  315. .B 0
  316. on success,
  317. .B -1
  318. otherwise.
  319. .SH BUGS
  320. Error handling is minimal at best.
  321. .PP
  322. The
  323. .B MMIOT
  324. created by
  325. .I mkd_string
  326. is deleted by the
  327. .I markdown
  328. function.
  329. .PP
  330. This is an
  331. .SM APE
  332. library.