version 1.92, 2010/07/02 12:54:33 |
version 1.99, 2010/07/23 00:08:57 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
#include "out.h" |
#include "out.h" |
#include "html.h" |
#include "html.h" |
#include "regs.h" |
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "main.h" |
#include "main.h" |
|
|
Line 73 static int mdoc_aq_pre(MDOC_ARGS); |
|
Line 72 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 int mdoc_bf_pre(MDOC_ARGS); |
|
static void mdoc_bk_post(MDOC_ARGS); |
|
static int mdoc_bk_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 void mdoc_bq_post(MDOC_ARGS); |
Line 124 static int mdoc_pq_pre(MDOC_ARGS); |
|
Line 125 static int mdoc_pq_pre(MDOC_ARGS); |
|
static int mdoc_rs_pre(MDOC_ARGS); |
static int mdoc_rs_pre(MDOC_ARGS); |
static int mdoc_rv_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_sm_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); |
Line 208 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 210 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{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 */ |
{mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */ |
{mdoc_ms_pre, NULL}, /* Ms */ |
{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 */ |
Line 226 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 228 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{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 */ /* FIXME - no idea. */ |
{mdoc_sm_pre, NULL}, /* Sm */ |
{mdoc_sx_pre, NULL}, /* Sx */ |
{mdoc_sx_pre, NULL}, /* Sx */ |
{mdoc_sy_pre, NULL}, /* Sy */ |
{mdoc_sy_pre, NULL}, /* Sy */ |
{NULL, NULL}, /* Tn */ |
{NULL, NULL}, /* Tn */ |
Line 237 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 239 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{NULL, NULL}, /* Fc */ |
{NULL, NULL}, /* Fc */ |
{mdoc_op_pre, mdoc_op_post}, /* Oo */ |
{mdoc_op_pre, mdoc_op_post}, /* Oo */ |
{NULL, NULL}, /* Oc */ |
{NULL, NULL}, /* Oc */ |
{NULL, NULL}, /* Bk */ |
{mdoc_bk_pre, mdoc_bk_post}, /* Bk */ |
{NULL, NULL}, /* Ek */ |
{NULL, NULL}, /* Ek */ |
{mdoc_bt_pre, NULL}, /* Bt */ |
{mdoc_bt_pre, NULL}, /* Bt */ |
{NULL, NULL}, /* Hf */ |
{NULL, NULL}, /* Hf */ |
Line 442 print_mdoc_node(MDOC_ARGS) |
|
Line 444 print_mdoc_node(MDOC_ARGS) |
|
break; |
break; |
} |
} |
|
|
|
if (HTML_KEEP & h->flags) { |
|
if (n->prev && n->prev->line != n->line) { |
|
h->flags &= ~HTML_KEEP; |
|
h->flags |= HTML_PREKEEP; |
|
} else if (NULL == n->prev) { |
|
if (n->parent && n->parent->line != n->line) { |
|
h->flags &= ~HTML_KEEP; |
|
h->flags |= HTML_PREKEEP; |
|
} |
|
} |
|
} |
|
|
if (child && n->child) |
if (child && n->child) |
print_mdoc_nodelist(m, n->child, h); |
print_mdoc_nodelist(m, n->child, h); |
|
|
Line 1074 mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struc |
|
Line 1088 mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struc |
|
static int |
static int |
mdoc_it_pre(MDOC_ARGS) |
mdoc_it_pre(MDOC_ARGS) |
{ |
{ |
int i, wp, comp; |
int i, comp; |
const struct mdoc_node *bl, *nn; |
const struct mdoc_node *bl, *nn; |
struct roffsu width, offs; |
struct roffsu width, offs; |
enum mdoc_list type; |
enum mdoc_list type; |
Line 1116 mdoc_it_pre(MDOC_ARGS) |
|
Line 1130 mdoc_it_pre(MDOC_ARGS) |
|
if (bl->data.Bl->width) |
if (bl->data.Bl->width) |
a2width(bl->data.Bl->width, &width); |
a2width(bl->data.Bl->width, &width); |
|
|
wp = -1; |
|
for (i = 0; bl->args && i < (int)bl->args->argc; i++) |
|
switch (bl->args->argv[i].arg) { |
|
case (MDOC_Column): |
|
wp = i; /* Save for later. */ |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* Override width in some cases. */ |
/* Override width in some cases. */ |
|
|
switch (type) { |
switch (type) { |
Line 1149 mdoc_it_pre(MDOC_ARGS) |
|
Line 1153 mdoc_it_pre(MDOC_ARGS) |
|
for (i = 0; nn && nn != n; nn = nn->next) |
for (i = 0; nn && nn != n; nn = nn->next) |
if (MDOC_BODY == nn->type) |
if (MDOC_BODY == nn->type) |
i++; |
i++; |
if (i < (int)bl->args->argv[wp].sz) |
if (i < (int)bl->data.Bl->ncols) |
a2width(bl->args->argv[wp].value[i], &width); |
a2width(bl->data.Bl->cols[i], &width); |
} |
} |
|
|
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
Line 1719 mdoc_fn_pre(MDOC_ARGS) |
|
Line 1723 mdoc_fn_pre(MDOC_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
|
mdoc_sm_pre(MDOC_ARGS) |
|
{ |
|
|
|
assert(n->child && MDOC_TEXT == n->child->type); |
|
if (0 == strcmp("on", n->child->string)) { |
|
/* FIXME: no p->col to check... */ |
|
h->flags &= ~HTML_NOSPACE; |
|
h->flags &= ~HTML_NONOSPACE; |
|
} else |
|
h->flags |= HTML_NONOSPACE; |
|
|
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
mdoc_sp_pre(MDOC_ARGS) |
mdoc_sp_pre(MDOC_ARGS) |
{ |
{ |
int len; |
int len; |
Line 1734 mdoc_sp_pre(MDOC_ARGS) |
|
Line 1755 mdoc_sp_pre(MDOC_ARGS) |
|
len = 0; |
len = 0; |
break; |
break; |
default: |
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; |
len = 1; |
break; |
break; |
} |
} |
Line 2236 mdoc__x_post(MDOC_ARGS) |
|
Line 2262 mdoc__x_post(MDOC_ARGS) |
|
|
|
h->flags |= HTML_NOSPACE; |
h->flags |= HTML_NOSPACE; |
print_text(h, n->next ? "," : "."); |
print_text(h, n->next ? "," : "."); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
mdoc_bk_pre(MDOC_ARGS) |
|
{ |
|
|
|
switch (n->type) { |
|
case (MDOC_BLOCK): |
|
break; |
|
case (MDOC_HEAD): |
|
return(0); |
|
case (MDOC_BODY): |
|
h->flags |= HTML_PREKEEP; |
|
break; |
|
default: |
|
abort(); |
|
/* NOTREACHED */ |
|
} |
|
|
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
mdoc_bk_post(MDOC_ARGS) |
|
{ |
|
|
|
if (MDOC_BODY == n->type) |
|
h->flags &= ~(HTML_KEEP | HTML_PREKEEP); |
} |
} |