aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-07-11 23:46:37 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-07-11 23:46:37 +0000
commit0ae5dd38980852a8fe3370aa6b65f9d1cba15c86 (patch)
treed64e5b19e29e2dbdc7317f0034d9aab58cd45d72 /mdoc_man.c
parentc5229a1040262fbfa34adb8a912bb5cd1681e69d (diff)
downloadmandoc-0ae5dd38980852a8fe3370aa6b65f9d1cba15c86.tar.gz
mandoc-0ae5dd38980852a8fe3370aa6b65f9d1cba15c86.tar.zst
mandoc-0ae5dd38980852a8fe3370aa6b65f9d1cba15c86.zip
Polish -Tman .Rs support.
All mdoc(7) macros are now supported by -Tman. OpenBSD rev. 1.32
Diffstat (limited to 'mdoc_man.c')
-rw-r--r--mdoc_man.c96
1 files changed, 68 insertions, 28 deletions
diff --git a/mdoc_man.c b/mdoc_man.c
index c50286c5..83ee55a6 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.33 2012/07/11 16:19:08 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.34 2012/07/11 23:46:37 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -43,6 +43,7 @@ static int cond_body(DECL_ARGS);
static int cond_head(DECL_ARGS);
static void font_push(char);
static void font_pop(void);
+static void post__t(DECL_ARGS);
static void post_bd(DECL_ARGS);
static void post_bf(DECL_ARGS);
static void post_bk(DECL_ARGS);
@@ -65,6 +66,7 @@ static void post_pf(DECL_ARGS);
static void post_sect(DECL_ARGS);
static void post_sp(DECL_ARGS);
static void post_vt(DECL_ARGS);
+static int pre__t(DECL_ARGS);
static int pre_an(DECL_ARGS);
static int pre_ap(DECL_ARGS);
static int pre_bd(DECL_ARGS);
@@ -90,6 +92,7 @@ static int pre_nm(DECL_ARGS);
static int pre_no(DECL_ARGS);
static int pre_ns(DECL_ARGS);
static int pre_pp(DECL_ARGS);
+static int pre_rs(DECL_ARGS);
static int pre_sm(DECL_ARGS);
static int pre_sp(DECL_ARGS);
static int pre_sect(DECL_ARGS);
@@ -152,17 +155,17 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ NULL, pre_em, post_font, NULL, NULL }, /* Va */
{ NULL, pre_vt, post_vt, NULL, NULL }, /* Vt */
{ NULL, pre_xr, NULL, NULL, NULL }, /* Xr */
- { NULL, NULL, post_percent, NULL, NULL }, /* _%A */
- { NULL, NULL, NULL, NULL, NULL }, /* _%B */
- { NULL, NULL, post_percent, NULL, NULL }, /* _%D */
- { NULL, NULL, NULL, NULL, NULL }, /* _%I */
- { NULL, pre_enc, post_percent, "\\fI", "\\fP" }, /* %J */
- { NULL, NULL, NULL, NULL, NULL }, /* _%N */
- { NULL, NULL, NULL, NULL, NULL }, /* _%O */
- { NULL, NULL, NULL, NULL, NULL }, /* _%P */
- { NULL, NULL, NULL, NULL, NULL }, /* _%R */
- { NULL, pre_enc, post_percent, "\"", "\"" }, /* %T */
- { NULL, NULL, NULL, NULL, NULL }, /* _%V */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %A */
+ { NULL, pre_em, post_percent, NULL, NULL }, /* %B */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %D */
+ { NULL, pre_em, post_percent, NULL, NULL }, /* %I */
+ { NULL, pre_em, post_percent, NULL, NULL }, /* %J */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %N */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %O */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %P */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %R */
+ { NULL, pre__t, post__t, NULL, NULL }, /* %T */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %V */
{ NULL, NULL, NULL, NULL, NULL }, /* Ac */
{ cond_body, pre_enc, post_enc, "<", ">" }, /* Ao */
{ cond_body, pre_enc, post_enc, "<", ">" }, /* Aq */
@@ -196,7 +199,7 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ cond_body, pre_enc, post_enc, "\"", "\"" }, /* Qo */
{ cond_body, pre_enc, post_enc, "\"", "\"" }, /* Qq */
{ NULL, NULL, NULL, NULL, NULL }, /* Re */
- { cond_body, pre_pp, NULL, NULL, NULL }, /* Rs */
+ { cond_body, pre_rs, NULL, NULL, NULL }, /* Rs */
{ NULL, NULL, NULL, NULL, NULL }, /* Sc */
{ cond_body, pre_enc, post_enc, "`", "'" }, /* So */
{ cond_body, pre_enc, post_enc, "`", "'" }, /* Sq */
@@ -205,8 +208,8 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ NULL, pre_sy, post_font, NULL, NULL }, /* Sy */
{ NULL, pre_li, post_font, NULL, NULL }, /* Tn */
{ NULL, pre_ux, NULL, "UNIX", NULL }, /* Ux */
- { NULL, NULL, NULL, NULL, NULL }, /* _Xc */
- { NULL, NULL, NULL, NULL, NULL }, /* _Xo */
+ { NULL, NULL, NULL, NULL, NULL }, /* Xc */
+ { NULL, NULL, NULL, NULL, NULL }, /* Xo */
{ NULL, pre_fo, post_fo, NULL, NULL }, /* Fo */
{ NULL, NULL, NULL, NULL, NULL }, /* Fc */
{ cond_body, pre_enc, post_enc, "[", "]" }, /* Oo */
@@ -224,15 +227,15 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ cond_body, pre_enc, post_enc, "{", "}" }, /* Brq */
{ cond_body, pre_enc, post_enc, "{", "}" }, /* Bro */
{ NULL, NULL, NULL, NULL, NULL }, /* Brc */
- { NULL, NULL, NULL, NULL, NULL }, /* _%C */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %C */
{ NULL, NULL, NULL, NULL, NULL }, /* Es */
{ NULL, NULL, NULL, NULL, NULL }, /* En */
{ NULL, pre_ux, NULL, "DragonFly", NULL }, /* Dx */
- { NULL, NULL, NULL, NULL, NULL }, /* _%Q */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %Q */
{ NULL, pre_br, NULL, NULL, NULL }, /* br */
{ NULL, pre_sp, post_sp, NULL, NULL }, /* sp */
- { NULL, NULL, NULL, NULL, NULL }, /* _%U */
- { NULL, NULL, NULL, NULL, NULL }, /* _Ta */
+ { NULL, NULL, post_percent, NULL, NULL }, /* %U */
+ { NULL, NULL, NULL, NULL, NULL }, /* Ta */
{ NULL, NULL, NULL, NULL, NULL }, /* ROOT */
};
@@ -539,24 +542,49 @@ post_font(DECL_ARGS)
font_pop();
}
-/*
- * Used in listings (percent = %A, e.g.).
- * FIXME: this is incomplete.
- * It doesn't print a nice ", and" for lists.
- */
static void
post_percent(DECL_ARGS)
{
- post_enc(m, n);
- if (n->next)
+ if (pre_em == manacts[n->tok].pre)
+ font_pop();
+ if (n->next) {
print_word(",");
- else {
+ if (n->prev && n->prev->tok == n->tok &&
+ n->next->tok == n->tok)
+ print_word("and");
+ } else {
print_word(".");
outflags |= MMAN_nl;
}
}
+static int
+pre__t(DECL_ARGS)
+{
+
+ if (n->parent && MDOC_Rs == n->parent->tok &&
+ n->parent->norm->Rs.quote_T) {
+ print_word("\"");
+ outflags &= ~MMAN_spc;
+ } else
+ font_push('I');
+ return(1);
+}
+
+static void
+post__t(DECL_ARGS)
+{
+
+ if (n->parent && MDOC_Rs == n->parent->tok &&
+ n->parent->norm->Rs.quote_T) {
+ outflags &= ~MMAN_spc;
+ print_word("\"");
+ } else
+ font_pop();
+ post_percent(m, n);
+}
+
/*
* Print before a section header.
*/
@@ -1225,7 +1253,19 @@ pre_pp(DECL_ARGS)
else
print_word(".PP");
outflags |= MMAN_nl;
- return(MDOC_Rs == n->tok);
+ return(0);
+}
+
+static int
+pre_rs(DECL_ARGS)
+{
+
+ if (SEC_SEE_ALSO == n->sec) {
+ outflags |= MMAN_nl;
+ print_word(".PP");
+ outflags |= MMAN_nl;
+ }
+ return(1);
}
static int