version 1.115, 2010/12/15 14:52:16 |
version 1.122, 2010/12/16 22:57:20 |
Line 103 static int mdoc_nm_pre(MDOC_ARGS); |
|
Line 103 static int mdoc_nm_pre(MDOC_ARGS); |
|
static int mdoc_ns_pre(MDOC_ARGS); |
static int mdoc_ns_pre(MDOC_ARGS); |
static int mdoc_pa_pre(MDOC_ARGS); |
static int mdoc_pa_pre(MDOC_ARGS); |
static void mdoc_pf_post(MDOC_ARGS); |
static void mdoc_pf_post(MDOC_ARGS); |
|
static int mdoc_pp_pre(MDOC_ARGS); |
static void mdoc_quote_post(MDOC_ARGS); |
static void mdoc_quote_post(MDOC_ARGS); |
static int mdoc_quote_pre(MDOC_ARGS); |
static int mdoc_quote_pre(MDOC_ARGS); |
static int mdoc_rs_pre(MDOC_ARGS); |
static int mdoc_rs_pre(MDOC_ARGS); |
Line 126 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 127 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{NULL, NULL}, /* Os */ |
{NULL, NULL}, /* Os */ |
{mdoc_sh_pre, NULL }, /* Sh */ |
{mdoc_sh_pre, NULL }, /* Sh */ |
{mdoc_ss_pre, NULL }, /* Ss */ |
{mdoc_ss_pre, NULL }, /* Ss */ |
{mdoc_sp_pre, NULL}, /* Pp */ |
{mdoc_pp_pre, NULL}, /* Pp */ |
{mdoc_d1_pre, NULL}, /* D1 */ |
{mdoc_d1_pre, NULL}, /* D1 */ |
{mdoc_d1_pre, NULL}, /* Dl */ |
{mdoc_d1_pre, NULL}, /* Dl */ |
{mdoc_bd_pre, NULL}, /* Bd */ |
{mdoc_bd_pre, NULL}, /* Bd */ |
Line 227 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 228 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{NULL, NULL}, /* Fr */ |
{NULL, NULL}, /* Fr */ |
{mdoc_ud_pre, NULL}, /* Ud */ |
{mdoc_ud_pre, NULL}, /* Ud */ |
{mdoc_lb_pre, NULL}, /* Lb */ |
{mdoc_lb_pre, NULL}, /* Lb */ |
{mdoc_sp_pre, NULL}, /* Lp */ |
{mdoc_pp_pre, NULL}, /* Lp */ |
{mdoc_lk_pre, NULL}, /* Lk */ |
{mdoc_lk_pre, NULL}, /* Lk */ |
{mdoc_mt_pre, NULL}, /* Mt */ |
{mdoc_mt_pre, NULL}, /* Mt */ |
{mdoc_quote_pre, mdoc_quote_post}, /* Brq */ |
{mdoc_quote_pre, mdoc_quote_post}, /* Brq */ |
Line 246 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 247 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
|
|
static const char * const lists[LIST_MAX] = { |
static const char * const lists[LIST_MAX] = { |
NULL, |
NULL, |
"list-bullet", |
"list-bul", |
"list-column", |
"list-col", |
"list-dash", |
"list-dash", |
"list-diag", |
"list-diag", |
"list-enum", |
"list-enum", |
"list-hang", |
"list-hang", |
"list-hyphen", |
"list-hyph", |
"list-inset", |
"list-inset", |
"list-item", |
"list-item", |
"list-ohang", |
"list-ohang", |
|
|
print_mdoc(MDOC_ARGS) |
print_mdoc(MDOC_ARGS) |
{ |
{ |
struct tag *t; |
struct tag *t; |
struct htmlpair tag; |
|
|
|
t = print_otag(h, TAG_HEAD, 0, NULL); |
t = print_otag(h, TAG_HEAD, 0, NULL); |
print_mdoc_head(m, n, h); |
print_mdoc_head(m, n, h); |
print_tagq(h, t); |
print_tagq(h, t); |
|
|
t = print_otag(h, TAG_BODY, 0, NULL); |
t = print_otag(h, TAG_BODY, 0, NULL); |
|
|
tag.key = ATTR_CLASS; |
|
tag.val = "body"; |
|
print_otag(h, TAG_DIV, 1, &tag); |
|
|
|
print_mdoc_nodelist(m, n, h); |
print_mdoc_nodelist(m, n, h); |
print_tagq(h, t); |
print_tagq(h, t); |
} |
} |
Line 479 mdoc_root_post(MDOC_ARGS) |
|
Line 474 mdoc_root_post(MDOC_ARGS) |
|
|
|
time2a(m->date, b, DATESIZ); |
time2a(m->date, b, DATESIZ); |
|
|
/* |
|
* XXX: this should use divs, but in Firefox, divs with nested |
|
* divs for some reason puke when trying to put a border line |
|
* below. So I use tables, instead. |
|
*/ |
|
|
|
PAIR_CLASS_INIT(&tag[0], "footer"); |
PAIR_CLASS_INIT(&tag[0], "footer"); |
bufcat_style(h, "width", "100%"); |
bufcat_style(h, "width", "100%"); |
PAIR_STYLE_INIT(&tag[1], h); |
PAIR_STYLE_INIT(&tag[1], h); |
Line 518 mdoc_root_pre(MDOC_ARGS) |
|
Line 507 mdoc_root_pre(MDOC_ARGS) |
|
struct tag *t, *tt; |
struct tag *t, *tt; |
char b[BUFSIZ], title[BUFSIZ]; |
char b[BUFSIZ], title[BUFSIZ]; |
|
|
(void)strlcpy(b, m->vol, BUFSIZ); |
strlcpy(b, m->vol, BUFSIZ); |
|
|
if (m->arch) { |
if (m->arch) { |
(void)strlcat(b, " (", BUFSIZ); |
strlcat(b, " (", BUFSIZ); |
(void)strlcat(b, m->arch, BUFSIZ); |
strlcat(b, m->arch, BUFSIZ); |
(void)strlcat(b, ")", BUFSIZ); |
strlcat(b, ")", BUFSIZ); |
} |
} |
|
|
(void)snprintf(title, BUFSIZ - 1, |
snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec); |
"%s(%s)", m->title, m->msec); |
|
|
|
/* XXX: see note in mdoc_root_post() about divs. */ |
|
|
|
PAIR_CLASS_INIT(&tag[0], "header"); |
PAIR_CLASS_INIT(&tag[0], "header"); |
bufcat_style(h, "width", "100%"); |
bufcat_style(h, "width", "100%"); |
PAIR_STYLE_INIT(&tag[1], h); |
PAIR_STYLE_INIT(&tag[1], h); |
Line 903 mdoc_it_pre(MDOC_ARGS) |
|
Line 889 mdoc_it_pre(MDOC_ARGS) |
|
{ |
{ |
struct roffsu su; |
struct roffsu su; |
enum mdoc_list type; |
enum mdoc_list type; |
struct htmlpair tag; |
struct htmlpair tag[2]; |
const struct mdoc_node *bl; |
const struct mdoc_node *bl; |
|
|
bl = n->parent; |
bl = n->parent; |
Line 914 mdoc_it_pre(MDOC_ARGS) |
|
Line 900 mdoc_it_pre(MDOC_ARGS) |
|
|
|
type = bl->data.Bl->type; |
type = bl->data.Bl->type; |
|
|
/* Whether we're top-padded (not "compact"). */ |
assert(lists[type]); |
|
PAIR_CLASS_INIT(&tag[0], lists[type]); |
|
|
SCALE_VS_INIT(&su, ! bl->data.Bl->comp); |
|
bufcat_su(h, "margin-top", &su); |
|
PAIR_STYLE_INIT(&tag, h); |
|
|
|
if (MDOC_HEAD == n->type) { |
if (MDOC_HEAD == n->type) { |
switch (type) { |
switch (type) { |
case(LIST_bullet): |
case(LIST_bullet): |
Line 941 mdoc_it_pre(MDOC_ARGS) |
|
Line 924 mdoc_it_pre(MDOC_ARGS) |
|
case(LIST_ohang): |
case(LIST_ohang): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case(LIST_tag): |
case(LIST_tag): |
print_otag(h, TAG_DT, 1, &tag); |
SCALE_VS_INIT(&su, ! bl->data.Bl->comp); |
|
bufcat_su(h, "margin-top", &su); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
print_otag(h, TAG_DT, 2, tag); |
break; |
break; |
case(LIST_column): |
case(LIST_column): |
break; |
break; |
Line 959 mdoc_it_pre(MDOC_ARGS) |
|
Line 945 mdoc_it_pre(MDOC_ARGS) |
|
case(LIST_enum): |
case(LIST_enum): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case(LIST_item): |
case(LIST_item): |
/* FALLTHROUGH */ |
SCALE_VS_INIT(&su, ! bl->data.Bl->comp); |
print_otag(h, TAG_LI, 1, &tag); |
bufcat_su(h, "margin-top", &su); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
print_otag(h, TAG_LI, 2, tag); |
break; |
break; |
case(LIST_diag): |
case(LIST_diag): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
Line 971 mdoc_it_pre(MDOC_ARGS) |
|
Line 959 mdoc_it_pre(MDOC_ARGS) |
|
case(LIST_ohang): |
case(LIST_ohang): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case(LIST_tag): |
case(LIST_tag): |
print_otag(h, TAG_DD, 0, NULL); |
if (NULL == bl->data.Bl->width) { |
|
print_otag(h, TAG_DD, 1, tag); |
|
break; |
|
} |
|
a2width(bl->data.Bl->width, &su); |
|
bufcat_su(h, "margin-left", &su); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
print_otag(h, TAG_DD, 2, tag); |
break; |
break; |
case(LIST_column): |
case(LIST_column): |
print_otag(h, TAG_TD, 1, &tag); |
SCALE_VS_INIT(&su, ! bl->data.Bl->comp); |
|
bufcat_su(h, "margin-top", &su); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
print_otag(h, TAG_TD, 2, tag); |
break; |
break; |
default: |
default: |
break; |
break; |
Line 982 mdoc_it_pre(MDOC_ARGS) |
|
Line 980 mdoc_it_pre(MDOC_ARGS) |
|
} else { |
} else { |
switch (type) { |
switch (type) { |
case (LIST_column): |
case (LIST_column): |
print_otag(h, TAG_TR, 0, NULL); |
print_otag(h, TAG_TR, 1, tag); |
break; |
break; |
default: |
default: |
break; |
break; |
|
|
mdoc_bl_pre(MDOC_ARGS) |
mdoc_bl_pre(MDOC_ARGS) |
{ |
{ |
size_t i; |
size_t i; |
struct htmlpair tag[2]; |
struct htmlpair tag[3]; |
struct roffsu su; |
struct roffsu su; |
|
|
if (MDOC_BODY == n->type) { |
if (MDOC_BODY == n->type) { |
Line 1031 mdoc_bl_pre(MDOC_ARGS) |
|
Line 1029 mdoc_bl_pre(MDOC_ARGS) |
|
return(0); |
return(0); |
} |
} |
|
|
|
SCALE_VS_INIT(&su, 0); |
|
bufcat_su(h, "margin-top", &su); |
|
bufcat_su(h, "margin-bottom", &su); |
|
PAIR_STYLE_INIT(&tag[0], h); |
|
|
assert(lists[n->data.Bl->type]); |
assert(lists[n->data.Bl->type]); |
PAIR_CLASS_INIT(&tag[0], lists[n->data.Bl->type]); |
PAIR_CLASS_INIT(&tag[1], lists[n->data.Bl->type]); |
i = 1; |
i = 2; |
|
|
/* Set the block's left-hand margin. */ |
/* Set the block's left-hand margin. */ |
|
|
if (n->data.Bl->offs) { |
if (n->data.Bl->offs) { |
a2offs(n->data.Bl->offs, &su); |
a2offs(n->data.Bl->offs, &su); |
bufcat_su(h, "margin-left", &su); |
bufcat_su(h, "margin-left", &su); |
PAIR_STYLE_INIT(&tag[1], h); |
PAIR_STYLE_INIT(&tag[2], h); |
i = 2; |
i = 3; |
|
|
} |
} |
|
|
switch (n->data.Bl->type) { |
switch (n->data.Bl->type) { |
Line 1138 mdoc_d1_pre(MDOC_ARGS) |
|
Line 1140 mdoc_d1_pre(MDOC_ARGS) |
|
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
return(1); |
return(1); |
|
|
/* FIXME: D1 shouldn't be literal. */ |
SCALE_VS_INIT(&su, 0); |
|
bufcat_su(h, "margin-top", &su); |
|
bufcat_su(h, "margin-bottom", &su); |
|
PAIR_STYLE_INIT(&tag[0], h); |
|
print_otag(h, TAG_BLOCKQUOTE, 1, tag); |
|
|
SCALE_VS_INIT(&su, INDENT - 2); |
/* BLOCKQUOTE needs a block body. */ |
bufcat_su(h, "margin-left", &su); |
|
PAIR_CLASS_INIT(&tag[0], "lit"); |
if (MDOC_Dl == n->tok) { |
PAIR_STYLE_INIT(&tag[1], h); |
PAIR_CLASS_INIT(&tag[1], "lit"); |
print_otag(h, TAG_DIV, 2, tag); |
print_otag(h, TAG_DIV, 1, tag); |
|
} else |
|
print_otag(h, TAG_DIV, 0, tag); |
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 1539 mdoc_sm_pre(MDOC_ARGS) |
|
Line 1548 mdoc_sm_pre(MDOC_ARGS) |
|
return(0); |
return(0); |
} |
} |
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_pp_pre(MDOC_ARGS) |
|
{ |
|
|
|
print_otag(h, TAG_P, 0, NULL); |
|
return(0); |
|
|
|
} |
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_sp_pre(MDOC_ARGS) |
mdoc_sp_pre(MDOC_ARGS) |
{ |
{ |
int len; |
|
struct htmlpair tag; |
|
struct roffsu su; |
struct roffsu su; |
|
struct htmlpair tag; |
|
|
switch (n->tok) { |
SCALE_VS_INIT(&su, 1); |
case (MDOC_sp): |
|
/* FIXME: can this have a scaling indicator? */ |
|
len = n->child ? atoi(n->child->string) : 1; |
|
break; |
|
case (MDOC_br): |
|
len = 0; |
|
break; |
|
default: |
|
assert(n->parent); |
|
if ((NULL == n->next || NULL == n->prev) && |
|
(MDOC_Ss == n->parent->tok || |
|
MDOC_Sh == n->parent->tok)) |
|
return(0); |
|
len = 1; |
|
break; |
|
} |
|
|
|
SCALE_VS_INIT(&su, len); |
if (MDOC_sp == n->tok) { |
|
if (n->child) |
|
a2roffsu(n->child->string, &su, SCALE_VS); |
|
} else |
|
su.scale = 0; |
|
|
bufcat_su(h, "height", &su); |
bufcat_su(h, "height", &su); |
PAIR_STYLE_INIT(&tag, h); |
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
|
|
/* So the div isn't empty: */ |
/* So the div isn't empty: */ |
print_text(h, "\\~"); |
print_text(h, "\\~"); |
|
|
Line 1577 mdoc_sp_pre(MDOC_ARGS) |
|
Line 1584 mdoc_sp_pre(MDOC_ARGS) |
|
|
|
} |
} |
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_lk_pre(MDOC_ARGS) |
mdoc_lk_pre(MDOC_ARGS) |
Line 1864 mdoc_rs_pre(MDOC_ARGS) |
|
Line 1870 mdoc_rs_pre(MDOC_ARGS) |
|
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
return(1); |
return(1); |
|
|
if (n->prev && SEC_SEE_ALSO == n->sec) { |
if (n->prev && SEC_SEE_ALSO == n->sec) |
print_otag(h, TAG_BR, 0, NULL); |
print_otag(h, TAG_P, 0, NULL); |
print_otag(h, TAG_BR, 0, NULL); |
|
} |
|
|
|
PAIR_CLASS_INIT(&tag, "ref"); |
PAIR_CLASS_INIT(&tag, "ref"); |
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |