aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--libman.h3
-rw-r--r--man.77
-rw-r--r--man.c25
-rw-r--r--man.h3
-rw-r--r--man_html.c11
-rw-r--r--man_term.c10
-rw-r--r--mdoc.77
-rw-r--r--mdoc_html.c4
-rw-r--r--mdoc_term.c4
9 files changed, 53 insertions, 21 deletions
diff --git a/libman.h b/libman.h
index e1a9aecc..e085693a 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.44 2010/11/30 15:36:28 kristaps Exp $ */
+/* $Id: libman.h,v 1.45 2011/01/12 10:43:22 kristaps 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/man.7 b/man.7
index d8bd6ee7..66f7fb01 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.94 2011/01/04 23:32:21 kristaps Exp $
+.\" $Id: man.7,v 1.95 2011/01/12 10:43:22 kristaps 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 4 2011 $
+.Dd $Mdocdate: January 12 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/man.c b/man.c
index 6788c923..78c311b7 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.96 2011/01/03 11:31:26 kristaps Exp $ */
+/* $Id: man.c,v 1.97 2011/01/12 10:43:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -44,7 +44,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 *);
@@ -129,6 +129,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) :
@@ -229,7 +231,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;
@@ -238,6 +241,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);
}
@@ -247,7 +254,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;
@@ -260,7 +267,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;
@@ -273,7 +280,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;
@@ -286,7 +293,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;
@@ -299,7 +306,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))
@@ -317,7 +324,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/man.h b/man.h
index 581f55ff..4373f8e6 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.50 2011/01/01 12:59:17 kristaps Exp $ */
+/* $Id: man.h,v 1.51 2011/01/12 10:43:22 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 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/man_html.c b/man_html.c
index da6880a1..9e666c77 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.62 2011/01/07 13:20:58 kristaps Exp $ */
+/* $Id: man_html.c,v 1.63 2011/01/12 10:43:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -197,7 +197,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/man_term.c b/man_term.c
index 8500ad9f..c94900fc 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.95 2011/01/11 00:39:00 kristaps Exp $ */
+/* $Id: man_term.c,v 1.96 2011/01/12 10:43:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -859,10 +859,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);
@@ -878,6 +881,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/mdoc.7 b/mdoc.7
index 6ecd5a7b..8c55a832 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.174 2011/01/04 23:32:21 kristaps Exp $
+.\" $Id: mdoc.7,v 1.175 2011/01/12 10:43:22 kristaps 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 4 2011 $
+.Dd $Mdocdate: January 12 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/mdoc_html.c b/mdoc_html.c
index 44b41d2f..b2a421bd 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.142 2011/01/07 13:20:58 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.143 2011/01/12 10:43:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -420,6 +420,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/mdoc_term.c b/mdoc_term.c
index 0f699abd..d0eab85a 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.208 2011/01/06 14:05:12 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.209 2011/01/12 10:43:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -315,6 +315,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):