version 1.9, 2009/09/24 15:05:56 |
version 1.14, 2009/09/26 18:02:51 |
Line 60 static int mdoc_tbl_block_pre(MDOC_ARGS, int, int, |
|
Line 60 static int mdoc_tbl_block_pre(MDOC_ARGS, int, int, |
|
static int mdoc_tbl_body_pre(MDOC_ARGS, int, int); |
static int mdoc_tbl_body_pre(MDOC_ARGS, int, int); |
static int mdoc_tbl_head_pre(MDOC_ARGS, int, int); |
static int mdoc_tbl_head_pre(MDOC_ARGS, int, int); |
|
|
|
static void mdoc__x_post(MDOC_ARGS); |
|
static int mdoc__x_pre(MDOC_ARGS); |
static int mdoc_ad_pre(MDOC_ARGS); |
static int mdoc_ad_pre(MDOC_ARGS); |
static int mdoc_an_pre(MDOC_ARGS); |
static int mdoc_an_pre(MDOC_ARGS); |
static int mdoc_ap_pre(MDOC_ARGS); |
static int mdoc_ap_pre(MDOC_ARGS); |
Line 172 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 174 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{mdoc_va_pre, NULL}, /* Va */ |
{mdoc_va_pre, NULL}, /* Va */ |
{mdoc_vt_pre, NULL}, /* Vt */ |
{mdoc_vt_pre, NULL}, /* Vt */ |
{mdoc_xr_pre, NULL}, /* Xr */ |
{mdoc_xr_pre, NULL}, /* Xr */ |
{NULL, NULL}, /* %A */ |
{mdoc__x_pre, mdoc__x_post}, /* %A */ |
{NULL, NULL}, /* %B */ |
{mdoc__x_pre, mdoc__x_post}, /* %B */ |
{NULL, NULL}, /* %D */ |
{mdoc__x_pre, mdoc__x_post}, /* %D */ |
{NULL, NULL}, /* %I */ |
{mdoc__x_pre, mdoc__x_post}, /* %I */ |
{NULL, NULL}, /* %J */ |
{mdoc__x_pre, mdoc__x_post}, /* %J */ |
{NULL, NULL}, /* %N */ |
{mdoc__x_pre, mdoc__x_post}, /* %N */ |
{NULL, NULL}, /* %O */ |
{mdoc__x_pre, mdoc__x_post}, /* %O */ |
{NULL, NULL}, /* %P */ |
{mdoc__x_pre, mdoc__x_post}, /* %P */ |
{NULL, NULL}, /* %R */ |
{mdoc__x_pre, mdoc__x_post}, /* %R */ |
{NULL, NULL}, /* %T */ |
{mdoc__x_pre, mdoc__x_post}, /* %T */ |
{NULL, NULL}, /* %V */ |
{mdoc__x_pre, mdoc__x_post}, /* %V */ |
{NULL, NULL}, /* Ac */ |
{NULL, NULL}, /* Ac */ |
{mdoc_aq_pre, mdoc_aq_post}, /* Ao */ |
{mdoc_aq_pre, mdoc_aq_post}, /* Ao */ |
{mdoc_aq_pre, mdoc_aq_post}, /* Aq */ |
{mdoc_aq_pre, mdoc_aq_post}, /* Aq */ |
Line 244 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 246 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{mdoc_brq_pre, mdoc_brq_post}, /* Brq */ |
{mdoc_brq_pre, mdoc_brq_post}, /* Brq */ |
{mdoc_brq_pre, mdoc_brq_post}, /* Bro */ |
{mdoc_brq_pre, mdoc_brq_post}, /* Bro */ |
{NULL, NULL}, /* Brc */ |
{NULL, NULL}, /* Brc */ |
{NULL, NULL}, /* %C */ |
{mdoc__x_pre, mdoc__x_post}, /* %C */ |
{NULL, NULL}, /* Es */ /* TODO */ |
{NULL, NULL}, /* Es */ /* TODO */ |
{NULL, NULL}, /* En */ /* TODO */ |
{NULL, NULL}, /* En */ /* TODO */ |
{mdoc_xx_pre, NULL}, /* Dx */ |
{mdoc_xx_pre, NULL}, /* Dx */ |
{NULL, NULL}, /* %Q */ |
{mdoc__x_pre, mdoc__x_post}, /* %Q */ |
{mdoc_sp_pre, NULL}, /* br */ |
{mdoc_sp_pre, NULL}, /* br */ |
{mdoc_sp_pre, NULL}, /* sp */ |
{mdoc_sp_pre, NULL}, /* sp */ |
}; |
}; |
Line 523 mdoc_root_pre(MDOC_ARGS) |
|
Line 525 mdoc_root_pre(MDOC_ARGS) |
|
tt = print_otag(h, TAG_TR, 0, NULL); |
tt = print_otag(h, TAG_TR, 0, NULL); |
|
|
tag[0].key = ATTR_STYLE; |
tag[0].key = ATTR_STYLE; |
tag[0].val = "width: 33%;"; |
tag[0].val = "width: 10%;"; |
print_otag(h, TAG_TD, 1, tag); |
print_otag(h, TAG_TD, 1, tag); |
print_text(h, title); |
print_text(h, title); |
print_stagq(h, tt); |
print_stagq(h, tt); |
|
|
tag[0].key = ATTR_STYLE; |
tag[0].key = ATTR_STYLE; |
tag[0].val = "width: 33%; text-align: center;"; |
tag[0].val = "width: 80%; white-space: nowrap; text-align: center;"; |
print_otag(h, TAG_TD, 1, tag); |
print_otag(h, TAG_TD, 1, tag); |
print_text(h, b); |
print_text(h, b); |
print_stagq(h, tt); |
print_stagq(h, tt); |
|
|
tag[0].key = ATTR_STYLE; |
tag[0].key = ATTR_STYLE; |
tag[0].val = "width: 33%; text-align: right;"; |
tag[0].val = "width: 10%; text-align: right;"; |
print_otag(h, TAG_TD, 1, tag); |
print_otag(h, TAG_TD, 1, tag); |
print_text(h, title); |
print_text(h, title); |
print_tagq(h, t); |
print_tagq(h, t); |
Line 871 mdoc_bx_pre(MDOC_ARGS) |
|
Line 873 mdoc_bx_pre(MDOC_ARGS) |
|
static int |
static int |
mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int c) |
mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int c) |
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
const struct mdoc_node *nn; |
|
|
switch (t) { |
switch (t) { |
case (MDOC_Column): |
case (MDOC_Column): |
Line 887 mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int |
|
Line 890 mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int |
|
} |
} |
|
|
if ( ! c && MDOC_Column != t) { |
if ( ! c && MDOC_Column != t) { |
if (n->prev && n->prev->body->child) |
for (nn = n; nn; nn = nn->parent) { |
bufcat("padding-top: 1em;"); |
if (MDOC_BLOCK != nn->type) |
else if (NULL == n->prev) |
continue; |
bufcat("padding-top: 1em;"); |
switch (nn->tok) { |
|
case (MDOC_Ss): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Sh): |
|
c = 1; |
|
break; |
|
default: |
|
break; |
|
} |
|
if (nn->prev) |
|
break; |
|
} |
|
if (MDOC_Diag == t && n->prev) |
|
if (NULL == n->prev->body->child) |
|
c = 1; |
|
if ( ! c) |
|
bufcat("padding-top: 1em;"); |
} |
} |
|
|
tag.key = ATTR_STYLE; |
tag.key = ATTR_STYLE; |
Line 986 mdoc_tbl_pre(MDOC_ARGS, int type) |
|
Line 1005 mdoc_tbl_pre(MDOC_ARGS, int type) |
|
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
bl = bl->parent; |
bl = bl->parent; |
|
|
/* FIXME: fmt_vspace() equivalent. */ |
|
|
|
assert(bl->args); |
assert(bl->args); |
|
|
w = o = c = 0; |
w = o = c = 0; |
Line 1063 mdoc_bl_pre(MDOC_ARGS) |
|
Line 1080 mdoc_bl_pre(MDOC_ARGS) |
|
if (MDOC_Enum != a2list(n)) |
if (MDOC_Enum != a2list(n)) |
return(1); |
return(1); |
|
|
|
/* Allocate an -enum on the stack of indices. */ |
|
|
ord = malloc(sizeof(struct ord)); |
ord = malloc(sizeof(struct ord)); |
if (NULL == ord) |
if (NULL == ord) |
err(EXIT_FAILURE, "malloc"); |
err(EXIT_FAILURE, "malloc"); |
Line 1308 mdoc_bd_pre(MDOC_ARGS) |
|
Line 1327 mdoc_bd_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag[2]; |
struct htmlpair tag[2]; |
int t, c, o, i; |
int t, c, o, i; |
const struct mdoc_node *bl; |
const struct mdoc_node *bl, *nn; |
|
|
/* FIXME: fmt_vspace() shit. */ |
|
|
|
if (MDOC_BLOCK == n->type) |
if (MDOC_BLOCK == n->type) |
bl = n; |
bl = n; |
else if (MDOC_HEAD == n->type) |
else if (MDOC_HEAD == n->type) |
Line 1325 mdoc_bd_pre(MDOC_ARGS) |
|
Line 1342 mdoc_bd_pre(MDOC_ARGS) |
|
switch (bl->args->argv[i].arg) { |
switch (bl->args->argv[i].arg) { |
case (MDOC_Offset): |
case (MDOC_Offset): |
assert(bl->args->argv[i].sz); |
assert(bl->args->argv[i].sz); |
o = a2offs (bl->args->argv[i].value[0]); |
o = a2offs(bl->args->argv[i].value[0]); |
break; |
break; |
case (MDOC_Compact): |
case (MDOC_Compact): |
c = 1; |
c = 1; |
Line 1344 mdoc_bd_pre(MDOC_ARGS) |
|
Line 1361 mdoc_bd_pre(MDOC_ARGS) |
|
if (MDOC_BLOCK == n->type) { |
if (MDOC_BLOCK == n->type) { |
if (o) |
if (o) |
buffmt("margin-left: %dem;", o); |
buffmt("margin-left: %dem;", o); |
bufcat("margin-top: 1em;"); |
if ( ! c) { |
|
for (nn = n; nn; nn = nn->parent) { |
|
if (MDOC_BLOCK != nn->type) |
|
continue; |
|
switch (nn->tok) { |
|
case (MDOC_Ss): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Sh): |
|
c = 1; |
|
break; |
|
default: |
|
break; |
|
} |
|
if (nn->prev) |
|
break; |
|
} |
|
if ( ! c) |
|
bufcat("margin-top: 1em;"); |
|
} |
tag[0].key = ATTR_STYLE; |
tag[0].key = ATTR_STYLE; |
tag[0].val = buf; |
tag[0].val = buf; |
print_otag(h, TAG_DIV, 1, tag); |
print_otag(h, TAG_DIV, 1, tag); |
return(1); |
return(1); |
} |
} |
|
|
switch (t) { |
if (MDOC_Unfilled != t && MDOC_Literal != t) |
case (MDOC_Unfilled): |
|
case (MDOC_Literal): |
|
break; |
|
default: |
|
return(1); |
return(1); |
} |
|
|
|
bufcat("white-space: pre;"); |
bufcat("white-space: pre;"); |
tag[0].key = ATTR_STYLE; |
tag[0].key = ATTR_STYLE; |
Line 1367 mdoc_bd_pre(MDOC_ARGS) |
|
Line 1397 mdoc_bd_pre(MDOC_ARGS) |
|
|
|
print_otag(h, TAG_DIV, 2, tag); |
print_otag(h, TAG_DIV, 2, tag); |
|
|
for (n = n->child; n; n = n->next) { |
for (nn = n->child; nn; nn = nn->next) { |
h->flags |= HTML_NOSPACE; |
print_mdoc_node(m, nn, h); |
print_mdoc_node(m, n, h); |
if (NULL == nn->next) |
if (n->next) |
continue; |
|
if (nn->prev && nn->prev->line < nn->line) |
print_text(h, "\n"); |
print_text(h, "\n"); |
} |
} |
|
|
Line 1595 mdoc_fn_pre(MDOC_ARGS) |
|
Line 1626 mdoc_fn_pre(MDOC_ARGS) |
|
|
|
assert(n->child->string); |
assert(n->child->string); |
sp = n->child->string; |
sp = n->child->string; |
while ((ep = strchr(sp, ' '))) { |
while (NULL != (ep = strchr(sp, ' '))) { |
sz = MIN((int)(ep - sp), BUFSIZ - 1); |
sz = MIN((int)(ep - sp), BUFSIZ - 1); |
(void)memcpy(nbuf, sp, (size_t)sz); |
(void)memcpy(nbuf, sp, (size_t)sz); |
nbuf[sz] = '\0'; |
nbuf[sz] = '\0'; |
Line 2096 mdoc_lb_pre(MDOC_ARGS) |
|
Line 2127 mdoc_lb_pre(MDOC_ARGS) |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc__x_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
tag.key = ATTR_CLASS; |
|
|
|
switch (n->tok) { |
|
case(MDOC__A): |
|
tag.val = "ref-auth"; |
|
break; |
|
case(MDOC__B): |
|
tag.val = "ref-book"; |
|
break; |
|
case(MDOC__C): |
|
tag.val = "ref-city"; |
|
break; |
|
case(MDOC__D): |
|
tag.val = "ref-date"; |
|
break; |
|
case(MDOC__I): |
|
tag.val = "ref-issue"; |
|
break; |
|
case(MDOC__J): |
|
tag.val = "ref-jrnl"; |
|
break; |
|
case(MDOC__N): |
|
tag.val = "ref-num"; |
|
break; |
|
case(MDOC__O): |
|
tag.val = "ref-opt"; |
|
break; |
|
case(MDOC__P): |
|
tag.val = "ref-page"; |
|
break; |
|
case(MDOC__Q): |
|
tag.val = "ref-corp"; |
|
break; |
|
case(MDOC__R): |
|
tag.val = "ref-rep"; |
|
break; |
|
case(MDOC__T): |
|
print_text(h, "\\(lq"); |
|
h->flags |= HTML_NOSPACE; |
|
tag.val = "ref-title"; |
|
break; |
|
case(MDOC__V): |
|
tag.val = "ref-vol"; |
|
break; |
|
default: |
|
abort(); |
|
/* NOTREACHED */ |
|
} |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
mdoc__x_post(MDOC_ARGS) |
|
{ |
|
|
|
h->flags |= HTML_NOSPACE; |
|
switch (n->tok) { |
|
case (MDOC__T): |
|
print_text(h, "\\(rq"); |
|
h->flags |= HTML_NOSPACE; |
|
break; |
|
default: |
|
break; |
|
} |
|
print_text(h, n->next ? "," : "."); |
} |
} |