* mdocml: Add support for `OP', one of the extended man macros.
@ 2012-01-03 15:16 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2012-01-03 15:16 UTC (permalink / raw)
To: source
Log Message:
-----------
Add support for `OP', one of the extended man macros. This also requires
some man(7) changes to accomodate for the an-ext compatibility.
Modified Files:
--------------
mdocml:
man.7
man.c
man.h
man_html.c
man_macro.c
man_term.c
man_validate.c
Revision Data
-------------
Index: man.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.7,v
retrieving revision 1.112
retrieving revision 1.113
diff -Lman.7 -Lman.7 -u -p -r1.112 -r1.113
--- man.7
+++ 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 packa
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
Index: man_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -Lman_term.c -Lman_term.c -u -p -r1.126 -r1.127
--- man_term.c
+++ man_term.c
@@ -68,21 +68,22 @@ static void print_man_foot(struct ter
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
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
{ pre_ft, NULL, MAN_NOTEXT }, /* ft */
+ { pre_OP, NULL, 0 }, /* OP */
};
@@ -320,6 +322,29 @@ pre_B(DECL_ARGS)
term_fontrepl(p, TERMFONT_BOLD);
return(1);
+}
+
+/* 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 */
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -Lman_html.c -Lman_html.c -u -p -r1.85 -r1.86
--- man_html.c
+++ 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 */
};
/*
@@ -583,6 +583,37 @@ man_HP_pre(MAN_ARGS)
print_otag(h, TAG_P, 1, &tag);
return(1);
}
+
+/* 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
Index: man.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lman.h -Lman.h -u -p -r1.59 -r1.60
--- man.h
+++ man.h
@@ -51,6 +51,7 @@ enum mant {
MAN_AT,
MAN_in,
MAN_ft,
+ MAN_OP,
MAN_MAX
};
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -Lman.c -Lman.c -u -p -r1.114 -r1.115
--- man.c
+++ man.c
@@ -40,7 +40,7 @@ const char *const __man_macronames[MAN_M
"RI", "na", "sp", "nf",
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
- "ft"
+ "ft", "OP"
};
const char * const *man_macronames = __man_macronames;
Index: man_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_validate.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -Lman_validate.c -Lman_validate.c -u -p -r1.79 -r1.80
--- man_validate.c
+++ 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
{ 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
{ 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)
Index: man_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_macro.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -Lman_macro.c -Lman_macro.c -u -p -r1.70 -r1.71
--- man_macro.c
+++ man_macro.c
@@ -84,6 +84,7 @@ const struct man_macro __man_macros[MAN_
{ 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;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-01-03 15:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-03 15:16 mdocml: Add support for `OP', one of the extended man macros kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).