summaryrefslogtreecommitdiffstats
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
commit72ef1a02b61a65916df100dacb53fc1315b215f5 (patch)
treebb48ede4063bf4880e9231143eedebab1d70d14d /mdoc_term.c
parent2302db180178413966db5db96a8d327e78b53afe (diff)
downloadmandoc-72ef1a02b61a65916df100dacb53fc1315b215f5.tar.gz
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.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 633394d1..5138a22d 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -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)
{