From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: fix vertical spacing for -Tman SYNOPSIS .Fn .Fo .Ft .In .Nm .Va
Date: Sun, 8 Jul 2012 14:39:48 -0400 (EDT) [thread overview]
Message-ID: <201207081839.q68IdmTv016937@krisdoz.my.domain> (raw)
Log Message:
-----------
fix vertical spacing for -Tman SYNOPSIS .Fn .Fo .Ft .In .Nm .Va .Vt
OpenBSD rev. 1.21
Modified Files:
--------------
mdocml:
mdoc_man.c
Revision Data
-------------
Index: mdoc_man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.22 -r1.23
--- mdoc_man.c
+++ mdoc_man.c
@@ -67,6 +67,7 @@ static int pre_enc(DECL_ARGS);
static int pre_fa(DECL_ARGS);
static int pre_fn(DECL_ARGS);
static int pre_fo(DECL_ARGS);
+static int pre_ft(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_it(DECL_ARGS);
static int pre_nm(DECL_ARGS);
@@ -75,6 +76,7 @@ static int pre_pp(DECL_ARGS);
static int pre_sm(DECL_ARGS);
static int pre_sp(DECL_ARGS);
static int pre_sect(DECL_ARGS);
+static void pre_syn(const struct mdoc_node *);
static int pre_vt(DECL_ARGS);
static int pre_ux(DECL_ARGS);
static int pre_xr(DECL_ARGS);
@@ -112,7 +114,7 @@ static const struct manact manacts[MDOC_
{ NULL, NULL, NULL, NULL, NULL }, /* _Fd */
{ NULL, pre_enc, post_enc, "\\fB-", "\\fP" }, /* Fl */
{ NULL, pre_fn, post_fn, NULL, NULL }, /* Fn */
- { NULL, pre_enc, post_enc, "\\fI", "\\fP" }, /* Ft */
+ { NULL, pre_ft, post_enc, NULL, "\\fP" }, /* Ft */
{ NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Ic */
{ NULL, pre_in, post_in, NULL, NULL }, /* In */
{ NULL, pre_enc, post_enc, "\\fR", "\\fP" }, /* Li */
@@ -488,6 +490,46 @@ post_sect(DECL_ARGS)
outflags &= ~(MMAN_An_split | MMAN_An_nosplit);
}
+/* See mdoc_term.c, synopsis_pre() for comments. */
+static void
+pre_syn(const struct mdoc_node *n)
+{
+
+ if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
+ return;
+
+ if (n->prev->tok == n->tok &&
+ MDOC_Ft != n->tok &&
+ MDOC_Fo != n->tok &&
+ MDOC_Fn != n->tok) {
+ outflags |= MMAN_br;
+ return;
+ }
+
+ switch (n->prev->tok) {
+ case (MDOC_Fd):
+ /* FALLTHROUGH */
+ case (MDOC_Fn):
+ /* FALLTHROUGH */
+ case (MDOC_Fo):
+ /* FALLTHROUGH */
+ case (MDOC_In):
+ /* FALLTHROUGH */
+ case (MDOC_Vt):
+ outflags |= MMAN_sp;
+ break;
+ case (MDOC_Ft):
+ if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
+ outflags |= MMAN_sp;
+ break;
+ }
+ /* FALLTHROUGH */
+ default:
+ outflags |= MMAN_br;
+ break;
+ }
+}
+
static int
pre_an(DECL_ARGS)
{
@@ -654,12 +696,12 @@ static int
pre_fn(DECL_ARGS)
{
+ pre_syn(n);
+
n = n->child;
if (NULL == n)
return(0);
- if (MDOC_SYNPRETTY & n->flags)
- outflags |= MMAN_br;
print_word("\\fB");
outflags &= ~MMAN_spc;
print_node(m, n);
@@ -685,9 +727,10 @@ pre_fo(DECL_ARGS)
{
switch (n->type) {
+ case (MDOC_BLOCK):
+ pre_syn(n);
+ break;
case (MDOC_HEAD):
- if (MDOC_SYNPRETTY & n->flags)
- outflags |= MMAN_br;
print_word("\\fB");
outflags &= ~MMAN_spc;
break;
@@ -720,11 +763,21 @@ post_fo(DECL_ARGS)
}
static int
+pre_ft(DECL_ARGS)
+{
+
+ pre_syn(n);
+ print_word("\\fI");
+ outflags &= ~MMAN_spc;
+ return(1);
+}
+
+static int
pre_in(DECL_ARGS)
{
if (MDOC_SYNPRETTY & n->flags) {
- outflags |= MMAN_br;
+ pre_syn(n);
print_word("\\fB#include <");
} else
print_word("<\\fI");
@@ -781,10 +834,12 @@ static int
pre_nm(DECL_ARGS)
{
+ if (MDOC_BLOCK == n->type)
+ pre_syn(n);
if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)
return(1);
- if (MDOC_SYNPRETTY & n->flags)
- outflags |= MMAN_br;
+ if (NULL == n->child && NULL == m->name)
+ return(0);
print_word("\\fB");
outflags &= ~MMAN_spc;
if (NULL == n->child)
@@ -865,13 +920,13 @@ pre_vt(DECL_ARGS)
if (MDOC_SYNPRETTY & n->flags) {
switch (n->type) {
case (MDOC_BLOCK):
+ pre_syn(n);
return(1);
case (MDOC_BODY):
break;
default:
return(0);
}
- outflags |= MMAN_br;
}
print_word("\\fI");
outflags &= ~MMAN_spc;
@@ -887,8 +942,6 @@ post_vt(DECL_ARGS)
outflags &= ~MMAN_spc;
print_word("\\fP");
- if (MDOC_SYNPRETTY & n->flags)
- outflags |= MMAN_br;
}
static int
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2012-07-08 18:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201207081839.q68IdmTv016937@krisdoz.my.domain \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).