From: Ingo Schwarze <schwarze@usta.de>
To: tech@mdocml.bsd.lv
Subject: fix the vertical spacing around tbl(7) in man(7)
Date: Sun, 27 May 2012 03:17:26 +0200 [thread overview]
Message-ID: <20120527011726.GE31629@iris.usta.de> (raw)
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
next reply other threads:[~2012-05-27 1:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-27 1:17 Ingo Schwarze [this message]
2012-05-27 15:28 ` Kristaps Dzonsons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120527011726.GE31629@iris.usta.de \
--to=schwarze@usta.de \
--cc=tech@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).