From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout.scc.kit.edu (mailout.scc.kit.edu [129.13.185.202]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id q4R1HSta007191 for ; Sat, 26 May 2012 21:17:29 -0400 (EDT) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1SYS6o-0008KH-To; Sun, 27 May 2012 03:17:26 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1SYS6o-0001Bi-W3 for tech@mdocml.bsd.lv; Sun, 27 May 2012 03:17:26 +0200 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1SYS6o-00074X-VD for tech@mdocml.bsd.lv; Sun, 27 May 2012 03:17:26 +0200 Received: from schwarze by usta.de with local (Exim 4.77) (envelope-from ) id 1SYS6o-0006SX-HR for tech@mdocml.bsd.lv; Sun, 27 May 2012 03:17:26 +0200 Date: Sun, 27 May 2012 03:17:26 +0200 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: fix the vertical spacing around tbl(7) in man(7) Message-ID: <20120527011726.GE31629@iris.usta.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by krisdoz.my.domain id q4R1HSta007191 And another one. I'm leaving the regress/ part even though, obviously, i'm not planning to commit it to bsd.lv - but it may help to see how the spacing is intended to look like. ----- Forwarded message from Ingo Schwarze ----- From: Ingo Schwarze Sender: owner-source-changes@openbsd.org Date: Sat, 26 May 2012 19:01:25 -0600 (MDT) To: source-changes@cvs.openbsd.org Subject: CVS: cvs.openbsd.org: src CVSROOT: /cvs Module name: src Changes by: schwarze@cvs.openbsd.org 2012/05/26 19:01:25 Modified files: usr.bin/mandoc : tbl_term.c term.c term.h Added files: regress/usr.bin/mandoc/man/TS: Makefile vspace.in vspace.out_ascii Log message: Fix the vertical spacing around tbl(7) instances in man(7). Groff forces the document author to manually request sufficient spacing after .TE - that is, at least .sp 1v after a table with the "box" option and at least .sp 2v after a table with the "doublebox" option - or else it clobbers the box. I consider that insane, so i'm not imitating groff in that respect. Instead, i add at least as much vertical space as groff, or more where required to avoid clobbering the box. Consequently, output will be identical for input that looks sane with groff, and mandoc will make output look better for input that looks bad with groff. As a side effect, having identical output for portable input makes it possible to set up the first regression tests for tbl(7). ----- End forwarded message ----- Index: usr.bin/mandoc/tbl_term.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/tbl_term.c,v retrieving revision 1.12 diff -u -p -r1.12 tbl_term.c --- usr.bin/mandoc/tbl_term.c 26 May 2012 20:53:17 -0000 1.12 +++ usr.bin/mandoc/tbl_term.c 27 May 2012 00:37:33 -0000 @@ -167,10 +167,14 @@ term_tbl(struct termp *tp, const struct if (TBL_SPAN_LAST & sp->flags) { if (TBL_OPT_DBOX & sp->tbl->opts || - TBL_OPT_BOX & sp->tbl->opts) + TBL_OPT_BOX & sp->tbl->opts) { tbl_hframe(tp, sp, 0); - if (TBL_OPT_DBOX & sp->tbl->opts) + tp->skipvsp = 1; + } + if (TBL_OPT_DBOX & sp->tbl->opts) { tbl_hframe(tp, sp, 1); + tp->skipvsp = 2; + } assert(tp->tbl.cols); free(tp->tbl.cols); tp->tbl.cols = NULL; Index: usr.bin/mandoc/term.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/term.c,v retrieving revision 1.62 diff -u -p -r1.62 term.c --- usr.bin/mandoc/term.c 21 Sep 2011 09:57:11 -0000 1.62 +++ usr.bin/mandoc/term.c 27 May 2012 00:37:33 -0000 @@ -1,7 +1,7 @@ /* $Id: term.c,v 1.62 2011/09/21 09:57:11 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2011 Ingo Schwarze + * Copyright (c) 2010, 2011, 2012 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 @@ -312,7 +312,10 @@ term_vspace(struct termp *p) term_newln(p); p->viscol = 0; - (*p->endline)(p); + if (0 < p->skipvsp) + p->skipvsp--; + else + (*p->endline)(p); } void Index: usr.bin/mandoc/term.h =================================================================== RCS file: /cvs/src/usr.bin/mandoc/term.h,v retrieving revision 1.34 diff -u -p -r1.34 term.h --- usr.bin/mandoc/term.h 13 Nov 2011 13:30:42 -0000 1.34 +++ usr.bin/mandoc/term.h 27 May 2012 00:37:33 -0000 @@ -63,6 +63,7 @@ struct termp { int col; /* Bytes in buf. */ size_t viscol; /* Chars on current line. */ int overstep; /* See termp_flushln(). */ + int skipvsp; /* Vertical space to skip. */ int flags; #define TERMP_SENTENCE (1 << 1) /* Space before a sentence. */ #define TERMP_NOSPACE (1 << 2) /* No space before words. */ Index: regress/usr.bin/mandoc/man/TS/Makefile =================================================================== RCS file: regress/usr.bin/mandoc/man/TS/Makefile diff -N regress/usr.bin/mandoc/man/TS/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/mandoc/man/TS/Makefile 27 May 2012 00:37:33 -0000 @@ -0,0 +1,12 @@ +# $OpenBSD: Makefile,v 1.4 2011/02/05 18:26:14 schwarze Exp $ + +REGRESS_TARGETS=vspace + +TBL=/usr/local/bin/tbl + +.for t in ${REGRESS_TARGETS} +${t}.out_ascii: ${t}.in + ${TBL} ${.ALLSRC} | ${NROFF} > ${.TARGET} +.endfor + +.include Index: regress/usr.bin/mandoc/man/TS/vspace.in =================================================================== RCS file: regress/usr.bin/mandoc/man/TS/vspace.in diff -N regress/usr.bin/mandoc/man/TS/vspace.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/mandoc/man/TS/vspace.in 27 May 2012 00:37:33 -0000 @@ -0,0 +1,48 @@ +.TH TBL-VSPACE 1 +.SH NAME +tbl-vspace \- vertical spacing around tables +.SH DESCRIPTION +normal text before table +.TS +L . +table without box +.TE +normal text after table without box +.TS +box; +L . +table with box +.TE +.\" at least one vertical space is required here +.\" or groff will clobber the box +.sp 1v +normal text after table with box +.TS +doublebox; +L . +table with double box +.TE +.\" at least two vertical spaces are required here +.\" or groff will clobber the box +.sp 2v +normal text after table with double box +.TS +L . +table without box +.TE +.TS +box; +L . +table with box +.TE +.sp 1v +.TS +doublebox; +L . +table with double box +.TE +.sp 2v +.TS +L . +table without box +.TE Index: regress/usr.bin/mandoc/man/TS/vspace.out_ascii =================================================================== RCS file: regress/usr.bin/mandoc/man/TS/vspace.out_ascii diff -N regress/usr.bin/mandoc/man/TS/vspace.out_ascii --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/mandoc/man/TS/vspace.out_ascii 27 May 2012 00:37:33 -0000 @@ -0,0 +1,42 @@ +TBL-VSPACE(1) OpenBSD Reference Manual TBL-VSPACE(1) + + + +NNAAMMEE + tbl-vspace - vertical spacing around tables + +DDEESSCCRRIIPPTTIIOONN + normal text before table + + table without box + normal text after table without box + + +---------------+ + |table with box | + +---------------+ + normal text after table with box + + +----------------------+ + +----------------------+ + |table with double box | + +----------------------+ + +----------------------+ + normal text after table with double box + + table without box + + +---------------+ + |table with box | + +---------------+ + + +----------------------+ + +----------------------+ + |table with double box | + +----------------------+ + +----------------------+ + + table without box + + + + TBL-VSPACE(1) -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv