version 1.1, 2008/12/10 00:52:46 |
version 1.33, 2010/12/20 13:07:55 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se> |
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the |
* purpose with or without fee is hereby granted, provided that the above |
* above copyright notice and this permission notice appear in all |
* copyright notice and this permission notice appear in all copies. |
* copies. |
|
* |
* |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* PERFORMANCE OF THIS SOFTWARE. |
|
*/ |
*/ |
#ifndef HTML_H |
#ifndef HTML_H |
#define HTML_H |
#define HTML_H |
|
|
#include "ml.h" |
__BEGIN_DECLS |
|
|
enum html_tag { |
enum htmltag { |
HTML_TAG_SPAN = 0, |
TAG_HTML, |
HTML_TAG_HTML = 1, |
TAG_HEAD, |
HTML_TAG_HEAD = 2, |
TAG_BODY, |
HTML_TAG_META = 3, |
TAG_META, |
HTML_TAG_TITLE = 4, |
TAG_TITLE, |
HTML_TAG_STYLE = 5, |
TAG_DIV, |
HTML_TAG_LINK = 6, |
TAG_H1, |
HTML_TAG_BODY = 7, |
TAG_H2, |
HTML_TAG_DIV = 8, |
TAG_SPAN, |
HTML_TAG_TABLE = 9, |
TAG_LINK, |
HTML_TAG_TD = 10, |
TAG_BR, |
HTML_TAG_TR = 11, |
TAG_A, |
HTML_TAG_OL = 12, |
TAG_TABLE, |
HTML_TAG_UL = 13, |
TAG_TBODY, |
HTML_TAG_LI = 14, |
TAG_COL, |
HTML_TAG_H1 = 15, |
TAG_TR, |
HTML_TAG_H2 = 16, |
TAG_TD, |
HTML_TAG_A = 17, |
TAG_LI, |
|
TAG_UL, |
|
TAG_OL, |
|
TAG_DL, |
|
TAG_DT, |
|
TAG_DD, |
|
TAG_BLOCKQUOTE, |
|
TAG_P, |
|
TAG_PRE, |
|
TAG_B, |
|
TAG_I, |
|
TAG_U, |
|
TAG_MAX |
}; |
}; |
|
|
enum html_attr { |
enum htmlattr { |
HTML_ATTR_CLASS = 0, |
ATTR_HTTPEQUIV, |
HTML_ATTR_HTTP_EQUIV = 1, |
ATTR_CONTENT, |
HTML_ATTR_CONTENT = 2, |
ATTR_NAME, |
HTML_ATTR_NAME = 3, |
ATTR_REL, |
HTML_ATTR_TYPE = 4, |
ATTR_HREF, |
HTML_ATTR_REL = 5, |
ATTR_TYPE, |
HTML_ATTR_HREF = 6, |
ATTR_MEDIA, |
HTML_ATTR_WIDTH = 7, |
ATTR_CLASS, |
|
ATTR_STYLE, |
|
ATTR_WIDTH, |
|
ATTR_ID, |
|
ATTR_SUMMARY, |
|
ATTR_ALIGN, |
|
ATTR_MAX |
}; |
}; |
|
|
enum html_type { |
enum htmlfont { |
HTML_TYPE_4_01_STRICT = 0 |
HTMLFONT_NONE = 0, |
|
HTMLFONT_BOLD, |
|
HTMLFONT_ITALIC, |
|
HTMLFONT_MAX |
}; |
}; |
|
|
struct html_pair { |
struct tag { |
enum html_attr attr; |
struct tag *next; |
char *val; |
enum htmltag tag; |
}; |
}; |
|
|
__BEGIN_DECLS |
struct tagq { |
|
struct tag *head; |
|
}; |
|
|
int html_typeput(struct md_mbuf *, |
struct htmlpair { |
enum html_type, size_t *); |
enum htmlattr key; |
int html_commentput(struct md_mbuf *, |
const char *val; |
enum ml_scope, size_t *); |
}; |
int html_tput(struct md_mbuf *, |
|
enum ml_scope, enum html_tag, size_t *); |
#define PAIR_INIT(p, t, v) \ |
int html_aput(struct md_mbuf *, enum ml_scope, |
do { \ |
enum html_tag, size_t *, |
(p)->key = (t); \ |
int, const struct html_pair *); |
(p)->val = (v); \ |
int html_stput(struct md_mbuf *, |
} while (/* CONSTCOND */ 0) |
enum html_tag, size_t *); |
|
int html_saput(struct md_mbuf *, enum html_tag, |
#define PAIR_ID_INIT(p, v) PAIR_INIT(p, ATTR_ID, v) |
size_t *, int, const struct html_pair *); |
#define PAIR_CLASS_INIT(p, v) PAIR_INIT(p, ATTR_CLASS, v) |
|
#define PAIR_HREF_INIT(p, v) PAIR_INIT(p, ATTR_HREF, v) |
|
#define PAIR_STYLE_INIT(p, h) PAIR_INIT(p, ATTR_STYLE, (h)->buf) |
|
#define PAIR_SUMMARY_INIT(p, v) PAIR_INIT(p, ATTR_SUMMARY, v) |
|
|
|
enum htmltype { |
|
HTML_HTML_4_01_STRICT, |
|
HTML_XHTML_1_0_STRICT |
|
}; |
|
|
|
struct html { |
|
int flags; |
|
#define HTML_NOSPACE (1 << 0) |
|
#define HTML_IGNDELIM (1 << 1) |
|
#define HTML_KEEP (1 << 2) |
|
#define HTML_PREKEEP (1 << 3) |
|
#define HTML_NONOSPACE (1 << 4) |
|
struct tagq tags; |
|
void *symtab; |
|
char *base; |
|
char *base_man; |
|
char *base_includes; |
|
char *style; |
|
char buf[BUFSIZ]; |
|
size_t buflen; |
|
struct tag *metaf; |
|
enum htmlfont metal; |
|
enum htmlfont metac; |
|
enum htmltype type; |
|
}; |
|
|
|
struct roffsu; |
|
|
|
void print_gen_decls(struct html *); |
|
void print_gen_head(struct html *); |
|
struct tag *print_ofont(struct html *, enum htmlfont); |
|
struct tag *print_otag(struct html *, enum htmltag, |
|
int, const struct htmlpair *); |
|
void print_tagq(struct html *, const struct tag *); |
|
void print_stagq(struct html *, const struct tag *); |
|
void print_text(struct html *, const char *); |
|
|
|
void bufcat_su(struct html *, const char *, |
|
const struct roffsu *); |
|
void buffmt_man(struct html *, |
|
const char *, const char *); |
|
void buffmt_includes(struct html *, const char *); |
|
void buffmt(struct html *, const char *, ...); |
|
void bufcat(struct html *, const char *); |
|
void bufcat_style(struct html *, |
|
const char *, const char *); |
|
void bufncat(struct html *, const char *, size_t); |
|
void bufinit(struct html *); |
|
|
|
void html_idcat(char *, const char *, int); |
|
|
__END_DECLS |
__END_DECLS |
|
|