aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-10-17 20:54:58 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-10-17 20:54:58 +0000
commit80da5c33753e6423f0c705cd021a073af20577a9 (patch)
tree86853f332a4ac8f07b3d088aeccb48fc5611ebc6
parentde451aaf7a927d2994d3e526df07235dee8005af (diff)
downloadmandoc-80da5c33753e6423f0c705cd021a073af20577a9.tar.gz
mandoc-80da5c33753e6423f0c705cd021a073af20577a9.tar.zst
mandoc-80da5c33753e6423f0c705cd021a073af20577a9.zip
Implement the .UR/.UE block (uniform resource identifier) introduced in the
man-ext macros by Eric S. Raymond, enabled by default in groff_man(7). Usual disclaimer: You don't write new man(7) code, so you are not going to use these, either. Improves e.g. the bzr(1) and etherape(1) manuals. Thanks to naddy@ for bringing these to my attention.
-rw-r--r--man.c5
-rw-r--r--man.h4
-rw-r--r--man_html.c30
-rw-r--r--man_macro.c7
-rw-r--r--man_term.c32
-rw-r--r--man_validate.c19
6 files changed, 89 insertions, 8 deletions
diff --git a/man.c b/man.c
index 24ffc638..10cf610c 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.119 2012/11/17 00:26:33 schwarze Exp $ */
+/* $Id: man.c,v 1.120 2013/10/17 20:54:58 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -40,7 +40,8 @@ const char *const __man_macronames[MAN_MAX] = {
"RI", "na", "sp", "nf",
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
- "ft", "OP", "EX", "EE"
+ "ft", "OP", "EX", "EE",
+ "UR", "UE"
};
const char * const *man_macronames = __man_macronames;
diff --git a/man.h b/man.h
index e85da9ae..ef9480f2 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.61 2012/06/02 20:16:23 schwarze Exp $ */
+/* $Id: man.h,v 1.62 2013/10/17 20:54:58 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -54,6 +54,8 @@ enum mant {
MAN_OP,
MAN_EX,
MAN_EE,
+ MAN_UR,
+ MAN_UE,
MAN_MAX
};
diff --git a/man_html.c b/man_html.c
index 100188bd..2c4e220a 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,6 +1,7 @@
-/* $Id: man_html.c,v 1.89 2012/11/17 00:26:33 schwarze Exp $ */
+/* $Id: man_html.c,v 1.90 2013/10/17 20:54:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -70,6 +71,7 @@ static int man_RS_pre(MAN_ARGS);
static int man_SH_pre(MAN_ARGS);
static int man_SM_pre(MAN_ARGS);
static int man_SS_pre(MAN_ARGS);
+static int man_UR_pre(MAN_ARGS);
static int man_alt_pre(MAN_ARGS);
static int man_br_pre(MAN_ARGS);
static int man_ign_pre(MAN_ARGS);
@@ -115,6 +117,8 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_OP_pre, NULL }, /* OP */
{ man_literal_pre, NULL }, /* EX */
{ man_literal_pre, NULL }, /* EE */
+ { man_UR_pre, NULL }, /* UR */
+ { NULL, NULL }, /* UE */
};
/*
@@ -688,3 +692,27 @@ man_RS_pre(MAN_ARGS)
print_otag(h, TAG_DIV, 1, &tag);
return(1);
}
+
+/* ARGSUSED */
+static int
+man_UR_pre(MAN_ARGS)
+{
+ struct htmlpair tag[2];
+
+ n = n->child;
+ assert(MAN_HEAD == n->type);
+ if (n->nchild) {
+ assert(MAN_TEXT == n->child->type);
+ PAIR_CLASS_INIT(&tag[0], "link-ext");
+ PAIR_HREF_INIT(&tag[1], n->child->string);
+ print_otag(h, TAG_A, 2, tag);
+ }
+
+ assert(MAN_BODY == n->next->type);
+ if (n->next->nchild)
+ n = n->next;
+
+ print_man_nodelist(man, n->child, mh, h);
+
+ return(0);
+}
diff --git a/man_macro.c b/man_macro.c
index 6631f14d..eaa8fba0 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.75 2012/11/17 00:26:33 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.76 2013/10/17 20:54:58 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -88,6 +88,8 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* OP */
{ in_line_eoln, MAN_BSCOPE }, /* EX */
{ in_line_eoln, MAN_BSCOPE }, /* EE */
+ { blk_exp, MAN_BSCOPE | MAN_EXPLICIT }, /* UR */
+ { blk_close, 0 }, /* UE */
};
const struct man_macro * const man_macros = __man_macros;
@@ -284,6 +286,9 @@ blk_close(MACRO_PROT_ARGS)
case (MAN_RE):
ntok = MAN_RS;
break;
+ case (MAN_UE):
+ ntok = MAN_UR;
+ break;
default:
abort();
/* NOTREACHED */
diff --git a/man_term.c b/man_term.c
index db5719ce..4dc6d8bd 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.136 2013/01/05 22:19:12 schwarze Exp $ */
+/* $Id: man_term.c,v 1.137 2013/10/17 20:54:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -78,6 +78,7 @@ static int pre_RS(DECL_ARGS);
static int pre_SH(DECL_ARGS);
static int pre_SS(DECL_ARGS);
static int pre_TP(DECL_ARGS);
+static int pre_UR(DECL_ARGS);
static int pre_alternate(DECL_ARGS);
static int pre_ft(DECL_ARGS);
static int pre_ign(DECL_ARGS);
@@ -91,6 +92,7 @@ static void post_RS(DECL_ARGS);
static void post_SH(DECL_ARGS);
static void post_SS(DECL_ARGS);
static void post_TP(DECL_ARGS);
+static void post_UR(DECL_ARGS);
static const struct termact termacts[MAN_MAX] = {
{ pre_sp, NULL, MAN_NOTEXT }, /* br */
@@ -129,6 +131,8 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_OP, NULL, 0 }, /* OP */
{ pre_literal, NULL, 0 }, /* EX */
{ pre_literal, NULL, 0 }, /* EE */
+ { pre_UR, post_UR, 0 }, /* UR */
+ { NULL, NULL, 0 }, /* UE */
};
@@ -939,6 +943,32 @@ post_RS(DECL_ARGS)
mt->lmargincur = mt->lmarginsz;
}
+/* ARGSUSED */
+static int
+pre_UR(DECL_ARGS)
+{
+
+ return (MAN_HEAD != n->type);
+}
+
+/* ARGSUSED */
+static void
+post_UR(DECL_ARGS)
+{
+
+ if (MAN_BLOCK != n->type)
+ return;
+
+ term_word(p, "<");
+ p->flags |= TERMP_NOSPACE;
+
+ if (NULL != n->child->child)
+ print_man_node(p, mt, n->child->child, meta);
+
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, ">");
+}
+
static void
print_man_node(DECL_ARGS)
{
diff --git a/man_validate.c b/man_validate.c
index 7a9deede..da2e557e 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,7 +1,7 @@
-/* $Id: man_validate.c,v 1.85 2012/11/17 00:26:33 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.86 2013/10/17 20:54:58 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -49,6 +49,7 @@ static int check_eq2(CHKARGS);
static int check_le1(CHKARGS);
static int check_ge2(CHKARGS);
static int check_le5(CHKARGS);
+static int check_head1(CHKARGS);
static int check_par(CHKARGS);
static int check_part(CHKARGS);
static int check_root(CHKARGS);
@@ -80,6 +81,7 @@ static v_check posts_sec[] = { post_sec, NULL };
static v_check posts_sp[] = { post_vs, check_le1, NULL };
static v_check posts_th[] = { check_ge2, check_le5, post_TH, NULL };
static v_check posts_uc[] = { post_UC, NULL };
+static v_check posts_ur[] = { check_head1, check_part, NULL };
static v_check pres_sec[] = { pre_sec, NULL };
static const struct man_valid man_valids[MAN_MAX] = {
@@ -119,6 +121,8 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, posts_eq2 }, /* OP */
{ NULL, posts_nf }, /* EX */
{ NULL, posts_fi }, /* EE */
+ { NULL, posts_ur }, /* UR */
+ { NULL, NULL }, /* UE */
};
@@ -246,6 +250,17 @@ INEQ_DEFINE(2, >=, ge2)
INEQ_DEFINE(5, <=, le5)
static int
+check_head1(CHKARGS)
+{
+
+ if (MAN_HEAD == n->type && 1 != n->nchild)
+ mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line,
+ n->pos, "line arguments eq 1 (have %d)", n->nchild);
+
+ return(1);
+}
+
+static int
post_ft(CHKARGS)
{
char *cp;