discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
* tbl(7) text blocks
@ 2014-03-28  7:21 Anthony J. Bentley
  2014-03-28 21:30 ` Ingo Schwarze
  2014-03-28 21:50 ` Guy Harris
  0 siblings, 2 replies; 5+ messages in thread
From: Anthony J. Bentley @ 2014-03-28  7:21 UTC (permalink / raw)
  To: discuss

Hi,

Groff's tbl(1) manual has a section named "Text blocks." Quoting from it:

  A text block can be used to enter data as a single entry which would be
  too long as a simple string between tabs.  It is started with `T{' and
  closed with `T}'.  The former must end a line, and the latter must
  start a line, probably followed by other data columns (separated with
  tabs or the character given with the tab global option).

This feature is used by reStructuredText. For example, the following
selection from mpv(1)'s documentation:

    =============   ================================================
    left-click      play previous file in playlist
    shift+L-click   show playlist
    =============   ================================================

generates the following tbl(7) source:

.TS
center;
|l|l|.
_
T{
left\-click
T}      T{
play previous file in playlist
T}
_
T{
shift+L\-click
T}      T{
show playlist
T}
_
.TE

Groff converts that to the following:

                       +--------------+-----------------------+
                       |left-click    | play previous file in |
                       |              | playlist              |
                       +--------------+-----------------------+
                       |shift+L-click | show playlist         |
                       +--------------+-----------------------+

Mandoc outputs nothing. -Tlint reveals:

/tmp/mpv.1:9:3: ERROR: bad table layout
/tmp/mpv.1:11:1: ERROR: bad table layout
/tmp/mpv.1:12:4: ERROR: bad table layout
/tmp/mpv.1:13:1: ERROR: bad table layout
/tmp/mpv.1:14:1: ERROR: bad table layout
/tmp/mpv.1:15:1: ERROR: bad table layout
/tmp/mpv.1:17:1: ERROR: bad table layout
/tmp/mpv.1:18:1: ERROR: bad table layout
/tmp/mpv.1:19:1: ERROR: bad table layout
/tmp/mpv.1:20:1: ERROR: bad table layout
/tmp/mpv.1:21:1: ERROR: bad table layout
/tmp/mpv.1:7:1: ERROR: no table data cells specified

-- 
Anthony J. Bentley
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tbl(7) text blocks
  2014-03-28  7:21 tbl(7) text blocks Anthony J. Bentley
@ 2014-03-28 21:30 ` Ingo Schwarze
  2014-03-28 23:37   ` Ingo Schwarze
  2014-03-28 21:50 ` Guy Harris
  1 sibling, 1 reply; 5+ messages in thread
From: Ingo Schwarze @ 2014-03-28 21:30 UTC (permalink / raw)
  To: Anthony J. Bentley; +Cc: discuss

Hi Anthony,

Anthony J. Bentley wrote on Fri, Mar 28, 2014 at 01:21:04AM -0600:

> Groff's tbl(1) manual has a section named "Text blocks." Quoting from it:
> 
>   A text block can be used to enter data as a single entry which would be
>   too long as a simple string between tabs.  It is started with `T{' and
>   closed with `T}'.  The former must end a line, and the latter must
>   start a line, probably followed by other data columns (separated with
>   tabs or the character given with the tab global option).

That's supported by mandoc as well, quoting tbl(7):

    If the last cell of a line is T{, all subsequent lines are included
    as part of the cell until T} is specified as its own data cell.
    It may then be followed by a tab (or as designated by tab) or an
    end-of-line to terminate the row.

> This feature is used by reStructuredText. For example, the following
> selection from mpv(1)'s documentation:
> 
>     =============   ================================================
>     left-click      play previous file in playlist
>     shift+L-click   show playlist
>     =============   ================================================
> 
> generates the following tbl(7) source:
> 
> .TS
> center;
> |l|l|.

Hum.  What mandoc doesn't seem to support is leading vertical lines
(ignored, see tbl_term.c, term_tbl(), 
 if (NULL != hp->prev) tbl_vrule(tp, hp); )
and trailing vertical lines
(errors out, see tbl_layout.c, cell() handles '|' at the beginning,
 but not at the end).

> _
> T{
> left\-click
> T}	T{
> play previous file in playlist
> T}
> _
> T{
> shift+L\-click
> T}	T{
> show playlist
> T}
> _
> .TE

The following slight modification works with mandoc:

.TH bentley140328mod 1
.SH NAME
bentley140328 \- bug report
.SH DESCRIPTION
normal text
.TS
box center;
l | l.
T{
left\-click
T}	T{
play previous file in playlist
T}
_
T{
shift+L\-click
T}	T{
show playlist
T}
.TE
normal text

Probably, the two missing features should be implemented in mandoc.

Thanks for the report,
  Ingo
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tbl(7) text blocks
  2014-03-28  7:21 tbl(7) text blocks Anthony J. Bentley
  2014-03-28 21:30 ` Ingo Schwarze
@ 2014-03-28 21:50 ` Guy Harris
  1 sibling, 0 replies; 5+ messages in thread
From: Guy Harris @ 2014-03-28 21:50 UTC (permalink / raw)
  To: discuss


On Mar 28, 2014, at 12:21 AM, Anthony J. Bentley <anthony@cathet.us> wrote:

> Groff's tbl(1) manual has a section named "Text blocks."

FYI, it dates back well before Groff (and well before the GNU project and well before C++...):

	http://www.plan9.bell-labs.com/7thEdMan/v7vol2a.pdf

Look for "TBL - Tbl — A Program to Format Tables".

(For fun, also see

	http://www.plan9.bell-labs.com/7thEdMan/v7vol2b.pdf

and look for "Lex – A Lexical Analyzer Generator", co-written by Mike Lesk and some guy who I think is at Google now. :-))
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tbl(7) text blocks
  2014-03-28 21:30 ` Ingo Schwarze
@ 2014-03-28 23:37   ` Ingo Schwarze
  2014-03-29  0:02     ` Anthony J. Bentley
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Schwarze @ 2014-03-28 23:37 UTC (permalink / raw)
  To: Anthony J. Bentley; +Cc: discuss

Hi Anthony,

Ingo Schwarze wrote on Fri, Mar 28, 2014 at 10:30:59PM +0100:
> Anthony J. Bentley wrote on Fri, Mar 28, 2014 at 01:21:04AM -0600:

>> .TS
>> center;
>> |l|l|.

> Hum.  What mandoc doesn't seem to support is leading vertical lines
> (ignored, see tbl_term.c, term_tbl(), 
>  if (NULL != hp->prev) tbl_vrule(tp, hp); )
> and trailing vertical lines
> (errors out, see tbl_layout.c, cell() handles '|' at the beginning,
>  but not at the end).

That was easier than i thought.

I have committed the following patch to both OpenBSD and bsd.lv.

It would be nice if you could

  cd /usr/src/usr.bin/mandoc; cvs up -dP;
  make obj; make depend; make; sudo make install

and look whether the page now formats better for you.

Yours,
  Ingo


 ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 -----

Log Message:
-----------
Allow leading and trailing vertical lines, 
and format them in the same way as groff.
While here, do not require whitespace before vertical lines 
in layout specifications.
Issues found by bentley@ in mpv(1).

Modified Files:
--------------
    mdocml:
        mandoc.h
        tbl_layout.c
        tbl_term.c

Revision Data
-------------
Index: tbl_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tbl_term.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -Ltbl_term.c -Ltbl_term.c -u -p -r1.25 -r1.26
--- tbl_term.c
+++ tbl_term.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -105,7 +105,8 @@ term_tbl(struct termp *tp, const struct 
 
 	/* Vertical frame at the start of each row. */
 
-	if (TBL_OPT_BOX & sp->opts->opts || TBL_OPT_DBOX & sp->opts->opts)
+	if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
+	    sp->head->vert)
 		term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
 			TBL_SPAN_DHORIZ == sp->pos ? "+" : "|");
 
