summaryrefslogtreecommitdiffstats
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
commitb0095a770753743c2ece0f095b914220c7ae47fb (patch)
tree9d8d3dc027cb910cbb92875536a785225dc6b3e8 /mdoc_man.c
parentb9ad3d659b9f14475c8f929576c2d0d901d89742 (diff)
downloadmandoc-b0095a770753743c2ece0f095b914220c7ae47fb.tar.gz
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.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/mdoc_man.c b/mdoc_man.c
index 98984238..1c84958f 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -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;