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.

137 lines
2.7 KiB

  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_EXTRA_FOOTNOTE
  108. Enable markdown extra-style footnotes.
  109. .El
  110. .Sh RETURN VALUES
  111. .Fn markdown
  112. returns 0 on success, 1 on failure.
  113. The
  114. .Fn mkd_in
  115. and
  116. .Fn mkd_string
  117. functions return a MMIOT* on success, null on failure.
  118. .Sh SEE ALSO
  119. .Xr markdown 1 ,
  120. .Xr mkd-callbacks 3 ,
  121. .Xr mkd-functions 3 ,
  122. .Xr mkd-line 3 ,
  123. .Xr markdown 7 ,
  124. .Xr mkd-extensions 7 ,
  125. .Xr mmap 2 .
  126. .Pp
  127. http://daringfireball.net/projects/markdown/syntax
  128. .Sh BUGS
  129. Error handling is minimal at best.
  130. .Pp
  131. The
  132. .Ar MMIOT
  133. created by
  134. .Fn mkd_string
  135. is deleted by the
  136. .Nm
  137. function.