summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-04 21:49:39 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-04 21:49:39 +0000
commit14deda6326abdec269681291139d0ae022db56f9 (patch)
treee54066223fec52451a6c76fe663d1ea51c445ff7
parent8c29167218188f6baf91ea99e4a5cd3e70080638 (diff)
downloadmandoc-14deda6326abdec269681291139d0ae022db56f9.tar.gz
Documented `In' in full.
Fixed `In' to behave properly: it wasn't properly breaking lines, formatting, or really anything else. Noted COMPATIBILITY with OpenBSD's groff, which pukes all over `In'.
-rw-r--r--mdoc.723
-rw-r--r--mdoc_html.c20
-rw-r--r--mdoc_term.c31
-rw-r--r--regress/mdoc/In/in.in24
4 files changed, 63 insertions, 35 deletions
diff --git a/mdoc.7 b/mdoc.7
index b8b787ca..73f0ecf6 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -33,7 +33,7 @@ section describes compatibility with other troff \-mdoc implementations.
.Pp
An
.Nm
-document follows simple rules: lines beginning with the control
+document follows simple rules: lines beginning with the control
character
.Sq \.
are parsed for macros. Other lines are interpreted within the scope of
@@ -122,7 +122,7 @@ escape followed by an indicator: B (bold), I, (italic), R (Roman), or P
A numerical representation 3, 2, or 1 (bold, italic, and Roman,
respectively) may be used instead.
A text decoration is valid within
-the current font scope only: if a macro opens a font scope alongside
+the current font scope only: if a macro opens a font scope alongside
its own scope, such as
.Sx \&Bf
.Cm \&Sy ,
@@ -1679,6 +1679,19 @@ and
.Ss \&Hf
.Ss \&Ic
.Ss \&In
+An
+.Qq include
+file.
+In the
+.Em SYNOPSIS
+section (only if invoked as the line macro), the first argument is
+preceded by
+.Qq #include ,
+the arguments is enclosed in angled braces, and a newline is asserted.
+In all other invocations, only angled braces will enclose the argument.
+.Pp
+Examples
+.D1 \&.In sys/types
.Ss \&It
A list item. The syntax of this macro depends on the list type.
.Pp
@@ -2035,6 +2048,12 @@ Heirloom troff, the other significant troff implementation accepting
.Pp
.Bl -dash -compact
.It
+Historic groff formats the
+.Sx \&In
+badly: trailing arguments are trashed and
+.Em SYNOPSIS
+is not specially treated.
+.It
groff does not accept the
.Sq \&Ta
pseudo-macro as a line macro.
diff --git a/mdoc_html.c b/mdoc_html.c
index 970b0db0..0f96cf63 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1823,31 +1823,16 @@ mdoc_in_pre(MDOC_ARGS)
struct tag *t;
struct htmlpair tag[2];
int i;
- struct roffsu su;
-
- if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
- if (n->next && MDOC_In != n->next->tok) {
- SCALE_VS_INIT(&su, 1);
- bufcat_su(h, "margin-bottom", &su);
- PAIR_STYLE_INIT(&tag[0], h);
- print_otag(h, TAG_DIV, 1, tag);
- } else
- print_otag(h, TAG_DIV, 0, NULL);
- }
-
- /* FIXME: there's a buffer bug in here somewhere. */
PAIR_CLASS_INIT(&tag[0], "includes");
print_otag(h, TAG_SPAN, 1, tag);
- if (SEC_SYNOPSIS == n->sec)
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
print_text(h, "#include");
print_text(h, "<");
h->flags |= HTML_NOSPACE;
- /* XXX -- see warning in termp_in_post(). */
-
for (nn = n->child; nn; nn = nn->next) {
PAIR_CLASS_INIT(&tag[0], "link-includes");
i = 1;
@@ -1865,6 +1850,9 @@ mdoc_in_pre(MDOC_ARGS)
h->flags |= HTML_NOSPACE;
print_text(h, ">");
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
+ print_otag(h, TAG_BR, 0, NULL);
+
return(0);
}
diff --git a/mdoc_term.c b/mdoc_term.c
index ffe8905f..6f67f621 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1847,11 +1847,15 @@ static int
termp_in_pre(DECL_ARGS)
{
- term_fontpush(p, TERMFONT_BOLD);
- if (SEC_SYNOPSIS == n->sec)
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
+ term_fontpush(p, TERMFONT_BOLD);
term_word(p, "#include");
+ term_word(p, "<");
+ } else {
+ term_word(p, "<");
+ term_fontpush(p, TERMFONT_UNDER);
+ }
- term_word(p, "<");
p->flags |= TERMP_NOSPACE;
return(1);
}
@@ -1862,23 +1866,16 @@ static void
termp_in_post(DECL_ARGS)
{
- term_fontpush(p, TERMFONT_BOLD);
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
+ term_fontpush(p, TERMFONT_BOLD);
+
p->flags |= TERMP_NOSPACE;
term_word(p, ">");
- term_fontpop(p);
-
- if (SEC_SYNOPSIS != n->sec || ! (MDOC_LINE & n->flags))
- return;
- term_newln(p);
- /*
- * XXX Not entirely correct. If `.In foo bar' is specified in
- * the SYNOPSIS section, then it produces a single break after
- * the <foo>; mandoc asserts a vertical space. Since this
- * construction is rarely used, I think it's fine.
- */
- if (n->next && MDOC_In != n->next->tok)
- term_vspace(p);
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
+ term_fontpop(p);
+ term_newln(p);
+ }
}
diff --git a/regress/mdoc/In/in.in b/regress/mdoc/In/in.in
new file mode 100644
index 00000000..28831768
--- /dev/null
+++ b/regress/mdoc/In/in.in
@@ -0,0 +1,24 @@
+.\" THIS WILL PUKE HORRIBLY ON OLD GROFF, WHICH HAS COMPLETELY
+.\" DIFFERENT ("BAD") BEHAVIOUR.
+.Dd $Mdocdate$
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh SYNOPSIS
+1
+.In 2 3
+6
+.In 2 3
+.Qq In 2
+.Fd a
+6
+.In 4
+5
+.Sh DESCRIPTION
+1
+.In 2 3
+6
+.In 4
+5