aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2010-07-01 15:38:56 +0000
committerIngo Schwarze <schwarze@openbsd.org>2010-07-01 15:38:56 +0000
commitd746b90cb9ec627434f26fc89fadf2b702e7956d (patch)
treed7cdc5ab197f036e5f2bd039c257f57ce1490a95 /mdoc_term.c
parent6aa434a613ae90a05243c999174fdf0231c54b3a (diff)
downloadmandoc-d746b90cb9ec627434f26fc89fadf2b702e7956d.tar.gz
mandoc-d746b90cb9ec627434f26fc89fadf2b702e7956d.tar.zst
mandoc-d746b90cb9ec627434f26fc89fadf2b702e7956d.zip
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 'mdoc_term.c')
-rw-r--r--mdoc_term.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 02077563..338e3c72 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.163 2010/07/01 14:34:03 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.164 2010/07/01 15:38:56 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -85,6 +85,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);
@@ -170,7 +171,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 */
@@ -1025,11 +1026,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);
@@ -1038,6 +1063,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)
{