From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Properly handle -mdoc %A in all outputs.
Date: Sat, 4 Sep 2010 15:01:54 -0400 (EDT) [thread overview]
Message-ID: <201009041901.o84J1su0028487@krisdoz.my.domain> (raw)
Log Message:
-----------
Properly handle -mdoc %A in all outputs. This has two-author entires
separated by only "and" while two or more are with ", and" for the last
author.
Also remove relevant TODO and add regression tests.
Modified Files:
--------------
mdocml:
mdoc_html.c
mdoc_term.c
TODO
Added Files:
-----------
mdocml/regress/mdoc/Rs:
one_author.in
three_authors.in
two_authors.in
Revision Data
-------------
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.43
retrieving revision 1.44
diff -LTODO -LTODO -u -p -r1.43 -r1.44
--- TODO
+++ 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
************************************************************************
@@ -105,10 +103,6 @@
This is parsed as
text("${name") text("[") Ns() text(selector)...
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
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.102 -r1.103
--- mdoc_html.c
+++ 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);
}
@@ -2254,6 +2258,11 @@ mdoc__x_pre(MDOC_ARGS)
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 */
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.183 -r1.184
--- mdoc_term.c
+++ 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[MDO
{ 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)
{
@@ -2097,6 +2111,16 @@ termp_ap_pre(DECL_ARGS)
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. */
--- /dev/null
+++ 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
--- /dev/null
+++ 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
--- /dev/null
+++ 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
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2010-09-04 19:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201009041901.o84J1su0028487@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).