---
name: "markdown"
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/markdown/3"
---

# markdown(3)

process Markdown documents

## NAME

**markdown** – process Markdown documents

## LIBRARY

Markdown  (libmarkdown, -lmarkdown)

## SYNOPSIS

**#include \<mkdio.h\>**

*MMIOT*\

**\*mkd\_in**(*FILE \*input*, *int flags*);

*MMIOT*\

**\*mkd\_string**(*char \*string*, *int size*, *int flags*);

*int*\

**markdown**(*MMIOT \*doc*, *FILE \*output*, *int flags*);

## DESCRIPTION

These functions convert *Markdown* documents and strings into HTML. **markdown**() processes an entire document, while **mkd\_text**() processes a single string.

To process a file, you pass a FILE\* to **mkd\_in**(), and if it returns a nonzero value you pass that in to  **markdown**(), which then writes the converted document to the specified *FILE\**. If your input has already been written into a string (generated input or a file opened  with  [mmap(2)](/mmap/2.md)) you can feed that string to  **mkd\_string**() and pass its return value to **markdown.**()

**Markdown**() accepts the following flag values (or-ed together if needed) to restrict how it processes input:

- *MKD\_NOLINKS*

  Don't do link processing, block  *\<a\>* tags.

- *MKD\_NOIMAGE*

  Don't do image processing, block *\<img\>*.

- *MKD\_NOPANTS*

  Don't run  *smartypants()*.

- *MKD\_NOHTML*

  Don't allow raw html through AT ALL

- *MKD\_STRICT*

  Disable  superscript and relaxed emphasis.

- *MKD\_TAGTEXT*

  Process text to put inside an html tag (ID=, NAME=, \<title\>, &tc); no  *\<em\>*, no  *\<bold\>*, no html or *\[\]* expansion.

- *MKD\_NO\_EXT*

  Don't allow pseudo-protocols.

- *MKD\_CDATA*

  Generate code for xml  *!\[CDATA\[...\]\]*.

- *MKD\_NOSUPERSCRIPT*

  Don't generate superscripts. Emphasis happens \_everywhere\_

- *MKD\_NOTABLES*

  Disallow tables.

- *MKD\_NOSTRIKETHROUGH*

  Forbid  *~~strikethrough~~*.

- *MKD\_TOC*

  Do table-of-contents processing.

- *MKD\_1\_COMPAT*

  Compatibility with MarkdownTest\_1.0

- *MKD\_AUTOLINK*

  Make  *http://foo.com* into a link even without *\<\>* *s.*

- *MKD\_SAFELINK*

  Paranoid check for link protocol.

- *MKD\_NOHEADER*

  Don't process header blocks.

- *MKD\_TABSTOP*

  Expand tabs to 4 spaces.

- *MKD\_NODIVQUOTE*

  Forbid  *\>%class%* blocks.

- *MKD\_NOALPHALIST*

  Forbid alphabetic lists.

- *MKD\_NODLIST*

  Forbid definition lists.

- *MKD\_NODLDISCOUNT*

  Disable the discount definition list syntax style.

- *MKD\_DLEXTRA*

  Enable the extra definition list syntax style.

- *MKD\_EXTRA\_FOOTNOTE*

  Enable markdown extra-style footnotes.

- *MKD\_NOSTYLE*

  Do not extract (omit) \<style/\> blocks from the output.

- *MKD\_FENCEDCODE*

  Allow fenced code blocks.

- *MKD\_IDANCHOR*

  Use id= anchors instead of \<a name=/\> for table-of-contents links.

- *MKD\_GITHUBTAGS*

  Allow underscore and dash in passed through element names.

- *MKD\_URLENCODEDANCHOR*

  Use html5 encoding for multibyte and nonalphanumeric characters rather than hex expansion in toc links.

## RETURN VALUES

**markdown**() returns 0 on success, 1 on failure. The **mkd\_in**() and **mkd\_string**() functions return a MMIOT\* on success, null on failure.

## SEE ALSO

[markdown(1)](/markdown/1.md), [mkd-callbacks(3)](/mkd-callbacks/3.md), [mkd-functions(3)](/mkd-functions/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).

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

## BUGS

Error handling is minimal at best.

The *MMIOT* created by **mkd\_string**() is deleted by the **markdown** function.
