aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-10-05 21:35:17 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-10-05 21:35:17 +0000
commitf383f7b17706b2186a0194c0227f7b6c80542b3c (patch)
tree19bdfb3b295d620477835b8071ded71fc4295691 /man_html.c
parent4bc55ae9552362c7707a31de6c34b7d27ff3dbba (diff)
downloadmandoc-f383f7b17706b2186a0194c0227f7b6c80542b3c.tar.gz
mandoc-f383f7b17706b2186a0194c0227f7b6c80542b3c.tar.zst
mandoc-f383f7b17706b2186a0194c0227f7b6c80542b3c.zip
Add the -Ofragment option to -T[]x]html. This accomodates for embedding
manual output in existing HTML or XHTML documents, e.g., when invoking mandoc from an SSI or CGI.
Diffstat (limited to 'man_html.c')
-rw-r--r--man_html.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/man_html.c b/man_html.c
index db6b1f90..e2873402 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.81 2011/08/18 09:16:01 kristaps Exp $ */
+/* $Id: man_html.c,v 1.82 2011/10/05 21:35:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -141,33 +141,32 @@ print_bvspace(struct html *h, const struct man_node *n)
void
html_man(void *arg, const struct man *m)
{
- struct html *h;
- struct tag *t;
struct mhtml mh;
- h = (struct html *)arg;
-
- print_gen_decls(h);
-
memset(&mh, 0, sizeof(struct mhtml));
-
- t = print_otag(h, TAG_HTML, 0, NULL);
- print_man(man_meta(m), man_node(m), &mh, h);
- print_tagq(h, t);
-
- printf("\n");
+ print_man(man_meta(m), man_node(m), &mh, (struct html *)arg);
+ putchar('\n');
}
static void
print_man(MAN_ARGS)
{
- struct tag *t;
+ struct tag *t, *tt;
+ struct htmlpair tag;
- t = print_otag(h, TAG_HEAD, 0, NULL);
- print_man_head(m, n, mh, h);
- print_tagq(h, t);
+ PAIR_CLASS_INIT(&tag, "mandoc");
+
+ if ( ! (HTML_FRAGMENT & h->oflags)) {
+ print_gen_decls(h);
+ t = print_otag(h, TAG_HTML, 0, NULL);
+ tt = print_otag(h, TAG_HEAD, 0, NULL);
+ print_man_head(m, n, mh, h);
+ print_tagq(h, tt);
+ print_otag(h, TAG_BODY, 0, NULL);
+ print_otag(h, TAG_DIV, 1, &tag);
+ } else
+ t = print_otag(h, TAG_DIV, 1, &tag);
- t = print_otag(h, TAG_BODY, 0, NULL);
print_man_nodelist(m, n, mh, h);
print_tagq(h, t);
}