version 1.44, 2009/10/31 06:10:58 |
version 1.56, 2010/04/03 14:25:12 |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
#ifdef HAVE_CONFIG_H |
|
#include "config.h" |
|
#endif |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> |
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
|
const struct mdoc_node *n, \ |
const struct mdoc_node *n, \ |
struct html *h |
struct html *h |
|
|
|
#ifndef MIN |
|
#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) |
|
#endif |
|
|
struct htmlmdoc { |
struct htmlmdoc { |
int (*pre)(MDOC_ARGS); |
int (*pre)(MDOC_ARGS); |
void (*post)(MDOC_ARGS); |
void (*post)(MDOC_ARGS); |
Line 126 static int mdoc_vt_pre(MDOC_ARGS); |
|
Line 133 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); |
|
|
#ifdef __linux__ |
|
extern size_t strlcpy(char *, const char *, size_t); |
|
extern size_t strlcat(char *, const char *, size_t); |
|
#endif |
|
|
|
static const struct htmlmdoc mdocs[MDOC_MAX] = { |
static const struct htmlmdoc mdocs[MDOC_MAX] = { |
{mdoc_ap_pre, NULL}, /* Ap */ |
{mdoc_ap_pre, NULL}, /* Ap */ |
{NULL, NULL}, /* Dd */ |
{NULL, NULL}, /* Dd */ |
Line 198 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
Line 200 static const struct htmlmdoc mdocs[MDOC_MAX] = { |
|
{NULL, NULL}, /* Dc */ |
{NULL, NULL}, /* Dc */ |
{mdoc_dq_pre, mdoc_dq_post}, /* 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 */ /* FIXME: no space */ |
{NULL, NULL}, /* Ef */ |
{NULL, NULL}, /* Ef */ |
{mdoc_em_pre, NULL}, /* Em */ |
{mdoc_em_pre, NULL}, /* Em */ |
{NULL, NULL}, /* Eo */ |
{NULL, NULL}, /* Eo */ |
Line 264 html_mdoc(void *arg, const struct mdoc *m) |
|
Line 266 html_mdoc(void *arg, const struct mdoc *m) |
|
|
|
h = (struct html *)arg; |
h = (struct html *)arg; |
|
|
print_gen_doctype(h); |
print_gen_decls(h); |
t = print_otag(h, TAG_HTML, 0, NULL); |
t = print_otag(h, TAG_HTML, 0, NULL); |
print_mdoc(mdoc_meta(m), mdoc_node(m), h); |
print_mdoc(mdoc_meta(m), mdoc_node(m), h); |
print_tagq(h, t); |
print_tagq(h, t); |
Line 424 print_mdoc_node(MDOC_ARGS) |
|
Line 426 print_mdoc_node(MDOC_ARGS) |
|
break; |
break; |
case (MDOC_TEXT): |
case (MDOC_TEXT): |
print_text(h, n->string); |
print_text(h, n->string); |
break; |
return; |
default: |
default: |
if (mdocs[n->tok].pre) |
if (mdocs[n->tok].pre) |
child = (*mdocs[n->tok].pre)(m, n, h); |
child = (*mdocs[n->tok].pre)(m, n, h); |
Line 441 print_mdoc_node(MDOC_ARGS) |
|
Line 443 print_mdoc_node(MDOC_ARGS) |
|
case (MDOC_ROOT): |
case (MDOC_ROOT): |
mdoc_root_post(m, n, h); |
mdoc_root_post(m, n, h); |
break; |
break; |
case (MDOC_TEXT): |
|
break; |
|
default: |
default: |
if (mdocs[n->tok].post) |
if (mdocs[n->tok].post) |
(*mdocs[n->tok].post)(m, n, h); |
(*mdocs[n->tok].post)(m, n, h); |
Line 663 mdoc_fl_pre(MDOC_ARGS) |
|
Line 663 mdoc_fl_pre(MDOC_ARGS) |
|
|
|
PAIR_CLASS_INIT(&tag, "flag"); |
PAIR_CLASS_INIT(&tag, "flag"); |
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
if (MDOC_Fl == n->tok) { |
|
print_text(h, "\\-"); |
/* `Cm' has no leading hyphen. */ |
|
|
|
if (MDOC_Cm == n->tok) |
|
return(1); |
|
|
|
print_text(h, "\\-"); |
|
|
|
/* A blank `Fl' should incur a subsequent space. */ |
|
|
|
if (n->child) |
h->flags |= HTML_NOSPACE; |
h->flags |= HTML_NOSPACE; |
} |
|
return(1); |
return(1); |
} |
} |
|
|
Line 725 mdoc_nm_pre(MDOC_ARGS) |
|
Line 734 mdoc_nm_pre(MDOC_ARGS) |
|
{ |
{ |
struct htmlpair tag; |
struct htmlpair tag; |
|
|
if ( ! (HTML_NEWLINE & h->flags)) |
if (SEC_SYNOPSIS == n->sec && n->prev) { |
if (SEC_SYNOPSIS == n->sec) { |
bufcat_style(h, "clear", "both"); |
bufcat_style(h, "clear", "both"); |
PAIR_STYLE_INIT(&tag, h); |
PAIR_STYLE_INIT(&tag, h); |
print_otag(h, TAG_BR, 1, &tag); |
print_otag(h, TAG_BR, 1, &tag); |
} |
} |
|
|
|
PAIR_CLASS_INIT(&tag, "name"); |
PAIR_CLASS_INIT(&tag, "name"); |
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |
Line 748 mdoc_xr_pre(MDOC_ARGS) |
|
Line 756 mdoc_xr_pre(MDOC_ARGS) |
|
struct htmlpair tag[2]; |
struct htmlpair tag[2]; |
const struct mdoc_node *nn; |
const struct mdoc_node *nn; |
|
|
|
if (NULL == n->child) |
|
return(0); |
|
|
PAIR_CLASS_INIT(&tag[0], "link-man"); |
PAIR_CLASS_INIT(&tag[0], "link-man"); |
|
|
if (h->base_man) { |
if (h->base_man) { |
Line 810 mdoc_xx_pre(MDOC_ARGS) |
|
Line 821 mdoc_xx_pre(MDOC_ARGS) |
|
pp = "BSDI BSD/OS"; |
pp = "BSDI BSD/OS"; |
break; |
break; |
case (MDOC_Dx): |
case (MDOC_Dx): |
pp = "DragonFlyBSD"; |
pp = "DragonFly"; |
break; |
break; |
case (MDOC_Fx): |
case (MDOC_Fx): |
pp = "FreeBSD"; |
pp = "FreeBSD"; |
Line 951 mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w |
|
Line 962 mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w |
|
|
|
switch (type) { |
switch (type) { |
case (MDOC_Item): |
case (MDOC_Item): |
/* FALLTHROUGH */ |
|
case (MDOC_Ohang): |
|
return(0); |
return(0); |
|
case (MDOC_Ohang): |
|
print_otag(h, TAG_DIV, 0, &tag); |
|
return(1); |
case (MDOC_Column): |
case (MDOC_Column): |
bufcat_su(h, "min-width", width); |
bufcat_su(h, "min-width", width); |
bufcat_style(h, "clear", "none"); |
bufcat_style(h, "clear", "none"); |
Line 1067 mdoc_it_pre(MDOC_ARGS) |
|
Line 1079 mdoc_it_pre(MDOC_ARGS) |
|
/* Override width in some cases. */ |
/* Override width in some cases. */ |
|
|
switch (type) { |
switch (type) { |
|
case (MDOC_Ohang): |
|
/* FALLTHROUGH */ |
case (MDOC_Item): |
case (MDOC_Item): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Inset): |
case (MDOC_Inset): |
Line 1572 mdoc_vt_pre(MDOC_ARGS) |
|
Line 1586 mdoc_vt_pre(MDOC_ARGS) |
|
struct htmlpair tag; |
struct htmlpair tag; |
struct roffsu su; |
struct roffsu su; |
|
|
if (SEC_SYNOPSIS == n->sec) { |
if (MDOC_BLOCK == n->type) { |
if (n->next && MDOC_Vt != n->next->tok) { |
if (n->prev && MDOC_Vt != n->prev->tok) { |
SCALE_VS_INIT(&su, 1); |
SCALE_VS_INIT(&su, 1); |
bufcat_su(h, "margin-bottom", &su); |
bufcat_su(h, "margin-top", &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); |
} else |
} else |
print_otag(h, TAG_DIV, 0, NULL); |
print_otag(h, TAG_DIV, 0, NULL); |
} |
|
|
return(1); |
|
} else if (MDOC_HEAD == n->type) |
|
return(0); |
|
|
PAIR_CLASS_INIT(&tag, "type"); |
PAIR_CLASS_INIT(&tag, "type"); |
print_otag(h, TAG_SPAN, 1, &tag); |
print_otag(h, TAG_SPAN, 1, &tag); |