LOWDOWN_ODT_NEW(3)

πŸ’– LOWDOWN_ODT_NEW πŸ’–

okay bestie, so this is LOWDOWN_ODT_NEW(3), part of the Library Functions Manual β€” yes, we're deep in the liblowdown cinematic universe and it's giving very much main character. 🌟

✨ NAME ✨

lowdown_odt_new β€” allocate a Markdown OpenDocument renderer πŸŽ€

πŸ“š LIBRARY πŸ“š

library β€œliblowdown”

πŸ¦‹ SYNOPSIS πŸ¦‹

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

void *
lowdown_odt_new(const struct lowdown_opts *opts);

πŸ’… DESCRIPTION πŸ’…

So what this does is allocate an OpenDocument renderer using opts->flags, or zero if opts is NULL. That field? It's documented over in lowdown(3), iykyk. The pointer you get back can be used with multiple invocations of lowdown_odt_rndr(3) β€” she's reusable, periodt β€” and she must be freed with lowdown_odt_free(3). Don't ghost her, free her. 🫢

Now, the bits that get recognised in opts->oflags? Only two, and they're:

  • LOWDOWN_SKIP_HTML
  • LOWDOWN_STANDALONE

And then there's the opts->odt.sty field β€” if it's not NULL, it overrides the default <office:font-face-decls>, <office:scripts>, and <office:styles> elements of the document styles. Custom styles? Oh she's fancy. πŸ‘‘

πŸŒ€ RETURN VALUES πŸŒ€

Returns a pointer to the renderer, or NULL on memory failure. 😭 And again, for the people in the back: the returned pointer must be freed with lowdown_odt_free(3).

⚠️ girl. free the pointer. it's literally right there in the docs, twice. no cap.

🌈 EXAMPLES 🌈

okay so this little cutie parses b of length bsz and outputs in β€œflat” OpenDocument format. Look at her go:

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_odt_new(NULL)) == NULL)
    err(1, NULL);
if (!lowdown_odt_rndr(out, rndr, n))
    err(1, NULL);

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

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

notice how every single thing gets freed at the end? that's the vibe check passing. 🌸

πŸ‘€ SEE ALSO πŸ‘€

lowdown(3), lowdown_odt_free(3), lowdown_odt_rndr(3)

⭐ STANDARDS ⭐

The referenced OpenDocument standard is 1.3: https://docs.oasis-open.org/office/OpenDocument/v1.3/.


and that's the whole page, bestie!! πŸ’œ this little legend ships with Debian, dated $Mdocdate$, and she answers to the name LOWDOWN_ODT_NEW(3). slay, go render something gorgeous. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from