TBL(3)
β¨ TBL(3) β Library Functions Manual β¨
okay bestie, gather round, because today we're talking about tbl_alloc, tbl_read, tbl_restart, tbl_span, tbl_end, and tbl_free β aka the roff table parser library for mandoc. no cap, this is the whole vibe. π
πΈ NAME πΈ
tbl_alloc, tbl_read, tbl_restart, tbl_span, tbl_end, tbl_free β the roff table parser library for mandoc π
π¦ SYNOPSIS π¦
#include <sys/types.h>
#include <tbl.h>
#include <tbl_parse.h>
struct tbl_node *
tbl_alloc(int pos, int line);
void
tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs);
void
tbl_restart(int line, int pos, struct tbl_node *tbl);
const struct tbl_span *
tbl_span(struct tbl_node *tbl);
void
tbl_end(struct tbl_node **tblp);
void
tbl_free(struct tbl_node *tbl);
π DESCRIPTION π
so like, this library is tightly integrated into the mandoc(1) utility β it is not designed for stand-alone use, bestie. it's giving "built-in, not a plugin." this whole manual is meant as a reference for the devs working on mandoc(1), periodt. π
π§ Data structures
unless noted otherwise, literally all of these data structures live in <tbl.h>, and they all get deleted in tbl_free(). so they're a package deal, okay? π
struct tbl_nodeβ this one describes a complete table. it's declared in<tbl_int.h>, created intbl_alloc(), and stored in the membersfirst_tbl,last_tbl, andtblofstruct roff[roff.c].- the
first_span,current_span,last_span, andnextmembers may beNULL. - the
first_rowandlast_rowmembers may beNULLtoo, but if there is a span, the functiontbl_layout()guarantees those pointers are notNULL. so like, either both or neither, iykyk. π
- the
struct tbl_optsβ describes the options of one table. it's used as a substructure ofstruct tbl_node, so it gets created and deleted right along with it. it's filled intbl_options(). πstruct tbl_rowβ describes one layout line in a table by maintaining a list of all the cells in that line. it's allocated and filled inrow()[tbl_layout.c], and referenced from thelayoutmember ofstruct tbl_node.- the
nextmember may beNULL. - the function
tbl_layout()guarantees that thefirstandlastmembers are notNULL. π«Ά
- the
struct tbl_cellβ describes one layout cell in a table, specifically its alignment, its membership in spans, and its usage for lines. it's allocated and filled incell_alloc()[tbl_layout.c], and referenced from thefirstandlastmembers ofstruct tbl_row.- the
nextmember may beNULL. β¨
- the
struct tbl_spanβ describes one data line in a table, either by maintaining a list of all data cells in that line or by specifying that it's a horizontal line. it's allocated and filled innewspan()[tbl_data.c], which is called fromtbl_data(), and it's referenced from thefirst_span,current_span, andlast_spanmembers ofstruct tbl_node, plus from thespanmembers ofstruct man_nodeandstruct mdoc_nodefrom<man.h>and<mdoc.h>.- the
first,last,prev, andnextmembers may beNULL. - the function
newspan()[tbl_data.c] guarantees that theoptsandlayoutmembers are notNULL. π
- the
struct tbl_datβ describes one data cell in a table, by specifying whether it contains a line or data, whether it spans additional layout cells, and by storing the data. it's allocated and filled intbl_data(), and referenced from thefirstandlastmembers ofstruct tbl_span.- the
stringandnextmembers may beNULL. - the function
getdata()guarantees that thelayoutmember is notNULL. π
- the
π Interface functions
these ones are implemented in tbl.c, and every single caller lives in roff.c. slay. π
tbl_alloc()β allocates, initializes, and returns a brand-newstruct tbl_node. called fromroff_TS().tbl_read()β dispatches totbl_option(),tbl_layout(),tbl_cdata(), andtbl_data()(more on those below, bestie). called fromroff_parseln().tbl_restart()β resets thepartmember ofstruct tbl_nodetoTBL_PART_LAYOUT. called fromroff_T_().tbl_span()β on the first call, it returns the firststruct tbl_span; for later calls, it returns the next one, orNULL. called fromroff_span().tbl_end()β flags the last span asTBL_SPAN_LASTand clears the pointer passed in as an argument. called fromroff_TE()androff_endparse().tbl_free()β frees the specifiedstruct tbl_nodeplus all thetbl_row,tbl_cell,tbl_span, andtbl_datstructures referenced from it. called fromroff_free()androff_reset(). bye bestie, it was iconic π
π Private functions
these ones are declared in <tbl_int.h>. shhh, they're the backstage crew. π§
int tbl_options(struct tbl_node *tbl, int ln, const char *p)β parses the options line intostruct tbl_opts. implemented intbl_opts.c, called fromtbl_read().int tbl_layout(struct tbl_node *tbl, int ln, const char *p)β allocates and fills onestruct tbl_rowfor each layout line and onestruct tbl_cellfor each layout cell. implemented intbl_layout.c, called fromtbl_read().int tbl_data(struct tbl_node *tbl, int ln, const char *p)β allocates onestruct tbl_spanfor each data line and callsgetdata()for each data cell. implemented intbl_data.c, called fromtbl_read().int tbl_cdata(struct tbl_node *tbl, int ln, const char *p)β keeps parsing a data line: when it findsT}, it switches back toTBL_PART_DATAmode and callsgetdata()if there are more data cells on the line. otherwise, it appends the data to the current data cell. implemented intbl_data.c, called fromtbl_read().int getdata(struct tbl_node *tbl, struct tbl_span *dp, int ln, const char *p, int *pos)β parses one data cell into onestruct tbl_dat. implemented intbl_data.c, called fromtbl_data()andtbl_cdata().
π SEE ALSO π
π AUTHORS π
the tbl library was written by Kristaps Dzonsons <kristaps@bsd.lv> with contributions from Ingo Schwarze <schwarze@openbsd.org>. legends, honestly. π«Άπ
and that's the whole page, bestie β this one shipped with Debian, dated December 14, 2018. go forth and parse those tables, you absolute main character π β¨π
π¦ where this page comes from
- alpine 3.22: mandoc-doc 1.14.6-r13 Β· ISC
- alpine 3.23: mandoc-doc 1.14.6-r14 Β· ISC
- alpine 3.24: mandoc-doc 1.14.6-r15 Β· ISC
- debian trixie: libmandoc-dev 1.14.6-4 Β· ISC
- epel 10: libmandoc-devel 1.14.6-11.el10_1 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- epel 9: libmandoc-devel 1.14.6-2.el9 Β· ISC
- fedora 43: libmandoc-devel 1.14.6-12.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- fedora 43: libmandoc-devel 1.14.6-12.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- fedora 44: libmandoc-devel 1.14.6-13.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- fedora 44: libmandoc-devel 1.14.6-13.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- ubuntu questing: libmandoc-dev 1.14.6-4
- ubuntu resolute: libmandoc-dev 1.14.6-4build1 Β· ISC
- ubuntu stonking: libmandoc-dev 1.14.6-4build1 Β· ISC
- Copyright (c) 2013, 2015, 2018 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms