diff options
-rw-r--r-- | regress/usr.bin/mandoc/char/space/Makefile | 6 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/char/space/leading-man.in | 12 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/char/space/leading-man.out_ascii | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/char/space/leading-mdoc.in | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/char/space/leading-mdoc.out_ascii | 10 | ||||
-rw-r--r-- | share/man/man7/man.7 | 7 | ||||
-rw-r--r-- | share/man/man7/mdoc.7 | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/libman.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/man.c | 25 | ||||
-rw-r--r-- | usr.bin/mandoc/man.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/man_html.c | 11 | ||||
-rw-r--r-- | usr.bin/mandoc/man_term.c | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 4 |
14 files changed, 106 insertions, 24 deletions
diff --git a/regress/usr.bin/mandoc/char/space/Makefile b/regress/usr.bin/mandoc/char/space/Makefile index 076851b0b6a..055270628f2 100644 --- a/regress/usr.bin/mandoc/char/space/Makefile +++ b/regress/usr.bin/mandoc/char/space/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.3 2011/01/02 15:13:35 schwarze Exp $ +# $OpenBSD: Makefile,v 1.4 2011/01/16 02:56:47 schwarze Exp $ -REGRESS_TARGETS=multiple nobreak tab tab-man -GROFF_TARGETS=multiple nobreak tab tab-man +REGRESS_TARGETS=leading-mdoc leading-man multiple nobreak tab tab-man +GROFF_TARGETS=leading-mdoc leading-man multiple nobreak tab tab-man .include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/char/space/leading-man.in b/regress/usr.bin/mandoc/char/space/leading-man.in new file mode 100644 index 00000000000..54105bc28a9 --- /dev/null +++ b/regress/usr.bin/mandoc/char/space/leading-man.in @@ -0,0 +1,12 @@ +.TH SPACE-LEADING-MAN 1 "January 15, 2011" +.SH NAME +pace-leading-man \- leading spaces on text lines in man documents +.SH DESCRIPTION +normal line of text +second normal line + leading space +.BI bold italic +normal after macro +.B +.BI bold italic + leading space after a macro line diff --git a/regress/usr.bin/mandoc/char/space/leading-man.out_ascii b/regress/usr.bin/mandoc/char/space/leading-man.out_ascii new file mode 100644 index 00000000000..6fadfa696dd --- /dev/null +++ b/regress/usr.bin/mandoc/char/space/leading-man.out_ascii @@ -0,0 +1,14 @@ +SPACE-LEADING-MAN(1) SPACE-LEADING-MAN(1) + + + +NNAAMMEE + pace-leading-man - leading spaces on text lines in man documents + +DDEESSCCRRIIPPTTIIOONN + normal line of text second normal line + leading space bboolldd_i_t_a_l_i_c normal after macro bboolldd_i_t_a_l_i_c + leading space after a macro line + + + diff --git a/regress/usr.bin/mandoc/char/space/leading-mdoc.in b/regress/usr.bin/mandoc/char/space/leading-mdoc.in new file mode 100644 index 00000000000..9b806cf18d2 --- /dev/null +++ b/regress/usr.bin/mandoc/char/space/leading-mdoc.in @@ -0,0 +1,14 @@ +.Dd January 15, 2011 +.Dt SPACE-LEADING_MDOC 1 +.Os +.Sh NAME +.Nm space-leading-mdoc +.Nd leading spaces on text lines in mdoc documents +.Sh DESCRIPTION +normal line of text +second normal line + line with a leading space +.Ux +normal line after a macro line +.Ux + leading space after a macro line diff --git a/regress/usr.bin/mandoc/char/space/leading-mdoc.out_ascii b/regress/usr.bin/mandoc/char/space/leading-mdoc.out_ascii new file mode 100644 index 00000000000..eda38c67b4e --- /dev/null +++ b/regress/usr.bin/mandoc/char/space/leading-mdoc.out_ascii @@ -0,0 +1,10 @@ +SPACE-LEADING_MDOC(1) OpenBSD Reference Manual SPACE-LEADING_MDOC(1) + +NNAAMMEE + ssppaaccee--lleeaaddiinngg--mmddoocc - leading spaces on text lines in mdoc documents + +DDEESSCCRRIIPPTTIIOONN + normal line of text second normal line + line with a leading space UNIX normal line after a macro line UNIX + leading space after a macro line + diff --git a/share/man/man7/man.7 b/share/man/man7/man.7 index 2447413852e..7570ba88698 100644 --- a/share/man/man7/man.7 +++ b/share/man/man7/man.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: man.7,v 1.13 2011/01/09 15:24:57 schwarze Exp $ +.\" $OpenBSD: man.7,v 1.14 2011/01/16 02:56:47 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 9 2011 $ +.Dd $Mdocdate: January 16 2011 $ .Dt MAN 7 .Os .Sh NAME @@ -59,6 +59,9 @@ line termination. .Pp Blank lines are acceptable; where found, the output will assert a vertical space. +.Pp +If the first character of a line is a space, that line is printed +with a leading newline. .Ss Comments Text following a .Sq \e\*q , diff --git a/share/man/man7/mdoc.7 b/share/man/man7/mdoc.7 index b11539a5e90..ed8c90bdc3a 100644 --- a/share/man/man7/mdoc.7 +++ b/share/man/man7/mdoc.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mdoc.7,v 1.60 2011/01/09 15:24:57 schwarze Exp $ +.\" $OpenBSD: mdoc.7,v 1.61 2011/01/16 02:56:47 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 9 2011 $ +.Dd $Mdocdate: January 16 2011 $ .Dt MDOC 7 .Os .Sh NAME @@ -55,6 +55,9 @@ character, and, in certain circumstances, the tab character. All manuals must have .Ux line terminators. +.Pp +If the first character of a line is a space, that line is printed +with a leading newline. .Ss Comments Text following a .Sq \e\*q , diff --git a/usr.bin/mandoc/libman.h b/usr.bin/mandoc/libman.h index ddd55de6cc5..dcbc2b4137a 100644 --- a/usr.bin/mandoc/libman.h +++ b/usr.bin/mandoc/libman.h @@ -1,4 +1,4 @@ -/* $Id: libman.h,v 1.26 2010/12/01 23:02:57 schwarze Exp $ */ +/* $Id: libman.h,v 1.27 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -34,6 +34,7 @@ struct man { #define MAN_ILINE (1 << 3) /* Ignored in next-line scope. */ #define MAN_LITERAL (1 << 4) /* Literal input. */ #define MAN_BPLINE (1 << 5) +#define MAN_NEWLINE (1 << 6) /* first macro/text in a line */ enum man_next next; /* where to put the next node */ struct man_node *last; /* the last parsed node */ struct man_node *first; /* the first parsed node */ diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index 09d79242b7c..dd39e73d8ef 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.53 2011/01/09 13:16:48 schwarze Exp $ */ +/* $Id: man.c,v 1.54 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -40,7 +40,7 @@ const char *const __man_macronames[MAN_MAX] = { const char * const *man_macronames = __man_macronames; -static struct man_node *man_node_alloc(int, int, +static struct man_node *man_node_alloc(struct man *, int, int, enum man_type, enum mant); static int man_node_append(struct man *, struct man_node *); @@ -125,6 +125,8 @@ int man_parseln(struct man *m, int ln, char *buf, int offs) { + m->flags |= MAN_NEWLINE; + assert( ! (MAN_HALT & m->flags)); return(('.' == buf[offs] || '\'' == buf[offs]) ? man_pmacro(m, ln, buf, offs) : @@ -225,7 +227,8 @@ man_node_append(struct man *man, struct man_node *p) static struct man_node * -man_node_alloc(int line, int pos, enum man_type type, enum mant tok) +man_node_alloc(struct man *m, int line, int pos, + enum man_type type, enum mant tok) { struct man_node *p; @@ -234,6 +237,10 @@ man_node_alloc(int line, int pos, enum man_type type, enum mant tok) p->pos = pos; p->type = type; p->tok = tok; + + if (MAN_NEWLINE & m->flags) + p->flags |= MAN_LINE; + m->flags &= ~MAN_NEWLINE; return(p); } @@ -243,7 +250,7 @@ man_elem_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_ELEM, tok); + p = man_node_alloc(m, line, pos, MAN_ELEM, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -256,7 +263,7 @@ man_head_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_HEAD, tok); + p = man_node_alloc(m, line, pos, MAN_HEAD, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -269,7 +276,7 @@ man_body_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_BODY, tok); + p = man_node_alloc(m, line, pos, MAN_BODY, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -282,7 +289,7 @@ man_block_alloc(struct man *m, int line, int pos, enum mant tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_BLOCK, tok); + p = man_node_alloc(m, line, pos, MAN_BLOCK, tok); if ( ! man_node_append(m, p)) return(0); m->next = MAN_NEXT_CHILD; @@ -295,7 +302,7 @@ man_span_alloc(struct man *m, const struct tbl_span *span) struct man_node *n; /* FIXME: grab from span */ - n = man_node_alloc(0, 0, MAN_TBL, MAN_MAX); + n = man_node_alloc(m, 0, 0, MAN_TBL, MAN_MAX); n->span = span; if ( ! man_node_append(m, n)) @@ -313,7 +320,7 @@ man_word_alloc(struct man *m, int line, int pos, const char *word) len = strlen(word); - n = man_node_alloc(line, pos, MAN_TEXT, MAN_MAX); + n = man_node_alloc(m, line, pos, MAN_TEXT, MAN_MAX); n->string = mandoc_malloc(len + 1); sv = strlcpy(n->string, word, len + 1); diff --git a/usr.bin/mandoc/man.h b/usr.bin/mandoc/man.h index f459db294f3..4c8bd5e4fc2 100644 --- a/usr.bin/mandoc/man.h +++ b/usr.bin/mandoc/man.h @@ -1,4 +1,4 @@ -/* $Id: man.h,v 1.33 2011/01/04 22:28:17 schwarze Exp $ */ +/* $Id: man.h,v 1.34 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -97,6 +97,7 @@ struct man_node { int flags; #define MAN_VALID (1 << 0) /* has been validated */ #define MAN_EOS (1 << 2) /* at sentence boundary */ +#define MAN_LINE (1 << 3) /* first macro/text on line */ enum man_type type; /* AST node type */ char *string; /* TEXT node argument */ struct man_node *head; /* BLOCK node HEAD ptr */ diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index 042a1ef1cd0..78d2da75f6e 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.30 2011/01/09 16:31:45 schwarze Exp $ */ +/* $Id: man_html.c,v 1.31 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -193,7 +193,16 @@ print_man_node(MAN_ARGS) child = man_root_pre(m, n, mh, h); break; case (MAN_TEXT): + if ('\0' == *n->string) { + print_otag(h, TAG_P, 0, NULL); + return; + } + + if (' ' == *n->string && MAN_LINE & n->flags) + print_otag(h, TAG_BR, 0, NULL); + print_text(h, n->string); + if (MANH_LITERAL & mh->fl) print_otag(h, TAG_BR, 0, NULL); return; diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 0cdf4ca08c4..1f93e57d939 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.59 2011/01/11 00:59:28 schwarze Exp $ */ +/* $Id: man_term.c,v 1.60 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -855,10 +855,13 @@ print_man_node(DECL_ARGS) switch (n->type) { case(MAN_TEXT): - if (0 == *n->string) { + if ('\0' == *n->string) { term_vspace(p); break; - } + } + + if (' ' == *n->string && MAN_LINE & n->flags) + term_newln(p); term_word(p, n->string); @@ -874,6 +877,7 @@ print_man_node(DECL_ARGS) p->rmargin = rm; p->maxrmargin = rmax; } + break; case (MAN_TBL): if (TBL_SPAN_FIRST & n->span->flags) diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index fea03ced049..c5f25283289 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.46 2011/01/09 16:31:46 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.47 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -416,6 +416,8 @@ print_mdoc_node(MDOC_ARGS) child = mdoc_root_pre(m, n, h); break; case (MDOC_TEXT): + if (' ' == *n->string && MDOC_LINE & n->flags) + print_otag(h, TAG_BR, 0, NULL); print_text(h, n->string); return; case (MDOC_TBL): diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 0ab17e294c2..eeece6df44c 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.123 2011/01/09 16:09:41 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.124 2011/01/16 02:56:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -311,6 +311,8 @@ print_mdoc_node(DECL_ARGS) switch (n->type) { case (MDOC_TEXT): + if (' ' == *n->string && MDOC_LINE & n->flags) + term_newln(p); term_word(p, n->string); break; case (MDOC_TBL): |