version 1.19, 2008/12/10 00:52:46 |
version 1.24, 2008/12/10 13:41:58 |
Line 72 static int html_begin(struct md_mbuf *, |
|
Line 72 static int html_begin(struct md_mbuf *, |
|
const struct md_args *, |
const struct md_args *, |
const struct tm *, |
const struct tm *, |
const char *, const char *, |
const char *, const char *, |
enum roffmsec, const char *); |
enum roffmsec, enum roffvol); |
static int html_printargs(struct md_mbuf *, int, |
static int html_printargs(struct md_mbuf *, int, |
const char *, const int *, |
const char *, const int *, |
const char **, size_t *); |
const char **, size_t *); |
static int html_end(struct md_mbuf *, |
static int html_end(struct md_mbuf *, |
const struct md_args *); |
const struct md_args *, |
|
const struct tm *, |
|
const char *, const char *, |
|
enum roffmsec, enum roffvol); |
static int html_blocktagname(struct md_mbuf *, |
static int html_blocktagname(struct md_mbuf *, |
const struct md_args *, int, |
const struct md_args *, int, |
struct htmlq *, const int *, |
struct htmlq *, const int *, |
Line 382 html_aputln(struct md_mbuf *mbuf, enum ml_scope scope, |
|
Line 385 html_aputln(struct md_mbuf *mbuf, enum ml_scope scope, |
|
static int |
static int |
html_begin(struct md_mbuf *mbuf, const struct md_args *args, |
html_begin(struct md_mbuf *mbuf, const struct md_args *args, |
const struct tm *tm, const char *os, |
const struct tm *tm, const char *os, |
const char *name, enum roffmsec msec, const char *vol) |
const char *name, enum roffmsec msec, enum roffvol vol) |
{ |
{ |
|
enum roffvol bvol; |
struct html_pair attr[4]; |
struct html_pair attr[4]; |
char ts[32]; |
char ts[32], title[64]; |
int i; |
int i; |
|
|
(void)snprintf(ts, sizeof(ts), "%s(%s)", |
(void)snprintf(ts, sizeof(ts), "%s(%s)", |
name, roff_msecname(msec)); |
name, roff_msecname(msec)); |
|
|
|
if (vol >= ROFF_ARCH_START) { |
|
switch (msec) { |
|
case(ROFF_MSEC_1): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_6): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_7): |
|
bvol = ROFF_VOL_URM; |
|
break; |
|
case(ROFF_MSEC_2): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_3): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_3p): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_4): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_5): |
|
bvol = ROFF_VOL_PRM; |
|
break; |
|
case(ROFF_MSEC_8): |
|
bvol = ROFF_VOL_PRM; |
|
break; |
|
case(ROFF_MSEC_9): |
|
bvol = ROFF_VOL_KM; |
|
break; |
|
case(ROFF_MSEC_UNASS): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_DRAFT): |
|
/* FALLTHROUGH */ |
|
case(ROFF_MSEC_PAPER): |
|
bvol = ROFF_VOL_NONE; |
|
break; |
|
default: |
|
abort(); |
|
/* NOTREACHED */ |
|
} |
|
|
|
(void)snprintf(title, sizeof(title), "%s (%s)", |
|
roff_volname(bvol), roff_volname(vol)); |
|
} else |
|
(void)snprintf(title, sizeof(title), "%s", roff_volname(vol)); |
|
|
|
|
i = 0; |
i = 0; |
|
|
if ( ! html_typeput(mbuf, HTML_TYPE_4_01_STRICT, NULL)) |
if ( ! html_typeput(mbuf, HTML_TYPE_4_01_STRICT, NULL)) |
Line 431 html_begin(struct md_mbuf *mbuf, const struct md_args |
|
Line 479 html_begin(struct md_mbuf *mbuf, const struct md_args |
|
HTML_TAG_STYLE, 1, attr)) |
HTML_TAG_STYLE, 1, attr)) |
return(0); |
return(0); |
if ( ! html_commentput(mbuf, ML_OPEN, NULL)) |
if ( ! html_commentput(mbuf, ML_OPEN, NULL)) |
return(NULL); |
return(0); |
|
|
if ( ! html_loadcss(mbuf, args->params.html.css)) |
if ( ! html_loadcss(mbuf, args->params.html.css)) |
return(0); |
return(0); |
|
|
if ( ! html_commentput(mbuf, ML_CLOSE, NULL)) |
if ( ! html_commentput(mbuf, ML_CLOSE, NULL)) |
return(NULL); |
return(0); |
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_STYLE)) |
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_STYLE)) |
return(0); |
return(0); |
} else { |
} else { |
Line 466 html_begin(struct md_mbuf *mbuf, const struct md_args |
|
Line 514 html_begin(struct md_mbuf *mbuf, const struct md_args |
|
|
|
attr[0].attr = HTML_ATTR_WIDTH; |
attr[0].attr = HTML_ATTR_WIDTH; |
attr[0].val = "100%"; |
attr[0].val = "100%"; |
|
attr[1].attr = HTML_ATTR_CLASS; |
|
attr[1].val = "header-table"; |
|
|
if ( ! html_aputln(mbuf, ML_OPEN, i++, HTML_TAG_TABLE, 1, attr)) |
if ( ! html_aputln(mbuf, ML_OPEN, i++, HTML_TAG_TABLE, 2, attr)) |
return(0); |
return(0); |
if ( ! html_tputln(mbuf, ML_OPEN, i++, HTML_TAG_TR)) |
if ( ! html_tputln(mbuf, ML_OPEN, i++, HTML_TAG_TR)) |
return(0); |
return(0); |
|
|
if ( ! html_tputln(mbuf, ML_OPEN, i, HTML_TAG_TD)) |
attr[0].attr = HTML_ATTR_ALIGN; |
|
attr[0].val = "left"; |
|
attr[1].attr = HTML_ATTR_CLASS; |
|
attr[1].val = "header-section"; |
|
|
|
if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) |
return(0); |
return(0); |
if ( ! ml_putstring(mbuf, ts, NULL)) |
if ( ! ml_putstring(mbuf, ts, NULL)) |
return(0); |
return(0); |
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) |
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) |
return(0); |
return(0); |
|
|
if ( ! html_tputln(mbuf, ML_OPEN, i, HTML_TAG_TD)) |
attr[0].attr = HTML_ATTR_ALIGN; |
|
attr[0].val = "center"; |
|
attr[1].attr = HTML_ATTR_CLASS; |
|
attr[1].val = "header-volume"; |
|
|
|
if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) |
return(0); |
return(0); |
/* TODO: middle. */ |
if ( ! ml_putstring(mbuf, title, NULL)) |
|
return(0); |
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) |
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) |
return(0); |
return(0); |
|
|
if ( ! html_tputln(mbuf, ML_OPEN, i, HTML_TAG_TD)) |
attr[0].attr = HTML_ATTR_ALIGN; |
|
attr[0].val = "right"; |
|
attr[1].attr = HTML_ATTR_CLASS; |
|
attr[1].val = "header-section"; |
|
|
|
if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) |
return(0); |
return(0); |
if ( ! ml_putstring(mbuf, ts, NULL)) |
if ( ! ml_putstring(mbuf, ts, NULL)) |
return(0); |
return(0); |
Line 500 html_begin(struct md_mbuf *mbuf, const struct md_args |
|
Line 566 html_begin(struct md_mbuf *mbuf, const struct md_args |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
html_end(struct md_mbuf *mbuf, const struct md_args *args) |
html_end(struct md_mbuf *mbuf, const struct md_args *args, |
|
const struct tm *tm, const char *os, |
|
const char *name, enum roffmsec msec, enum roffvol vol) |
{ |
{ |
|
struct html_pair attr[4]; |
|
int i; |
|
char ts[64]; |
|
|
|
if (0 == strftime(ts, sizeof(ts), "%B %d, %Y", tm)) { |
|
warn("strftime"); |
|
return(0); |
|
} |
|
|
|
i = 0; |
|
|
|
attr[0].attr = HTML_ATTR_WIDTH; |
|
attr[0].val = "100%"; |
|
attr[1].attr = HTML_ATTR_CLASS; |
|
attr[1].val = "header-footer"; |
|
|
|
if ( ! html_aputln(mbuf, ML_OPEN, i++, HTML_TAG_TABLE, 2, attr)) |
|
return(0); |
|
if ( ! html_tputln(mbuf, ML_OPEN, i++, HTML_TAG_TR)) |
|
return(0); |
|
|
|
attr[0].attr = HTML_ATTR_ALIGN; |
|
attr[0].val = "left"; |
|
attr[1].attr = HTML_ATTR_CLASS; |
|
attr[1].val = "footer-os"; |
|
|
|
if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) |
|
return(0); |
|
if ( ! ml_putstring(mbuf, os, NULL)) |
|
return(0); |
|
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) |
|
return(0); |
|
|
|
attr[0].attr = HTML_ATTR_ALIGN; |
|
attr[0].val = "right"; |
|
attr[1].attr = HTML_ATTR_CLASS; |
|
attr[1].val = "footer-date"; |
|
|
|
if ( ! html_aputln(mbuf, ML_OPEN, i, HTML_TAG_TD, 2, attr)) |
|
return(0); |
|
if ( ! ml_putstring(mbuf, ts, NULL)) |
|
return(0); |
|
if ( ! html_tputln(mbuf, ML_CLOSE, i, HTML_TAG_TD)) |
|
return(0); |
|
|
|
if ( ! html_tputln(mbuf, ML_CLOSE, --i, HTML_TAG_TR)) |
|
return(0); |
|
if ( ! html_tputln(mbuf, ML_CLOSE, --i, HTML_TAG_TABLE)) |
|
return(0); |
|
|
if ( ! html_tputln(mbuf, ML_CLOSE, 0, HTML_TAG_DIV)) |
if ( ! html_tputln(mbuf, ML_CLOSE, 0, HTML_TAG_DIV)) |
return(0); |
return(0); |
if ( ! html_tputln(mbuf, ML_CLOSE, 0, HTML_TAG_BODY)) |
if ( ! html_tputln(mbuf, ML_CLOSE, 0, HTML_TAG_BODY)) |
Line 647 html_inlinetagargs(struct md_mbuf *mbuf, |
|
Line 764 html_inlinetagargs(struct md_mbuf *mbuf, |
|
return(0); |
return(0); |
|
|
switch (tok) { |
switch (tok) { |
|
case (ROFF_Sh): |
|
|
|
/* FIXME: use API in ml.h. */ |
|
|
|
assert(*argv); |
|
if ( ! ml_nputs(mbuf, " name=\"", 7, res)) |
|
return(0); |
|
if ( ! ml_putstring(mbuf, *argv++, res)) |
|
return(0); |
|
while (*argv) { |
|
if ( ! ml_putstring(mbuf, "_", res)) |
|
return(0); |
|
if ( ! ml_putstring(mbuf, *argv++, res)) |
|
return(0); |
|
} |
|
if ( ! ml_nputs(mbuf, "\"", 1, res)) |
|
return(0); |
|
break; |
|
|
case (ROFF_Sx): |
case (ROFF_Sx): |
|
|
/* FIXME: use API in ml.h. */ |
/* FIXME: use API in ml.h. */ |
Line 654 html_inlinetagargs(struct md_mbuf *mbuf, |
|
Line 790 html_inlinetagargs(struct md_mbuf *mbuf, |
|
assert(*argv); |
assert(*argv); |
if ( ! ml_nputs(mbuf, " href=\"#", 8, res)) |
if ( ! ml_nputs(mbuf, " href=\"#", 8, res)) |
return(0); |
return(0); |
if ( ! ml_putstring(mbuf, *argv, res)) |
if ( ! ml_putstring(mbuf, *argv++, res)) |
return(0); |
return(0); |
|
while (*argv) { |
|
if ( ! ml_putstring(mbuf, "_", res)) |
|
return(0); |
|
if ( ! ml_putstring(mbuf, *argv++, res)) |
|
return(0); |
|
} |
if ( ! ml_nputs(mbuf, "\"", 1, res)) |
if ( ! ml_nputs(mbuf, "\"", 1, res)) |
return(0); |
return(0); |
|
|
break; |
break; |
default: |
default: |
break; |
break; |
Line 674 html_inlinetagname(struct md_mbuf *mbuf, |
|
Line 817 html_inlinetagname(struct md_mbuf *mbuf, |
|
{ |
{ |
|
|
switch (tok) { |
switch (tok) { |
|
case (ROFF_Sh): |
|
return(html_stput(mbuf, HTML_TAG_A, res)); |
case (ROFF_Pp): |
case (ROFF_Pp): |
return(html_stput(mbuf, HTML_TAG_DIV, res)); |
return(html_stput(mbuf, HTML_TAG_DIV, res)); |
case (ROFF_Sx): |
case (ROFF_Sx): |
Line 842 html_free(void *p) |
|
Line 987 html_free(void *p) |
|
} |
} |
|
|
|
|
|
/* ARGSUSED */ |
static ssize_t |
static ssize_t |
html_beginhttp(struct md_mbuf *mbuf, |
html_beginhttp(struct md_mbuf *mbuf, |
const struct md_args *args, |
const struct md_args *args, |
Line 860 html_beginhttp(struct md_mbuf *mbuf, |
|
Line 1006 html_beginhttp(struct md_mbuf *mbuf, |
|
} |
} |
|
|
|
|
|
/* ARGSUSED */ |
static ssize_t |
static ssize_t |
html_endhttp(struct md_mbuf *mbuf, |
html_endhttp(struct md_mbuf *mbuf, |
const struct md_args *args, |
const struct md_args *args, |