From: schwarze Date: Wed, 25 Dec 2013 14:40:29 +0000 (+0000) Subject: In the SYNOPSIS, implement hanging indentation for .Fo X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=740f368b29ddba47de9589095bf6e5f80a377ae5;p=openbsd In the SYNOPSIS, implement hanging indentation for .Fo and avoid output line breaks inside .Fa arguments. This reduces groff-mandoc differences in base by more than 8%. Patch from Franco Fichtner (DragonFly). --- diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index ac5b7e0d0c7..1888ffd2105 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,7 +1,8 @@ -/* $Id: mdoc_term.c,v 1.157 2013/12/25 00:39:13 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.158 2013/12/25 14:40:29 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013 Ingo Schwarze + * Copyright (c) 2013 Franco Fichtner * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -1597,20 +1598,17 @@ termp_fa_pre(DECL_ARGS) for (nn = n->child; nn; nn = nn->next) { term_fontpush(p, TERMFONT_UNDER); + if (MDOC_SYNPRETTY & n->flags) + p->flags |= TERMP_NBRWORD; term_word(p, nn->string); term_fontpop(p); - if (nn->next) { + if (nn->next || (n->next && n->next->tok == MDOC_Fa)) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } } - if (n->child && n->next && n->next->tok == MDOC_Fa) { - p->flags |= TERMP_NOSPACE; - term_word(p, ","); - } - return(0); } @@ -2032,16 +2030,32 @@ termp_quote_post(DECL_ARGS) static int termp_fo_pre(DECL_ARGS) { + size_t width, rmargin = 0; + int pretty; + + pretty = MDOC_SYNPRETTY & n->flags; if (MDOC_BLOCK == n->type) { synopsis_pre(p, n); return(1); } else if (MDOC_BODY == n->type) { + if (pretty) { + width = term_len(p, 4); + rmargin = p->rmargin; + p->rmargin = p->offset + width; + p->flags |= TERMP_NOBREAK | TERMP_HANG; + } p->flags |= TERMP_NOSPACE; term_word(p, "("); p->flags |= TERMP_NOSPACE; + if (pretty) { + term_flushln(p); + p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); + p->offset = p->rmargin; + p->rmargin = rmargin; + } return(1); - } + } if (NULL == n->child) return(0); @@ -2069,6 +2083,7 @@ termp_fo_post(DECL_ARGS) if (MDOC_SYNPRETTY & n->flags) { p->flags |= TERMP_NOSPACE; term_word(p, ";"); + term_flushln(p); } }