summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO6
-rw-r--r--mdoc_html.c9
-rw-r--r--mdoc_term.c26
-rw-r--r--regress/mdoc/Rs/one_author.in15
-rw-r--r--regress/mdoc/Rs/three_authors.in17
-rw-r--r--regress/mdoc/Rs/two_authors.in16
6 files changed, 82 insertions, 7 deletions
diff --git a/TODO b/TODO
index f613335a..6a08db97 100644
--- a/TODO
+++ b/TODO
@@ -90,8 +90,6 @@
try e.g. .Bl -column It Ta Ta
reported by millert Fri, 02 Apr 2010 16:13:46 -0400
-- %A doesn't put an "and" before the final author name.
-
************************************************************************
* formatting issues: gratuitious differences
************************************************************************
@@ -107,10 +105,6 @@
Opening punctuation should not fall out of .Ns.
see for example OpenBSD csh(1)
-- .%A should append the last author with " and " (if there are two)
- or ", and " (if there are more), not ", "
- see for example OpenBSD csh(1)
-
- In .Bl -bullet, the groff bullet is "+\b+\bo\bo", the mandoc bullet
is just "o\bo".
see for example OpenBSD ksh(1)
diff --git a/mdoc_html.c b/mdoc_html.c
index 53889135..93807dd5 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -2194,6 +2194,9 @@ mdoc__x_pre(MDOC_ARGS)
switch (n->tok) {
case(MDOC__A):
PAIR_CLASS_INIT(&tag[0], "ref-auth");
+ if (n->prev && MDOC__A == n->prev->tok)
+ if (NULL == n->next || MDOC__A != n->next->tok)
+ print_text(h, "and");
break;
case(MDOC__B):
PAIR_CLASS_INIT(&tag[0], "ref-book");
@@ -2246,6 +2249,7 @@ mdoc__x_pre(MDOC_ARGS)
PAIR_HREF_INIT(&tag[1], n->child->string);
print_otag(h, TAG_A, 2, tag);
+
return(1);
}
@@ -2255,6 +2259,11 @@ static void
mdoc__x_post(MDOC_ARGS)
{
+ if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
+ if (NULL == n->next->next || MDOC__A != n->next->next->tok)
+ if (NULL == n->prev || MDOC__A != n->prev->tok)
+ return;
+
/* TODO: %U */
h->flags |= HTML_NOSPACE;
diff --git a/mdoc_term.c b/mdoc_term.c
index 55d5d1e8..ff8d47aa 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -92,6 +92,7 @@ static void termp_sh_post(DECL_ARGS);
static void termp_sq_post(DECL_ARGS);
static void termp_ss_post(DECL_ARGS);
+static int termp__a_pre(DECL_ARGS);
static int termp_an_pre(DECL_ARGS);
static int termp_ap_pre(DECL_ARGS);
static int termp_aq_pre(DECL_ARGS);
@@ -178,7 +179,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_under_pre, NULL }, /* Va */
{ termp_vt_pre, NULL }, /* Vt */
{ termp_xr_pre, NULL }, /* Xr */
- { NULL, termp____post }, /* %A */
+ { termp__a_pre, termp____post }, /* %A */
{ termp_under_pre, termp____post }, /* %B */
{ NULL, termp____post }, /* %D */
{ termp_under_pre, termp____post }, /* %I */
@@ -1079,6 +1080,19 @@ termp_fl_pre(DECL_ARGS)
/* ARGSUSED */
static int
+termp__a_pre(DECL_ARGS)
+{
+
+ if (n->prev && MDOC__A == n->prev->tok)
+ if (NULL == n->next || MDOC__A != n->next->tok)
+ term_word(p, "and");
+
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
termp_an_pre(DECL_ARGS)
{
@@ -2098,6 +2112,16 @@ static void
termp____post(DECL_ARGS)
{
+ /*
+ * Handle lists of authors. In general, print each followed by
+ * a comma. Don't print the comma if there are only two
+ * authors.
+ */
+ if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
+ if (NULL == n->next->next || MDOC__A != n->next->next->tok)
+ if (NULL == n->prev || MDOC__A != n->prev->tok)
+ return;
+
/* TODO: %U. */
p->flags |= TERMP_NOSPACE;
diff --git a/regress/mdoc/Rs/one_author.in b/regress/mdoc/Rs/one_author.in
new file mode 100644
index 00000000..98934ec0
--- /dev/null
+++ b/regress/mdoc/Rs/one_author.in
@@ -0,0 +1,15 @@
+.Dd May 1, 2009
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh DESCRIPTION
+blah blah
+.Pp
+.Rs
+.%A joe
+.%T title
+.Re
+.Pp
+and so on
diff --git a/regress/mdoc/Rs/three_authors.in b/regress/mdoc/Rs/three_authors.in
new file mode 100644
index 00000000..245023c5
--- /dev/null
+++ b/regress/mdoc/Rs/three_authors.in
@@ -0,0 +1,17 @@
+.Dd May 1, 2009
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh DESCRIPTION
+blah blah
+.Pp
+.Rs
+.%A billy-bob
+.%A joe
+.%A frank
+.%T title
+.Re
+.Pp
+and so on
diff --git a/regress/mdoc/Rs/two_authors.in b/regress/mdoc/Rs/two_authors.in
new file mode 100644
index 00000000..d1a74f27
--- /dev/null
+++ b/regress/mdoc/Rs/two_authors.in
@@ -0,0 +1,16 @@
+.Dd May 1, 2009
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh DESCRIPTION
+blah blah
+.Pp
+.Rs
+.%A joe
+.%A frank
+.%T title
+.Re
+.Pp
+and so on