version 1.246, 2013/05/18 17:47:47 |
version 1.250, 2013/12/22 23:34:13 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 313 print_mdoc_node(DECL_ARGS) |
|
Line 313 print_mdoc_node(DECL_ARGS) |
|
*/ |
*/ |
|
|
if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) { |
if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) { |
if (n->prev && n->prev->line != n->line) { |
if (n->prev ? (n->prev->line != n->line) : |
|
(n->parent && n->parent->line != n->line)) { |
p->flags &= ~TERMP_KEEP; |
p->flags &= ~TERMP_KEEP; |
p->flags |= TERMP_PREKEEP; |
p->flags |= TERMP_PREKEEP; |
} else if (NULL == n->prev) { |
|
if (n->parent && n->parent->line != n->line) { |
|
p->flags &= ~TERMP_KEEP; |
|
p->flags |= TERMP_PREKEEP; |
|
} |
|
} |
} |
} |
} |
|
|
Line 428 print_mdoc_foot(struct termp *p, const void *arg) |
|
Line 424 print_mdoc_foot(struct termp *p, const void *arg) |
|
p->offset = 0; |
p->offset = 0; |
p->rmargin = (p->maxrmargin - |
p->rmargin = (p->maxrmargin - |
term_strlen(p, meta->date) + term_len(p, 1)) / 2; |
term_strlen(p, meta->date) + term_len(p, 1)) / 2; |
|
p->trailspace = 1; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
|
|
term_word(p, meta->os); |
term_word(p, meta->os); |
Line 442 print_mdoc_foot(struct termp *p, const void *arg) |
|
Line 439 print_mdoc_foot(struct termp *p, const void *arg) |
|
|
|
p->offset = p->rmargin; |
p->offset = p->rmargin; |
p->rmargin = p->maxrmargin; |
p->rmargin = p->maxrmargin; |
|
p->trailspace = 0; |
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
Line 493 print_mdoc_head(struct termp *p, const void *arg) |
|
Line 491 print_mdoc_head(struct termp *p, const void *arg) |
|
titlen = term_strlen(p, title); |
titlen = term_strlen(p, title); |
|
|
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |
|
p->trailspace = 1; |
p->offset = 0; |
p->offset = 0; |
p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ? |
p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ? |
(p->maxrmargin - |
(p->maxrmargin - |
Line 511 print_mdoc_head(struct termp *p, const void *arg) |
|
Line 510 print_mdoc_head(struct termp *p, const void *arg) |
|
term_flushln(p); |
term_flushln(p); |
|
|
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
|
p->trailspace = 0; |
if (p->rmargin + titlen <= p->maxrmargin) { |
if (p->rmargin + titlen <= p->maxrmargin) { |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
p->offset = p->rmargin; |
p->offset = p->rmargin; |
Line 798 termp_it_pre(DECL_ARGS) |
|
Line 798 termp_it_pre(DECL_ARGS) |
|
case (LIST_dash): |
case (LIST_dash): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (LIST_hyphen): |
case (LIST_hyphen): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD != n->type) |
p->flags |= TERMP_NOBREAK; |
break; |
|
p->flags |= TERMP_NOBREAK; |
|
p->trailspace = 1; |
break; |
break; |
case (LIST_hang): |
case (LIST_hang): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD != n->type) |
p->flags |= TERMP_NOBREAK; |
|
else |
|
break; |
break; |
|
|
/* |
/* |
Line 816 termp_it_pre(DECL_ARGS) |
|
Line 816 termp_it_pre(DECL_ARGS) |
|
if (n->next->child && |
if (n->next->child && |
(MDOC_Bl == n->next->child->tok || |
(MDOC_Bl == n->next->child->tok || |
MDOC_Bd == n->next->child->tok)) |
MDOC_Bd == n->next->child->tok)) |
p->flags &= ~TERMP_NOBREAK; |
break; |
else |
|
p->flags |= TERMP_HANG; |
p->flags |= TERMP_NOBREAK | TERMP_HANG; |
|
p->trailspace = 1; |
break; |
break; |
case (LIST_tag): |
case (LIST_tag): |
if (MDOC_HEAD == n->type) |
|
p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE; |
|
|
|
if (MDOC_HEAD != n->type) |
if (MDOC_HEAD != n->type) |
break; |
break; |
|
|
|
p->flags |= TERMP_NOBREAK; |
|
p->trailspace = 2; |
|
|
if (NULL == n->next || NULL == n->next->child) |
if (NULL == n->next || NULL == n->next->child) |
p->flags |= TERMP_DANGLE; |
p->flags |= TERMP_DANGLE; |
break; |
break; |
Line 833 termp_it_pre(DECL_ARGS) |
|
Line 835 termp_it_pre(DECL_ARGS) |
|
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
break; |
break; |
|
|
if (NULL == n->next) |
if (NULL == n->next) { |
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
else |
p->trailspace = 0; |
|
} else { |
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_NOBREAK; |
|
p->trailspace = 1; |
|
} |
|
|
break; |
break; |
case (LIST_diag): |
case (LIST_diag): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD != n->type) |
p->flags |= TERMP_NOBREAK; |
break; |
|
p->flags |= TERMP_NOBREAK; |
|
p->trailspace = 1; |
break; |
break; |
default: |
default: |
break; |
break; |
Line 993 termp_it_post(DECL_ARGS) |
|
Line 1000 termp_it_post(DECL_ARGS) |
|
|
|
p->flags &= ~TERMP_DANGLE; |
p->flags &= ~TERMP_DANGLE; |
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_NOBREAK; |
p->flags &= ~TERMP_TWOSPACE; |
|
p->flags &= ~TERMP_HANG; |
p->flags &= ~TERMP_HANG; |
|
p->trailspace = 0; |
} |
} |
|
|
|
|
Line 1027 termp_nm_pre(DECL_ARGS) |
|
Line 1034 termp_nm_pre(DECL_ARGS) |
|
|
|
if (MDOC_HEAD == n->type && n->next->child) { |
if (MDOC_HEAD == n->type && n->next->child) { |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
|
p->trailspace = 1; |
p->rmargin = p->offset + term_len(p, 1); |
p->rmargin = p->offset + term_len(p, 1); |
if (NULL == n->child) { |
if (NULL == n->child) { |
p->rmargin += term_strlen(p, meta->name); |
p->rmargin += term_strlen(p, meta->name); |
Line 1055 termp_nm_post(DECL_ARGS) |
|
Line 1063 termp_nm_post(DECL_ARGS) |
|
if (MDOC_HEAD == n->type && n->next->child) { |
if (MDOC_HEAD == n->type && n->next->child) { |
term_flushln(p); |
term_flushln(p); |
p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); |
p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); |
|
p->trailspace = 0; |
} else if (MDOC_BODY == n->type && n->child) |
} else if (MDOC_BODY == n->type && n->child) |
term_flushln(p); |
term_flushln(p); |
} |
} |
Line 1929 termp_quote_pre(DECL_ARGS) |
|
Line 1938 termp_quote_pre(DECL_ARGS) |
|
case (MDOC_Do): |
case (MDOC_Do): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dq): |
case (MDOC_Dq): |
term_word(p, "``"); |
term_word(p, "\\(lq"); |
break; |
break; |
case (MDOC_Eo): |
case (MDOC_Eo): |
break; |
break; |
Line 1950 termp_quote_pre(DECL_ARGS) |
|
Line 1959 termp_quote_pre(DECL_ARGS) |
|
case (MDOC_So): |
case (MDOC_So): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Sq): |
case (MDOC_Sq): |
term_word(p, "`"); |
term_word(p, "\\(oq"); |
break; |
break; |
default: |
default: |
abort(); |
abort(); |
Line 1995 termp_quote_post(DECL_ARGS) |
|
Line 2004 termp_quote_post(DECL_ARGS) |
|
case (MDOC_Do): |
case (MDOC_Do): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dq): |
case (MDOC_Dq): |
term_word(p, "''"); |
term_word(p, "\\(rq"); |
break; |
break; |
case (MDOC_Eo): |
case (MDOC_Eo): |
break; |
break; |
Line 2016 termp_quote_post(DECL_ARGS) |
|
Line 2025 termp_quote_post(DECL_ARGS) |
|
case (MDOC_So): |
case (MDOC_So): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Sq): |
case (MDOC_Sq): |
term_word(p, "'"); |
term_word(p, "\\(cq"); |
break; |
break; |
default: |
default: |
abort(); |
abort(); |
|
|
termp_bk_post(DECL_ARGS) |
termp_bk_post(DECL_ARGS) |
{ |
{ |
|
|
if (MDOC_BODY == n->type) |
if (MDOC_BODY == n->type && ! (MDOC_SYNPRETTY & n->flags)) |
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); |
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); |
} |
} |
|
|