aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-07-10 19:54:11 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-07-10 19:54:11 +0000
commitd45cc7c440a1f85350b1c3e857288a4ec2b93f28 (patch)
treeb076c81b8aaf5fe28c736abb7749aafa8ba37cfb /mdoc_man.c
parentd37d4166a2cbe775074aef6e163c5d73be7ad9e8 (diff)
downloadmandoc-d45cc7c440a1f85350b1c3e857288a4ec2b93f28.tar.gz
mandoc-d45cc7c440a1f85350b1c3e857288a4ec2b93f28.tar.zst
mandoc-d45cc7c440a1f85350b1c3e857288a4ec2b93f28.zip
multiple fixes to -Tascii .HP rendering:
* do not add an excessive blank line before the block * in literal mode, start a new line after the tag getting this to work requires some general (print_man_node) fixes: * in literal mode, break the output line at the end of each input line, not just after those input lines ending in text * but don't break it when there was no output on the line * and adjust the margins after the .HP tag these general fixes require an adjustment to -Tascii .TP rendering: * set up NOBREAK mode before the body, not after the head finally, based on all this, implement -Tman .Bl -hang in terms of .HP OpenBSD rev. 1.84 and 1.29, respectively
Diffstat (limited to 'mdoc_man.c')
-rw-r--r--mdoc_man.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/mdoc_man.c b/mdoc_man.c
index 28922204..af0e0cdc 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.30 2012/07/10 14:38:51 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.31 2012/07/10 19:54:11 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -100,7 +100,7 @@ static int pre_ux(DECL_ARGS);
static int pre_xr(DECL_ARGS);
static void print_word(const char *);
static void print_offs(const char *);
-static void print_width(const char *);
+static void print_width(const char *, const struct mdoc_node *);
static void print_count(int *);
static void print_node(DECL_ARGS);
@@ -360,22 +360,34 @@ print_offs(const char *v)
}
void
-print_width(const char *v)
+print_width(const char *v, const struct mdoc_node *child)
{
char buf[24];
struct roffsu su;
- size_t sz;
+ size_t sz, chsz;
+
+ /* XXX Rough estimation, might have multiple parts. */
+ chsz = (NULL != child && MDOC_TEXT == child->type) ?
+ strlen(child->string) : 0;
if (a2roffsu(v, &su, SCALE_MAX)) {
if (SCALE_EN == su.unit)
sz = su.scale;
else {
+ if (chsz)
+ print_word(".HP");
+ else
+ print_word(".TP");
print_word(v);
return;
}
} else
sz = strlen(v);
+ if (chsz > sz)
+ print_word(".HP");
+ else
+ print_word(".TP");
snprintf(buf, sizeof(buf), "%ldn", sz + 2);
print_word(buf);
}
@@ -1027,8 +1039,7 @@ pre_it(DECL_ARGS)
case (LIST_dash):
/* FALLTHROUGH */
case (LIST_hyphen):
- print_word(".TP");
- print_width(bln->norm->Bl.width);
+ print_width(bln->norm->Bl.width, NULL);
outflags |= MMAN_nl;
font_push('B');
if (LIST_bullet == bln->norm->Bl.type)
@@ -1038,15 +1049,18 @@ pre_it(DECL_ARGS)
font_pop();
break;
case (LIST_enum):
- print_word(".TP");
- print_width(bln->norm->Bl.width);
+ print_width(bln->norm->Bl.width, NULL);
outflags |= MMAN_nl;
print_count(&bln->norm->Bl.count);
outflags |= MMAN_nl;
break;
+ case (LIST_hang):
+ print_width(bln->norm->Bl.width, n->child);
+ outflags |= MMAN_nl;
+ break;
default:
if (bln->norm->Bl.width)
- print_width(bln->norm->Bl.width);
+ print_width(bln->norm->Bl.width, n->child);
break;
}
outflags |= MMAN_nl;