1 /* $Id: eqn_html.c,v 1.2 2011/07/24 10:09:03 kristaps Exp $ */
3 * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 static const enum htmltag fontmap[EQNFONT__MAX] = {
31 TAG_SPAN, /* EQNFONT_NONE */
32 TAG_SPAN, /* EQNFONT_ROMAN */
33 TAG_B, /* EQNFONT_BOLD */
34 TAG_B, /* EQNFONT_FAT */
35 TAG_I /* EQNFONT_ITALIC */
39 static void eqn_box(struct html *, const struct eqn_box *);
42 print_eqn(struct html *p, const struct eqn *ep)
47 PAIR_CLASS_INIT(&tag, "eqn");
48 t = print_otag(p, TAG_SPAN, 1, &tag);
50 p->flags |= HTML_NONOSPACE;
52 p->flags &= ~HTML_NONOSPACE;
58 eqn_box(struct html *p, const struct eqn_box *bp)
62 t = EQNFONT_NONE == bp->font ? NULL :
63 print_otag(p, fontmap[(int)bp->font], 0, NULL);
66 print_text(p, bp->left);
69 print_text(p, bp->text);
72 eqn_box(p, bp->first);
77 print_text(p, bp->right);