man_html.c revision 698f87a48e2e945bfe5493ce168e0d0ae1cedd5c
/* $Id: man_html.c,v 1.90 2013/10/17 20:54:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mandoc.h"
#include "out.h"
#include "html.h"
#include "man.h"
#include "main.h"
/* TODO: preserve ident widths. */
/* FIXME: have PD set the default vspace width. */
#define INDENT 5
const struct man_node *n, \
struct html *h
struct mhtml {
int fl;
};
struct htmlman {
};
static void print_bvspace(struct html *,
const struct man_node *);
static void print_man_head(MAN_ARGS);
static void print_man_nodelist(MAN_ARGS);
static void print_man_node(MAN_ARGS);
struct roffsu *);
static int man_HP_pre(MAN_ARGS);
static int man_IP_pre(MAN_ARGS);
static int man_OP_pre(MAN_ARGS);
static int man_PP_pre(MAN_ARGS);
static int man_RS_pre(MAN_ARGS);
static int man_SH_pre(MAN_ARGS);
static int man_SM_pre(MAN_ARGS);
static int man_SS_pre(MAN_ARGS);
static int man_UR_pre(MAN_ARGS);
static int man_alt_pre(MAN_ARGS);
static int man_br_pre(MAN_ARGS);
static int man_ign_pre(MAN_ARGS);
static int man_in_pre(MAN_ARGS);
static int man_literal_pre(MAN_ARGS);
static void man_root_post(MAN_ARGS);
static void man_root_pre(MAN_ARGS);
};
/*
* Printing leading vertical space before a block.
* This is used for the paragraph macros.
* The rules are pretty simple, since there's very little nesting going
* then don't emit vertical space. If we are (RS), then do. If not the
* first, print it.
*/
static void
{
return;
return;
}
void
{
putchar('\n');
}
static void
{
if ( ! (HTML_FRAGMENT & h->oflags)) {
print_gen_decls(h);
print_tagq(h, tt);
} else
print_tagq(h, t);
}
/* ARGSUSED */
static void
{
print_gen_head(h);
print_text(h, h->buf);
}
static void
{
if (n->next)
}
static void
{
int child;
struct tag *t;
child = 1;
switch (n->type) {
case (MAN_ROOT):
break;
case (MAN_TEXT):
/*
* If we have a blank line, output a vertical space.
* If we have a space as the first character, break
* before printing the line's data.
*/
if ('\0' == *n->string) {
return;
}
print_text(h, n->string);
return;
case (MAN_EQN):
break;
case (MAN_TBL):
/*
* This will take care of initialising all of the table
* state data for the first table, then tearing it down
* for the last one.
*/
return;
default:
/*
* Close out scope of font prior to opening a macro
* scope.
*/
if (HTMLFONT_NONE != h->metac) {
h->metac = HTMLFONT_NONE;
}
/*
* Close out the current table, if it's open, and unset
* the "meta" table state. This will be reopened on the
* next table element.
*/
if (h->tblt) {
print_tblclose(h);
}
break;
}
/* This will automatically close out any font scope. */
print_stagq(h, t);
switch (n->type) {
case (MAN_ROOT):
break;
case (MAN_EQN):
break;
default:
break;
}
}
static int
{
return(0);
return(1);
return(0);
}
/* ARGSUSED */
static void
{
b[0] = 0;
print_text(h, title);
print_stagq(h, tt);
print_text(h, b);
print_stagq(h, tt);
print_text(h, title);
print_tagq(h, t);
}
/* ARGSUSED */
static void
{
print_stagq(h, tt);
print_tagq(h, t);
}
/* ARGSUSED */
static int
{
} else
bufinit(h);
PAIR_STYLE_INIT(&tag, h);
/* So the div isn't empty: */
print_text(h, "\\~");
return(0);
}
/* ARGSUSED */
static int
{
return(1);
return(1);
return(1);
}
/* ARGSUSED */
static int
{
int i, savelit;
struct tag *t;
t = NULL;
switch (n->tok) {
case (MAN_BI):
break;
case (MAN_IB):
break;
case (MAN_RI):
break;
case (MAN_IR):
break;
case (MAN_BR):
break;
case (MAN_RB):
break;
default:
abort();
/* NOTREACHED */
}
if (i)
h->flags |= HTML_NOSPACE;
if (t)
print_tagq(h, t);
}
if (savelit)
return(0);
}
/* ARGSUSED */
static int
{
return(1);
}
/* ARGSUSED */
static int
{
return(1);
return(1);
return(1);
}
/* ARGSUSED */
static int
{
return(0);
print_bvspace(h, n);
return(1);
}
/* ARGSUSED */
static int
{
return(1);
return(1);
}
/* FIXME: width specification. */
/* For IP, only print the first header element. */
/* For TP, only print next-line header elements. */
return(0);
}
/* ARGSUSED */
static int
{
return(0);
return(1);
bufinit(h);
print_bvspace(h, n);
PAIR_STYLE_INIT(&tag, h);
return(1);
}
/* ARGSUSED */
static int
{
print_text(h, "[");
h->flags |= HTML_NOSPACE;
print_text(h, n->string);
}
print_stagq(h, tt);
}
print_stagq(h, tt);
h->flags |= HTML_NOSPACE;
print_text(h, "]");
return(0);
}
/* ARGSUSED */
static int
{
return(1);
}
/* ARGSUSED */
static int
{
return(1);
}
/* ARGSUSED */
static int
{
} else
return(0);
}
/* ARGSUSED */
static int
{
return(0);
}
/* ARGSUSED */
static int
{
return(0);
}
/* ARGSUSED */
static int
{
return(0);
return(1);
bufinit(h);
PAIR_STYLE_INIT(&tag, h);
return(1);
}
/* ARGSUSED */
static int
{
n = n->child;
if (n->nchild) {
}
n = n->next;
return(0);
}