From 9d2ef545376117ce8b24ed652f358c029d7b8f4c Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 25 Jun 2017 11:42:02 +0000 Subject: add support for the MT and ME mailto macros, used for example in wg(8); patch from bentley@ --- man.7 | 18 ++++++++++++++++-- man_html.c | 13 +++++++++++-- man_macro.c | 7 ++++++- man_term.c | 4 +++- man_validate.c | 4 +++- mandoc.1 | 12 ++++++++---- roff.c | 4 ++-- roff.h | 4 +++- 8 files changed, 52 insertions(+), 14 deletions(-) diff --git a/man.7 b/man.7 index 1a79f298..570e7ac3 100644 --- a/man.7 +++ b/man.7 @@ -1,4 +1,4 @@ -.\" $Id: man.7,v 1.135 2017/05/07 21:44:49 schwarze Exp $ +.\" $Id: man.7,v 1.136 2017/06/25 11:42:02 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons .\" Copyright (c) 2011-2015 Ingo Schwarze @@ -16,7 +16,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: May 7 2017 $ +.Dd $Mdocdate: June 25 2017 $ .Dt MAN 7 .Os .Sh NAME @@ -466,6 +466,20 @@ See also .Sx \&PP , and .Sx \&TP . +.Ss \&ME +End a mailto block. +This is a non-standard GNU extension, included only for compatibility. +See +.Sx \&MT . +.Ss \&MT +Begin a mailto block. +This is a non-standard GNU extension, included only for compatibility. +It has the following syntax: +.Bd -literal -offset indent +.Pf \. Sx \&MT Ar address +link description to be shown +.Pf \. Sx ME +.Ed .Ss \&OP Optional command-line argument. This is a non-standard GNU extension, included only for compatibility. diff --git a/man_html.c b/man_html.c index 127a46e0..a304b3e4 100644 --- a/man_html.c +++ b/man_html.c @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.144 2017/06/24 14:38:32 schwarze Exp $ */ +/* $Id: man_html.c,v 1.145 2017/06/25 11:42:02 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze @@ -106,6 +106,8 @@ static const struct htmlman __mans[MAN_MAX - MAN_TH] = { { NULL, NULL }, /* EE */ { man_UR_pre, NULL }, /* UR */ { NULL, NULL }, /* UE */ + { man_UR_pre, NULL }, /* MT */ + { NULL, NULL }, /* ME */ }; static const struct htmlman *const mans = __mans - MAN_TH; @@ -230,6 +232,7 @@ print_man_node(MAN_ARGS) case MAN_P: /* reopen .nf in the body. */ case MAN_RS: case MAN_UR: + case MAN_MT: fillmode(h, MAN_fi); break; default: @@ -644,11 +647,17 @@ man_RS_pre(MAN_ARGS) static int man_UR_pre(MAN_ARGS) { + char *cp; n = n->child; assert(n->type == ROFFT_HEAD); if (n->child != NULL) { assert(n->child->type == ROFFT_TEXT); - print_otag(h, TAG_A, "cTh", "Lk", n->child->string); + if (n->tok == MAN_MT) { + mandoc_asprintf(&cp, "mailto:%s", n->child->string); + print_otag(h, TAG_A, "cTh", "Mt", cp); + free(cp); + } else + print_otag(h, TAG_A, "cTh", "Lk", n->child->string); } assert(n->next->type == ROFFT_BODY); diff --git a/man_macro.c b/man_macro.c index 6f04327f..aa8b2001 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.122 2017/06/17 16:47:48 schwarze Exp $ */ +/* $Id: man_macro.c,v 1.123 2017/06/25 11:45:37 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2012-2015, 2017 Ingo Schwarze @@ -75,6 +75,8 @@ const struct man_macro __man_macros[MAN_MAX - MAN_TH] = { { in_line_eoln, MAN_BSCOPE }, /* EE */ { blk_exp, MAN_BSCOPE }, /* UR */ { blk_close, MAN_BSCOPE }, /* UE */ + { blk_exp, MAN_BSCOPE }, /* MT */ + { blk_close, MAN_BSCOPE }, /* ME */ }; const struct man_macro *const man_macros = __man_macros - MAN_TH; @@ -217,6 +219,9 @@ blk_close(MACRO_PROT_ARGS) case MAN_UE: ntok = MAN_UR; break; + case MAN_ME: + ntok = MAN_MT; + break; default: abort(); } diff --git a/man_term.c b/man_term.c index 44b25d34..fcdb45df 100644 --- a/man_term.c +++ b/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.207 2017/06/17 13:06:16 schwarze Exp $ */ +/* $Id: man_term.c,v 1.208 2017/06/25 11:42:02 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017 Ingo Schwarze @@ -128,6 +128,8 @@ static const struct termact __termacts[MAN_MAX - MAN_TH] = { { pre_literal, NULL, 0 }, /* EE */ { pre_UR, post_UR, 0 }, /* UR */ { NULL, NULL, 0 }, /* UE */ + { pre_UR, post_UR, 0 }, /* MT */ + { NULL, NULL, 0 }, /* ME */ }; static const struct termact *termacts = __termacts - MAN_TH; diff --git a/man_validate.c b/man_validate.c index e874cabb..12ba6e22 100644 --- a/man_validate.c +++ b/man_validate.c @@ -89,6 +89,8 @@ static const v_check __man_valids[MAN_MAX - MAN_TH] = { NULL, /* EE */ post_UR, /* UR */ NULL, /* UE */ + post_UR, /* MT */ + NULL, /* ME */ }; static const v_check *man_valids = __man_valids - MAN_TH; @@ -212,7 +214,7 @@ post_UR(CHKARGS) if (n->type == ROFFT_HEAD && n->child == NULL) mandoc_vmsg(MANDOCERR_UR_NOHEAD, man->parse, - n->line, n->pos, "UR"); + n->line, n->pos, roff_name[n->tok]); check_part(man, n); } diff --git a/mandoc.1 b/mandoc.1 index 2eae464b..9906a39d 100644 --- a/mandoc.1 +++ b/mandoc.1 @@ -1,4 +1,4 @@ -.\" $Id: mandoc.1,v 1.205 2017/06/24 21:08:44 schwarze Exp $ +.\" $Id: mandoc.1,v 1.206 2017/06/25 11:42:02 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2012, 2014-2017 Ingo Schwarze @@ -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: June 24 2017 $ +.Dd $Mdocdate: June 25 2017 $ .Dt MANDOC 1 .Os .Sh NAME @@ -1278,6 +1278,7 @@ A .Ic \&Bl , .Ic \&D1 , .Ic \&Dl , +.Ic \&MT , .Ic \&RS , or .Ic \&UR @@ -1413,6 +1414,8 @@ An empty pair of square brackets is shown. .It Sy "missing resource identifier, using \(dq\(dq" .Pq man The +.Ic \&MT +or .Ic \&UR macro is invoked without any argument. An empty pair of angle brackets is shown. @@ -1765,7 +1768,7 @@ An .Xr mdoc 7 block closing macro, a .Xr man 7 -.Ic \&RE +.Ic \&ME , \&RE or .Ic \&UE macro, an @@ -1799,7 +1802,7 @@ At the end of the document, an explicit block, a .Xr man 7 next-line scope or -.Ic \&RS +.Ic \&MT , \&RS or .Ic \&UR block, an equation, table, or @@ -1971,6 +1974,7 @@ A macro or request is invoked with too many arguments: .Bl -dash -offset 2n -width 2n -compact .It .Ic \&Fo , +.Ic \&MT , .Ic \&PD , .Ic \&RS , .Ic \&UR , diff --git a/roff.c b/roff.c index b182664a..5a0fcd85 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.316 2017/06/24 14:38:33 schwarze Exp $ */ +/* $Id: roff.c,v 1.317 2017/06/25 11:42:02 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017 Ingo Schwarze @@ -330,7 +330,7 @@ const char *__roff_name[MAN_MAX + 1] = { "RE", "RS", "DT", "UC", "PD", "AT", "in", "OP", "EX", "EE", "UR", - "UE", NULL + "UE", "MT", "ME", NULL }; const char *const *roff_name = __roff_name; diff --git a/roff.h b/roff.h index 03160983..e182c5f0 100644 --- a/roff.h +++ b/roff.h @@ -1,4 +1,4 @@ -/* $Id: roff.h,v 1.56 2017/06/24 14:38:33 schwarze Exp $ */ +/* $Id: roff.h,v 1.57 2017/06/25 11:42:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze @@ -467,6 +467,8 @@ enum roff_tok { MAN_EE, MAN_UR, MAN_UE, + MAN_MT, + MAN_ME, MAN_MAX }; -- cgit v1.2.3-56-ge451