version 1.7, 2008/12/05 11:28:16 |
version 1.8, 2008/12/05 17:43:14 |
|
|
#include "ml.h" |
#include "ml.h" |
|
|
|
|
|
/* TODO: allow head/tail-less invocations (just "div" start). */ |
|
/* FIXME: free htmlq. */ |
|
|
struct htmlnode { |
struct htmlnode { |
int type; |
int tok; |
|
enum md_ns ns; |
int *argc[ROFF_MAXLINEARG]; |
int *argc[ROFF_MAXLINEARG]; |
char *argv[ROFF_MAXLINEARG]; |
char *argv[ROFF_MAXLINEARG]; |
struct htmlnode *parent; |
struct htmlnode *parent; |
|
|
}; |
}; |
|
|
|
|
|
static void htmlnode_free(struct htmlnode *); |
|
static void htmlnode_free(struct htmlnode *); |
|
|
static int html_loadcss(struct md_mbuf *, const char *); |
static int html_loadcss(struct md_mbuf *, const char *); |
|
|
static ssize_t html_endtag(struct md_mbuf *, |
static ssize_t html_endtag(struct md_mbuf *, void *, |
const struct md_args *, |
const struct md_args *, |
enum md_ns, int); |
enum md_ns, int); |
static ssize_t html_begintag(struct md_mbuf *, |
static ssize_t html_begintag(struct md_mbuf *, void *, |
const struct md_args *, |
const struct md_args *, |
enum md_ns, int, |
enum md_ns, int, |
const int *, const char **); |
const int *, const char **); |
Line 352 html_inlinetagname(struct md_mbuf *mbuf, |
|
Line 359 html_inlinetagname(struct md_mbuf *mbuf, |
|
|
|
|
|
static ssize_t |
static ssize_t |
html_begintag(struct md_mbuf *mbuf, const struct md_args *args, |
html_begintag(struct md_mbuf *mbuf, void *data, |
enum md_ns ns, int tok, |
const struct md_args *args, enum md_ns ns, |
const int *argc, const char **argv) |
int tok, const int *argc, const char **argv) |
{ |
{ |
size_t res; |
size_t res; |
|
struct htmlq *q; |
|
struct htmlnode *node; |
|
|
assert(ns != MD_NS_DEFAULT); |
assert(ns != MD_NS_DEFAULT); |
res = 0; |
res = 0; |
|
|
|
assert(data); |
|
q = (struct htmlq *)data; |
|
|
|
if (NULL == (node = calloc(1, sizeof(struct htmlnode)))) { |
|
warn("calloc"); |
|
return(-1); |
|
} |
|
|
|
node->parent = q->last; |
|
node->tok = tok; |
|
node->ns = ns; |
|
|
|
q->last = node; |
|
|
switch (ns) { |
switch (ns) { |
case (MD_NS_BLOCK): |
case (MD_NS_BLOCK): |
if ( ! html_blocktagname(mbuf, args, tok, &res)) |
if ( ! html_blocktagname(mbuf, args, tok, &res)) |
Line 397 html_begintag(struct md_mbuf *mbuf, const struct md_ar |
|
Line 420 html_begintag(struct md_mbuf *mbuf, const struct md_ar |
|
|
|
|
|
static ssize_t |
static ssize_t |
html_endtag(struct md_mbuf *mbuf, const struct md_args *args, |
html_endtag(struct md_mbuf *mbuf, void *data, |
enum md_ns ns, int tok) |
const struct md_args *args, enum md_ns ns, int tok) |
{ |
{ |
size_t res; |
size_t res; |
|
struct htmlq *q; |
|
struct htmlnode *node; |
|
|
assert(ns != MD_NS_DEFAULT); |
assert(ns != MD_NS_DEFAULT); |
res = 0; |
res = 0; |
|
|
|
assert(data); |
|
q = (struct htmlq *)data; |
|
|
switch (ns) { |
switch (ns) { |
case (MD_NS_BLOCK): |
case (MD_NS_BLOCK): |
if ( ! html_blocktagname(mbuf, args, tok, &res)) |
if ( ! html_blocktagname(mbuf, args, tok, &res)) |
Line 424 html_endtag(struct md_mbuf *mbuf, const struct md_args |
|
Line 452 html_endtag(struct md_mbuf *mbuf, const struct md_args |
|
break; |
break; |
} |
} |
|
|
|
node = q->last; |
|
q->last = node->parent; |
|
|
|
htmlnode_free(node); |
|
|
return((ssize_t)res); |
return((ssize_t)res); |
} |
} |
|
|
|
|
md_init_html(const struct md_args *args, |
md_init_html(const struct md_args *args, |
struct md_mbuf *mbuf, const struct md_rbuf *rbuf) |
struct md_mbuf *mbuf, const struct md_rbuf *rbuf) |
{ |
{ |
|
struct htmlq *q; |
|
|
return(mlg_alloc(args, rbuf, mbuf, html_begintag, |
if (NULL == (q = calloc(1, sizeof(struct htmlq)))) { |
|
warn("calloc"); |
|
return(NULL); |
|
} |
|
|
|
return(mlg_alloc(args, q, rbuf, mbuf, html_begintag, |
html_endtag, html_begin, html_end)); |
html_endtag, html_begin, html_end)); |
} |
} |
|
|