LOWDOWN_LATEX_NEW(3)

✨ LOWDOWN_LATEX_NEW(3) ✨

okay so bestie, welcome to the Library Functions Manual page for lowdown_latex_new, which is part of the library β€œliblowdown” πŸ’… she's giving very much "I make LaTeX out of Markdown" and honestly? obsessed.


πŸŽ€ NAME πŸŽ€

lowdown_latex_new β€” allocate a Markdown LaTeX renderer

like... she builds you a renderer. a LaTeX one. for Markdown. that's the whole job. iconic behavior fr fr ✨


πŸ“š LIBRARY πŸ“š

library β€œliblowdown” 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

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

void *
lowdown_latex_new(const struct lowdown_opts *opts);

ngl that's the whole vibe right there. one function, one pointer argument, no drama πŸŽ€


πŸ’– DESCRIPTION πŸ’–

So basically? lowdown_latex_new allocates a LaTeX renderer, and it sets it up using opts->flags β€” or, if opts is NULL, it just uses zero instead. no cap. 🫢

That flags field? it's documented over in lowdown(3), so if you wanna know what's in there, that's your girl.

The pointer you get back is reusable β€” you can hit lowdown_latex_rndr(3) with it multiple times, like, as many invocations as you want, she doesn't mind πŸ’… β€” but when you're done being obsessed with her, you must free her with lowdown_latex_free(3). periodt. no leaks allowed in this group chat 🌸

Now, the bits that are actually recognised inside opts->oflags are:

  • LOWDOWN_LATEX_NUMBERED
  • LOWDOWN_SKIP_HTML
  • LOWDOWN_STANDALONE

those three, and like, only those three. iykyk ✨


🌈 RETURN VALUES 🌈

She hands you a pointer to the renderer πŸ’– β€” or NULL if memory failure happens (rip, tragic, we've all been there 😭).

And yes, bestie, one more time for the people in the back: the returned pointer must be freed with lowdown_latex_free(3). that's not a suggestion, that's the law πŸ”₯


πŸ“ EXAMPLES πŸ“

okay so here's the moment you've been waiting for. this little number parses b of length bsz and outputs in LaTeX format. slay.

struct lowdown_buf *out;
struct lowdown_doc *doc;
struct lowdown_node *n;
void *rndr;

if ((doc = lowdown_doc_new(NULL)) == NULL)
        err(1, NULL);
if ((n = lowdown_doc_parse(doc, NULL, b, bsz, NULL)) == NULL)
        err(1, NULL);
if ((out = lowdown_buf_new(256)) == NULL)
        err(1, NULL);
if ((rndr = lowdown_latex_new(NULL)) == NULL)
        err(1, NULL);
if (!lowdown_latex_rndr(out, rndr, n))
        err(1, NULL);

fwrite(out->data, 1, out->size, stdout);

lowdown_latex_free(rndr);
lowdown_buf_free(out);
lowdown_node_free(n);
lowdown_doc_free(doc);

look at that cleanup at the bottom. four frees, in order, gorgeous, no notes πŸ‘‘ that's main character energy right there.


πŸ‘€ SEE ALSO πŸ‘€

go read them, they're all part of the same friend group πŸ¦‹


and that's the page, bestie πŸ’œ this one came from Debian, version $Mdocdate$, filed under LOWDOWN_LATEX_NEW(3). now go free your renderer, drink some water, and slay the rest of your day πŸŽ€βœ¨

πŸ“¦ where this page comes from