From c262512cda526a647bc53812a01794100b385be9 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 25 Nov 2018 21:17:34 +0000 Subject: Let cells containing nothing but \^ extend the cell above. Missing feature reported by Pali dot Rohar at gmail dot com. --- TODO | 6 +----- tbl.7 | 22 ++++++++++++++-------- tbl_data.c | 27 +++++++++++++++++---------- tbl_html.c | 19 ++++++++++++------- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/TODO b/TODO index 48b3be8a..1f549a29 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.277 2018/11/25 19:24:20 schwarze Exp $ +* $Id: TODO,v 1.278 2018/11/25 21:17:34 schwarze Exp $ ************************************************************************ Many issues are annotated for difficulty as follows: @@ -168,10 +168,6 @@ are mere guesses, and some may be wrong. --- missing tbl features ----------------------------------------------- -- vertically spanning cells by \^ in the data section - pali dot rohar at gmail dot com 16 Jul 2018 13:03:35 +0200 - loc * exist * algo * size * imp *** - - the "s" layout column specifier is used for placement of data into columns, but ignored during column width calculations synaptics(4) found by tedu@ Mon, 17 Aug 2015 21:17:42 -0400 diff --git a/tbl.7 b/tbl.7 index 3883b409..6c1df147 100644 --- a/tbl.7 +++ b/tbl.7 @@ -1,7 +1,7 @@ -.\" $Id: tbl.7,v 1.29 2017/10/17 23:19:12 schwarze Exp $ +.\" $Id: tbl.7,v 1.30 2018/11/25 21:17:34 schwarze Exp $ .\" .\" Copyright (c) 2010, 2011 Kristaps Dzonsons -.\" Copyright (c) 2014, 2015, 2017 Ingo Schwarze +.\" Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 17 2017 $ +.Dd $Mdocdate: November 25 2018 $ .Dt TBL 7 .Os .Sh NAME @@ -147,9 +147,9 @@ The combined cell as a whole consumes only one cell of the corresponding data line. .It Cm a Left-justify a string and pad with one space. -.It Cm ^ +.It Cm \(ha Vertically span rows from the last -.Pf non- Cm ^ +.Pf non- Cm \(ha layout cell. It is an error to invoke a vertical span on the first layout line. Unlike a horizontal span, a vertical span consumes a data cell @@ -231,7 +231,13 @@ Each data line consists of one or more data cells, delimited by .Cm tab characters. .Pp -If a data cells contains only the single character +If a data cell contains only the two bytes +.Ql \e\(ha , +the cell above spans to this row, as if the layout specification +of this cell were +.Cm \(ha . +.Pp +If a data cell contains only the single character .Ql _ or .Ql = , @@ -332,8 +338,8 @@ Spans and skipping width calculations: \&.TS box tab(:); lz s | rt -lt| cb| ^ -^ | rz s. +lt| cb| \(ha +\(ha | rz s. left:r l:center: :right diff --git a/tbl_data.c b/tbl_data.c index 9339465e..577da6a1 100644 --- a/tbl_data.c +++ b/tbl_data.c @@ -1,4 +1,4 @@ -/* $Id: tbl_data.c,v 1.46 2018/11/25 19:24:20 schwarze Exp $ */ +/* $Id: tbl_data.c,v 1.47 2018/11/25 21:17:34 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2015, 2017, 2018 Ingo Schwarze @@ -45,6 +45,15 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, struct tbl_span *pdp; int sv; + /* + * Determine the length of the string in the cell + * and advance the parse point to the end of the cell. + */ + + sv = *pos; + while (p[*pos] != '\0' && p[*pos] != tbl->opts.tab) + (*pos)++; + /* Advance to the next layout cell, skipping spanners. */ cp = dp->last == NULL ? dp->layout->first : dp->last->layout->next; @@ -67,8 +76,8 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, dp->layout->last = cp; } else { mandoc_msg(MANDOCERR_TBLDATA_EXTRA, tbl->parse, - ln, *pos, p + *pos); - while (p[*pos]) + ln, sv, p + sv); + while (p[*pos] != '\0') (*pos)++; return; } @@ -91,7 +100,8 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, * can be reused for more than one data row. */ - if (cp->pos == TBL_CELL_DOWN) { + if (cp->pos == TBL_CELL_DOWN || + (*pos - sv == 2 && p[sv] == '\\' && p[sv + 1] == '^')) { pdp = dp; while ((pdp = pdp->prev) != NULL) { pdat = pdp->first; @@ -100,7 +110,8 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, pdat = pdat->next; if (pdat == NULL) break; - if (pdat->layout->pos != TBL_CELL_DOWN) { + if (pdat->layout->pos != TBL_CELL_DOWN && + strcmp(pdat->string, "\\^") != 0) { pdat->vspans++; break; } @@ -126,10 +137,6 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, dp->last->next = dat; dp->last = dat; - sv = *pos; - while (p[*pos] && p[*pos] != tbl->opts.tab) - (*pos)++; - /* * Check for a continued-data scope opening. This consists of a * trailing `T{' at the end of the line. Subsequent lines, @@ -143,7 +150,7 @@ getdata(struct tbl_node *tbl, struct tbl_span *dp, dat->string = mandoc_strndup(p + sv, *pos - sv); - if (p[*pos]) + if (p[*pos] != '\0') (*pos)++; if ( ! strcmp(dat->string, "_")) diff --git a/tbl_html.c b/tbl_html.c index b6090038..4523036c 100644 --- a/tbl_html.c +++ b/tbl_html.c @@ -1,4 +1,4 @@ -/* $Id: tbl_html.c,v 1.26 2018/11/25 19:24:20 schwarze Exp $ */ +/* $Id: tbl_html.c,v 1.27 2018/11/25 21:17:34 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze @@ -126,13 +126,18 @@ print_tbl(struct html *h, const struct tbl_span *sp) default: for (dp = sp->first; dp != NULL; dp = dp->next) { print_stagq(h, tt); - switch (dp->layout->pos) { - case TBL_CELL_SPAN: - case TBL_CELL_DOWN: + + /* + * Do not generate elements for continuations + * of spanned cells. Larger elements covering + * this space were already generated earlier. + */ + + if (dp->layout->pos == TBL_CELL_SPAN || + dp->layout->pos == TBL_CELL_DOWN || + (dp->string != NULL && + strcmp(dp->string, "\\^") == 0)) continue; - default: - break; - } /* Determine the attribute values. */ -- cgit v1.2.3