diff options
-rw-r--r-- | mdoc.c | 3 | ||||
-rw-r--r-- | mdoc.h | 3 | ||||
-rw-r--r-- | mdoc_html.c | 12 | ||||
-rw-r--r-- | mdoc_macro.c | 7 | ||||
-rw-r--r-- | mdoc_term.c | 4 | ||||
-rw-r--r-- | tree.c | 8 |
6 files changed, 22 insertions, 15 deletions
@@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.205 2013/10/21 23:47:58 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.206 2013/12/24 19:11:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> @@ -434,6 +434,7 @@ node_alloc(struct mdoc *mdoc, int line, int pos, p->sec = mdoc->lastsec; p->line = line; p->pos = pos; + p->lastline = line; p->tok = tok; p->type = type; @@ -1,4 +1,4 @@ -/* $Id: mdoc.h,v 1.124 2012/11/16 17:16:55 schwarze Exp $ */ +/* $Id: mdoc.h,v 1.125 2013/12/24 19:11:45 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -351,6 +351,7 @@ struct mdoc_node { int nchild; /* number children */ int line; /* parse line */ int pos; /* parse column */ + int lastline; /* the node ends on this line */ enum mdoct tok; /* tok or MDOC__MAX if none */ int flags; #define MDOC_VALID (1 << 0) /* has been validated */ diff --git a/mdoc_html.c b/mdoc_html.c index ba93749b..151657fb 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.184 2012/11/17 00:26:33 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.185 2013/12/24 19:11:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -459,15 +459,11 @@ print_mdoc_node(MDOC_ARGS) break; } - if (HTML_KEEP & h->flags) { - if (n->prev && n->prev->line != n->line) { + if (HTML_KEEP & h->flags || MDOC_SYNPRETTY & n->flags) { + if (n->prev ? (n->prev->lastline != n->line) : + (n->parent && n->parent->line != n->line)) { h->flags &= ~HTML_KEEP; h->flags |= HTML_PREKEEP; - } else if (NULL == n->prev) { - if (n->parent && n->parent->line != n->line) { - h->flags &= ~HTML_KEEP; - h->flags |= HTML_PREKEEP; - } } } diff --git a/mdoc_macro.c b/mdoc_macro.c index 4a018eed..cbf90d2c 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.123 2013/10/21 23:47:58 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.124 2013/12/24 19:11:46 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> @@ -561,6 +561,9 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc, case (REWIND_NONE): return(1); case (REWIND_THIS): + n->lastline = line - + (MDOC_NEWLINE & mdoc->flags && + ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)); break; case (REWIND_FORCE): mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse, @@ -569,6 +572,8 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc, mdoc_macronames[n->tok]); /* FALLTHROUGH */ case (REWIND_MORE): + n->lastline = line - + (MDOC_NEWLINE & mdoc->flags ? 1 : 0); n = n->parent; continue; case (REWIND_LATER): diff --git a/mdoc_term.c b/mdoc_term.c index 7207df39..08bf9fe4 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.251 2013/12/23 02:20:09 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.252 2013/12/24 19:11:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> @@ -313,7 +313,7 @@ print_mdoc_node(DECL_ARGS) */ if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) { - if (n->prev ? (n->prev->line != n->line) : + if (n->prev ? (n->prev->lastline != n->line) : (n->parent && n->parent->line != n->line)) { p->flags &= ~TERMP_KEEP; p->flags |= TERMP_PREKEEP; @@ -1,6 +1,7 @@ -/* $Id: tree.c,v 1.49 2013/09/15 17:33:57 schwarze Exp $ */ +/* $Id: tree.c,v 1.50 2013/12/24 19:11:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -163,7 +164,10 @@ print_mdoc(const struct mdoc_node *n, int indent) putchar(' '); if (MDOC_LINE & n->flags) putchar('*'); - printf("%d:%d\n", n->line, n->pos); + printf("%d:%d", n->line, n->pos); + if (n->lastline != n->line) + printf("-%d", n->lastline); + putchar('\n'); } if (n->child) |