LOWDOWN_DOC_PARSE(3)
π LOWDOWN_DOC_PARSE(3) π
okay bestie, welcome to the lowdown_doc_parse page, straight out of the Library Functions Manual π
this one lives in the library liblowdown and it's literally the glow-up moment where your Markdown text becomes a whole β¨ AST β¨
πΈ NAME πΈ
lowdown_doc_parse β parse a Markdown document into an AST, no cap π§
π LIBRARY π
library βliblowdownβ π«Ά that's the one, that's the vibe
β¨ SYNOPSIS β¨
#include <sys/queue.h>
#include <stdio.h>
#include <lowdown.h>
struct lowdown_node *
lowdown_doc_parse(struct lowdown_doc *doc, size_t *maxn,
const char *input, size_t inputsz, struct lowdown_metaq *metaq);
like, include the headers first, obviously π
π¦ DESCRIPTION π¦
so basically: you hand it a lowdown(5) document input of length inputsz, and it parses that whole thing into an AST using the parser doc. main character energy fr fr π₯
the maxn argument β if it's not NULL β gets set to one greater than the highest node identifier. and heads up, bestie: its value is undefined if the function returns NULL. so like, don't go reading it after a fail, that's giving chaos π
if metaq is not NULL, it gets filled in with document metadata (if any). metadata key names are canonicalised and duplicate names are ignored β yes, she said what she said. and you gotta free those results with lowdown_metaq_free(3) afterwards, don't leave them hanging π
fun fact: you can invoke this function multiple times with a single doc and different input. reusing her? iconic. she doesn't mind π
π RETURN VALUES π
returns the root of the parse tree, or NULL on memory allocation failure π
if it's not NULL, the returned node is always of type LOWDOWN_ROOT. periodt. β
π EXAMPLES π
ok so here's the whole little ritual: it parses b of length bsz. first it allocates the parser, then the document, then the renderer (HTML in this case, because slay). then it passes output to the renderer, prints it, and cleans up resources. on any memory errors, it exits with err(3). π
struct lowdown_doc *doc;
struct lowdown_node *n;
struct lowdown_buf *ob;
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 ((rndr = lowdown_html_new(NULL)) == NULL)
err(1, NULL);
if ((ob = lowdown_buf_new(1024)) == NULL)
err(1, NULL);
if (!lowdown_html_rndr(ob, rndr, n))
err(1, NULL);
fwrite(stdout, 1, ob->size, ob->data);
lowdown_buf_free(ob);
lowdown_html_rndr_free(rndr);
lowdown_node_free(n);
lowdown_doc_free(doc);
also can we talk about the cleanup section?? she frees everything.lowdown_buf_free,lowdown_html_rndr_free,lowdown_node_free,lowdown_doc_free. memory hygiene is the real self-care π«Ά
π₯ SEE ALSO π₯
and that's the whole page, bestie π this one shipped with Debian and carries the date $Mdocdate$, filed under LOWDOWN_DOC_PARSE(3). go forth and parse, you absolute legend πβ¨
π¦ 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
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- ubuntu noble: liblowdown-dev 1.1.0-1 Β· ISC
- 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