diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-07-02 10:42:46 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-07-02 10:42:46 +0000 |
commit | 52a3716203cb7389a3626ca93f6ef093a25e02af (patch) | |
tree | c612959b893ad786543089e3ac1b49ec930aed83 /mdoc_html.c | |
parent | d1662ea3b33fccef5c46617b2aac33de6c3f7367 (diff) | |
download | mandoc-52a3716203cb7389a3626ca93f6ef093a25e02af.tar.gz |
Implemented -Thtml bits for handling `Nm' blocks.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r-- | mdoc_html.c | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/mdoc_html.c b/mdoc_html.c index 3ce6bf90..067d1a46 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -736,17 +736,70 @@ mdoc_op_post(MDOC_ARGS) static int mdoc_nm_pre(MDOC_ARGS) { - struct htmlpair tag; + struct htmlpair tag; + struct roffsu su; + const char *cp; - if (NULL == n->child && NULL == m->name) - return(1); + /* + * Accomodate for `Nm' being both an element (which may have + * NULL children AND no m->name) and a block. + */ - synopsis_pre(h, n); + cp = NULL; + + if (MDOC_ELEM == n->type) { + if (NULL == n->child && NULL == m->name) + return(1); + synopsis_pre(h, n); + PAIR_CLASS_INIT(&tag, "name"); + print_otag(h, TAG_SPAN, 1, &tag); + if (NULL == n->child) + print_text(h, m->name); + } else if (MDOC_BLOCK == n->type) { + synopsis_pre(h, n); + + bufcat_style(h, "clear", "both"); + if (n->head->child || m->name) { + if (n->head->child && MDOC_TEXT == + n->head->child->type) + cp = n->head->child->string; + if (NULL == cp || '\0' == *cp) + cp = m->name; + + SCALE_HS_INIT(&su, (double)strlen(cp)); + bufcat_su(h, "padding-left", &su); + } + + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_DIV, 1, &tag); + } else if (MDOC_HEAD == n->type) { + if (NULL == n->child && NULL == m->name) + return(1); + + if (n->child && MDOC_TEXT == n->child->type) + cp = n->child->string; + if (NULL == cp || '\0' == *cp) + cp = m->name; + + SCALE_HS_INIT(&su, (double)strlen(cp)); + + bufcat_style(h, "float", "left"); + bufcat_su(h, "min-width", &su); + SCALE_INVERT(&su); + bufcat_su(h, "margin-left", &su); + + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_DIV, 1, &tag); + + if (NULL == n->child) + print_text(h, m->name); + } else if (MDOC_BODY == n->type) { + SCALE_HS_INIT(&su, 2); + bufcat_su(h, "margin-left", &su); + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_DIV, 1, &tag); + } - PAIR_CLASS_INIT(&tag, "name"); - print_otag(h, TAG_SPAN, 1, &tag); - if (NULL == n->child) - print_text(h, m->name); return(1); } |