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.

186 lines
4.1 KiB

  1. .\"
  2. .Dd January 18, 2008
  3. .Dt MKD_FUNCTIONS 3
  4. .Os Mastodon
  5. .Sh NAME
  6. .Nm mkd_functions
  7. .Nd access and process Markdown documents.
  8. .Sh LIBRARY
  9. Markdown
  10. .Pq libmarkdown , -lmarkdown
  11. .Sh SYNOPSIS
  12. .Fd #include <mkdio.h>
  13. .Ft int
  14. .Fn mkd_compile "MMIOT *document" "int flags"
  15. .Ft int
  16. .Fn mkd_css "MMIOT *document" "char **doc"
  17. .Ft int
  18. .Fn mkd_generatecss "MMIOT *document" "FILE *output"
  19. .Ft int
  20. .Fn mkd_document "MMIOT *document" "char **doc"
  21. .Ft int
  22. .Fn mkd_generatehtml "MMIOT *document" "FILE *output"
  23. .Ft int
  24. .Fn mkd_xhtmlpage "MMIOT *document" "int flags" "FILE *output"
  25. .Ft int
  26. .Fn mkd_toc "MMIOT *document" "char **doc"
  27. .Ft void
  28. .Fn mkd_generatetoc "MMIOT *document" "FILE *output"
  29. .Ft void
  30. .Fn mkd_cleanup "MMIOT*"
  31. .Ft char*
  32. .Fn mkd_doc_title "MMIOT*"
  33. .Ft char*
  34. .Fn mkd_doc_author "MMIOT*"
  35. .Ft char*
  36. .Fn mkd_doc_date "MMIOT*"
  37. .Sh DESCRIPTION
  38. .Pp
  39. The
  40. .Nm markdown
  41. format supported in this implementation includes
  42. Pandoc-style header and inline
  43. .Ar \<style\>
  44. blocks, and the standard
  45. .Xr markdown 3
  46. functions do not provide access to
  47. the data provided by either of those extensions.
  48. These functions give you access to that data, plus
  49. they provide a finer-grained way of converting
  50. .Em Markdown
  51. documents into HTML.
  52. .Pp
  53. Given a
  54. .Ar MMIOT*
  55. generated by
  56. .Fn mkd_in
  57. or
  58. .Fn mkd_string ,
  59. .Fn mkd_compile
  60. compiles the document into
  61. .Em \<style\> ,
  62. .Em Pandoc ,
  63. and
  64. .Em html
  65. sections.
  66. .Pp
  67. Once compiled, the document can be examined and written
  68. by the
  69. .Fn mkd_css ,
  70. .Fn mkd_document ,
  71. .Fn mkd_generatecss ,
  72. .Fn mkd_generatehtml ,
  73. .Fn mkd_generatetoc ,
  74. .Fn mkd_toc ,
  75. .Fn mkd_xhtmlpage ,
  76. .Fn mkd_doc_title ,
  77. .Fn mkd_doc_author ,
  78. and
  79. .Fn mkd_doc_date
  80. functions.
  81. .Pp
  82. .Fn mkd_css
  83. allocates a string and populates it with any \<style\> sections
  84. provided in the document,
  85. .Fn mkd_generatecss
  86. writes any \<style\> sections to the output,
  87. .Fn mkd_document
  88. points
  89. .Ar text
  90. to the text of the document and returns the
  91. size of the document,
  92. .Fn mkd_generatehtml
  93. writes the rest of the document to the output,
  94. and
  95. .Fn mkd_doc_title ,
  96. .Fn mkd_doc_author ,
  97. .Fn mkd_doc_date
  98. are used to read the contents of a Pandoc header,
  99. if any.
  100. .Pp
  101. .Fn mkd_xhtmlpage
  102. writes a xhtml page containing the document. The regular set of
  103. flags can be passed.
  104. .Pp
  105. .Fn mkd_toc
  106. writes a document outline, in the form of a collection of nested
  107. lists with links to each header in the document, into a string
  108. allocated with
  109. .Fn malloc ,
  110. and returns the size.
  111. .Pp
  112. .Fn mkd_generatetoc
  113. is like
  114. .Fn mkd_toc ,
  115. except that it writes the document outline to the given
  116. .Pa FILE*
  117. argument.
  118. .Pp
  119. .Fn mkd_cleanup
  120. deletes a
  121. .Ar MMIOT*
  122. after processing is done.
  123. .Pp
  124. .Fn mkd_compile
  125. accepts the same flags that
  126. .Fn markdown
  127. and
  128. .Fn mkd_string
  129. do;
  130. .Bl -tag -width MKD_NOSTRIKETHROUGH -compact
  131. .It Ar MKD_NOIMAGE
  132. Do not process `![]' and
  133. remove
  134. .Em \<img\>
  135. tags from the output.
  136. .It Ar MKD_NOLINKS
  137. Do not process `[]' and remove
  138. .Em \<a\>
  139. tags from the output.
  140. .It Ar MKD_NOPANTS
  141. Do not do Smartypants-style mangling of quotes, dashes, or ellipses.
  142. .It Ar MKD_TAGTEXT
  143. Process the input as if you were inside a html tag. This means that
  144. no html tags will be generated, and
  145. .Fn mkd_compile
  146. will attempt to escape anything that might terribly confuse a
  147. web browser.
  148. .It Ar MKD_NO_EXT
  149. Do not process any markdown pseudo-protocols when
  150. handing
  151. .Ar [][]
  152. links.
  153. .It Ar MKD_NOHEADER
  154. Do not attempt to parse any Pandoc-style headers.
  155. .It Ar MKD_TOC
  156. Label all headers for use with the
  157. .Fn mkd_generatetoc
  158. function.
  159. .It Ar MKD_1_COMPAT
  160. MarkdownTest_1.0 compatibility flag; trim trailing spaces from the
  161. first line of code blocks and disable implicit reference links.
  162. .It Ar MKD_NOSTRIKETHROUGH
  163. Disable strikethrough support.
  164. .El
  165. .Sh RETURN VALUES
  166. The function
  167. .Fn mkd_compile
  168. returns 1 in the case of success, or 0 if the document is already compiled.
  169. The function
  170. .Fn mkd_generatecss
  171. returns the number of bytes written in the case of success, or EOF if an error
  172. occurred.
  173. The function
  174. .Fn mkd_generatehtml
  175. returns 0 on success, \-1 on failure.
  176. .Sh SEE ALSO
  177. .Xr markdown 1 ,
  178. .Xr markdown 3 ,
  179. .Xr mkd-line 3 ,
  180. .Xr markdown 7 ,
  181. .Xr mkd-extensions 7 ,
  182. .Xr mmap 2 .
  183. .Pp
  184. http://daringfireball.net/projects/markdown/syntax
  185. .Sh BUGS
  186. Error handling is minimal at best.