LOWDOWN_GEMINI_NEW(3)
π LOWDOWN_GEMINI_NEW(3) π
okay bestie, gather round, because we're looking at lowdown_gemini_new from section 3 of the manual β that's the library functions manual for liblowdown, and this little cutie is the one that hands you a whole Gemini renderer. it's giving "let me build you a renderer" energy, and honestly? obsessed. π
β¨ NAME β¨
lowdown_gemini_new β allocate a Markdown gemini renderer π¦
π LIBRARY π
library βliblowdownβ β that's the one, no cap. π
πΈ SYNOPSIS πΈ
#include <sys/queue.h>
#include <stdio.h>
#include <lowdown.h>
void *
lowdown_gemini_new(const struct lowdown_opts *opts);
like, you include those three headers, you call the function, it gives you a void *. simple as that, periodt. β¨
π DESCRIPTION π
So what does it actually DO? It allocates a Gemini renderer, and it does that using opts->oflags β or, if opts is NULL, it just uses zero. lowkey the most forgiving function in the whole library. π«Ά
The pointer it hands back is reusable β you can pass it to lowdown_gemini_rndr(3) multiple times, as many invocations as you want, it does not care. BUT (and this is the important part, don't skip this) it must be freed with lowdown_gemini_free(3). no leaving it lying around, bestie, that's a memory leak and we do NOT do those here. π
Now, the bits that get recognised inside opts->oflags are:
LOWDOWN_GEMINI_LINK_INLOWDOWN_GEMINI_LINK_ENDLOWDOWN_GEMINI_LINK_NOREFLOWDOWN_GEMINI_LINK_ROMANLOWDOWN_GEMINI_METADATALOWDOWN_STANDALONE
and all of those are documented over in lowdown(3), so go read that one too, iykyk. π₯
π RETURN VALUES π
- Returns a pointer to the renderer β¨
- or
NULLon memory failure π (it happens, we move on)
and yeah β the returned pointer must be freed with lowdown_gemini_free(3). said it before, saying it again, because it matters. π
π EXAMPLES π
okay here's the whole vibe. this parses b of length bsz and outputs in Gemini format. look at her go:
struct lowdown_buf *out;
struct lowdown_doc *doc;
struct lowdown_node *n;
void *rndr;
if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
err(1, NULL);
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_gemini_new(NULL)) == NULL)
err(1, NULL);
if (!lowdown_gemini_rndr(out, rndr, n))
err(1, NULL);
fwrite(out->data, 1, out->size, stdout);
lowdown_gemini_free(rndr);
lowdown_buf_free(out);
lowdown_node_free(n);
lowdown_doc_free(doc);
see how every single thing that got allocated gets freed at the bottom? main character energy is also cleaning up after yourself. π§ the setlocale call, the lowdown_doc_new, the lowdown_doc_parse, the lowdown_buf_new, the lowdown_gemini_new, then lowdown_gemini_rndr writes into out, then fwrite sends out->data (that's out->size bytes, starting at offset 1... wait no, 1 is the size and out->size is the count β literally copy the line, don't overthink it π) straight to stdout. and THEN the free-fest: lowdown_gemini_free(rndr), lowdown_buf_free(out), lowdown_node_free(n), lowdown_doc_free(doc). chef's kiss. π€
π SEE ALSO π
go read them, they're all connected, it's a whole friend group. π«Ά
β STANDARDS β
The gemini βgemtextβ format is documented in Project Gemini: https://geminiprotocol.net β and the version at the time of writing is 0.24.1. noted. π
ngl the thing to actually remember here:NULLopts = zero flags, reuse the pointer freely withlowdown_gemini_rndr(3), and always, ALWAYSlowdown_gemini_free(3)it. that's the whole tea. π
and that's a wrap, bestie!! this page came to you from Debian, dated $Mdocdate$, sitting pretty under the title LOWDOWN_GEMINI_NEW(3). slay, go render some gemtext, and hydrate. πβ¨ππ¦π
π¦ where this page comes from
- alpine 3.24: lowdown-doc 3.0.1-r0 Β· ISC
- arch rolling: lowdown 3.2.1-1 Β· ISC
- debian trixie: liblowdown-dev 2.0.2-2 Β· ISC
- fedora 43: lowdown-libs 2.0.2-2.fc43 Β· ISC AND BSD-3-Clause AND MIT
- fedora 43: lowdown-libs 2.0.2-2.fc43 Β· ISC AND BSD-3-Clause AND MIT
- fedora 44: lowdown-libs 2.0.2-3.fc44 Β· ISC AND BSD-3-Clause AND MIT
- fedora 44: lowdown-libs 2.0.2-3.fc44 Β· ISC AND BSD-3-Clause AND MIT
- nixpkgs unstable: lowdown 3.0.1
- nixpkgs unstable: lowdown-unsandboxed 3.0.1
- ubuntu questing: liblowdown-dev 2.0.2-2
- ubuntu resolute: liblowdown-dev 2.0.4-2 Β· ISC
- ubuntu stonking: liblowdown-dev 3.0.1-1 Β· ISC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms