summaryrefslogtreecommitdiffstats
path: root/mdoc_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
commite5dd3a864124758be3ede5144cdd2340239b30ee (patch)
treeef299b09ae12118fcb0f9c4fbb090a273b445b3c /mdoc_html.c
parent0576ea2495c06ed8b674a501710158e099efcf3f (diff)
downloadmandoc-e5dd3a864124758be3ede5144cdd2340239b30ee.tar.gz
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 'mdoc_html.c')
-rw-r--r--mdoc_html.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 966e2c44..b51adc45 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -262,17 +262,9 @@ static const char * const lists[LIST_MAX] = {
void
html_mdoc(void *arg, const struct mdoc *m)
{
- struct html *h;
- struct tag *t;
-
- h = (struct html *)arg;
-
- print_gen_decls(h);
- t = print_otag(h, TAG_HTML, 0, NULL);
- print_mdoc(mdoc_meta(m), mdoc_node(m), h);
- print_tagq(h, t);
- printf("\n");
+ print_mdoc(mdoc_meta(m), mdoc_node(m), (struct html *)arg);
+ putchar('\n');
}
@@ -360,13 +352,22 @@ a2offs(const char *p, struct roffsu *su)
static void
print_mdoc(MDOC_ARGS)
{
- struct tag *t;
+ struct tag *t, *tt;
+ struct htmlpair tag;
- t = print_otag(h, TAG_HEAD, 0, NULL);
- print_mdoc_head(m, n, 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_mdoc_head(m, n, 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_mdoc_nodelist(m, n, h);
print_tagq(h, t);
}