---
name: "mkd-callbacks"
section: "3"
platform: "linux"
package: "discount"
version: "3.0.2.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mkd-callbacks"
---

# mkd-callbacks(3)

functions that modify link targets

## NAME

**mkd\_callbacks** – functions that modify link targets

## LIBRARY

Markdown  (libmarkdown, -lmarkdown)

## 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.

- **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/1.md), [markdown(3)](/markdown/3.md), [mkd-line(3)](/mkd-line/3.md), [markdown(7)](/markdown/7.md), [mkd-extensions(7)](/mkd-extensions/7.md), [mmap(2)](/mmap/2.md).

basename.c

http://daringfireball.net/projects/markdown/syntax

## BUGS

Error handling is minimal at best.
