LOWDOWN_DOC_NEW(3)

πŸ“¦
version 3.2.1 Β· 2 versions
, in alpine 3.24, arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ LOWDOWN_DOC_NEW(3) ✨

okay so bestie, we're in the Library Functions Manual part of the liblowdown saga, and this page is literally just about one lil function: lowdown_doc_new. she's the girl who sets everything up πŸ’…


🌸 NAME 🌸

lowdown_doc_new β€” allocate a Markdown parser

πŸ“š LIBRARY πŸ“š

the library is β€œliblowdown” πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <sys/queue.h>
#include <stdio.h>
#include <lowdown.h>

struct lowdown_doc *
lowdown_doc_new(const struct lowdown_opts *opts);

πŸ’– DESCRIPTION πŸ’–

so what she does is she allocates a Markdown parser instance with the configuration you hand her in opts. that's it, that's the job, she's an icon, she ate πŸ’…βœ¨

now β€” if opts is NULL, every value is assumed to be zero, except the maximum parse depth, which is fixed at 128. no cap. that one's just built different πŸ”₯

the instance she gives you back? you can use it with multiple invocations of lowdown_doc_parse(3). she's reusable, she's versatile, she's main character energy πŸ‘‘

🌈 RETURN VALUES 🌈

she returns a pointer to the parser, or NULL on memory allocation failure 😭 (rare but real, vibe check failed).

the returned pointer must be freed with a call to lowdown_doc_free(3). do not ghost her. free your girl 🫢

also important: any pointer values in opts, like the ones chilling in meta and metaovr, get copied over, so they don't need to persist after you pass them to lowdown_doc_new(). you can let them go, they're safe, they're memorised, it's giving "I already screenshotted it" πŸ“Έ

πŸ“ EXAMPLES πŸ“

here's a little demo where she parses b if the length is bsz, and then just… throws the result away. dramatic? yes. useful? also yes πŸ’€

struct lowdown_doc *doc;
struct lowdown_node *n;

if ((doc = lowdown_doc_new(NULL)) == NULL)
        err(1, NULL);
if ((n = lowdown_doc_parse(doc, NULL, b, bsz, NULL)) == NULL)
        err(1, NULL);

lowdown_node_free(n);
lowdown_doc_free(doc);

notice how she frees both of them at the end? that's called being a responsible queen πŸ‘‘βœ¨

πŸ‘€ SEE ALSO πŸ‘€


Debian 🧚 $Mdocdate$ 🧚 LOWDOWN_DOC_NEW(3)

and that's the whole page bestie, go forth and parse, ily, don't forget to free πŸ’œπŸ¦‹πŸŒΈ