summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-07-01 15:37:00 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-07-01 15:37:00 +0000
commitf493f0926a306b8c080500d57168d36f304aedba (patch)
tree20ead7e44f8a1947654fa6420c2bea13394efbff /usr.bin/mandoc/mdoc_term.c
parent6205336faf2316e657dd16af846cba2cdc9bffe7 (diff)
Improve .Nm indentation in the SYNOPSIS;
kristaps@ will do the missing HTML part soon. "looks nicer" jmc@ "seems perfect to me" sobrado@ "slap it in" kristaps@
Diffstat (limited to 'usr.bin/mandoc/mdoc_term.c')
-rw-r--r--usr.bin/mandoc/mdoc_term.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index bd0e761e681..90c6fde3ba7 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.93 2010/06/29 17:10:30 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.94 2010/07/01 15:36:59 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -81,6 +81,7 @@ static void termp_fo_post(DECL_ARGS);
static void termp_in_post(DECL_ARGS);
static void termp_it_post(DECL_ARGS);
static void termp_lb_post(DECL_ARGS);
+static void termp_nm_post(DECL_ARGS);
static void termp_op_post(DECL_ARGS);
static void termp_pf_post(DECL_ARGS);
static void termp_pq_post(DECL_ARGS);
@@ -166,7 +167,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_in_pre, termp_in_post }, /* In */
{ termp_li_pre, NULL }, /* Li */
{ termp_nd_pre, NULL }, /* Nd */
- { termp_nm_pre, NULL }, /* Nm */
+ { termp_nm_pre, termp_nm_post }, /* Nm */
{ termp_op_pre, termp_op_post }, /* Op */
{ NULL, NULL }, /* Ot */
{ termp_under_pre, NULL }, /* Pa */
@@ -1021,11 +1022,35 @@ static int
termp_nm_pre(DECL_ARGS)
{
- if (NULL == n->child && NULL == m->name)
+ if (MDOC_BLOCK == n->type)
+ return(1);
+
+ if (MDOC_BODY == n->type) {
+ if (NULL == n->child)
+ return(0);
+ p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
+ p->offset += term_len(p, 1) +
+ (NULL == n->prev->child ? term_strlen(p, m->name) :
+ MDOC_TEXT == n->prev->child->type ?
+ term_strlen(p, n->prev->child->string) :
+ term_len(p, 5));
return(1);
+ }
+
+ if (NULL == n->child && NULL == m->name)
+ return(0);
synopsis_pre(p, n);
+ if (MDOC_HEAD == n->type && n->next->child) {
+ p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_HANG;
+ p->rmargin = p->offset + term_len(p, 1) +
+ (NULL == n->child ? term_strlen(p, m->name) :
+ MDOC_TEXT == n->child->type ?
+ term_strlen(p, n->child->string) :
+ term_len(p, 5));
+ }
+
term_fontpush(p, TERMFONT_BOLD);
if (NULL == n->child)
term_word(p, m->name);
@@ -1034,6 +1059,21 @@ termp_nm_pre(DECL_ARGS)
/* ARGSUSED */
+static void
+termp_nm_post(DECL_ARGS)
+{
+
+ if (MDOC_HEAD == n->type && n->next->child) {
+ term_flushln(p);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ } else if (MDOC_BODY == n->type && n->child) {
+ term_flushln(p);
+ p->flags &= ~TERMP_NOLPAD;
+ }
+}
+
+
+/* ARGSUSED */
static int
termp_fl_pre(DECL_ARGS)
{