summaryrefslogtreecommitdiffstats
path: root/man_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2023-10-24 20:53:12 +0000
committerIngo Schwarze <schwarze@openbsd.org>2023-10-24 20:53:12 +0000
commit91555cb3f3238cb10f575c9191c3c2729c8f9473 (patch)
tree039de9bbee59547678c7bbded6b319d34dcdc4e9 /man_term.c
parent8a8bc122106d3c6164977db2ba5b07c3e2bf359d (diff)
downloadmandoc-91555cb3f3238cb10f575c9191c3c2729c8f9473.tar.gz
Implement the man(7) .MR macro, a 2023 GNU extension.
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.
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/man_term.c b/man_term.c
index a45a0ed2..4dac9ceb 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * 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
@@ -74,6 +74,7 @@ static int pre_DT(DECL_ARGS);
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);
@@ -134,6 +135,7 @@ static const struct man_term_act man_term_acts[MAN_MAX - MAN_TH] = {
{ 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);
@@ -328,6 +330,29 @@ pre_B(DECL_ARGS)
}
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)
{
term_word(p, "[");