MKD_CALLBACKS(3)
β¨ NAME β¨
This is MKD_CALLBACKS(3), straight from the Library Functions Manual, and itβs all about mkd_callbacks β functions that modify link targets. Yes bestie, weβre customizing links and code blocks. π
π LIBRARY π
Markdown (libmarkdown, -lmarkdown) β iconic library, no cap. π
π§ SYNOPSIS π§
#include <mkdio.h>
char*
(*mkd_callback_t)(const char*, const int, void*);
void
(*mkd_free_t)(char *, void*);
void
mkd_e_url(MMIOT *document, mkd_callback_t edit);
void
mkd_e_flags(MMIOT *document, mkd_callback_t edit);
void
mkd_e_free(MMIOT *document, mkd_free_t dealloc);
void
mkd_e_code(MMIOT *document, mkd_callback_t edit);
void
mkd_e_data(MMIOT *document, void *data);
π DESCRIPTION π
Discount provides a small set of data access functions to let a library user modify the generated html. Itβs giving backstage-pass energy. ποΈβ¨
Hereβs the callback lineup:
mkd_e_url()β modifies the target given in a[]link.mkd_e_flags()β adds additional flags to a[]link.mkd_e_code()β lets you manipulate the contents of a code block.
The data access functions are passed a character pointer to the url being generated, the size of the url, and a data pointer pointing to a user data area (set by the mkd_e_data() function.) After the callback function is called the data freeing function (if supplied) is called and passed the character pointer and user data pointer.
π EXAMPLE π
The mkd_basename() function (in the module basename.c) is implemented by means of mkd callbacks; it modifies urls that start with a / so that they begin with a user-supplied url base by allocating a new string and filling it with the base + the url. Discount plugs that url in place of the original, then calls the basename free function (it only does this when mkd_e_url() or mkd_e_flags() returns nonzero) to deallocate this memory.
β οΈ Note that only one level of callbacks are supported; if you wish to do multiple callbacks, you need to write your own code to handle them all.
π¦ SEE ALSO π¦
markdown(1)markdown(3)mkd-line(3)markdown(7)mkd-extensions(7)mmap(2)basename.chttp://daringfireball.net/projects/markdown/syntax
π BUGS π
Straight up: Error handling is minimal at best. Thatβs it, thatβs the bug section. π
Signed, sealed, delivered: this page came from Mastodon, dated January 18, 2008, and itβs the MKD_CALLBACKS(3) manual page. Stay slaying those callbacks, bestie. πβ¨
π¦ where this page comes from
- alpine 3.24: discount-doc 3.0.1.2-r1 Β· BSD-3-Clause
- arch rolling: discount 3.0.2.0-1 Β· BSD-3-Clause
- nixos 26.05: discount 3.0.1.2
- nixpkgs unstable: discount 3.0.2.0
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libmarkdown-devel 3.0.0a-160000.2.2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms