1 .\" $Id: tbl.3,v 1.2 2015/01/30 04:11:50 schwarze Exp $
3 .\" Copyright (c) 2013 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: January 30 2015 $
27 .Nd roff table parser library for mandoc
36 .Fa "struct mparse *parse"
40 .Fa "struct tbl_node *tbl"
49 .Fa "struct tbl_node *tbl"
51 .Ft const struct tbl_span *
53 .Fa "struct tbl_node *tbl"
57 .Fa "struct tbl_node **tblp"
61 .Fa "struct tbl_node *tbl"
64 This library is tightly integrated into the
66 utility and not designed for stand-alone use.
67 The present manual is intended as a reference for developers working on
70 Unless otherwise noted, all of the following data structures are defined in
75 .It Vt struct tbl_node
76 This structure describes a complete table.
81 and stored in the members
87 .Vt struct roff Bq Pa roff.c .
103 but if there is a span, the function
105 guarantees that these pointers are not
113 .It Vt struct tbl_opts
114 This structure describes the options of one table.
115 It is used as a substructure of
117 and thus created and deleted together with it.
120 .It Vt struct tbl_row
121 This structure describes one layout line in a table
122 by maintaining a list of all the cells in that line.
123 It is allocated and filled in
124 .Fn row Bq Pa tbl_layout.c
125 and referenced from the
128 .Vt struct tbl_node .
140 members are not NULL.
141 .It Vt struct tbl_cell
142 This structure describes one layout cell in a table,
143 in particular its alignment, membership in spans, and
145 It is allocated and filled in
146 .Fn cell_alloc Bq Pa tbl_layout.c
147 and referenced from the
158 .It Vt struct tbl_span
159 This structure describes one data line in a table
160 by maintaining a list of all data cells in that line
161 or by specifying that it is a horizontal line.
162 It is allocated and filled in
163 .Fn newspan Bq Pa tbl_data.c
166 and referenced from the
172 .Vt struct tbl_node ,
193 .Fn newspan Bq Pa tbl_data.c
200 .It Vt struct tbl_dat
201 This structure describes one data cell in a table by specifying
202 whether it contains a line or data, whether it spans additional
203 layout cells, and by storing the data.
204 It is allocated and filled in
206 and referenced from the
211 .Vt struct tbl_span .
226 .Ss Interface functions
227 The following functions are implemented in
233 Allocates, initializes, and returns a new
234 .Vt struct tbl_node .
253 .Dv TBL_PART_LAYOUT .
257 On the first call, return the first
258 .Vt struct tbl_span ;
259 for later calls, return the next one or
264 Flags the last span as
266 and clears the pointer passed as an argment.
274 and all the tbl_row, tbl_cell, tbl_span, and tbl_dat structures
281 .Ss Private functions
283 .It Ft int Fn tbl_options "struct tbl_node *tbl" "int ln" "const char *p"
284 Parses the options line into
285 .Vt struct tbl_opts .
290 .It Ft int Fn tbl_layout "struct tbl_node *tbl" "int ln" "const char *p"
291 Allocates and fills one
293 for each layout line and one
295 for each layout cell.
300 .It Ft int Fn tbl_data "struct tbl_node *tbl" "int ln" "const char *p"
303 for each data line and calls
310 .It Ft int Fn tbl_cdata "struct tbl_node *tbl" "int ln" "const char *p"
311 Continues parsing a data line:
318 if there are more data cells on the line.
319 Otherwise, appends the data to the current data cell.
327 .Fa "struct tbl_node *tbl"
328 .Fa "struct tbl_span *dp"
334 Parses one data cell into one
351 library was written by
352 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
353 with contributions from
354 .An Ingo Schwarze Aq Mt schwarze@openbsd.org .