From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Fixed -Tascii and -Thtml rendering of `Ft' and `Fo'.
Date: Sun, 6 Jun 2010 06:50:59 -0400 (EDT) [thread overview]
Message-ID: <201006061050.o56AoxGG021373@krisdoz.my.domain> (raw)
Log Message:
-----------
Fixed -Tascii and -Thtml rendering of `Ft' and `Fo'.
Modified Files:
--------------
mdocml:
mdoc_html.c
mdoc_term.c
Added Files:
-----------
mdocml/regress/mdoc/Fo:
fo0.in
mdocml/regress/mdoc/Ft:
before-fo.in
before-fn.in
ft0.in
Revision Data
-------------
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.76 -r1.77
--- mdoc_html.c
+++ 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);
}
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.140
retrieving revision 1.141
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.140 -r1.141
--- mdoc_term.c
+++ 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[MDO
{ 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, ";");
+ }
+ }
}
--- /dev/null
+++ regress/mdoc/Fo/fo0.in
@@ -0,0 +1,32 @@
+.Dd $Mdocdate: June 6 2010 $
+.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
--- /dev/null
+++ regress/mdoc/Ft/ft0.in
@@ -0,0 +1,25 @@
+.Dd $Mdocdate: June 6 2010 $
+.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
--- /dev/null
+++ regress/mdoc/Ft/before-fn.in
@@ -0,0 +1,21 @@
+.Dd $Mdocdate: June 6 2010 $
+.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"
--- /dev/null
+++ regress/mdoc/Ft/before-fo.in
@@ -0,0 +1,21 @@
+.Dd $Mdocdate: June 6 2010 $
+.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
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2010-06-06 10:50 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=201006061050.o56AoxGG021373@krisdoz.my.domain \
--to=kristaps@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).