summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-12-25 14:40:34 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-12-25 14:40:34 +0000
commit8ed6a69e4d9860f9bace906849affaa24191bc26 (patch)
treebb96c9f92bfe0616448e4021a6fb4dc546537f63 /mdoc_term.c
parentd23ba31b434c545e8b66f70a57fbd64c245d445d (diff)
downloadmandoc-8ed6a69e4d9860f9bace906849affaa24191bc26.tar.gz
In the SYNOPSIS, implement hanging indentation for .Fo
and avoid output line breaks inside .Fa arguments. This reduces groff-mandoc differences in OpenBSD base by more than 8%. Patch from Franco Fichtner <franco at lastsummer dot de> (DragonFly).
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index a68a4698..96639e98 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1601,20 +1602,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);
}
@@ -2036,16 +2034,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);
@@ -2073,6 +2087,7 @@ termp_fo_post(DECL_ARGS)
if (MDOC_SYNPRETTY & n->flags) {
p->flags |= TERMP_NOSPACE;
term_word(p, ";");
+ term_flushln(p);
}
}