markdown.3 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. .\"
  2. .Dd December 20, 2007
  3. .Dt MARKDOWN 3
  4. .Os Mastodon
  5. .Sh NAME
  6. .Nm markdown
  7. .Nd process Markdown documents
  8. .Sh LIBRARY
  9. Markdown
  10. .Pq libmarkdown , -lmarkdown
  11. .Sh SYNOPSIS
  12. .Fd #include <mkdio.h>
  13. .Ft MMIOT
  14. .Fn *mkd_in "FILE *input" "int flags"
  15. .Ft MMIOT
  16. .Fn *mkd_string "char *string" "int size" "int flags"
  17. .Ft int
  18. .Fn markdown "MMIOT *doc" "FILE *output" "int flags"
  19. .Sh DESCRIPTION
  20. These functions
  21. convert
  22. .Em Markdown
  23. documents and strings into HTML.
  24. .Fn markdown
  25. processes an entire document, while
  26. .Fn mkd_text
  27. processes a single string.
  28. .Pp
  29. To process a file, you pass a FILE* to
  30. .Fn mkd_in ,
  31. and if it returns a nonzero value you pass that in to
  32. .Fn markdown ,
  33. which then writes the converted document to the specified
  34. .Em FILE* .
  35. If your input has already been written into a string (generated
  36. input or a file opened
  37. with
  38. .Xr mmap 2 )
  39. you can feed that string to
  40. .Fn mkd_string
  41. and pass its return value to
  42. .Fn markdown.
  43. .Pp
  44. .Fn Markdown
  45. accepts the following flag values (or-ed together if needed)
  46. to restrict how it processes input:
  47. .Bl -tag -width MKD_NOSTRIKETHROUGH -compact
  48. .It Ar MKD_NOLINKS
  49. Don't do link processing, block
  50. .Em <a>
  51. tags.
  52. .It Ar MKD_NOIMAGE
  53. Don't do image processing, block
  54. .Em <img> .
  55. .It Ar MKD_NOPANTS
  56. Don't run
  57. .Em smartypants() .
  58. .It Ar MKD_NOHTML
  59. Don't allow raw html through AT ALL
  60. .It Ar MKD_STRICT
  61. Disable
  62. superscript and relaxed emphasis.
  63. .It Ar MKD_TAGTEXT
  64. Process text inside an html tag; no
  65. .Em <em> ,
  66. no
  67. .Em <bold> ,
  68. no html or
  69. .Em []
  70. expansion.
  71. .It Ar MKD_NO_EXT
  72. Don't allow pseudo-protocols.
  73. .It Ar MKD_CDATA
  74. Generate code for xml
  75. .Em ![CDATA[...]] .
  76. .It Ar MKD_NOSUPERSCRIPT
  77. Don't generate superscripts.
  78. Emphasis happens _everywhere_
  79. .It Ar MKD_NOTABLES
  80. Disallow tables.
  81. .It Ar MKD_NOSTRIKETHROUGH
  82. Forbid
  83. .Em ~~strikethrough~~ .
  84. .It Ar MKD_TOC
  85. Do table-of-contents processing.
  86. .It Ar MKD_1_COMPAT
  87. Compatibility with MarkdownTest_1.0
  88. .It Ar MKD_AUTOLINK
  89. Make
  90. .Em http://foo.com
  91. into a link even without
  92. .Em <> s.
  93. .It Ar MKD_SAFELINK
  94. Paranoid check for link protocol.
  95. .It Ar MKD_NOHEADER
  96. Don't process header blocks.
  97. .It Ar MKD_TABSTOP
  98. Expand tabs to 4 spaces.
  99. .It Ar MKD_NODIVQUOTE
  100. Forbid
  101. .Em >%class%
  102. blocks.
  103. .It Ar MKD_NOALPHALIST
  104. Forbid alphabetic lists.
  105. .It Ar MKD_NODLIST
  106. Forbid definition lists.
  107. .It Ar MKD_NODLDISCOUNT
  108. Disable the discount definition list syntax style.
  109. .It Ar MKD_DLEXTRA
  110. Enable the extra definition list syntax style.
  111. .It Ar MKD_EXTRA_FOOTNOTE
  112. Enable markdown extra-style footnotes.
  113. .It Ar MKD_NOSTYLE
  114. Do not extract (omit) <style/> blocks from the output.
  115. .It Ar MKD_FENCEDCODE
  116. Allow fenced code blocks.
  117. .It Ar MKD_IDANCHOR
  118. Use id= anchors instead of <a name=/> for table-of-contents links.
  119. .It Ar MKD_GITHUBTAGS
  120. Allow underscore and dash in passed through element names.
  121. .It Ar MKD_URLENCODEDANCHOR
  122. Use url-encoded chars for multibyte and nonalphanumeric chars rather than dots in toc links.
  123. .El
  124. .Sh RETURN VALUES
  125. .Fn markdown
  126. returns 0 on success, 1 on failure.
  127. The
  128. .Fn mkd_in
  129. and
  130. .Fn mkd_string
  131. functions return a MMIOT* on success, null on failure.
  132. .Sh SEE ALSO
  133. .Xr markdown 1 ,
  134. .Xr mkd-callbacks 3 ,
  135. .Xr mkd-functions 3 ,
  136. .Xr mkd-line 3 ,
  137. .Xr markdown 7 ,
  138. .Xr mkd-extensions 7 ,
  139. .Xr mmap 2 .
  140. .Pp
  141. http://daringfireball.net/projects/markdown/syntax
  142. .Sh BUGS
  143. Error handling is minimal at best.
  144. .Pp
  145. The
  146. .Ar MMIOT
  147. created by
  148. .Fn mkd_string
  149. is deleted by the
  150. .Nm
  151. function.