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.

71 lines
1.9 KiB

  1. .\"
  2. .Dd January 18, 2008
  3. .Dt MKD_CALLBACKS 3
  4. .Os Mastodon
  5. .Sh NAME
  6. .Nm mkd_callbacks
  7. .Nd functions that modify link targets
  8. .Sh LIBRARY
  9. Markdown
  10. .Pq libmarkdown , -lmarkdown
  11. .Sh SYNOPSIS
  12. .Fd #include <mkdio.h>
  13. .Ft char*
  14. .Fn (*mkd_callback_t) "const char*" "const int" "void*"
  15. .Ft void
  16. .Fn (*mkd_free_t) "char *" "void*"
  17. .Ft void
  18. .Fn mkd_e_url "MMIOT *document" "mkd_callback_t edit"
  19. .Ft void
  20. .Fn mkd_e_flags "MMIOT *document" "mkd_callback_t edit"
  21. .Ft void
  22. .Fn mkd_e_free "MMIOT *document" "mkd_free_t dealloc"
  23. .Ft void
  24. .Fn mkd_e_data "MMIOT *document" "void *data"
  25. .Sh DESCRIPTION
  26. .Pp
  27. .Nm Discount
  28. provides a small set of data access functions to let a
  29. library user modify the targets given in a `[]' link, and to
  30. add additional flags to the generated link.
  31. .Pp
  32. The data access functions are passed a character pointer to
  33. the url being generated, the size of the url, and a data pointer
  34. pointing to a user data area (set by the
  35. .Fn mkd_e_data
  36. function.) After the callback function is called (either
  37. .Fn mkd_e_url
  38. or
  39. .Fn mkd_e_flags )
  40. the data freeing function (if supplied) is called and passed the
  41. character pointer and user data pointer.
  42. .Sh EXAMPLE
  43. The
  44. .Fn mkd_basename
  45. function (in the module basename.c) is implemented by means of
  46. mkd callbacks; it modifies urls that start with a `/' so that
  47. they begin with a user-supplied url base by allocating a new
  48. string and filling it with the base + the url. Discount plugs
  49. that url in in place of the original, then calls the basename
  50. free function (it only does this when
  51. .Fn mkd_e_url
  52. or
  53. .Fn mkd_e_flags
  54. returns nonzero) to deallocate this memory.
  55. .Pp
  56. Note that only one level of callbacks are supported; if you
  57. wish to do multiple callbacks, you need to write your own
  58. code to handle them all.
  59. .Sh SEE ALSO
  60. .Xr markdown 1 ,
  61. .Xr markdown 3 ,
  62. .Xr mkd-line 3 ,
  63. .Xr markdown 7 ,
  64. .Xr mkd-extensions 7 ,
  65. .Xr mmap 2 .
  66. .Pp
  67. basename.c
  68. .Pp
  69. http://daringfireball.net/projects/markdown/syntax
  70. .Sh BUGS
  71. Error handling is minimal at best.