1 .\" $Id: tbl.3,v 1.6 2018/12/14 06:33:14 schwarze Exp $
3 .\" Copyright (c) 2013, 2015, 2018 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: December 14 2018 $
27 .Nd roff table parser library for mandoc
39 .Fa "struct tbl_node *tbl"
48 .Fa "struct tbl_node *tbl"
50 .Ft const struct tbl_span *
52 .Fa "struct tbl_node *tbl"
56 .Fa "struct tbl_node **tblp"
60 .Fa "struct tbl_node *tbl"
63 This library is tightly integrated into the
65 utility and not designed for stand-alone use.
66 The present manual is intended as a reference for developers working on
69 Unless otherwise noted, all of the following data structures are declared in
74 .It Vt struct tbl_node
75 This structure describes a complete table.
80 and stored in the members
86 .Vt struct roff Bq Pa roff.c .
102 but if there is a span, the function
104 guarantees that these pointers are not
106 .It Vt struct tbl_opts
107 This structure describes the options of one table.
108 It is used as a substructure of
110 and thus created and deleted together with it.
113 .It Vt struct tbl_row
114 This structure describes one layout line in a table
115 by maintaining a list of all the cells in that line.
116 It is allocated and filled in
117 .Fn row Bq Pa tbl_layout.c
118 and referenced from the
121 .Vt struct tbl_node .
133 members are not NULL.
134 .It Vt struct tbl_cell
135 This structure describes one layout cell in a table,
136 in particular its alignment, membership in spans, and
138 It is allocated and filled in
139 .Fn cell_alloc Bq Pa tbl_layout.c
140 and referenced from the
151 .It Vt struct tbl_span
152 This structure describes one data line in a table
153 by maintaining a list of all data cells in that line
154 or by specifying that it is a horizontal line.
155 It is allocated and filled in
156 .Fn newspan Bq Pa tbl_data.c
159 and referenced from the
165 .Vt struct tbl_node ,
186 .Fn newspan Bq Pa tbl_data.c
193 .It Vt struct tbl_dat
194 This structure describes one data cell in a table by specifying
195 whether it contains a line or data, whether it spans additional
196 layout cells, and by storing the data.
197 It is allocated and filled in
199 and referenced from the
204 .Vt struct tbl_span .
219 .Ss Interface functions
220 The following functions are implemented in
222 and all callers are in
226 Allocates, initializes, and returns a new
227 .Vt struct tbl_node .
246 .Dv TBL_PART_LAYOUT .
250 On the first call, return the first
251 .Vt struct tbl_span ;
252 for later calls, return the next one or
257 Flags the last span as
259 and clears the pointer passed as an argment.
267 and all the tbl_row, tbl_cell, tbl_span, and tbl_dat structures
274 .Ss Private functions
275 The following functions are declared in
278 .It Ft int Fn tbl_options "struct tbl_node *tbl" "int ln" "const char *p"
279 Parses the options line into
280 .Vt struct tbl_opts .
285 .It Ft int Fn tbl_layout "struct tbl_node *tbl" "int ln" "const char *p"
286 Allocates and fills one
288 for each layout line and one
290 for each layout cell.
295 .It Ft int Fn tbl_data "struct tbl_node *tbl" "int ln" "const char *p"
298 for each data line and calls
305 .It Ft int Fn tbl_cdata "struct tbl_node *tbl" "int ln" "const char *p"
306 Continues parsing a data line:
313 if there are more data cells on the line.
314 Otherwise, appends the data to the current data cell.
322 .Fa "struct tbl_node *tbl"
323 .Fa "struct tbl_span *dp"
329 Parses one data cell into one
346 library was written by
347 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
348 with contributions from
349 .An Ingo Schwarze Aq Mt schwarze@openbsd.org .