summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdoc_html.c36
-rw-r--r--mdoc_term.c64
-rw-r--r--regress/mdoc/Fo/fo0.in32
-rw-r--r--regress/mdoc/Ft/before-fn.in21
-rw-r--r--regress/mdoc/Ft/before-fo.in21
-rw-r--r--regress/mdoc/Ft/ft0.in25
6 files changed, 154 insertions, 45 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 21395f0e..b2d075e4 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1247,7 +1247,7 @@ mdoc_d1_pre(MDOC_ARGS)
/* FIXME: D1 shouldn't be literal. */
- SCALE_VS_INIT(&su, INDENT - 1);
+ SCALE_VS_INIT(&su, INDENT - 2);
bufcat_su(h, "margin-left", &su);
PAIR_CLASS_INIT(&tag[0], "lit");
PAIR_STYLE_INIT(&tag[1], h);
@@ -1563,8 +1563,8 @@ mdoc_ft_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
- print_otag(h, TAG_DIV, 0, NULL);
+ if (SEC_SYNOPSIS == n->sec && n->prev)
+ print_otag(h, TAG_BR, 0, NULL);
PAIR_CLASS_INIT(&tag, "ftype");
print_otag(h, TAG_SPAN, 1, &tag);
@@ -1594,10 +1594,6 @@ mdoc_fn_pre(MDOC_ARGS)
SCALE_VS_INIT(&su, 1);
bufcat_su(h, "margin-top", &su);
}
- if (n->next) {
- SCALE_VS_INIT(&su, 1);
- bufcat_su(h, "margin-bottom", &su);
- }
PAIR_STYLE_INIT(&tag[0], h);
print_otag(h, TAG_DIV, 1, tag);
}
@@ -1785,25 +1781,39 @@ mdoc_mt_pre(MDOC_ARGS)
static int
mdoc_fo_pre(MDOC_ARGS)
{
- struct htmlpair tag;
- struct roffsu su;
+ struct htmlpair tag;
+ struct roffsu su;
+ struct tag *t;
if (MDOC_BODY == n->type) {
h->flags |= HTML_NOSPACE;
print_text(h, "(");
h->flags |= HTML_NOSPACE;
return(1);
- } else if (MDOC_BLOCK == n->type && n->next) {
+ } else if (MDOC_BLOCK == n->type) {
+ if (SEC_SYNOPSIS != n->sec)
+ return(1);
+ if (NULL == n->prev || MDOC_Ft == n->prev->tok) {
+ print_otag(h, TAG_DIV, 0, NULL);
+ return(1);
+ }
SCALE_VS_INIT(&su, 1);
- bufcat_su(h, "margin-bottom", &su);
+ bufcat_su(h, "margin-top", &su);
PAIR_STYLE_INIT(&tag, h);
print_otag(h, TAG_DIV, 1, &tag);
return(1);
}
+ /* XXX: we drop non-initial arguments as per groff. */
+
+ assert(n->child);
+ assert(n->child->string);
+
PAIR_CLASS_INIT(&tag, "fname");
- print_otag(h, TAG_SPAN, 1, &tag);
- return(1);
+ t = print_otag(h, TAG_SPAN, 1, &tag);
+ print_text(h, n->child->string);
+ print_tagq(h, t);
+ return(0);
}
diff --git a/mdoc_term.c b/mdoc_term.c
index 6e023feb..9c6cce7b 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -82,7 +82,6 @@ static void termp_dq_post(DECL_ARGS);
static void termp_fd_post(DECL_ARGS);
static void termp_fn_post(DECL_ARGS);
static void termp_fo_post(DECL_ARGS);
-static void termp_ft_post(DECL_ARGS);
static void termp_in_post(DECL_ARGS);
static void termp_it_post(DECL_ARGS);
static void termp_lb_post(DECL_ARGS);
@@ -166,7 +165,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_bold_pre, termp_fd_post }, /* Fd */
{ termp_fl_pre, NULL }, /* Fl */
{ termp_fn_pre, termp_fn_post }, /* Fn */
- { termp_ft_pre, termp_ft_post }, /* Ft */
+ { termp_ft_pre, NULL }, /* Ft */
{ termp_bold_pre, NULL }, /* Ic */
{ termp_in_pre, termp_in_post }, /* In */
{ termp_li_pre, NULL }, /* Li */
@@ -1511,9 +1510,9 @@ static int
termp_ft_pre(DECL_ARGS)
{
- if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
- if (n->prev && MDOC_Fo == n->prev->tok)
- term_vspace(p);
+ /* NB: MDOC_LINE does not effect this! */
+ if (SEC_SYNOPSIS == n->sec && n->prev)
+ term_vspace(p);
term_fontpush(p, TERMFONT_UNDER);
return(1);
@@ -1521,16 +1520,6 @@ termp_ft_pre(DECL_ARGS)
/* ARGSUSED */
-static void
-termp_ft_post(DECL_ARGS)
-{
-
- if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
- term_newln(p);
-}
-
-
-/* ARGSUSED */
static int
termp_fn_pre(DECL_ARGS)
{
@@ -1993,23 +1982,29 @@ termp_pq_post(DECL_ARGS)
static int
termp_fo_pre(DECL_ARGS)
{
- const struct mdoc_node *nn;
- if (MDOC_BODY == n->type) {
+ if (MDOC_BLOCK == n->type) {
+ /* NB: MDOC_LINE has no effect on this macro! */
+ if (SEC_SYNOPSIS != n->sec)
+ return(1);
+ if (n->prev && MDOC_Ft == n->prev->tok)
+ term_newln(p);
+ else if (n->prev)
+ term_vspace(p);
+ return(1);
+ } else if (MDOC_BODY == n->type) {
p->flags |= TERMP_NOSPACE;
term_word(p, "(");
p->flags |= TERMP_NOSPACE;
return(1);
- } else if (MDOC_HEAD != n->type)
- return(1);
+ }
- term_fontpush(p, TERMFONT_BOLD);
- for (nn = n->child; nn; nn = nn->next) {
- assert(MDOC_TEXT == nn->type);
- term_word(p, nn->string);
- }
- term_fontpop(p);
+ /* XXX: we drop non-initial arguments as per groff. */
+ assert(n->child);
+ assert(n->child->string);
+ term_fontpush(p, TERMFONT_BOLD);
+ term_word(p, n->child->string);
return(0);
}
@@ -2019,13 +2014,18 @@ static void
termp_fo_post(DECL_ARGS)
{
- if (MDOC_BODY != n->type)
- return;
- p->flags |= TERMP_NOSPACE;
- term_word(p, ")");
- p->flags |= TERMP_NOSPACE;
- term_word(p, ";");
- term_newln(p);
+ if (MDOC_BLOCK == n->type) {
+ /* NB: MDOC_LINE has no effect on this macro! */
+ if (SEC_SYNOPSIS == n->sec)
+ term_newln(p);
+ } else if (MDOC_BODY == n->type) {
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, ")");
+ if (SEC_SYNOPSIS == n->sec) {
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, ";");
+ }
+ }
}
diff --git a/regress/mdoc/Fo/fo0.in b/regress/mdoc/Fo/fo0.in
new file mode 100644
index 00000000..4ff66510
--- /dev/null
+++ b/regress/mdoc/Fo/fo0.in
@@ -0,0 +1,32 @@
+.Dd $Mdocdate$
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh SYNOPSIS
+.Fn b
+a
+.Fo b
+.Fc
+.Fo "a b c"
+.Fc
+.Ft "a"
+.Fo "b c"
+.Fc
+.Ft "a b"
+.Fo "b c" "d e"
+.Fc
+.Sh DESCRIPTION
+.Fn b
+a
+.Fo b
+.Fc
+.Fo "a b c"
+.Fc
+.Ft "a"
+.Fo "b c"
+.Fc
+.Ft "a b"
+.Fo "b c" "d e"
+.Fc
diff --git a/regress/mdoc/Ft/before-fn.in b/regress/mdoc/Ft/before-fn.in
new file mode 100644
index 00000000..10ef2ad3
--- /dev/null
+++ b/regress/mdoc/Ft/before-fn.in
@@ -0,0 +1,21 @@
+.Dd $Mdocdate$
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh SYNOPSIS
+.Fn b \" Get this out of the way.
+.Ft a
+.Fn b "c d"
+.Ft 1
+.Ft 2
+.Fn b "c d"
+.Fn b "c d"
+.Sh DESCRIPTION
+.Ft a
+.Fn b "c d"
+.Ft 1
+.Ft 2
+.Fn b "c d"
+.Fn b "c d"
diff --git a/regress/mdoc/Ft/before-fo.in b/regress/mdoc/Ft/before-fo.in
new file mode 100644
index 00000000..9d55f829
--- /dev/null
+++ b/regress/mdoc/Ft/before-fo.in
@@ -0,0 +1,21 @@
+.Dd $Mdocdate$
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh SYNOPSIS
+.Fn b \" Get this out of the way.
+.Ft a
+.Fo b
+.Fa "c d"
+.Fc
+.Ft 1
+.Ft 2
+.Sh DESCRIPTION
+.Ft a
+.Fo b
+.Fa "c d"
+.Fc
+.Ft 1
+.Ft 2
diff --git a/regress/mdoc/Ft/ft0.in b/regress/mdoc/Ft/ft0.in
new file mode 100644
index 00000000..d7f6cc68
--- /dev/null
+++ b/regress/mdoc/Ft/ft0.in
@@ -0,0 +1,25 @@
+.Dd $Mdocdate$
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh SYNOPSIS
+.Fn b \" Get this out of the way.
+.Ft a
+.Ft b
+a
+.Ft "c d"
+b
+.Ar foo
+.Ft "c d"
+.Ar bar
+.Sh DESCRIPTION
+.Ft a
+.Ft b
+a
+.Ft "c d"
+b
+.Ar foo
+.Ft "c d"
+.Ar bar