-#include "libmdocml.h"
-#include "private.h"
-#include "ml.h"
-
-
-static int html_loadcss(struct md_mbuf *, const char *);
-
-static ssize_t html_endtag(struct md_mbuf *,
- const struct md_args *,
- enum md_ns, int);
-static ssize_t html_begintag(struct md_mbuf *,
- const struct md_args *,
- enum md_ns, int,
- const int *, const char **);
-static int html_begin(struct md_mbuf *,
- const struct md_args *,
- const struct tm *,
- const char *, const char *,
- const char *, const char *);
-static int html_end(struct md_mbuf *,
- const struct md_args *);
-static ssize_t html_blocktagname(struct md_mbuf *,
- const struct md_args *, int);
-static ssize_t html_blocktagargs(struct md_mbuf *,
- const struct md_args *, int,
- const int *, const char **);
-static ssize_t html_blockheadtagname(struct md_mbuf *,
- const struct md_args *, int);
-static ssize_t html_blockheadtagargs(struct md_mbuf *,
- const struct md_args *, int,
- const int *, const char **);
-static ssize_t html_blockbodytagname(struct md_mbuf *,
- const struct md_args *, int);
-static ssize_t html_blockbodytagargs(struct md_mbuf *,
- const struct md_args *, int,
- const int *, const char **);
-static ssize_t html_inlinetagname(struct md_mbuf *,
- const struct md_args *, int);
-static ssize_t html_inlinetagargs(struct md_mbuf *,
- const struct md_args *, int,
- const int *, const char **);
-
-
-static int
-html_loadcss(struct md_mbuf *mbuf, const char *css)
+#include "out.h"
+#include "chars.h"
+#include "html.h"
+#include "main.h"
+
+#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
+
+#define DOCTYPE "-//W3C//DTD HTML 4.01//EN"
+#define DTD "http://www.w3.org/TR/html4/strict.dtd"
+
+struct htmldata {
+ const char *name;
+ int flags;
+#define HTML_CLRLINE (1 << 0)
+#define HTML_NOSTACK (1 << 1)
+};
+
+static const struct htmldata htmltags[TAG_MAX] = {
+ {"html", HTML_CLRLINE}, /* TAG_HTML */
+ {"head", HTML_CLRLINE}, /* TAG_HEAD */
+ {"body", HTML_CLRLINE}, /* TAG_BODY */
+ {"meta", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_META */
+ {"title", HTML_CLRLINE}, /* TAG_TITLE */
+ {"div", HTML_CLRLINE}, /* TAG_DIV */
+ {"h1", 0}, /* TAG_H1 */
+ {"h2", 0}, /* TAG_H2 */
+ {"p", HTML_CLRLINE}, /* TAG_P */
+ {"span", 0}, /* TAG_SPAN */
+ {"link", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_LINK */
+ {"br", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_LINK */
+ {"a", 0}, /* TAG_A */
+ {"table", HTML_CLRLINE}, /* TAG_TABLE */
+ {"col", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_COL */
+ {"tr", HTML_CLRLINE}, /* TAG_TR */
+ {"td", HTML_CLRLINE}, /* TAG_TD */
+ {"li", HTML_CLRLINE}, /* TAG_LI */
+ {"ul", HTML_CLRLINE}, /* TAG_UL */
+ {"ol", HTML_CLRLINE}, /* TAG_OL */
+ {"base", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_BASE */
+};
+
+static const char *const htmlattrs[ATTR_MAX] = {
+ "http-equiv",
+ "content",
+ "name",
+ "rel",
+ "href",
+ "type",
+ "media",
+ "class",
+ "style",
+ "width",
+ "valign",
+ "target",
+ "id",
+ "summary",
+};
+
+#ifdef __linux__
+extern int getsubopt(char **, char * const *, char **);
+#endif
+
+void *
+html_alloc(char *outopts)