SOLDOUT(3)
π SOLDOUT π
okay bestie, gather round, because we're talking about soldout β the markdown parser library, straight out of the Library Functions Manual (section 3, where the library functions live π«Ά). it's giving "I read markdown so you don't have to" and honestly? iconic.
β¨ DESCRIPTION β¨
so here's the tea β β the soldout library only performs the parsing of markdown input. that's it. that's the whole job. the construction of the output is left to a renderer, which is literally just a set of callback functions that get called when markdown elements are encountered. no cap.
pointers to these functions are gathered into a struct mkd_renderer, along with some renderer-related data. so the struct is like the group chat, and the callbacks are the members π
basic usage will be, step by step, no skipping:
- Create output, input buffers by
bufnew()function. - Fill input buffer by
bufput()function. - Create
struct mkd_rendereror use provided renderer. - Call
markdown()function. - Process output buffer.
- Call
bufrelease()function to clean up buffers.
like, that's the whole pipeline. six steps. a little main-character arc, fr fr π
πΈ EXAMPLES πΈ
here's a simple example that uses the first argument as a markdown string, converts it to an HTML and outputs it to stdout. she's little but she works π
#include <stdio.h>
#include <buffer.h>
#include <markdown.h>
#include <renderers.h>
#define INPUT_UNIT 1024
#define OUTPUT_UNIT 64
int
main(int argc, char *argv[])
{
struct buf *ib, *ob;
/* Make sure we have enough arguments. */
if (argc != 2) {
return 1;
}
ib = bufnew(INPUT_UNIT);
ob = bufnew(OUTPUT_UNIT);
/* bufputs() is a wrapper over bufput() for NUL-terminated string. */
bufputs(ib, argv[1]);
markdown(ob, ib, &mkd_html);
/* Note the resulted data is not NUL-terminated string;
* to make it use bufnullterm(). */
printf("%.*s", (int)ob->size, ob->data);
bufrelease(ib);
bufrelease(ob);
return 0;
}
β οΈ okay real talk for one sec β note the resulted data is not a NUL-terminated string. if you want it to be, usebufnullterm(). don't be out hereprintf-ing without knowing, bestie π
π SEE ALSO π
soldout_array(3)soldout_buffer(3)soldout_markdown(3)soldout_renderers(3)- John Gruber's markdown format:
http://daringfireball.net/projects/markdown/
π AUTHORS π
the soldout library was written by Natasha "Kerensikova" Porte <natacha@instinctive.eu>. the manual page was originally written by Massimo Manghi <mxmanghi@apache.org>, and rewritten to mdoc format by Svyatoslav Mishyn <juef@openmailbox.org>. absolute legends, all three of them, we love a credited queen π
and that's the whole page, babe π this one came from Debian, dated March 29, 2016, living in section 3 as SOLDOUT(3). go parse some markdown, you're gonna slay π
β¨
π¦ where this page comes from
- debian bookworm: libsoldout-dev 1.4-5 Β· ISC
- debian trixie: libsoldout-dev 1.4-7+b1 Β· ISC
- ubuntu jammy: libsoldout-dev 1.4-5 Β· ISC
- ubuntu noble: libsoldout-dev 1.4-5build1 Β· ISC
- ubuntu questing: libsoldout-dev 1.4-7
- ubuntu resolute: libsoldout-dev 1.4-7build1 Β· ISC
- ubuntu stonking: libsoldout-dev 1.4-7build1 Β· ISC
- Copyright (c) 2009 - 2016 Natacha PortΓ© <natacha@instinctive.eu>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms