tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* fix the vertical spacing around tbl(7) in man(7)
@ 2012-05-27  1:17 Ingo Schwarze
  2012-05-27 15:28 ` Kristaps Dzonsons
  0 siblings, 1 reply; 2+ messages in thread
From: Ingo Schwarze @ 2012-05-27  1:17 UTC (permalink / raw)
  To: tech

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 <schwarze@cvs.openbsd.org> -----

From: Ingo Schwarze <schwarze@cvs.openbsd.org>
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 <kristaps@bsd.lv>
- * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2011, 2012 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
@@ -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 <bsd.regress.mk>
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)
+
+
+
+N\bNA\bAM\bME\bE
+       tbl-vspace - vertical spacing around tables
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+       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

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

end of thread, other threads:[~2012-05-27 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-27  1:17 fix the vertical spacing around tbl(7) in man(7) Ingo Schwarze
2012-05-27 15:28 ` Kristaps Dzonsons

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).