summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2012-01-03 15:16:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2012-01-03 15:16:24 +0000
commit4873b4380a189665bf89eaa8180a9fc5696c5f73 (patch)
tree29e035a9b0675bbee7fd00013cc57264156045f6
parentd807641d331b60b360442bd3bc4084baa0342b98 (diff)
downloadmandoc-4873b4380a189665bf89eaa8180a9fc5696c5f73.tar.gz
Add support for `OP', one of the extended man macros. This also requires
some man(7) changes to accomodate for the an-ext compatibility.
-rw-r--r--man.727
-rw-r--r--man.c2
-rw-r--r--man.h1
-rw-r--r--man_html.c51
-rw-r--r--man_macro.c1
-rw-r--r--man_term.c29
-rw-r--r--man_validate.c8
7 files changed, 104 insertions, 15 deletions
diff --git a/man.7 b/man.7
index ff88058e..263a53ae 100644
--- a/man.7
+++ b/man.7
@@ -272,6 +272,10 @@ in the alphabetical reference below.
.It Sx RB Ta alternate between roman and boldface fonts
.It Sx RI Ta alternate between roman and italic fonts
.El
+.Ss Semantic markup
+.Bl -column "PP, LP, P" description
+.It Sx OP Ta optional arguments
+.El
.Sh MACRO REFERENCE
This section is a canonical reference to all macros, arranged
alphabetically.
@@ -437,6 +441,19 @@ See also
.Sx \&PP ,
and
.Sx \&TP .
+.Ss \&OP
+Optional command-line argument.
+This has the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&OP
+.Cm key Op Cm value
+.Ed
+.Pp
+The
+.Cm key
+is usually a command-line flag and
+.Cm value
+its argument.
.Ss \&P
Synonym for
.Sx \&LP .
@@ -691,6 +708,7 @@ The syntax is as follows:
.It Sx \&I Ta n Ta next-line Ta \&
.It Sx \&IB Ta n Ta current Ta \&
.It Sx \&IR Ta n Ta current Ta \&
+.It Sx \&OP Ta 0, 1 Ta current Ta compat
.It Sx \&R Ta n Ta next-line Ta \&
.It Sx \&RB Ta n Ta current Ta \&
.It Sx \&RI Ta n Ta current Ta \&
@@ -854,6 +872,12 @@ number when no
is given, like in
.Xr mdoc 7 .
.El
+.Pp
+The
+.Sx OP
+macro is part of the extended
+.Nm
+macro set, and may not be portable to non-GNU troff implementations.
.Sh SEE ALSO
.Xr man 1 ,
.Xr mandoc 1 ,
@@ -869,6 +893,9 @@ language first appeared as a macro package for the roff typesetting
system in
.At v7 .
It was later rewritten by James Clark as a macro package for groff.
+Eric S. Raymond wrote the extended
+.Nm
+macros for groff in 2007.
The stand-alone implementation that is part of the
.Xr mandoc 1
utility written by Kristaps Dzonsons appeared in
diff --git a/man.c b/man.c
index 170441b0..51a5f72f 100644
--- a/man.c
+++ b/man.c
@@ -40,7 +40,7 @@ const char *const __man_macronames[MAN_MAX] = {
"RI", "na", "sp", "nf",
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
- "ft"
+ "ft", "OP"
};
const char * const *man_macronames = __man_macronames;
diff --git a/man.h b/man.h
index 5096a611..b6ddea17 100644
--- a/man.h
+++ b/man.h
@@ -51,6 +51,7 @@ enum mant {
MAN_AT,
MAN_in,
MAN_ft,
+ MAN_OP,
MAN_MAX
};
diff --git a/man_html.c b/man_html.c
index 7adea05e..700450c1 100644
--- a/man_html.c
+++ b/man_html.c
@@ -58,26 +58,25 @@ static void print_man(MAN_ARGS);
static void print_man_head(MAN_ARGS);
static void print_man_nodelist(MAN_ARGS);
static void print_man_node(MAN_ARGS);
-
static int a2width(const struct man_node *,
struct roffsu *);
-
-static int man_alt_pre(MAN_ARGS);
-static int man_br_pre(MAN_ARGS);
-static int man_ign_pre(MAN_ARGS);
-static int man_in_pre(MAN_ARGS);
-static int man_literal_pre(MAN_ARGS);
-static void man_root_post(MAN_ARGS);
-static void man_root_pre(MAN_ARGS);
static int man_B_pre(MAN_ARGS);
static int man_HP_pre(MAN_ARGS);
-static int man_I_pre(MAN_ARGS);
static int man_IP_pre(MAN_ARGS);
+static int man_I_pre(MAN_ARGS);
+static int man_OP_pre(MAN_ARGS);
static int man_PP_pre(MAN_ARGS);
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_alt_pre(MAN_ARGS);
+static int man_br_pre(MAN_ARGS);
+static int man_ign_pre(MAN_ARGS);
+static int man_in_pre(MAN_ARGS);
+static int man_literal_pre(MAN_ARGS);
+static void man_root_post(MAN_ARGS);
+static void man_root_pre(MAN_ARGS);
static const struct htmlman mans[MAN_MAX] = {
{ man_br_pre, NULL }, /* br */
@@ -113,6 +112,7 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_ign_pre, NULL }, /* AT */
{ man_in_pre, NULL }, /* in */
{ man_ign_pre, NULL }, /* ft */
+ { man_OP_pre, NULL }, /* OP */
};
/*
@@ -586,6 +586,37 @@ man_HP_pre(MAN_ARGS)
/* ARGSUSED */
static int
+man_OP_pre(MAN_ARGS)
+{
+ struct tag *tt;
+ struct htmlpair tag;
+
+ print_text(h, "[");
+ h->flags |= HTML_NOSPACE;
+ PAIR_CLASS_INIT(&tag, "opt");
+ tt = print_otag(h, TAG_SPAN, 1, &tag);
+
+ if (NULL != (n = n->child)) {
+ print_otag(h, TAG_B, 0, NULL);
+ print_text(h, n->string);
+ }
+
+ print_stagq(h, tt);
+
+ if (NULL != n && NULL != n->next) {
+ print_otag(h, TAG_I, 0, NULL);
+ print_text(h, n->next->string);
+ }
+
+ print_stagq(h, tt);
+ h->flags |= HTML_NOSPACE;
+ print_text(h, "]");
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
man_B_pre(MAN_ARGS)
{
diff --git a/man_macro.c b/man_macro.c
index 50dd477d..bc56ae4c 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -84,6 +84,7 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* AT */
{ in_line_eoln, 0 }, /* in */
{ in_line_eoln, 0 }, /* ft */
+ { in_line_eoln, 0 }, /* OP */
};
const struct man_macro * const man_macros = __man_macros;
diff --git a/man_term.c b/man_term.c
index 0941f7cf..0d44e13f 100644
--- a/man_term.c
+++ b/man_term.c
@@ -68,21 +68,22 @@ static void print_man_foot(struct termp *, const void *);
static void print_bvspace(struct termp *,
const struct man_node *);
-static int pre_alternate(DECL_ARGS);
static int pre_B(DECL_ARGS);
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
+static int pre_OP(DECL_ARGS);
static int pre_PP(DECL_ARGS);
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_alternate(DECL_ARGS);
+static int pre_ft(DECL_ARGS);
static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
static int pre_sp(DECL_ARGS);
-static int pre_ft(DECL_ARGS);
static void post_IP(DECL_ARGS);
static void post_HP(DECL_ARGS);
@@ -125,6 +126,7 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
{ pre_ft, NULL, MAN_NOTEXT }, /* ft */
+ { pre_OP, NULL, 0 }, /* OP */
};
@@ -324,6 +326,29 @@ pre_B(DECL_ARGS)
/* ARGSUSED */
static int
+pre_OP(DECL_ARGS)
+{
+
+ term_word(p, "[");
+ p->flags |= TERMP_NOSPACE;
+
+ if (NULL != (n = n->child)) {
+ term_fontrepl(p, TERMFONT_BOLD);
+ term_word(p, n->string);
+ }
+ if (NULL != n && NULL != n->next) {
+ term_fontrepl(p, TERMFONT_UNDER);
+ term_word(p, n->next->string);
+ }
+
+ term_fontrepl(p, TERMFONT_NONE);
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, "]");
+ return(0);
+}
+
+/* ARGSUSED */
+static int
pre_ft(DECL_ARGS)
{
const char *cp;
diff --git a/man_validate.c b/man_validate.c
index c63dcdfc..822c64d2 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -45,6 +45,7 @@ struct man_valid {
};
static int check_eq0(CHKARGS);
+static int check_eq2(CHKARGS);
static int check_le1(CHKARGS);
static int check_ge2(CHKARGS);
static int check_le5(CHKARGS);
@@ -66,6 +67,7 @@ static int pre_sec(CHKARGS);
static v_check posts_at[] = { post_AT, NULL };
static v_check posts_br[] = { post_vs, check_eq0, NULL };
static v_check posts_eq0[] = { check_eq0, NULL };
+static v_check posts_eq2[] = { check_eq2, NULL };
static v_check posts_fi[] = { check_eq0, post_fi, NULL };
static v_check posts_ft[] = { post_ft, NULL };
static v_check posts_nf[] = { check_eq0, post_nf, NULL };
@@ -99,8 +101,8 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, NULL }, /* I */
{ NULL, NULL }, /* IR */
{ NULL, NULL }, /* RI */
- { NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */
- { NULL, posts_sp }, /* sp */ /* FIXME: should warn only. */
+ { NULL, posts_eq0 }, /* na */
+ { NULL, posts_sp }, /* sp */
{ NULL, posts_nf }, /* nf */
{ NULL, posts_fi }, /* fi */
{ NULL, NULL }, /* RE */
@@ -111,6 +113,7 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, posts_at }, /* AT */
{ NULL, NULL }, /* in */
{ NULL, posts_ft }, /* ft */
+ { NULL, posts_eq2 }, /* OP */
};
@@ -232,6 +235,7 @@ check_##name(CHKARGS) \
}
INEQ_DEFINE(0, ==, eq0)
+INEQ_DEFINE(2, ==, eq2)
INEQ_DEFINE(1, <=, le1)
INEQ_DEFINE(2, >=, ge2)
INEQ_DEFINE(5, <=, le5)