MARKDOWN(3)

πŸ“¦
version 3.0.2.0 Β· 2 versions
, in arch rolling, debian bookworm, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– markdown(3) β€” the Library Functions Manual glow-up πŸ’–

okay bestie, so this is markdown(3), a section 3 library function page, and it's literally the whole "process Markdown documents" situation. like. the moment. πŸŽ€


🌸 NAME 🌸

markdown β€” process Markdown documents πŸ’…

πŸ“š LIBRARY πŸ“š

Markdown, aka libmarkdown, which you link with -lmarkdown. she's a whole library, not just a vibe.

✨ 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 πŸ¦‹

so these functions do exactly one iconic thing: they take Markdown documents and strings and turn them into HTML. no cap.

markdown() handles a whole entire document. mkd_text() handles a single string. two different jobs, both eating.

k so here's how you actually use her. wanna process a file? you hand a FILE* to mkd_in(), and if what comes back is nonzero, you pass that into markdown(), which then writes the converted document out to the FILE* you picked. easy.

already got your input sitting in a string? (generated input, or a file you opened with mmap(2), iykyk) then you feed that string to mkd_string() and pass its return value to markdown(). boom. done. 🫢


πŸ’… OPTIONS πŸ’…

Markdown() takes these flag values β€” or them together with | if you need more than one, she's flexible like that β€” to restrict how she processes input:

  • MKD_NOLINKS β€” no link processing, and <a> tags get blocked. sorry to the linkers.
  • MKD_NOIMAGE β€” no image processing, <img> gets blocked. the girls are not being perceived today.
  • MKD_NOPANTS β€” don't run smartypants(). put the fancy quotes back in the closet.
  • MKD_NOHTML β€” raw html does NOT come through. AT ALL. like, zero. none.
  • MKD_STRICT β€” disables superscript and relaxed emphasis. strict mode is giving hall monitor.
  • MKD_TAGTEXT β€” process text that's going inside an html tag (think ID=, NAME=, <title>, &tc). no <em>, no <bold>, no html or [] expansion. she's contained, she's professional.
  • MKD_NO_EXT β€” don't allow pseudo-protocols.
  • MKD_CDATA β€” generate code for xml ![CDATA[...]].
  • MKD_NOSUPERSCRIPT β€” no superscripts generated. and emphasis happens everywhere. yes, everywhere everywhere.
  • MKD_NOTABLES β€” tables? disallowed. sorry table girlies.
  • MKD_NOSTRIKETHROUGH β€” ~~strikethrough~~ is forbidden. absolutely not. πŸ’€
  • MKD_TOC β€” do table-of-contents processing.
  • MKD_1_COMPAT β€” compatibility with MarkdownTest_1.0.
  • MKD_AUTOLINK β€” makes http://foo.com into a link even with no <> around it. auto-linking, auto-slaying.
  • MKD_SAFELINK β€” paranoid check for link protocol. she's just looking out for you bestie.
  • 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. so they stay in. noted.
  • MKD_FENCEDCODE β€” allow fenced code blocks. ``` gang rise up.
  • 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. she's a binary queen.
  • mkd_in() and mkd_string() return a MMIOT* on success, and null on failure. 😭

πŸ‘‘ SEE ALSO πŸ‘‘

markdown(1), mkd-callbacks(3), mkd-functions(3), mkd-line(3), markdown(7), mkd-extensions(7), mmap(2).

and also, for the full lore: http://daringfireball.net/projects/markdown/syntax 🌈

πŸ’€ BUGS πŸ’€

error handling is minimal at best. like, minimal. don't expect a whole emotional support system from her, okay?

⚠️ also important bestie: the MMIOT created by mkd_string() gets deleted by the markdown function. so don't go touching her after. she's gone. πŸ™ˆ

mastodon wrote this one down, and it's dated December 20, 2007 β€” so this page is a certified vintage classic, and honestly? she's still serving. periodt. πŸ’œβœ¨