=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.13 retrieving revision 1.15 diff -u -p -r1.13 -r1.15 --- mandoc/html.c 2008/12/06 21:10:31 1.13 +++ mandoc/html.c 2008/12/08 12:46:28 1.15 @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.13 2008/12/06 21:10:31 kristaps Exp $ */ +/* $Id: html.c,v 1.15 2008/12/08 12:46:28 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -55,6 +55,18 @@ static void html_free(void *); static ssize_t html_endtag(struct md_mbuf *, void *, const struct md_args *, enum md_ns, int); +static ssize_t html_beginstring(struct md_mbuf *, + const struct md_args *, + const char *, size_t); +static ssize_t html_beginhttp(struct md_mbuf *, + const struct md_args *, + const char *, size_t); +static ssize_t html_endstring(struct md_mbuf *, + const struct md_args *, + const char *, size_t); +static ssize_t html_endhttp(struct md_mbuf *, + const struct md_args *, + const char *, size_t); static ssize_t html_begintag(struct md_mbuf *, void *, const struct md_args *, enum md_ns, int, @@ -63,7 +75,7 @@ static int html_begin(struct md_mbuf *, const struct md_args *, const struct tm *, const char *, const char *, - const char *, const char *); + enum roffmsec, const char *); static int html_printargs(struct md_mbuf *, int, const char *, const int *, const char **, size_t *); @@ -127,6 +139,9 @@ html_It_headtagname(struct md_mbuf *mbuf, struct htmlq for (i = 0; ROFF_ARGMAX != n->argc[i] && i < ROFF_MAXLINEARG; i++) { switch (n->argc[i]) { + case (ROFF_Ohang): + return(ml_nputs(mbuf, "div", 3, res)); + case (ROFF_Tag): /* FALLTHROUGH */ case (ROFF_Column): @@ -136,11 +151,8 @@ html_It_headtagname(struct md_mbuf *mbuf, struct htmlq } } - assert(i != ROFF_MAXLINEARG); abort(); /* NOTREACHED */ - - return(1); } @@ -349,7 +361,7 @@ out: static int html_begin(struct md_mbuf *mbuf, const struct md_args *args, const struct tm *tm, const char *os, - const char *title, const char *section, + const char *title, enum roffmsec section, const char *vol) { const char *preamble, *css, *trail; @@ -377,7 +389,7 @@ html_begin(struct md_mbuf *mbuf, const struct md_args res = 0; (void)snprintf(buf, sizeof(buf) - 1, - preamble, title, section); + preamble, title, ml_section(section)); if ( ! ml_puts(mbuf, buf, &res)) return(0); @@ -739,6 +751,70 @@ html_free(void *p) } +static ssize_t +html_beginhttp(struct md_mbuf *mbuf, + const struct md_args *args, + const char *buf, size_t sz) +{ + size_t res; + + res = 0; + + if ( ! ml_puts(mbuf, "", &res)) + return(-1); + + return((ssize_t)res); +} + + +static ssize_t +html_endhttp(struct md_mbuf *mbuf, + const struct md_args *args, + const char *buf, size_t sz) +{ + size_t res; + + res = 0; + + if ( ! ml_puts(mbuf, "", &res)) + return(-1); + + return((ssize_t)res); +} + + +/* ARGSUSED */ +static ssize_t +html_beginstring(struct md_mbuf *mbuf, + const struct md_args *args, + const char *buf, size_t sz) +{ + + if (0 == strncmp(buf, "http://", 7)) + return(html_beginhttp(mbuf, args, buf, sz)); + + return(0); +} + + +/* ARGSUSED */ +static ssize_t +html_endstring(struct md_mbuf *mbuf, + const struct md_args *args, + const char *buf, size_t sz) +{ + + if (0 == strncmp(buf, "http://", 7)) + return(html_endhttp(mbuf, args, buf, sz)); + + return(0); +} + + int md_line_html(void *data, char *buf) { @@ -767,7 +843,8 @@ md_init_html(const struct md_args *args, cbs.ml_endtag = html_endtag; cbs.ml_begin = html_begin; cbs.ml_end = html_end; + cbs.ml_beginstring = html_beginstring; + cbs.ml_endstring = html_endstring; return(mlg_alloc(args, rbuf, mbuf, &cbs)); } -