@@ -159,7 +160,8 @@ term_tbl(struct termp *tp, const struct 
 
 	/* Vertical frame at the end of each row. */
 
-	if (TBL_OPT_BOX & sp->opts->opts || TBL_OPT_DBOX & sp->opts->opts)
+	if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
+	    sp->layout->vert)
 		term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
 			TBL_SPAN_DHORIZ == sp->pos ? "+" : " |");
 	term_flushln(tp);
Index: tbl_layout.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tbl_layout.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -Ltbl_layout.c -Ltbl_layout.c -u -p -r1.24 -r1.25
--- tbl_layout.c
+++ tbl_layout.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -100,6 +100,8 @@ mod:
 	case (','):
 		/* FALLTHROUGH */
 	case ('.'):
+		/* FALLTHROUGH */
+	case ('|'):
 		return(1);
 	default:
 		break;
@@ -217,6 +219,13 @@ cell(struct tbl_node *tbl, struct tbl_ro
 		vert++;
 	while (' ' == p[*pos])
 		(*pos)++;
+
+	/* Handle trailing vertical lines */
+
+	if ('.' == p[*pos] || '\0' == p[*pos]) {
+		rp->vert = vert;
+		return(1);
+	}
 
 	/* Parse the column position (`c', `l', `r', ...). */
 
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.118
retrieving revision 1.119
diff -Lmandoc.h -Lmandoc.h -u -p -r1.118 -r1.119
--- mandoc.h
+++ mandoc.h
@@ -240,6 +240,7 @@ struct	tbl_row {
 	struct tbl_row	 *next;
 	struct tbl_cell	 *first;
 	struct tbl_cell	 *last;
+	int		  vert; /* trailing vertical line */
 };
 
 enum	tbl_datt {
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tbl(7) text blocks
  2014-03-28 23:37   ` Ingo Schwarze
@ 2014-03-29  0:02     ` Anthony J. Bentley
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony J. Bentley @ 2014-03-29  0:02 UTC (permalink / raw)
  To: Ingo Schwarze; +Cc: discuss

Hi Ingo,

Ingo Schwarze writes:
> I have committed the following patch to both OpenBSD and bsd.lv.
> 
> It would be nice if you could
> 
>   cd /usr/src/usr.bin/mandoc; cvs up -dP;
>   make obj; make depend; make; sudo make install
> 
> and look whether the page now formats better for you.

Thanks for looking into this. Yes, with -current mandoc the tables now
display fine.

-- 
Anthony J. Bentley
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-29  0:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-28  7:21 tbl(7) text blocks Anthony J. Bentley
2014-03-28 21:30 ` Ingo Schwarze
2014-03-28 23:37   ` Ingo Schwarze
2014-03-29  0:02     ` Anthony J. Bentley
2014-03-28 21:50 ` Guy Harris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).