1 .\" Id: tbl.3,v 1.1 2013/06/01 05:44:39 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.
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 .
88 .It Vt struct tbl_opts
89 This structure describes the options of one table.
90 It is used as a substructure of
92 and thus created and deleted together with it.
95 .It Vt struct tbl_head
96 This structure describes one layout column in a table,
97 in particular the vertical line to its left.
98 It is allocated and filled in
99 .Fn cell_alloc Bq Pa tbl_layout.c
100 and referenced from the
105 .Vt struct tbl_node .
106 .It Vt struct tbl_row
107 This structure describes one layout line in a table
108 by maintaining a list of all the cells in that line.
109 It is allocated and filled in
110 .Fn row Bq Pa tbl_layout.c
111 and referenced from the
114 .Vt struct tbl_node .
115 .It Vt struct tbl_cell
116 This structure describes one layout cell in a table,
117 in particular its alignment, membership in spans, and
119 It is allocated and filled in
120 .Fn cell_alloc Bq Pa tbl_layout.c
121 and referenced from the
127 .It Vt struct tbl_span
128 This structure describes one data line in a table
129 by maintaining a list of all data cells in that line
130 or by specifying that it is a horizontal line.
131 It is allocated and filled in
132 .Fn newspan Bq Pa tbl_data.c
135 and referenced from the
141 .Vt struct tbl_node ,
152 .It Vt struct tbl_dat
153 This structure describes one data cell in a table by specifying
154 whether it contains a line or data, whether it spans additional
155 layout cells, and by storing the data.
156 It is allocated and filled in
158 and referenced from the
163 .Vt struct tbl_span .
165 .Ss Interface functions
166 The following functions are implemented in
172 Allocates, initializes, and returns a new
173 .Vt struct tbl_node .
192 .Dv TBL_PART_LAYOUT .
196 On the first call, return the first
197 .Vt struct tbl_span ;
198 for later calls, return the next one or
203 Flags the last span as
205 and clears the pointer passed as an argment.
213 and all the tbl_row, tbl_cell, tbl_span, tbl_dat and tbl_head structures
220 .Ss Private functions
222 .It Ft int Fn tbl_options "struct tbl_node *tbl" "int ln" "const char *p"
223 Parses the options line into
224 .Vt struct tbl_opts .
229 .It Ft int Fn tbl_layout "struct tbl_node *tbl" "int ln" "const char *p"
230 Allocates and fills one
232 for each layout column, one
234 for each layout line, and one
236 for each layout cell.
241 .It Ft int Fn tbl_data "struct tbl_node *tbl" "int ln" "const char *p"
244 for each data line and calls
251 .It Ft int Fn tbl_cdata "struct tbl_node *tbl" "int ln" "const char *p"
252 Continues parsing a data line:
259 if there are more data cells on the line.
260 Otherwise, appends the data to the current data cell.
268 .Fa "struct tbl_node *tbl"
269 .Fa "struct tbl_span *dp"
275 Parses one data cell into one
292 library was written by
293 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
294 with contributions from
295 .An Ingo Schwarze Aq Mt schwarze@openbsd.org .