version 1.1, 2009/09/21 14:56:57 |
version 1.30, 2009/10/15 01:33:12 |
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
#include <sys/types.h> |
#include <sys/types.h> |
|
#include <sys/param.h> |
#include <sys/queue.h> |
#include <sys/queue.h> |
|
|
#include <assert.h> |
#include <assert.h> |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
|
#include "out.h" |
#include "html.h" |
#include "html.h" |
#include "mdoc.h" |
#include "mdoc.h" |
|
#include "main.h" |
|
|
#define INDENT 5 |
#define INDENT 5 |
#define HALFINDENT 3 |
#define HALFINDENT 3 |
|
|
#define MDOC_ARGS const struct mdoc_meta *m, \ |
#define MDOC_ARGS const struct mdoc_meta *m, \ |
const struct mdoc_node *n, \ |
const struct mdoc_node *n, \ |
struct html *h |
struct html *h |
#define MAN_ARGS const struct man_meta *m, \ |
|
const struct man_node *n, \ |
|
struct html *h |
|
|
|
struct htmlmdoc { |
struct htmlmdoc { |
int (*pre)(MDOC_ARGS); |
int (*pre)(MDOC_ARGS); |
Line 48 static void print_mdoc_head(MDOC_ARGS); |
|
Line 48 static void print_mdoc_head(MDOC_ARGS); |
|
static void print_mdoc_node(MDOC_ARGS); |
static void print_mdoc_node(MDOC_ARGS); |
static void print_mdoc_nodelist(MDOC_ARGS); |
static void print_mdoc_nodelist(MDOC_ARGS); |
|
|
static int a2width(const char *); |
static void a2width(const char *, struct roffsu *); |
static int a2offs(const char *); |
static void a2offs(const char *, struct roffsu *); |
|
|
static int a2list(const struct mdoc_node *); |
static int a2list(const struct mdoc_node *); |
|
|
static void mdoc_root_post(MDOC_ARGS); |
static void mdoc_root_post(MDOC_ARGS); |
static int mdoc_root_pre(MDOC_ARGS); |
static int mdoc_root_pre(MDOC_ARGS); |
static int mdoc_tbl_pre(MDOC_ARGS, int); |
|
static int mdoc_tbl_block_pre(MDOC_ARGS, int, int, int, int); |
|
static int mdoc_tbl_body_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 void mdoc_aq_post(MDOC_ARGS); |
static void mdoc_aq_post(MDOC_ARGS); |
static int mdoc_aq_pre(MDOC_ARGS); |
static int mdoc_aq_pre(MDOC_ARGS); |
static int mdoc_ar_pre(MDOC_ARGS); |
static int mdoc_ar_pre(MDOC_ARGS); |
static int mdoc_bd_pre(MDOC_ARGS); |
static int mdoc_bd_pre(MDOC_ARGS); |
|
static int mdoc_bf_pre(MDOC_ARGS); |
static void mdoc_bl_post(MDOC_ARGS); |
static void mdoc_bl_post(MDOC_ARGS); |
static int mdoc_bl_pre(MDOC_ARGS); |
static int mdoc_bl_pre(MDOC_ARGS); |
|
static void mdoc_bq_post(MDOC_ARGS); |
|
static int mdoc_bq_pre(MDOC_ARGS); |
|
static void mdoc_brq_post(MDOC_ARGS); |
|
static int mdoc_brq_pre(MDOC_ARGS); |
|
static int mdoc_bt_pre(MDOC_ARGS); |
|
static int mdoc_bx_pre(MDOC_ARGS); |
static int mdoc_cd_pre(MDOC_ARGS); |
static int mdoc_cd_pre(MDOC_ARGS); |
static int mdoc_d1_pre(MDOC_ARGS); |
static int mdoc_d1_pre(MDOC_ARGS); |
static void mdoc_dq_post(MDOC_ARGS); |
static void mdoc_dq_post(MDOC_ARGS); |
Line 81 static int mdoc_em_pre(MDOC_ARGS); |
|
Line 88 static int mdoc_em_pre(MDOC_ARGS); |
|
static int mdoc_er_pre(MDOC_ARGS); |
static int mdoc_er_pre(MDOC_ARGS); |
static int mdoc_ev_pre(MDOC_ARGS); |
static int mdoc_ev_pre(MDOC_ARGS); |
static int mdoc_ex_pre(MDOC_ARGS); |
static int mdoc_ex_pre(MDOC_ARGS); |
|
static void mdoc_fo_post(MDOC_ARGS); |
|
static int mdoc_fo_pre(MDOC_ARGS); |
|
static int mdoc_ic_pre(MDOC_ARGS); |
|
static int mdoc_in_pre(MDOC_ARGS); |
|
static int mdoc_it_block_pre(MDOC_ARGS, int, int, |
|
struct roffsu *, struct roffsu *); |
|
static int mdoc_it_head_pre(MDOC_ARGS, int, |
|
struct roffsu *); |
|
static int mdoc_it_body_pre(MDOC_ARGS, int); |
static int mdoc_it_pre(MDOC_ARGS); |
static int mdoc_it_pre(MDOC_ARGS); |
|
static int mdoc_lb_pre(MDOC_ARGS); |
|
static int mdoc_li_pre(MDOC_ARGS); |
|
static int mdoc_lk_pre(MDOC_ARGS); |
|
static int mdoc_mt_pre(MDOC_ARGS); |
|
static int mdoc_ms_pre(MDOC_ARGS); |
static int mdoc_nd_pre(MDOC_ARGS); |
static int mdoc_nd_pre(MDOC_ARGS); |
static int mdoc_nm_pre(MDOC_ARGS); |
static int mdoc_nm_pre(MDOC_ARGS); |
static int mdoc_ns_pre(MDOC_ARGS); |
static int mdoc_ns_pre(MDOC_ARGS); |
static void mdoc_op_post(MDOC_ARGS); |
static void mdoc_op_post(MDOC_ARGS); |
static int mdoc_op_pre(MDOC_ARGS); |
static int mdoc_op_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 int mdoc_pf_pre(MDOC_ARGS); |
static void mdoc_pq_post(MDOC_ARGS); |
static void mdoc_pq_post(MDOC_ARGS); |
static int mdoc_pq_pre(MDOC_ARGS); |
static int mdoc_pq_pre(MDOC_ARGS); |
static void mdoc_qq_post(MDOC_ARGS); |
static int mdoc_rs_pre(MDOC_ARGS); |
static int mdoc_qq_pre(MDOC_ARGS); |
static int mdoc_rv_pre(MDOC_ARGS); |
static int mdoc_sh_pre(MDOC_ARGS); |
static int mdoc_sh_pre(MDOC_ARGS); |
static int mdoc_sp_pre(MDOC_ARGS); |
static int mdoc_sp_pre(MDOC_ARGS); |
static void mdoc_sq_post(MDOC_ARGS); |
static void mdoc_sq_post(MDOC_ARGS); |
static int mdoc_sq_pre(MDOC_ARGS); |
static int mdoc_sq_pre(MDOC_ARGS); |
static int mdoc_ss_pre(MDOC_ARGS); |
static int mdoc_ss_pre(MDOC_ARGS); |
static int mdoc_sx_pre(MDOC_ARGS); |
static int mdoc_sx_pre(MDOC_ARGS); |
|
static int mdoc_sy_pre(MDOC_ARGS); |
|
static int mdoc_ud_pre(MDOC_ARGS); |
|
static int mdoc_va_pre(MDOC_ARGS); |
static int mdoc_vt_pre(MDOC_ARGS); |
static int mdoc_vt_pre(MDOC_ARGS); |
static int mdoc_xr_pre(MDOC_ARGS); |
static int mdoc_xr_pre(MDOC_ARGS); |
static int mdoc_xx_pre(MDOC_ARGS); |
static int mdoc_xx_pre(MDOC_ARGS); |
Line 108 extern size_t strlcat(char *, const char *, size_ |
|
Line 134 extern size_t strlcat(char *, const char *, size_ |
|
#endif |
#endif |
|
|
static const struct htmlmdoc mdocs[MDOC_MAX] = { |
static const struct htmlmdoc mdocs[MDOC_MAX] = { |
{NULL, NULL}, /* Ap */ |
{mdoc_ap_pre, NULL}, /* Ap */ |
{NULL, NULL}, /* Dd */ |
{NULL, NULL}, /* Dd */ |
{NULL, NULL}, /* Dt */ |
{NULL, NULL}, /* Dt */ |
{NULL, NULL}, /* Os */ |
{NULL, NULL}, /* Os */ |
Line 136 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 162 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{mdoc_fl_pre, NULL}, /* Fl */ |
{mdoc_fl_pre, NULL}, /* Fl */ |
{mdoc_fn_pre, NULL}, /* Fn */ |
{mdoc_fn_pre, NULL}, /* Fn */ |
{mdoc_ft_pre, NULL}, /* Ft */ |
{mdoc_ft_pre, NULL}, /* Ft */ |
{NULL, NULL}, /* Ic */ |
{mdoc_ic_pre, NULL}, /* Ic */ |
{NULL, NULL}, /* In */ |
{mdoc_in_pre, NULL}, /* In */ |
{NULL, NULL}, /* Li */ |
{mdoc_li_pre, NULL}, /* Li */ |
{mdoc_nd_pre, NULL}, /* Nd */ |
{mdoc_nd_pre, NULL}, /* Nd */ |
{mdoc_nm_pre, NULL}, /* Nm */ |
{mdoc_nm_pre, NULL}, /* Nm */ |
{mdoc_op_pre, mdoc_op_post}, /* Op */ |
{mdoc_op_pre, mdoc_op_post}, /* Op */ |
{NULL, NULL}, /* Ot */ |
{NULL, NULL}, /* Ot */ |
{mdoc_pa_pre, NULL}, /* Pa */ |
{mdoc_pa_pre, NULL}, /* Pa */ |
{NULL, NULL}, /* Rv */ |
{mdoc_rv_pre, NULL}, /* Rv */ |
{NULL, NULL}, /* St */ |
{NULL, NULL}, /* St */ |
{NULL, 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 */ |
{NULL, NULL}, /* At */ |
{NULL, NULL}, /* At */ |
{NULL, NULL}, /* Bc */ |
{NULL, NULL}, /* Bc */ |
{NULL, NULL}, /* Bf */ |
{mdoc_bf_pre, NULL}, /* Bf */ |
{NULL, NULL}, /* Bo */ |
{mdoc_bq_pre, mdoc_bq_post}, /* Bo */ |
{NULL, NULL}, /* Bq */ |
{mdoc_bq_pre, mdoc_bq_post}, /* Bq */ |
{mdoc_xx_pre, NULL}, /* Bsx */ |
{mdoc_xx_pre, NULL}, /* Bsx */ |
{NULL, NULL}, /* Bx */ |
{mdoc_bx_pre, NULL}, /* Bx */ |
{NULL, NULL}, /* Db */ |
{NULL, NULL}, /* Db */ |
{NULL, NULL}, /* Dc */ |
{NULL, NULL}, /* Dc */ |
{NULL, NULL}, /* Do */ |
{mdoc_dq_pre, mdoc_dq_post}, /* Do */ |
{mdoc_dq_pre, mdoc_dq_post}, /* Dq */ |
{mdoc_dq_pre, mdoc_dq_post}, /* Dq */ |
{NULL, NULL}, /* Ec */ |
{NULL, NULL}, /* Ec */ |
{NULL, NULL}, /* Ef */ |
{NULL, NULL}, /* Ef */ |
{mdoc_em_pre, NULL}, /* Em */ |
{mdoc_em_pre, NULL}, /* Em */ |
{NULL, NULL}, /* Eo */ |
{NULL, NULL}, /* Eo */ |
{mdoc_xx_pre, NULL}, /* Fx */ |
{mdoc_xx_pre, NULL}, /* Fx */ |
{NULL, NULL}, /* Ms */ |
{mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */ |
{NULL, NULL}, /* No */ |
{NULL, NULL}, /* No */ |
{mdoc_ns_pre, NULL}, /* Ns */ |
{mdoc_ns_pre, NULL}, /* Ns */ |
{mdoc_xx_pre, NULL}, /* Nx */ |
{mdoc_xx_pre, NULL}, /* Nx */ |
{mdoc_xx_pre, NULL}, /* Ox */ |
{mdoc_xx_pre, NULL}, /* Ox */ |
{NULL, NULL}, /* Pc */ |
{NULL, NULL}, /* Pc */ |
{NULL, NULL}, /* Pf */ |
{mdoc_pf_pre, mdoc_pf_post}, /* Pf */ |
{mdoc_pq_pre, mdoc_pq_post}, /* Po */ |
{mdoc_pq_pre, mdoc_pq_post}, /* Po */ |
{mdoc_pq_pre, mdoc_pq_post}, /* Pq */ |
{mdoc_pq_pre, mdoc_pq_post}, /* Pq */ |
{NULL, NULL}, /* Qc */ |
{NULL, NULL}, /* Qc */ |
{NULL, NULL}, /* Ql */ |
{mdoc_sq_pre, mdoc_sq_post}, /* Ql */ |
{mdoc_qq_pre, mdoc_qq_post}, /* Qo */ |
{mdoc_dq_pre, mdoc_dq_post}, /* Qo */ |
{mdoc_qq_pre, mdoc_qq_post}, /* Qq */ |
{mdoc_dq_pre, mdoc_dq_post}, /* Qq */ |
{NULL, NULL}, /* Re */ |
{NULL, NULL}, /* Re */ |
{NULL, NULL}, /* Rs */ |
{mdoc_rs_pre, NULL}, /* Rs */ |
{NULL, NULL}, /* Sc */ |
{NULL, NULL}, /* Sc */ |
{mdoc_sq_pre, mdoc_sq_post}, /* So */ |
{mdoc_sq_pre, mdoc_sq_post}, /* So */ |
{mdoc_sq_pre, mdoc_sq_post}, /* Sq */ |
{mdoc_sq_pre, mdoc_sq_post}, /* Sq */ |
{NULL, NULL}, /* Sm */ |
{NULL, NULL}, /* Sm */ /* FIXME - no idea. */ |
{mdoc_sx_pre, NULL}, /* Sx */ |
{mdoc_sx_pre, NULL}, /* Sx */ |
{NULL, NULL}, /* Sy */ |
{mdoc_sy_pre, NULL}, /* Sy */ |
{NULL, NULL}, /* Tn */ |
{NULL, NULL}, /* Tn */ |
{mdoc_xx_pre, NULL}, /* Ux */ |
{mdoc_xx_pre, NULL}, /* Ux */ |
{NULL, NULL}, /* Xc */ |
{NULL, NULL}, /* Xc */ |
{NULL, NULL}, /* Xo */ |
{NULL, NULL}, /* Xo */ |
{NULL, NULL}, /* Fo */ |
{mdoc_fo_pre, mdoc_fo_post}, /* Fo */ |
{NULL, NULL}, /* Fc */ |
{NULL, NULL}, /* Fc */ |
{NULL, NULL}, /* Oo */ |
{mdoc_op_pre, mdoc_op_post}, /* Oo */ |
{NULL, NULL}, /* Oc */ |
{NULL, NULL}, /* Oc */ |
{NULL, NULL}, /* Bk */ |
{NULL, NULL}, /* Bk */ |
{NULL, NULL}, /* Ek */ |
{NULL, NULL}, /* Ek */ |
{NULL, NULL}, /* Bt */ |
{mdoc_bt_pre, NULL}, /* Bt */ |
{NULL, NULL}, /* Hf */ |
{NULL, NULL}, /* Hf */ |
{NULL, NULL}, /* Fr */ |
{NULL, NULL}, /* Fr */ |
{NULL, NULL}, /* Ud */ |
{mdoc_ud_pre, NULL}, /* Ud */ |
{NULL, NULL}, /* Lb */ |
{mdoc_lb_pre, NULL}, /* Lb */ |
{mdoc_sp_pre, NULL}, /* Lp */ |
{mdoc_sp_pre, NULL}, /* Lp */ |
{NULL, NULL}, /* Lk */ |
{mdoc_lk_pre, NULL}, /* Lk */ |
{NULL, NULL}, /* Mt */ |
{mdoc_mt_pre, NULL}, /* Mt */ |
{NULL, NULL}, /* Brq */ |
{mdoc_brq_pre, mdoc_brq_post}, /* Brq */ |
{NULL, NULL}, /* 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 */ |
{NULL, NULL}, /* Es */ /* TODO */ |
{NULL, NULL}, /* En */ |
{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 */ |
}; |
}; |
|
|
static char buf[BUFSIZ]; /* XXX */ |
|
|
|
#define bufcat(x) (void)strlcat(buf, (x), BUFSIZ) |
|
#define bufinit() buf[0] = 0 |
|
#define buffmt(...) (void)snprintf(buf, BUFSIZ - 1, __VA_ARGS__) |
|
|
|
void |
void |
html_mdoc(void *arg, const struct mdoc *m) |
html_mdoc(void *arg, const struct mdoc *m) |
{ |
{ |
Line 253 html_mdoc(void *arg, const struct mdoc *m) |
|
Line 274 html_mdoc(void *arg, const struct mdoc *m) |
|
} |
} |
|
|
|
|
|
/* |
|
* Return the list type for `Bl', e.g., `Bl -column' returns |
|
* MDOC_Column. This can ONLY be run for lists; it will abort() if no |
|
* list type is found. |
|
*/ |
static int |
static int |
a2list(const struct mdoc_node *n) |
a2list(const struct mdoc_node *n) |
{ |
{ |
int i; |
int i; |
|
|
assert(MDOC_BLOCK == n->type && MDOC_Bl == n->tok); |
|
assert(n->args); |
assert(n->args); |
|
|
for (i = 0; i < (int)n->args->argc; i++) |
for (i = 0; i < (int)n->args->argc; i++) |
switch (n->args->argv[i].arg) { |
switch (n->args->argv[i].arg) { |
case (MDOC_Enum): |
case (MDOC_Enum): |
Line 294 a2list(const struct mdoc_node *n) |
|
Line 318 a2list(const struct mdoc_node *n) |
|
} |
} |
|
|
|
|
static int |
/* |
a2width(const char *p) |
* Calculate the scaling unit passed in a `-width' argument. This uses |
|
* either a native scaling unit (e.g., 1i, 2m) or the string length of |
|
* the value. |
|
*/ |
|
static void |
|
a2width(const char *p, struct roffsu *su) |
{ |
{ |
int i, len; |
|
|
|
if (0 == (len = (int)strlen(p))) |
if (a2roffsu(p, su)) |
return(0); |
return; |
for (i = 0; i < len - 1; i++) |
su->unit = SCALE_EM; |
if ( ! isdigit((u_char)p[i])) |
su->scale = (int)strlen(p); |
break; |
|
|
|
if (i == len - 1) |
|
if ('n' == p[len - 1] || 'm' == p[len - 1]) |
|
return(atoi(p) + 2); |
|
|
|
return(len + 2); |
|
} |
} |
|
|
|
|
static int |
/* |
a2offs(const char *p) |
* Calculate the scaling unit passed in an `-offset' argument. This |
|
* uses either a native scaling unit (e.g., 1i, 2m), one of a set of |
|
* predefined strings (indent, etc.), or the string length of the value. |
|
*/ |
|
static void |
|
a2offs(const char *p, struct roffsu *su) |
{ |
{ |
int len, i; |
|
|
|
if (0 == strcmp(p, "left")) |
if (0 == strcmp(p, "left")) |
return(0); |
SCALE_HS_INIT(su, 0); |
if (0 == strcmp(p, "indent")) |
else if (0 == strcmp(p, "indent")) |
return(INDENT + 1); |
SCALE_HS_INIT(su, INDENT); |
if (0 == strcmp(p, "indent-two")) |
else if (0 == strcmp(p, "indent-two")) |
return((INDENT + 1) * 2); |
SCALE_HS_INIT(su, INDENT * 2); |
|
else if ( ! a2roffsu(p, su)) { |
if (0 == (len = (int)strlen(p))) |
su->unit = SCALE_EM; |
return(0); |
su->scale = (int)strlen(p); |
|
} |
for (i = 0; i < len - 1; i++) |
|
if ( ! isdigit((u_char)p[i])) |
|
break; |
|
|
|
if (i == len - 1) |
|
if ('n' == p[len - 1] || 'm' == p[len - 1]) |
|
return(atoi(p)); |
|
|
|
return(len); |
|
} |
} |
|
|
|
|
Line 365 print_mdoc(MDOC_ARGS) |
|
Line 381 print_mdoc(MDOC_ARGS) |
|
static void |
static void |
print_mdoc_head(MDOC_ARGS) |
print_mdoc_head(MDOC_ARGS) |
{ |
{ |
char b[BUFSIZ]; |
|
|
|
print_gen_head(h); |
print_gen_head(h); |
|
bufinit(h); |
|
buffmt(h, "%s(%d)", m->title, m->msec); |
|
|
(void)snprintf(b, BUFSIZ - 1, |
|
"%s(%d)", m->title, m->msec); |
|
|
|
if (m->arch) { |
if (m->arch) { |
(void)strlcat(b, " (", BUFSIZ); |
bufcat(h, " ("); |
(void)strlcat(b, m->arch, BUFSIZ); |
bufcat(h, m->arch); |
(void)strlcat(b, ")", BUFSIZ); |
bufcat(h, ")"); |
} |
} |
|
|
print_otag(h, TAG_TITLE, 0, NULL); |
print_otag(h, TAG_TITLE, 0, NULL); |
print_text(h, b); |
print_text(h, h->buf); |
} |
} |
|
|
|
|
Line 402 print_mdoc_node(MDOC_ARGS) |
|
Line 416 print_mdoc_node(MDOC_ARGS) |
|
child = 1; |
child = 1; |
t = SLIST_FIRST(&h->tags); |
t = SLIST_FIRST(&h->tags); |
|
|
bufinit(); |
bufinit(h); |
|
|
switch (n->type) { |
switch (n->type) { |
case (MDOC_ROOT): |
case (MDOC_ROOT): |
child = mdoc_root_pre(m, n, h); |
child = mdoc_root_pre(m, n, h); |
Line 422 print_mdoc_node(MDOC_ARGS) |
|
Line 435 print_mdoc_node(MDOC_ARGS) |
|
|
|
print_stagq(h, t); |
print_stagq(h, t); |
|
|
bufinit(); |
bufinit(h); |
|
|
switch (n->type) { |
switch (n->type) { |
case (MDOC_ROOT): |
case (MDOC_ROOT): |
mdoc_root_post(m, n, h); |
mdoc_root_post(m, n, h); |
Line 447 mdoc_root_post(MDOC_ARGS) |
|
Line 459 mdoc_root_post(MDOC_ARGS) |
|
struct tag *t, *tt; |
struct tag *t, *tt; |
char b[BUFSIZ]; |
char b[BUFSIZ]; |
|
|
|
/* |
|
* 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. |
|
*/ |
|
|
(void)localtime_r(&m->date, &tm); |
(void)localtime_r(&m->date, &tm); |
|
|
if (0 == strftime(b, BUFSIZ - 1, "%B %e, %Y", &tm)) |
if (0 == strftime(b, BUFSIZ - 1, "%B %e, %Y", &tm)) |
err(EXIT_FAILURE, "strftime"); |
err(EXIT_FAILURE, "strftime"); |
|
|
tag[0].key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag[0], "footer"); |
tag[0].val = "footer"; |
bufcat_style(h, "width", "100%"); |
tag[1].key = ATTR_STYLE; |
PAIR_STYLE_INIT(&tag[1], h); |
tag[1].val = "width: 100%;"; |
|
t = print_otag(h, TAG_TABLE, 2, tag); |
t = print_otag(h, TAG_TABLE, 2, tag); |
tt = print_otag(h, TAG_TR, 0, NULL); |
tt = print_otag(h, TAG_TR, 0, NULL); |
|
|
tag[0].key = ATTR_STYLE; |
bufinit(h); |
tag[0].val = "width: 50%;"; |
bufcat_style(h, "width", "50%"); |
|
PAIR_STYLE_INIT(&tag[0], h); |
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; |
bufinit(h); |
tag[0].val = "width: 50%; text-align: right;"; |
bufcat_style(h, "width", "50%"); |
|
bufcat_style(h, "text-align", "right"); |
|
PAIR_STYLE_INIT(&tag[0], h); |
print_otag(h, TAG_TD, 1, tag); |
print_otag(h, TAG_TD, 1, tag); |
print_text(h, m->os); |
print_text(h, m->os); |
print_tagq(h, t); |
print_tagq(h, t); |
Line 492 mdoc_root_pre(MDOC_ARGS) |
|
Line 512 mdoc_root_pre(MDOC_ARGS) |
|
(void)snprintf(title, BUFSIZ - 1, |
(void)snprintf(title, BUFSIZ - 1, |
"%s(%d)", m->title, m->msec); |
"%s(%d)", m->title, m->msec); |
|
|
tag[0].key = ATTR_CLASS; |
/* XXX: see note in mdoc_root_post() about divs. */ |
tag[0].val = "header"; |
|
tag[1].key = ATTR_STYLE; |
PAIR_CLASS_INIT(&tag[0], "header"); |
tag[1].val = "width: 100%;"; |
bufcat_style(h, "width", "100%"); |
|
PAIR_STYLE_INIT(&tag[1], h); |
t = print_otag(h, TAG_TABLE, 2, tag); |
t = print_otag(h, TAG_TABLE, 2, tag); |
tt = print_otag(h, TAG_TR, 0, NULL); |
tt = print_otag(h, TAG_TR, 0, NULL); |
|
|
tag[0].key = ATTR_STYLE; |
bufinit(h); |
tag[0].val = "width: 33%;"; |
bufcat_style(h, "width", "10%"); |
|
PAIR_STYLE_INIT(&tag[0], h); |
print_otag(h, TAG_TD, 1, tag); |
print_otag(h, TAG_TD, 1, tag); |
print_text(h, b); |
print_text(h, title); |
print_stagq(h, tt); |
print_stagq(h, tt); |
|
|
tag[0].key = ATTR_STYLE; |
bufinit(h); |
tag[0].val = "width: 33%; text-align: center;"; |
bufcat_style(h, "text-align", "center"); |
|
bufcat_style(h, "white-space", "nowrap"); |
|
bufcat_style(h, "width", "80%"); |
|
PAIR_STYLE_INIT(&tag[0], h); |
print_otag(h, TAG_TD, 1, tag); |
print_otag(h, TAG_TD, 1, tag); |
print_text(h, title); |
print_text(h, b); |
print_stagq(h, tt); |
print_stagq(h, tt); |
|
|
tag[0].key = ATTR_STYLE; |
bufinit(h); |
tag[0].val = "width: 33%; text-align: right;"; |
bufcat_style(h, "text-align", "right"); |
|
bufcat_style(h, "width", "10%"); |
|
PAIR_STYLE_INIT(&tag[0], h); |
print_otag(h, TAG_TD, 1, tag); |
print_otag(h, TAG_TD, 1, tag); |
print_text(h, b); |
print_text(h, title); |
print_tagq(h, t); |
print_tagq(h, t); |
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 527 mdoc_sh_pre(MDOC_ARGS) |
|
Line 553 mdoc_sh_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag[2]; |
struct htmlpair tag[2]; |
const struct mdoc_node *nn; |
const struct mdoc_node *nn; |
|
char lbuf[BUFSIZ]; |
|
struct roffsu su; |
|
|
if (MDOC_HEAD == n->type) { |
if (MDOC_BODY == n->type) { |
tag[0].key = ATTR_CLASS; |
SCALE_HS_INIT(&su, INDENT); |
tag[0].val = "sec-head"; |
bufcat_su(h, "margin-left", &su); |
print_otag(h, TAG_DIV, 1, tag); |
PAIR_CLASS_INIT(&tag[0], "sec-body"); |
print_otag(h, TAG_SPAN, 1, tag); |
PAIR_STYLE_INIT(&tag[1], h); |
|
print_otag(h, TAG_DIV, 2, tag); |
for (nn = n->child; nn; nn = nn->next) { |
|
bufcat(nn->string); |
|
if (nn->next) |
|
bufcat(" "); |
|
} |
|
tag[0].key = ATTR_NAME; |
|
tag[0].val = buf; |
|
print_otag(h, TAG_A, 1, tag); |
|
return(1); |
return(1); |
} else if (MDOC_BLOCK == n->type) { |
} else if (MDOC_BLOCK == n->type) { |
tag[0].key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag[0], "sec-block"); |
tag[0].val = "sec-block"; |
|
|
|
if (n->prev && NULL == n->prev->body->child) { |
if (n->prev && NULL == n->prev->body->child) { |
print_otag(h, TAG_DIV, 1, tag); |
print_otag(h, TAG_DIV, 1, tag); |
return(1); |
return(1); |
} |
} |
|
|
bufcat("margin-top: 1em;"); |
SCALE_VS_INIT(&su, 1); |
|
bufcat_su(h, "margin-top", &su); |
if (NULL == n->next) |
if (NULL == n->next) |
bufcat("margin-bottom: 1em;"); |
bufcat_su(h, "margin-bottom", &su); |
|
|
tag[1].key = ATTR_STYLE; |
PAIR_STYLE_INIT(&tag[1], h); |
tag[1].val = buf; |
|
|
|
print_otag(h, TAG_DIV, 2, tag); |
print_otag(h, TAG_DIV, 2, tag); |
return(1); |
return(1); |
} |
} |
|
|
buffmt("margin-left: %dem;", INDENT); |
lbuf[0] = 0; |
|
for (nn = n->child; nn; nn = nn->next) { |
tag[0].key = ATTR_CLASS; |
(void)strlcat(lbuf, nn->string, BUFSIZ); |
tag[0].val = "sec-body"; |
if (nn->next) |
tag[1].key = ATTR_STYLE; |
(void)strlcat(lbuf, "_", BUFSIZ); |
tag[1].val = buf; |
} |
|
|
|
/* |
|
* TODO: make sure there are no duplicates, as HTML does not |
|
* allow for multiple `id' tags of the same name. |
|
*/ |
|
|
|
PAIR_CLASS_INIT(&tag[0], "sec-head"); |
|
tag[1].key = ATTR_ID; |
|
tag[1].val = lbuf; |
print_otag(h, TAG_DIV, 2, tag); |
print_otag(h, TAG_DIV, 2, tag); |
return(1); |
return(1); |
} |
} |
Line 579 mdoc_sh_pre(MDOC_ARGS) |
|
Line 604 mdoc_sh_pre(MDOC_ARGS) |
|
static int |
static int |
mdoc_ss_pre(MDOC_ARGS) |
mdoc_ss_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag[2]; |
struct htmlpair tag[3]; |
int i; |
|
const struct mdoc_node *nn; |
const struct mdoc_node *nn; |
|
char lbuf[BUFSIZ]; |
|
struct roffsu su; |
|
|
i = 0; |
SCALE_VS_INIT(&su, 1); |
|
|
if (MDOC_BODY == n->type) { |
if (MDOC_BODY == n->type) { |
tag[i].key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag[0], "ssec-body"); |
tag[i++].val = "ssec-body"; |
|
if (n->parent->next && n->child) { |
if (n->parent->next && n->child) { |
bufcat("margin-bottom: 1em;"); |
bufcat_su(h, "margin-bottom", &su); |
tag[i].key = ATTR_STYLE; |
PAIR_STYLE_INIT(&tag[1], h); |
tag[i++].val = buf; |
print_otag(h, TAG_DIV, 2, tag); |
} |
} else |
print_otag(h, TAG_DIV, i, tag); |
print_otag(h, TAG_DIV, 1, tag); |
return(1); |
return(1); |
} else if (MDOC_BLOCK == n->type) { |
} else if (MDOC_BLOCK == n->type) { |
tag[i].key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag[0], "ssec-block"); |
tag[i++].val = "ssec-block"; |
|
if (n->prev) { |
if (n->prev) { |
bufcat("margin-top: 1em;"); |
bufcat_su(h, "margin-top", &su); |
tag[i].key = ATTR_STYLE; |
PAIR_STYLE_INIT(&tag[1], h); |
tag[i++].val = buf; |
print_otag(h, TAG_DIV, 2, tag); |
} |
} else |
print_otag(h, TAG_DIV, i, tag); |
print_otag(h, TAG_DIV, 1, tag); |
return(1); |
return(1); |
} |
} |
|
|
buffmt("margin-left: -%dem;", INDENT - HALFINDENT); |
/* TODO: see note in mdoc_sh_pre() about duplicates. */ |
|
|
tag[0].key = ATTR_CLASS; |
lbuf[0] = 0; |
tag[0].val = "ssec-head"; |
|
tag[1].key = ATTR_STYLE; |
|
tag[1].val = buf; |
|
|
|
print_otag(h, TAG_DIV, 2, tag); |
|
print_otag(h, TAG_SPAN, 1, tag); |
|
|
|
bufinit(); |
|
for (nn = n->child; nn; nn = nn->next) { |
for (nn = n->child; nn; nn = nn->next) { |
bufcat(nn->string); |
(void)strlcat(lbuf, nn->string, BUFSIZ); |
if (nn->next) |
if (nn->next) |
bufcat(" "); |
(void)strlcat(lbuf, "_", BUFSIZ); |
} |
} |
tag[0].key = ATTR_NAME; |
|
tag[0].val = buf; |
|
print_otag(h, TAG_A, 1, tag); |
|
|
|
|
SCALE_HS_INIT(&su, INDENT - HALFINDENT); |
|
su.scale = -su.scale; |
|
bufcat_su(h, "margin-left", &su); |
|
|
|
PAIR_CLASS_INIT(&tag[0], "ssec-head"); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
tag[2].key = ATTR_ID; |
|
tag[2].val = lbuf; |
|
print_otag(h, TAG_DIV, 3, tag); |
return(1); |
return(1); |
} |
} |
|
|
Line 637 mdoc_fl_pre(MDOC_ARGS) |
|
Line 659 mdoc_fl_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "flag"); |
tag.val = "flag"; |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
if (MDOC_Fl == n->tok) { |
if (MDOC_Fl == n->tok) { |
print_text(h, "\\-"); |
print_text(h, "\\-"); |
Line 658 mdoc_nd_pre(MDOC_ARGS) |
|
Line 678 mdoc_nd_pre(MDOC_ARGS) |
|
if (MDOC_BODY != n->type) |
if (MDOC_BODY != n->type) |
return(1); |
return(1); |
|
|
/* XXX - this can contain block elements! */ |
/* XXX: this tag in theory can contain block elements. */ |
|
|
print_text(h, "\\(em"); |
print_text(h, "\\(em"); |
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "desc-body"); |
tag.val = "desc-body"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 676 mdoc_op_pre(MDOC_ARGS) |
|
Line 696 mdoc_op_pre(MDOC_ARGS) |
|
if (MDOC_BODY != n->type) |
if (MDOC_BODY != n->type) |
return(1); |
return(1); |
|
|
/* XXX - this can contain block elements! */ |
/* XXX: this tag in theory can contain block elements. */ |
|
|
print_text(h, "\\(lB"); |
print_text(h, "\\(lB"); |
h->flags |= HTML_NOSPACE; |
h->flags |= HTML_NOSPACE; |
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "opt"); |
tag.val = "opt"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 705 mdoc_nm_pre(MDOC_ARGS) |
|
Line 725 mdoc_nm_pre(MDOC_ARGS) |
|
|
|
if ( ! (HTML_NEWLINE & h->flags)) |
if ( ! (HTML_NEWLINE & h->flags)) |
if (SEC_SYNOPSIS == n->sec) { |
if (SEC_SYNOPSIS == n->sec) { |
tag.key = ATTR_STYLE; |
bufcat_style(h, "clear", "both"); |
tag.val = "clear: both;"; |
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_BR, 1, &tag); |
print_otag(h, TAG_BR, 1, &tag); |
} |
} |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "name"); |
tag.val = "name"; |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
if (NULL == n->child) |
if (NULL == n->child) |
print_text(h, m->name); |
print_text(h, m->name); |
|
|
mdoc_xr_pre(MDOC_ARGS) |
mdoc_xr_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag[2]; |
struct htmlpair tag[2]; |
const char *name, *sec; |
|
const struct mdoc_node *nn; |
const struct mdoc_node *nn; |
|
|
nn = n->child; |
PAIR_CLASS_INIT(&tag[0], "link-man"); |
name = nn && nn->string ? nn->string : ""; |
|
nn = nn ? nn->next : NULL; |
|
sec = nn && nn->string ? nn->string : ""; |
|
|
|
buffmt("%s%s%s.html", name, name && sec ? "." : "", sec); |
if (h->base_man) { |
|
buffmt_man(h, n->child->string, |
|
n->child->next ? |
|
n->child->next->string : NULL); |
|
tag[1].key = ATTR_HREF; |
|
tag[1].val = h->buf; |
|
print_otag(h, TAG_A, 2, tag); |
|
} else |
|
print_otag(h, TAG_A, 1, tag); |
|
|
tag[0].key = ATTR_CLASS; |
|
tag[0].val = "link-man"; |
|
tag[1].key = ATTR_HREF; |
|
tag[1].val = buf; |
|
print_otag(h, TAG_A, 2, tag); |
|
|
|
nn = n->child; |
nn = n->child; |
print_text(h, nn->string); |
print_text(h, nn->string); |
|
|
if (NULL == (nn = nn->next)) |
if (NULL == (nn = nn->next)) |
return(0); |
return(0); |
|
|
Line 753 mdoc_xr_pre(MDOC_ARGS) |
|
Line 770 mdoc_xr_pre(MDOC_ARGS) |
|
print_text(h, nn->string); |
print_text(h, nn->string); |
h->flags |= HTML_NOSPACE; |
h->flags |= HTML_NOSPACE; |
print_text(h, ")"); |
print_text(h, ")"); |
|
|
return(0); |
return(0); |
} |
} |
|
|
Line 774 mdoc_ar_pre(MDOC_ARGS) |
|
Line 790 mdoc_ar_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "arg"); |
tag.val = "arg"; |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 812 mdoc_xx_pre(MDOC_ARGS) |
|
Line 826 mdoc_xx_pre(MDOC_ARGS) |
|
return(1); |
return(1); |
} |
} |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "unix"); |
tag.val = "unix"; |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
print_text(h, pp); |
print_text(h, pp); |
return(1); |
return(1); |
Line 823 mdoc_xx_pre(MDOC_ARGS) |
|
Line 835 mdoc_xx_pre(MDOC_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int c) |
mdoc_bx_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag; |
const struct mdoc_node *nn; |
|
struct htmlpair tag; |
|
|
switch (t) { |
PAIR_CLASS_INIT(&tag, "unix"); |
case (MDOC_Column): |
print_otag(h, TAG_SPAN, 1, &tag); |
/* FALLTHROUGH */ |
|
case (MDOC_Item): |
for (nn = n->child; nn; nn = nn->next) |
/* FALLTHROUGH */ |
print_mdoc_node(m, nn, h); |
case (MDOC_Ohang): |
|
buffmt("margin-left: %dem; clear: both;", o); |
if (n->child) |
break; |
h->flags |= HTML_NOSPACE; |
default: |
|
buffmt("margin-left: %dem; clear: both;", w + o); |
print_text(h, "BSD"); |
break; |
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_it_block_pre(MDOC_ARGS, int type, int comp, |
|
struct roffsu *offs, struct roffsu *width) |
|
{ |
|
struct htmlpair tag; |
|
const struct mdoc_node *nn; |
|
struct roffsu su; |
|
|
|
nn = n->parent->parent; |
|
assert(nn->args); |
|
|
|
/* XXX: see notes in mdoc_it_pre(). */ |
|
|
|
if (MDOC_Column == type) { |
|
/* Don't width-pad on the left. */ |
|
SCALE_HS_INIT(width, 0); |
|
/* Also disallow non-compact. */ |
|
comp = 1; |
} |
} |
|
if (MDOC_Diag == type) |
|
/* Mandate non-compact with empty prior. */ |
|
if (n->prev && NULL == n->prev->body->child) |
|
comp = 1; |
|
|
if ( ! c && MDOC_Column != t) { |
bufcat_style(h, "clear", "both"); |
if (n->prev && n->prev->body->child) |
if (offs->scale > 0) |
bufcat("padding-top: 1em;"); |
bufcat_su(h, "margin-left", offs); |
else if (NULL == n->prev) |
if (width->scale > 0) |
bufcat("padding-top: 1em;"); |
bufcat_su(h, "padding-left", width); |
|
|
|
PAIR_STYLE_INIT(&tag, h); |
|
|
|
/* Mandate compact following `Ss' and `Sh' starts. */ |
|
|
|
for (nn = n; nn && ! comp; nn = nn->parent) { |
|
if (MDOC_BLOCK != nn->type) |
|
continue; |
|
if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok) |
|
comp = 1; |
|
if (nn->prev) |
|
break; |
} |
} |
|
|
tag.key = ATTR_STYLE; |
if ( ! comp) { |
tag.val = buf; |
SCALE_VS_INIT(&su, 1); |
|
bufcat_su(h, "padding-top", &su); |
|
} |
|
|
|
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 856 mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int |
|
Line 911 mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_tbl_body_pre(MDOC_ARGS, int t, int w) |
mdoc_it_body_pre(MDOC_ARGS, int type) |
{ |
{ |
|
struct htmlpair tag; |
|
struct roffsu su; |
|
|
print_otag(h, TAG_DIV, 0, NULL); |
switch (type) { |
|
case (MDOC_Item): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Ohang): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Column): |
|
break; |
|
default: |
|
/* |
|
* XXX: this tricks CSS into aligning the bodies with |
|
* the right-padding in the head. |
|
*/ |
|
SCALE_HS_INIT(&su, 2); |
|
bufcat_su(h, "margin-left", &su); |
|
PAIR_STYLE_INIT(&tag, h); |
|
print_otag(h, TAG_DIV, 1, &tag); |
|
break; |
|
} |
|
|
return(1); |
return(1); |
} |
} |
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_tbl_head_pre(MDOC_ARGS, int t, int w) |
mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width) |
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
struct ord *ord; |
struct ord *ord; |
char nbuf[BUFSIZ]; |
char nbuf[BUFSIZ]; |
|
|
switch (t) { |
switch (type) { |
case (MDOC_Item): |
case (MDOC_Item): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Ohang): |
case (MDOC_Ohang): |
print_otag(h, TAG_DIV, 0, NULL); |
print_otag(h, TAG_DIV, 0, NULL); |
break; |
break; |
case (MDOC_Column): |
case (MDOC_Column): |
buffmt("min-width: %dem;", w); |
bufcat_su(h, "min-width", width); |
bufcat("clear: none;"); |
bufcat_style(h, "clear", "none"); |
if (n->next && MDOC_HEAD == n->next->type) |
if (n->next && MDOC_HEAD == n->next->type) |
bufcat("float: left;"); |
bufcat_style(h, "float", "left"); |
tag.key = ATTR_STYLE; |
PAIR_STYLE_INIT(&tag, h); |
tag.val = buf; |
|
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
break; |
break; |
default: |
default: |
buffmt("margin-left: -%dem;", w); |
bufcat_su(h, "min-width", width); |
bufcat("clear: left;"); |
SCALE_INVERT(width); |
bufcat("float: left;"); |
bufcat_su(h, "margin-left", width); |
bufcat("padding-right: 1em;"); |
if (n->next && n->next->child) |
tag.key = ATTR_STYLE; |
bufcat_style(h, "float", "left"); |
tag.val = buf; |
|
|
/* XXX: buffer if we run into body. */ |
|
SCALE_HS_INIT(width, 1); |
|
bufcat_su(h, "margin-right", width); |
|
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
break; |
break; |
} |
} |
|
|
switch (t) { |
switch (type) { |
case (MDOC_Diag): |
case (MDOC_Diag): |
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "diag"); |
tag.val = "diag"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
break; |
break; |
case (MDOC_Enum): |
case (MDOC_Enum): |
Line 915 mdoc_tbl_head_pre(MDOC_ARGS, int t, int w) |
|
Line 992 mdoc_tbl_head_pre(MDOC_ARGS, int t, int w) |
|
print_text(h, "\\(en"); |
print_text(h, "\\(en"); |
return(0); |
return(0); |
case (MDOC_Hyphen): |
case (MDOC_Hyphen): |
print_text(h, "\\-"); |
print_text(h, "\\(hy"); |
return(0); |
return(0); |
case (MDOC_Bullet): |
case (MDOC_Bullet): |
print_text(h, "\\(bu"); |
print_text(h, "\\(bu"); |
Line 929 mdoc_tbl_head_pre(MDOC_ARGS, int t, int w) |
|
Line 1006 mdoc_tbl_head_pre(MDOC_ARGS, int t, int w) |
|
|
|
|
|
static int |
static int |
mdoc_tbl_pre(MDOC_ARGS, int type) |
mdoc_it_pre(MDOC_ARGS) |
{ |
{ |
int i, w, o, c, wp; |
int i, type, wp, comp; |
const struct mdoc_node *bl, *nn; |
const struct mdoc_node *bl, *nn; |
|
struct roffsu width, offs; |
|
|
|
/* |
|
* XXX: be very careful in changing anything, here. Lists in |
|
* mandoc have many peculiarities; furthermore, they don't |
|
* translate well into HTML and require a bit of mangling. |
|
*/ |
|
|
bl = n->parent->parent; |
bl = n->parent->parent; |
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
bl = bl->parent; |
bl = bl->parent; |
|
|
/* FIXME: fmt_vspace() equivalent. */ |
type = a2list(bl); |
|
|
assert(bl->args); |
/* Set default width and offset. */ |
|
|
w = o = c = 0; |
SCALE_HS_INIT(&offs, 0); |
wp = -1; |
|
|
|
for (i = 0; i < (int)bl->args->argc; i++) |
|
if (MDOC_Width == bl->args->argv[i].arg) { |
|
assert(bl->args->argv[i].sz); |
|
wp = i; |
|
w = a2width(bl->args->argv[i].value[0]); |
|
} else if (MDOC_Offset == bl->args->argv[i].arg) { |
|
assert(bl->args->argv[i].sz); |
|
o = a2offs(bl->args->argv[i].value[0]); |
|
} else if (MDOC_Compact == bl->args->argv[i].arg) |
|
c = 1; |
|
|
|
if (MDOC_HEAD == n->type && MDOC_Column == type) { |
|
nn = n->parent->child; |
|
assert(nn && MDOC_HEAD == nn->type); |
|
for (i = 0; nn && nn != n; nn = nn->next, i++) |
|
/* Counter... */ ; |
|
assert(nn); |
|
if (wp >= 0 && i < (int)bl->args[wp].argv->sz) |
|
w = a2width(bl->args->argv[wp].value[i]); |
|
} |
|
|
|
switch (type) { |
switch (type) { |
case (MDOC_Enum): |
case (MDOC_Enum): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
Line 974 mdoc_tbl_pre(MDOC_ARGS, int type) |
|
Line 1036 mdoc_tbl_pre(MDOC_ARGS, int type) |
|
case (MDOC_Hyphen): |
case (MDOC_Hyphen): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Bullet): |
case (MDOC_Bullet): |
if (w < 4) |
SCALE_HS_INIT(&width, 2); |
w = 4; |
|
break; |
break; |
|
default: |
|
SCALE_HS_INIT(&width, INDENT); |
|
break; |
|
} |
|
|
|
/* Get width, offset, and compact arguments. */ |
|
|
|
for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++) |
|
switch (bl->args->argv[i].arg) { |
|
case (MDOC_Column): |
|
wp = i; /* Save for later. */ |
|
break; |
|
case (MDOC_Width): |
|
a2width(bl->args->argv[i].value[0], &width); |
|
break; |
|
case (MDOC_Offset): |
|
a2offs(bl->args->argv[i].value[0], &offs); |
|
break; |
|
case (MDOC_Compact): |
|
comp = 1; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* Override width in some cases. */ |
|
|
|
switch (type) { |
case (MDOC_Inset): |
case (MDOC_Inset): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Diag): |
case (MDOC_Diag): |
w = 1; |
SCALE_HS_INIT(&width, 0); |
break; |
break; |
default: |
default: |
if (0 == w) |
if (0 == width.scale) |
w = 10; |
SCALE_HS_INIT(&width, INDENT); |
break; |
break; |
} |
} |
|
|
switch (n->type) { |
/* Flip to body/block processing. */ |
case (MDOC_BLOCK): |
|
break; |
if (MDOC_BODY == n->type) |
case (MDOC_HEAD): |
return(mdoc_it_body_pre(m, n, h, type)); |
return(mdoc_tbl_head_pre(m, n, h, type, w)); |
if (MDOC_BLOCK == n->type) |
case (MDOC_BODY): |
return(mdoc_it_block_pre(m, n, h, type, comp, |
return(mdoc_tbl_body_pre(m, n, h, type, w)); |
&offs, &width)); |
default: |
|
abort(); |
/* Override column widths. */ |
/* NOTREACHED */ |
|
|
if (MDOC_Column == type) { |
|
nn = n->parent->child; |
|
for (i = 0; nn && nn != n; nn = nn->next, i++) |
|
/* Counter... */ ; |
|
if (i < (int)bl->args->argv[wp].sz) |
|
a2width(bl->args->argv[wp].value[i], &width); |
} |
} |
|
|
return(mdoc_tbl_block_pre(m, n, h, type, w, o, c)); |
return(mdoc_it_head_pre(m, n, h, type, &width)); |
} |
} |
|
|
|
|
Line 1021 mdoc_bl_pre(MDOC_ARGS) |
|
Line 1116 mdoc_bl_pre(MDOC_ARGS) |
|
ord->cookie = n; |
ord->cookie = n; |
ord->pos = 1; |
ord->pos = 1; |
SLIST_INSERT_HEAD(&h->ords, ord, entry); |
SLIST_INSERT_HEAD(&h->ords, ord, entry); |
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 1044 mdoc_bl_post(MDOC_ARGS) |
|
Line 1138 mdoc_bl_post(MDOC_ARGS) |
|
} |
} |
|
|
|
|
static int |
|
mdoc_it_pre(MDOC_ARGS) |
|
{ |
|
int type; |
|
|
|
if (MDOC_BLOCK == n->type) |
|
type = a2list(n->parent->parent); |
|
else |
|
type = a2list(n->parent->parent->parent); |
|
|
|
return(mdoc_tbl_pre(m, n, h, type)); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_ex_pre(MDOC_ARGS) |
mdoc_ex_pre(MDOC_ARGS) |
Line 1066 mdoc_ex_pre(MDOC_ARGS) |
|
Line 1146 mdoc_ex_pre(MDOC_ARGS) |
|
struct tag *t; |
struct tag *t; |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
print_text(h, "The"); |
PAIR_CLASS_INIT(&tag, "utility"); |
|
|
tag.key = ATTR_CLASS; |
print_text(h, "The"); |
tag.val = "utility"; |
|
|
|
for (nn = n->child; nn; nn = nn->next) { |
for (nn = n->child; nn; nn = nn->next) { |
t = print_otag(h, TAG_SPAN, 1, &tag); |
t = print_otag(h, TAG_SPAN, 1, &tag); |
print_text(h, nn->string); |
print_text(h, nn->string); |
Line 1176 mdoc_em_pre(MDOC_ARGS) |
|
Line 1254 mdoc_em_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "emph"); |
tag.val = "emph"; |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1188 mdoc_em_pre(MDOC_ARGS) |
|
Line 1264 mdoc_em_pre(MDOC_ARGS) |
|
static int |
static int |
mdoc_d1_pre(MDOC_ARGS) |
mdoc_d1_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag[2]; |
struct htmlpair tag[2]; |
|
struct roffsu su; |
|
|
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
return(1); |
return(1); |
|
|
buffmt("margin-left: %dem;", INDENT); |
SCALE_VS_INIT(&su, INDENT - 2); |
|
bufcat_su(h, "margin-left", &su); |
tag[0].key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag[0], "lit"); |
tag[0].val = "lit-block"; |
PAIR_STYLE_INIT(&tag[1], h); |
tag[1].key = ATTR_STYLE; |
|
tag[1].val = buf; |
|
|
|
print_otag(h, TAG_DIV, 2, tag); |
print_otag(h, TAG_DIV, 2, tag); |
return(1); |
return(1); |
} |
} |
Line 1211 mdoc_sx_pre(MDOC_ARGS) |
|
Line 1285 mdoc_sx_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag[2]; |
struct htmlpair tag[2]; |
const struct mdoc_node *nn; |
const struct mdoc_node *nn; |
|
char lbuf[BUFSIZ]; |
|
|
bufcat("#"); |
/* FIXME: duplicates? */ |
|
|
|
(void)strlcpy(lbuf, "#", BUFSIZ); |
for (nn = n->child; nn; nn = nn->next) { |
for (nn = n->child; nn; nn = nn->next) { |
bufcat(nn->string); |
(void)strlcat(lbuf, nn->string, BUFSIZ); |
if (nn->next) |
if (nn->next) |
bufcat(" "); |
(void)strlcat(lbuf, "_", BUFSIZ); |
} |
} |
|
|
tag[0].key = ATTR_HREF; |
PAIR_CLASS_INIT(&tag[0], "link-sec"); |
tag[0].val = buf; |
tag[1].key = ATTR_HREF; |
tag[1].key = ATTR_CLASS; |
tag[1].val = lbuf; |
tag[1].val = "link-sec"; |
|
|
|
print_otag(h, TAG_A, 2, tag); |
print_otag(h, TAG_A, 2, tag); |
return(1); |
return(1); |
|
|
mdoc_bd_pre(MDOC_ARGS) |
mdoc_bd_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag[2]; |
struct htmlpair tag[2]; |
int t, c, o, i; |
int type, comp, i; |
const struct mdoc_node *bl; |
const struct mdoc_node *bl, *nn; |
|
struct roffsu su; |
|
|
/* 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 1271 mdoc_bd_pre(MDOC_ARGS) |
|
Line 1346 mdoc_bd_pre(MDOC_ARGS) |
|
else |
else |
bl = n->parent; |
bl = n->parent; |
|
|
t = o = c = 0; |
SCALE_VS_INIT(&su, 0); |
|
|
|
type = comp = 0; |
for (i = 0; i < (int)bl->args->argc; i++) |
for (i = 0; i < (int)bl->args->argc; i++) |
switch (bl->args->argv[i].arg) { |
switch (bl->args->argv[i].arg) { |
case (MDOC_Offset): |
case (MDOC_Offset): |
assert(bl->args->argv[i].sz); |
a2offs(bl->args->argv[i].value[0], &su); |
o = a2offs (bl->args->argv[i].value[0]); |
|
break; |
break; |
case (MDOC_Compact): |
case (MDOC_Compact): |
c = 1; |
comp = 1; |
break; |
break; |
|
case (MDOC_Centred): |
|
/* FALLTHROUGH */ |
case (MDOC_Ragged): |
case (MDOC_Ragged): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Filled): |
case (MDOC_Filled): |
Line 1289 mdoc_bd_pre(MDOC_ARGS) |
|
Line 1366 mdoc_bd_pre(MDOC_ARGS) |
|
case (MDOC_Unfilled): |
case (MDOC_Unfilled): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Literal): |
case (MDOC_Literal): |
t = bl->args->argv[i].arg; |
type = bl->args->argv[i].arg; |
break; |
break; |
|
default: |
|
break; |
} |
} |
|
|
if (MDOC_BLOCK == n->type) { |
if (MDOC_BLOCK == n->type) { |
if (o) |
bufcat_su(h, "margin-left", &su); |
buffmt("margin-left: %dem;", o); |
for (nn = n; nn && ! comp; nn = nn->parent) { |
bufcat("margin-top: 1em;"); |
if (MDOC_BLOCK != nn->type) |
tag[0].key = ATTR_STYLE; |
continue; |
tag[0].val = buf; |
if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok) |
|
comp = 1; |
|
if (nn->prev) |
|
break; |
|
} |
|
if (comp) { |
|
print_otag(h, TAG_DIV, 0, tag); |
|
return(1); |
|
} |
|
SCALE_VS_INIT(&su, 1); |
|
bufcat_su(h, "margin-top", &su); |
|
PAIR_STYLE_INIT(&tag[0], h); |
print_otag(h, TAG_DIV, 1, tag); |
print_otag(h, TAG_DIV, 1, tag); |
return(1); |
return(1); |
} |
} |
|
|
switch (t) { |
if (MDOC_Unfilled != type && MDOC_Literal != type) |
case (MDOC_Unfilled): |
|
case (MDOC_Literal): |
|
break; |
|
default: |
|
return(1); |
return(1); |
} |
|
|
|
bufcat("white-space: pre;"); |
PAIR_CLASS_INIT(&tag[0], "lit"); |
tag[0].key = ATTR_STYLE; |
bufcat_style(h, "white-space", "pre"); |
tag[0].val = buf; |
PAIR_STYLE_INIT(&tag[1], h); |
tag[1].key = ATTR_CLASS; |
|
tag[1].val = "lit-block"; |
|
|
|
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; |
h->flags |= HTML_NOSPACE; |
print_mdoc_node(m, n, h); |
print_mdoc_node(m, nn, h); |
if (n->next) |
if (NULL == nn->next) |
|
continue; |
|
if (nn->prev && nn->prev->line < nn->line) |
print_text(h, "\n"); |
print_text(h, "\n"); |
|
else if (NULL == nn->prev) |
|
print_text(h, "\n"); |
} |
} |
|
|
return(0); |
return(0); |
Line 1336 mdoc_pa_pre(MDOC_ARGS) |
|
Line 1422 mdoc_pa_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "file"); |
tag.val = "file"; |
|
|
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1346 mdoc_pa_pre(MDOC_ARGS) |
|
Line 1430 mdoc_pa_pre(MDOC_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_qq_pre(MDOC_ARGS) |
|
{ |
|
|
|
if (MDOC_BODY != n->type) |
|
return(1); |
|
print_text(h, "\\*q"); |
|
h->flags |= HTML_NOSPACE; |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
mdoc_qq_post(MDOC_ARGS) |
|
{ |
|
|
|
if (MDOC_BODY != n->type) |
|
return; |
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, "\\*q"); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_ad_pre(MDOC_ARGS) |
mdoc_ad_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "addr"); |
tag.val = "addr"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1388 mdoc_an_pre(MDOC_ARGS) |
|
Line 1446 mdoc_an_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
/* TODO: -split and -nosplit (see termp_an_pre()). */ |
tag.val = "author"; |
|
|
PAIR_CLASS_INIT(&tag, "author"); |
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1401 mdoc_cd_pre(MDOC_ARGS) |
|
Line 1460 mdoc_cd_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
print_otag(h, TAG_DIV, 0, NULL); |
tag.val = "config"; |
PAIR_CLASS_INIT(&tag, "config"); |
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1414 mdoc_dv_pre(MDOC_ARGS) |
|
Line 1473 mdoc_dv_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "define"); |
tag.val = "define"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1427 mdoc_ev_pre(MDOC_ARGS) |
|
Line 1485 mdoc_ev_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "env"); |
tag.val = "env"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1440 mdoc_er_pre(MDOC_ARGS) |
|
Line 1497 mdoc_er_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "errno"); |
tag.val = "errno"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1455 mdoc_fa_pre(MDOC_ARGS) |
|
Line 1511 mdoc_fa_pre(MDOC_ARGS) |
|
struct htmlpair tag; |
struct htmlpair tag; |
struct tag *t; |
struct tag *t; |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "farg"); |
tag.val = "farg"; |
|
|
|
if (n->parent->tok != MDOC_Fo) { |
if (n->parent->tok != MDOC_Fo) { |
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
Line 1482 mdoc_fa_pre(MDOC_ARGS) |
|
Line 1536 mdoc_fa_pre(MDOC_ARGS) |
|
static int |
static int |
mdoc_fd_pre(MDOC_ARGS) |
mdoc_fd_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
struct roffsu su; |
|
|
if (SEC_SYNOPSIS == n->sec) { |
if (SEC_SYNOPSIS == n->sec) { |
if (n->next && MDOC_Fd != n->next->tok) { |
if (n->next && MDOC_Fd != n->next->tok) { |
tag.key = ATTR_STYLE; |
SCALE_VS_INIT(&su, 1); |
tag.val = "margin-bottom: 1em;"; |
bufcat_su(h, "margin-bottom", &su); |
|
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
} else |
} else |
print_otag(h, TAG_DIV, 0, NULL); |
print_otag(h, TAG_DIV, 0, NULL); |
} |
} |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "macro"); |
tag.val = "macro"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
Line 1504 mdoc_fd_pre(MDOC_ARGS) |
|
Line 1559 mdoc_fd_pre(MDOC_ARGS) |
|
static int |
static int |
mdoc_vt_pre(MDOC_ARGS) |
mdoc_vt_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
struct roffsu su; |
|
|
if (SEC_SYNOPSIS == n->sec) { |
if (SEC_SYNOPSIS == n->sec) { |
if (n->next && MDOC_Vt != n->next->tok) { |
if (n->next && MDOC_Vt != n->next->tok) { |
tag.key = ATTR_STYLE; |
SCALE_VS_INIT(&su, 1); |
tag.val = "margin-bottom: 1em;"; |
bufcat_su(h, "margin-bottom", &su); |
|
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
} else |
} else |
print_otag(h, TAG_DIV, 0, NULL); |
print_otag(h, TAG_DIV, 0, NULL); |
} |
} |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "type"); |
tag.val = "type"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mdoc_ft_pre(MDOC_ARGS) |
mdoc_ft_pre(MDOC_ARGS) |
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
struct roffsu su; |
|
|
if (SEC_SYNOPSIS == n->sec) { |
if (SEC_SYNOPSIS == n->sec) { |
if (n->prev && MDOC_Fo == n->prev->tok) { |
if (n->prev && MDOC_Fo == n->prev->tok) { |
tag.key = ATTR_STYLE; |
SCALE_VS_INIT(&su, 1); |
tag.val = "magin-bottom: 1em;"; |
bufcat_su(h, "margin-top", &su); |
|
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
} else |
} else |
print_otag(h, TAG_DIV, 0, NULL); |
print_otag(h, TAG_DIV, 0, NULL); |
} |
} |
|
|
tag.key = ATTR_CLASS; |
PAIR_CLASS_INIT(&tag, "ftype"); |
tag.val = "type"; |
|
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
return(1); |
return(1); |
} |
} |
|
|
mdoc_fn_pre(MDOC_ARGS) |
mdoc_fn_pre(MDOC_ARGS) |
{ |
{ |
struct tag *t; |
struct tag *t; |
struct htmlpair tag; |
struct htmlpair tag[2]; |
const struct mdoc_node *nn; |
const struct mdoc_node *nn; |
|
char nbuf[BUFSIZ]; |
|
const char *sp, *ep; |
|
int sz, i; |
|
struct roffsu su; |
|
|
if (SEC_SYNOPSIS == n->sec) { |
if (SEC_SYNOPSIS == n->sec) { |
|
SCALE_HS_INIT(&su, INDENT); |
|
bufcat_su(h, "margin-left", &su); |
|
su.scale = -su.scale; |
|
bufcat_su(h, "text-indent", &su); |
if (n->next) { |
if (n->next) { |
tag.key = ATTR_STYLE; |
SCALE_VS_INIT(&su, 1); |
tag.val = "margin-bottom: 1em"; |
bufcat_su(h, "margin-bottom", &su); |
print_otag(h, TAG_DIV, 1, &tag); |
} |
} else |
PAIR_STYLE_INIT(&tag[0], h); |
print_otag(h, TAG_DIV, 0, NULL); |
print_otag(h, TAG_DIV, 1, tag); |
} |
} |
|
|
tag.key = ATTR_CLASS; |
/* Split apart into type and name. */ |
tag.val = "type"; |
assert(n->child->string); |
|
sp = n->child->string; |
|
|
t = print_otag(h, TAG_SPAN, 1, &tag); |
ep = strchr(sp, ' '); |
print_text(h, n->child->string); |
if (NULL != ep) { |
|
PAIR_CLASS_INIT(&tag[0], "ftype"); |
|
t = print_otag(h, TAG_SPAN, 1, tag); |
|
|
|
while (ep) { |
|
sz = MIN((int)(ep - sp), BUFSIZ - 1); |
|
(void)memcpy(nbuf, sp, (size_t)sz); |
|
nbuf[sz] = '\0'; |
|
print_text(h, nbuf); |
|
sp = ++ep; |
|
ep = strchr(sp, ' '); |
|
} |
|
print_tagq(h, t); |
|
} |
|
|
|
PAIR_CLASS_INIT(&tag[0], "fname"); |
|
t = print_otag(h, TAG_SPAN, 1, tag); |
|
|
|
if (sp) { |
|
(void)strlcpy(nbuf, sp, BUFSIZ); |
|
print_text(h, nbuf); |
|
} |
|
|
print_tagq(h, t); |
print_tagq(h, t); |
|
|
h->flags |= HTML_NOSPACE; |
h->flags |= HTML_NOSPACE; |
print_text(h, "("); |
print_text(h, "("); |
|
|
|
bufinit(h); |
|
PAIR_CLASS_INIT(&tag[0], "farg"); |
|
bufcat_style(h, "white-space", "nowrap"); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
|
for (nn = n->child->next; nn; nn = nn->next) { |
for (nn = n->child->next; nn; nn = nn->next) { |
tag.key = ATTR_CLASS; |
i = 1; |
tag.val = "farg"; |
if (SEC_SYNOPSIS == n->sec) |
t = print_otag(h, TAG_SPAN, 1, &tag); |
i = 2; |
|
t = print_otag(h, TAG_SPAN, i, tag); |
print_text(h, nn->string); |
print_text(h, nn->string); |
print_tagq(h, t); |
print_tagq(h, t); |
if (nn->next) |
if (nn->next) |
Line 1581 mdoc_fn_pre(MDOC_ARGS) |
|
Line 1676 mdoc_fn_pre(MDOC_ARGS) |
|
} |
} |
|
|
print_text(h, ")"); |
print_text(h, ")"); |
|
|
if (SEC_SYNOPSIS == n->sec) |
if (SEC_SYNOPSIS == n->sec) |
print_text(h, ";"); |
print_text(h, ";"); |
|
|
Line 1593 mdoc_fn_pre(MDOC_ARGS) |
|
Line 1687 mdoc_fn_pre(MDOC_ARGS) |
|
static int |
static int |
mdoc_sp_pre(MDOC_ARGS) |
mdoc_sp_pre(MDOC_ARGS) |
{ |
{ |
int len; |
int len; |
struct htmlpair tag; |
struct htmlpair tag; |
|
struct roffsu su; |
|
|
switch (n->tok) { |
switch (n->tok) { |
case (MDOC_sp): |
case (MDOC_sp): |
|
/* FIXME: can this have a scaling indicator? */ |
len = n->child ? atoi(n->child->string) : 1; |
len = n->child ? atoi(n->child->string) : 1; |
break; |
break; |
case (MDOC_br): |
case (MDOC_br): |
Line 1608 mdoc_sp_pre(MDOC_ARGS) |
|
Line 1704 mdoc_sp_pre(MDOC_ARGS) |
|
break; |
break; |
} |
} |
|
|
buffmt("height: %dem", len); |
SCALE_VS_INIT(&su, len); |
tag.key = ATTR_STYLE; |
bufcat_su(h, "height", &su); |
tag.val = buf; |
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_DIV, 1, &tag); |
print_otag(h, TAG_DIV, 1, &tag); |
return(1); |
return(1); |
|
|
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_brq_pre(MDOC_ARGS) |
|
{ |
|
|
|
if (MDOC_BODY != n->type) |
|
return(1); |
|
print_text(h, "\\(lC"); |
|
h->flags |= HTML_NOSPACE; |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
mdoc_brq_post(MDOC_ARGS) |
|
{ |
|
|
|
if (MDOC_BODY != n->type) |
|
return; |
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, "\\(rC"); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_lk_pre(MDOC_ARGS) |
|
{ |
|
const struct mdoc_node *nn; |
|
struct htmlpair tag[2]; |
|
|
|
nn = n->child; |
|
|
|
PAIR_CLASS_INIT(&tag[0], "link-ext"); |
|
tag[1].key = ATTR_HREF; |
|
tag[1].val = nn->string; |
|
print_otag(h, TAG_A, 2, tag); |
|
|
|
for (nn = nn->next; nn; nn = nn->next) |
|
print_text(h, nn->string); |
|
|
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_mt_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag[2]; |
|
struct tag *t; |
|
const struct mdoc_node *nn; |
|
|
|
PAIR_CLASS_INIT(&tag[0], "link-mail"); |
|
|
|
for (nn = n->child; nn; nn = nn->next) { |
|
bufinit(h); |
|
bufcat(h, "mailto:"); |
|
bufcat(h, nn->string); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
t = print_otag(h, TAG_A, 2, tag); |
|
print_text(h, nn->string); |
|
print_tagq(h, t); |
|
} |
|
|
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_fo_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
if (MDOC_BODY == n->type) { |
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, "("); |
|
h->flags |= HTML_NOSPACE; |
|
return(1); |
|
} else if (MDOC_BLOCK == n->type) |
|
return(1); |
|
|
|
PAIR_CLASS_INIT(&tag, "fname"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
mdoc_fo_post(MDOC_ARGS) |
|
{ |
|
if (MDOC_BODY != n->type) |
|
return; |
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, ")"); |
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, ";"); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_in_pre(MDOC_ARGS) |
|
{ |
|
const struct mdoc_node *nn; |
|
struct tag *t; |
|
struct htmlpair tag[2]; |
|
int i; |
|
struct roffsu su; |
|
|
|
if (SEC_SYNOPSIS == n->sec) { |
|
if (n->next && MDOC_In != n->next->tok) { |
|
SCALE_VS_INIT(&su, 1); |
|
bufcat_su(h, "margin-bottom", &su); |
|
PAIR_STYLE_INIT(&tag[0], h); |
|
print_otag(h, TAG_DIV, 1, tag); |
|
} else |
|
print_otag(h, TAG_DIV, 0, NULL); |
|
} |
|
|
|
PAIR_CLASS_INIT(&tag[0], "includes"); |
|
print_otag(h, TAG_SPAN, 1, tag); |
|
|
|
if (SEC_SYNOPSIS == n->sec) |
|
print_text(h, "#include"); |
|
|
|
print_text(h, "<"); |
|
h->flags |= HTML_NOSPACE; |
|
|
|
/* XXX -- see warning in termp_in_post(). */ |
|
|
|
for (nn = n->child; nn; nn = nn->next) { |
|
PAIR_CLASS_INIT(&tag[0], "link-includes"); |
|
i = 1; |
|
if (h->base_includes) { |
|
buffmt_includes(h, nn->string); |
|
tag[i].key = ATTR_HREF; |
|
tag[i++].val = h->buf; |
|
} |
|
t = print_otag(h, TAG_A, i, tag); |
|
print_mdoc_node(m, nn, h); |
|
print_tagq(h, t); |
|
} |
|
|
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, ">"); |
|
|
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_ic_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
PAIR_CLASS_INIT(&tag, "cmd"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_rv_pre(MDOC_ARGS) |
|
{ |
|
const struct mdoc_node *nn; |
|
struct htmlpair tag; |
|
struct tag *t; |
|
|
|
print_otag(h, TAG_DIV, 0, NULL); |
|
print_text(h, "The"); |
|
|
|
for (nn = n->child; nn; nn = nn->next) { |
|
PAIR_CLASS_INIT(&tag, "fname"); |
|
t = print_otag(h, TAG_SPAN, 1, &tag); |
|
print_text(h, nn->string); |
|
print_tagq(h, t); |
|
|
|
h->flags |= HTML_NOSPACE; |
|
if (nn->next && NULL == nn->next->next) |
|
print_text(h, "(), and"); |
|
else if (nn->next) |
|
print_text(h, "(),"); |
|
else |
|
print_text(h, "()"); |
|
} |
|
|
|
if (n->child->next) |
|
print_text(h, "functions return"); |
|
else |
|
print_text(h, "function returns"); |
|
|
|
print_text(h, "the value 0 if successful; otherwise the value " |
|
"-1 is returned and the global variable"); |
|
|
|
PAIR_CLASS_INIT(&tag, "var"); |
|
t = print_otag(h, TAG_SPAN, 1, &tag); |
|
print_text(h, "errno"); |
|
print_tagq(h, t); |
|
print_text(h, "is set to indicate the error."); |
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_va_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
PAIR_CLASS_INIT(&tag, "var"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_bq_pre(MDOC_ARGS) |
|
{ |
|
|
|
if (MDOC_BODY != n->type) |
|
return(1); |
|
print_text(h, "\\(lB"); |
|
h->flags |= HTML_NOSPACE; |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
mdoc_bq_post(MDOC_ARGS) |
|
{ |
|
|
|
if (MDOC_BODY != n->type) |
|
return; |
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, "\\(rB"); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_ap_pre(MDOC_ARGS) |
|
{ |
|
|
|
h->flags |= HTML_NOSPACE; |
|
print_text(h, "\\(aq"); |
|
h->flags |= HTML_NOSPACE; |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_bf_pre(MDOC_ARGS) |
|
{ |
|
int i; |
|
struct htmlpair tag[2]; |
|
struct roffsu su; |
|
|
|
if (MDOC_HEAD == n->type) |
|
return(0); |
|
else if (MDOC_BLOCK != n->type) |
|
return(1); |
|
|
|
PAIR_CLASS_INIT(&tag[0], "lit"); |
|
|
|
if (n->head->child) { |
|
if ( ! strcmp("Em", n->head->child->string)) |
|
PAIR_CLASS_INIT(&tag[0], "emph"); |
|
else if ( ! strcmp("Sy", n->head->child->string)) |
|
PAIR_CLASS_INIT(&tag[0], "symb"); |
|
else if ( ! strcmp("Li", n->head->child->string)) |
|
PAIR_CLASS_INIT(&tag[0], "lit"); |
|
} else { |
|
assert(n->args); |
|
for (i = 0; i < (int)n->args->argc; i++) |
|
switch (n->args->argv[i].arg) { |
|
case (MDOC_Symbolic): |
|
PAIR_CLASS_INIT(&tag[0], "symb"); |
|
break; |
|
case (MDOC_Literal): |
|
PAIR_CLASS_INIT(&tag[0], "lit"); |
|
break; |
|
case (MDOC_Emphasis): |
|
PAIR_CLASS_INIT(&tag[0], "emph"); |
|
break; |
|
default: |
|
break; |
|
} |
|
} |
|
|
|
/* FIXME: div's have spaces stripped--we want them. */ |
|
|
|
bufcat_style(h, "display", "inline"); |
|
SCALE_HS_INIT(&su, 1); |
|
bufcat_su(h, "margin-right", &su); |
|
PAIR_STYLE_INIT(&tag[1], h); |
|
print_otag(h, TAG_DIV, 2, tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_ms_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
PAIR_CLASS_INIT(&tag, "symb"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_pf_pre(MDOC_ARGS) |
|
{ |
|
|
|
h->flags |= HTML_IGNDELIM; |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
mdoc_pf_post(MDOC_ARGS) |
|
{ |
|
|
|
h->flags &= ~HTML_IGNDELIM; |
|
h->flags |= HTML_NOSPACE; |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_rs_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
struct roffsu su; |
|
|
|
if (MDOC_BLOCK != n->type) |
|
return(1); |
|
|
|
if (n->prev && SEC_SEE_ALSO == n->sec) { |
|
SCALE_VS_INIT(&su, 1); |
|
bufcat_su(h, "margin-top", &su); |
|
PAIR_STYLE_INIT(&tag, h); |
|
print_otag(h, TAG_DIV, 1, &tag); |
|
} |
|
|
|
PAIR_CLASS_INIT(&tag, "ref"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_li_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
PAIR_CLASS_INIT(&tag, "lit"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_sy_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
PAIR_CLASS_INIT(&tag, "symb"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_bt_pre(MDOC_ARGS) |
|
{ |
|
|
|
print_text(h, "is currently in beta test."); |
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_ud_pre(MDOC_ARGS) |
|
{ |
|
|
|
print_text(h, "currently under development."); |
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_lb_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
if (SEC_SYNOPSIS == n->sec) |
|
print_otag(h, TAG_DIV, 0, NULL); |
|
PAIR_CLASS_INIT(&tag, "lib"); |
|
print_otag(h, TAG_SPAN, 1, &tag); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc__x_pre(MDOC_ARGS) |
|
{ |
|
struct htmlpair tag; |
|
|
|
switch (n->tok) { |
|
case(MDOC__A): |
|
PAIR_CLASS_INIT(&tag, "ref-auth"); |
|
break; |
|
case(MDOC__B): |
|
PAIR_CLASS_INIT(&tag, "ref-book"); |
|
break; |
|
case(MDOC__C): |
|
PAIR_CLASS_INIT(&tag, "ref-city"); |
|
break; |
|
case(MDOC__D): |
|
PAIR_CLASS_INIT(&tag, "ref-date"); |
|
break; |
|
case(MDOC__I): |
|
PAIR_CLASS_INIT(&tag, "ref-issue"); |
|
break; |
|
case(MDOC__J): |
|
PAIR_CLASS_INIT(&tag, "ref-jrnl"); |
|
break; |
|
case(MDOC__N): |
|
PAIR_CLASS_INIT(&tag, "ref-num"); |
|
break; |
|
case(MDOC__O): |
|
PAIR_CLASS_INIT(&tag, "ref-opt"); |
|
break; |
|
case(MDOC__P): |
|
PAIR_CLASS_INIT(&tag, "ref-page"); |
|
break; |
|
case(MDOC__Q): |
|
PAIR_CLASS_INIT(&tag, "ref-corp"); |
|
break; |
|
case(MDOC__R): |
|
PAIR_CLASS_INIT(&tag, "ref-rep"); |
|
break; |
|
case(MDOC__T): |
|
PAIR_CLASS_INIT(&tag, "ref-title"); |
|
print_text(h, "\\(lq"); |
|
h->flags |= HTML_NOSPACE; |
|
break; |
|
case(MDOC__V): |
|
PAIR_CLASS_INIT(&tag, "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 ? "," : "."); |
} |
} |