The syntax and semantics is almost identical to mdoc(7) .Xr.
This will be needed for reading the groff manual pages once our port
will be updated to 1.23, and the Linux Manual Pages Project is also
determined to start using it sooner or later. I did not advocate for
this new macro, but since we want to remain able to read all manual
pages found in the wild, there is little choice but to support it.
At least it is easy to do, they basically copied .Xr.
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2023/10/24 20:30:49 schwarze Exp $
+
+REGRESS_TARGETS = basic
+LINT_TARGETS = basic
+
+.include <bsd.regress.mk>
+
+# temporary hack while working towards an update of the groff port
+MANDOC = mandoc -O indent=5
+GROFF = /co/groff/build/test-groff ${GOPTS} -d MF=R ${MOPTS} -Wall -P-c
--- /dev/null
+.\" $OpenBSD: basic.in,v 1.1 2023/10/24 20:30:49 schwarze Exp $
+.TH MR-BASIC 1 "October 24, 2023" OpenBSD
+.SH NAME
+MR-basic \- manual page cross references
+.SH DESCRIPTION
+empty:
+.MR
+prints empty name and parentheses
+.PP
+single argument:
+.MR name
+prints empty parentheses
+.PP
+two arguments:
+.MR test 1
+normal use
+.PP
+three arguments:
+.MR test 1 suffix
+with suffix
+.PP
+four arguments:
+.MR test 1 suffix excess
+warning
+.PP
+five arguments:
+.MR test 1 suffix too many
+warning
+.PP
+after setting
+.ft B
+bold
+font:
+.MR test 1 suffix
+not bold
+.PP
+in bold next-line scope:
+.B
+.MR test 1 suffix
+not bold
+.TP 5n
+first tag
+first body
+.TP
+.MR test 1 tag
+test body
--- /dev/null
+MR-BASIC(1) General Commands Manual MR-BASIC(1)
+
+N\bNA\bAM\bME\bE
+ MR-basic - manual page cross references
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ empty: () prints empty name and parentheses
+
+ single argument: name() prints empty parentheses
+
+ two arguments: test(1) normal use
+
+ three arguments: test(1)suffix with suffix
+
+ four arguments: test(1)suffix warning
+
+ five arguments: test(1)suffix warning
+
+ after setting b\bbo\bol\bld\bd f\bfo\bon\bnt\bt:\b: test(1)suffix not bold
+
+ in bold next-line scope: test(1)suffix not bold
+
+ first tag
+ first body
+
+ test(1)tag
+ test body
+
+OpenBSD October 24, 2023 MR-BASIC(1)
--- /dev/null
+mandoc: basic.in:38:2: WARNING: line scope broken: MR breaks B
+mandoc: basic.in:7:2: ERROR: missing manual name, using "": MR
+mandoc: basic.in:11:2: WARNING: missing section argument: MR name
+mandoc: basic.in:23:19: ERROR: skipping excess arguments: MR ... excess
+mandoc: basic.in:27:19: ERROR: skipping excess arguments: MR ... too
-# $OpenBSD: Makefile,v 1.20 2022/04/27 17:04:15 schwarze Exp $
+# $OpenBSD: Makefile,v 1.21 2023/10/24 20:30:49 schwarze Exp $
-SUBDIR = AT B BI DT EX HP IP MT OP PD PP RS SH SS SY TH TP TS UC UR nf blank
+SUBDIR = AT B BI DT EX HP IP MR MT OP PD PP RS SH SS SY TH TP TS UC UR nf blank
.include "../Makefile.sub"
.include <bsd.subdir.mk>
-/* $OpenBSD: man_html.c,v 1.139 2023/10/18 16:11:29 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.140 2023/10/24 20:30:49 schwarze Exp $ */
/*
- * Copyright (c) 2013-2015,2017-2020,2022 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013-15,2017-20,2022-23 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
static int man_B_pre(MAN_ARGS);
static int man_IP_pre(MAN_ARGS);
static int man_I_pre(MAN_ARGS);
+static int man_MR_pre(MAN_ARGS);
static int man_OP_pre(MAN_ARGS);
static int man_PP_pre(MAN_ARGS);
static int man_RS_pre(MAN_ARGS);
{ NULL, NULL }, /* UE */
{ man_UR_pre, NULL }, /* MT */
{ NULL, NULL }, /* ME */
+ { man_MR_pre, NULL }, /* MR */
};
return 0;
}
+static int
+man_MR_pre(MAN_ARGS)
+{
+ struct tag *t;
+ const char *name, *section, *suffix;
+ char *label;
+
+ html_setfont(h, ESCAPE_FONTROMAN);
+ name = section = suffix = label = NULL;
+ if (n->child != NULL) {
+ name = n->child->string;
+ if (n->child->next != NULL) {
+ section = n->child->next->string;
+ mandoc_asprintf(&label,
+ "%s, section %s", name, section);
+ if (n->child->next->next != NULL)
+ suffix = n->child->next->next->string;
+ }
+ }
+
+ if (name != NULL && section != NULL && h->base_man1 != NULL)
+ t = print_otag(h, TAG_A, "chM?", "Xr",
+ name, section, "aria-label", label);
+ else
+ t = print_otag(h, TAG_A, "c?", "Xr", "aria-label", label);
+
+ free(label);
+ if (name != NULL) {
+ print_text(h, name);
+ h->flags |= HTML_NOSPACE;
+ }
+ print_text(h, "(");
+ h->flags |= HTML_NOSPACE;
+ if (section != NULL) {
+ print_text(h, section);
+ h->flags |= HTML_NOSPACE;
+ }
+ print_text(h, ")");
+ print_tagq(h, t);
+ if (suffix != NULL) {
+ h->flags |= HTML_NOSPACE;
+ print_text(h, suffix);
+ }
+ return 0;
+}
+
static int
man_OP_pre(MAN_ARGS)
{
-/* $OpenBSD: man_macro.c,v 1.109 2022/04/27 17:04:15 schwarze Exp $ */
+/* $OpenBSD: man_macro.c,v 1.110 2023/10/24 20:30:49 schwarze Exp $ */
/*
* Copyright (c) 2012-2015,2017-2020,2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
{ blk_close, MAN_XSCOPE }, /* UE */
{ blk_exp, MAN_XSCOPE }, /* MT */
{ blk_close, MAN_XSCOPE }, /* ME */
+ { in_line_eoln, 0 }, /* MR */
};
-/* $OpenBSD: man_term.c,v 1.195 2023/04/28 20:14:19 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.196 2023/10/24 20:30:49 schwarze Exp $ */
/*
- * Copyright (c) 2010-2015,2017-2020,2022 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-15,2017-20,2022-23 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
+static int pre_MR(DECL_ARGS);
static int pre_OP(DECL_ARGS);
static int pre_PD(DECL_ARGS);
static int pre_PP(DECL_ARGS);
{ NULL, NULL, 0 }, /* UE */
{ pre_UR, post_UR, 0 }, /* MT */
{ NULL, NULL, 0 }, /* ME */
+ { pre_MR, NULL, 0 }, /* MR */
};
static const struct man_term_act *man_term_act(enum roff_tok);
return 1;
}
+static int
+pre_MR(DECL_ARGS)
+{
+ term_fontrepl(p, TERMFONT_NONE);
+ n = n->child;
+ if (n != NULL) {
+ term_word(p, n->string); /* name */
+ p->flags |= TERMP_NOSPACE;
+ }
+ term_word(p, "(");
+ p->flags |= TERMP_NOSPACE;
+ if (n != NULL && (n = n->next) != NULL) {
+ term_word(p, n->string); /* section */
+ p->flags |= TERMP_NOSPACE;
+ }
+ term_word(p, ")");
+ if (n != NULL && (n = n->next) != NULL) {
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, n->string); /* suffix */
+ }
+ return 0;
+}
+
static int
pre_OP(DECL_ARGS)
{
-/* $OpenBSD: man_validate.c,v 1.128 2023/04/28 20:14:19 schwarze Exp $ */
+/* $OpenBSD: man_validate.c,v 1.129 2023/10/24 20:30:49 schwarze Exp $ */
/*
- * Copyright (c) 2010, 2012-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2020, 2023 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
#include "mandoc_aux.h"
#include "mandoc.h"
+#include "mandoc_xr.h"
#include "roff.h"
#include "man.h"
#include "libmandoc.h"
static void post_EE(CHKARGS);
static void post_EX(CHKARGS);
static void post_IP(CHKARGS);
+static void post_MR(CHKARGS);
static void post_OP(CHKARGS);
static void post_SH(CHKARGS);
static void post_TH(CHKARGS);
NULL, /* UE */
post_UR, /* MT */
NULL, /* ME */
+ post_MR, /* MR */
};
roff_node_delete(man, man->last);
}
+static void
+post_MR(CHKARGS)
+{
+ struct roff_node *nch;
+
+ if ((nch = n->child) == NULL) {
+ mandoc_msg(MANDOCERR_NM_NONAME, n->line, n->pos, "MR");
+ return;
+ }
+ if (nch->next == NULL) {
+ mandoc_msg(MANDOCERR_XR_NOSEC,
+ n->line, n->pos, "MR %s", nch->string);
+ return;
+ }
+ if (mandoc_xr_add(nch->next->string, nch->string, nch->line, nch->pos))
+ mandoc_msg(MANDOCERR_XR_SELF, nch->line, nch->pos,
+ "MR %s %s", nch->string, nch->next->string);
+ if ((nch = nch->next->next) == NULL || nch->next == NULL)
+ return;
+
+ mandoc_msg(MANDOCERR_ARG_EXCESS, nch->next->line, nch->next->pos,
+ "MR ... %s", nch->next->string);
+ while (nch->next != NULL)
+ roff_node_delete(man, nch->next);
+}
+
static void
post_UC(CHKARGS)
{
-.\" $OpenBSD: mandoc.1,v 1.191 2023/10/18 14:47:22 schwarze Exp $
+.\" $OpenBSD: mandoc.1,v 1.192 2023/10/24 20:30:49 schwarze Exp $
.\"
-.\" Copyright (c) 2012, 2014-2022 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2012, 2014-2023 Ingo Schwarze <schwarze@openbsd.org>
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 18 2023 $
+.Dd $Mdocdate: October 24 2023 $
.Dt MANDOC 1
.Os
.Sh NAME
A standard section header occurs in a section of the manual
where it normally isn't useful.
.It Sy "cross reference to self"
-.Pq mdoc
+.Pq mdoc , man
An
.Ic \&Xr
+or
+.Ic \&MR
macro refers to a name and section matching the section of the present
manual page and a name mentioned in an
.Ic \&Nm
macro on the next input line.
Such an empty block does not produce any output.
.It Sy "missing section argument"
-.Pq mdoc
+.Pq mdoc , man
An
.Ic \&Xr
+or
+.Ic \&MR
macro lacks its second, section number argument.
-The first argument, i.e. the name, is printed, but without subsequent
-parentheses.
+The first argument, i.e. the name, is printed, but without a section number.
+In the case of
+.Ic \&Xr ,
+the parentheses are also omitted.
.It Sy "missing -std argument, adding it"
.Pq mdoc
An
nor a single character escape sequence.
All arguments are ignored and printing of a margin character is disabled.
.It Sy "missing manual name, using \(dq\(dq"
-.Pq mdoc
+.Pq mdoc , man
The first call to
.Ic \&Nm ,
-or any call in the NAME section, lacks the required argument.
+or any call in the NAME section, lacks the required argument, or
+.Ic \&MR
+is called without any argument.
.It Sy "uname(3) system call failed, using UNKNOWN"
.Pq mdoc
The
family with more than two arguments
.It
.Ic \&Dt
+or
+.Ic \&MR
with more than three arguments
.It
.Ic \&TH
-/* $OpenBSD: roff.c,v 1.271 2023/10/23 20:07:18 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.272 2023/10/24 20:30:49 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2023 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
"PD", "AT", "in",
"SY", "YS", "OP",
"EX", "EE", "UR",
- "UE", "MT", "ME", NULL
+ "UE", "MT", "ME", "MR",
+ NULL
};
const char *const *roff_name = __roff_name;
-/* $OpenBSD: roff.h,v 1.57 2022/04/30 15:08:56 schwarze Exp $ */
+/* $OpenBSD: roff.h,v 1.58 2023/10/24 20:30:49 schwarze Exp $ */
/*
* Copyright (c) 2013-2015,2017-2020,2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
MAN_UE,
MAN_MT,
MAN_ME,
+ MAN_MR,
MAN_MAX /* End of man(7) macros. */
};