summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-08-17 11:03:07 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-08-17 11:03:07 +0000
commit68a4884e51e55098303cfe5b920959d493ee8e73 (patch)
tree86d7137d370dc24352eac08297e311d5e0aade0f
parentd8cc7939c87b98bce901828e6ad799e21b6154dc (diff)
downloadmandoc-68a4884e51e55098303cfe5b920959d493ee8e73.tar.gz
mandoc-68a4884e51e55098303cfe5b920959d493ee8e73.tar.zst
mandoc-68a4884e51e55098303cfe5b920959d493ee8e73.zip
`IP' and `TP' correctly handle width arguments.
Documented numeric widths.
-rw-r--r--man.733
-rw-r--r--man_term.c66
2 files changed, 77 insertions, 22 deletions
diff --git a/man.7 b/man.7
index 8a313a84..968f4787 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.25 2009/08/13 12:54:52 kristaps Exp $
+.\" $Id: man.7,v 1.26 2009/08/17 11:03:07 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -14,7 +14,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: August 13 2009 $
+.Dd $Mdocdate: August 17 2009 $
.Dt MAN 7
.Os
.\" SECTION
@@ -262,6 +262,18 @@ and
This section is a canonical reference to all macros, arranged
alphabetically. For the scoping of individual macros, see
.Sx MACRO SYNTAX .
+.\" SUBSECTION
+.Ss Terms
+In this reference, a numerical width may be either a standalone natural
+number (such as 3, 4, 10, etc.) or a natural number followed by a width
+multiplier
+.Qq n ,
+corresponding to the width of the formatted letter n, or
+.Qq m ,
+corresponding to the width of the formatted letter m. The latter is the
+default, if unspecified.
+.\" SUBSECTION
+.Ss Macro Reference
.Bl -tag -width Ds
.It \&B
Text is rendered in bold face.
@@ -296,11 +308,8 @@ Begin a paragraph with the following syntax:
.Pp
This follows the behaviour of the
.Sq \&TP
-macro except that
-.Va width ,
-which is only considered as such if properly-formed (e.g., 24n, 4,
-etc.), is used as the indentation offset instead of the default
-indentation value.
+except for the macro syntax (all arguments on the line, instead of
+having next-line scope).
.It \&IR
Text is rendered alternately in italics and roman (the default font).
Whitespace between arguments is omitted in output.
@@ -352,6 +361,16 @@ replaces the default rendered volume as dictated by the manual section.
Begin a paragraph where the head, if exceeding the indentation width, is
followed by a newline; if not, the body follows on the same line after a
buffer to the indentation width. Subsequent output lines are indented.
+.Pp
+The indentation width may be set as follows:
+.Bd -literal -offset indent
+\&.TP [width]
+.Ed
+.Pp
+Where
+.Va width
+must be a properly-formed numeric width. If unspecified or improperly
+formed, the default indentation width is used.
.It \&br
Breaks the current line. Consecutive invocations have no further effect.
.It \&fi
diff --git a/man_term.c b/man_term.c
index 56ac4ac9..2ea5d10a 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.22 2009/08/13 12:54:52 kristaps Exp $ */
+/* $Id: man_term.c,v 1.23 2009/08/17 11:03:07 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -474,9 +474,6 @@ pre_IP(DECL_ARGS)
int ival;
switch (n->type) {
- case (MAN_BLOCK):
- fmt_block_vspace(p, n);
- return(1);
case (MAN_BODY):
p->flags |= TERMP_NOLPAD;
p->flags |= TERMP_NOSPACE;
@@ -485,11 +482,14 @@ pre_IP(DECL_ARGS)
p->flags |= TERMP_NOBREAK;
p->flags |= TERMP_TWOSPACE;
break;
+ case (MAN_BLOCK):
+ fmt_block_vspace(p, n);
+ /* FALLTHROUGH */
default:
return(1);
}
- len = INDENT * 2;
+ len = INDENT;
ival = -1;
/* Calculate offset. */
@@ -503,11 +503,11 @@ pre_IP(DECL_ARGS)
}
switch (n->type) {
- case (MAN_BODY):
- p->offset = INDENT + len;
- p->rmargin = p->maxrmargin;
- break;
case (MAN_HEAD):
+ /* Handle zero-width lengths. */
+ if (0 == len)
+ len = 1;
+
p->offset = INDENT;
p->rmargin = INDENT + len;
if (ival < 0)
@@ -517,6 +517,10 @@ pre_IP(DECL_ARGS)
for (nn = n->child; nn->next; nn = nn->next)
print_node(p, fl, nn, m);
return(0);
+ case (MAN_BODY):
+ p->offset = INDENT + len;
+ p->rmargin = p->maxrmargin;
+ break;
default:
break;
}
@@ -551,21 +555,53 @@ post_IP(DECL_ARGS)
static int
pre_TP(DECL_ARGS)
{
+ const struct man_node *nn;
+ size_t len;
+ int ival;
switch (n->type) {
- case (MAN_BLOCK):
- fmt_block_vspace(p, n);
- break;
case (MAN_HEAD):
- p->rmargin = INDENT * 2;
- p->offset = INDENT;
p->flags |= TERMP_NOBREAK;
p->flags |= TERMP_TWOSPACE;
break;
case (MAN_BODY):
p->flags |= TERMP_NOLPAD;
p->flags |= TERMP_NOSPACE;
- p->offset = INDENT * 2;
+ break;
+ case (MAN_BLOCK):
+ fmt_block_vspace(p, n);
+ /* FALLTHROUGH */
+ default:
+ return(1);
+ }
+
+ len = INDENT;
+ ival = -1;
+
+ /* Calculate offset. */
+
+ if (NULL != (nn = n->parent->head->child))
+ if (NULL != nn->next)
+ if ((ival = arg_width(nn)) >= 0)
+ len = (size_t)ival;
+
+ switch (n->type) {
+ case (MAN_HEAD):
+ /* Handle zero-length properly. */
+ if (0 == len)
+ len = 1;
+
+ p->offset = INDENT;
+ p->rmargin = INDENT + len;
+
+ /* Don't print same-line elements. */
+ for (nn = n->child; nn; nn = nn->next)
+ if (nn->line > n->line)
+ print_node(p, fl, nn, m);
+ return(0);
+ case (MAN_BODY):
+ p->offset = INDENT + len;
+ p->rmargin = p->maxrmargin;
break;
default:
break;