Annotation of mandoc/roff_html.c, Revision 1.16
1.16 ! schwarze 1: /* $Id: roff_html.c,v 1.15 2018/12/16 00:17:02 schwarze Exp $ */
1.1 schwarze 2: /*
1.3 schwarze 3: * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
1.12 schwarze 4: * Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
1.1 schwarze 5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18: #include <sys/types.h>
19:
20: #include <assert.h>
1.15 schwarze 21: #include <stdio.h>
22: #include <string.h>
1.1 schwarze 23:
1.15 schwarze 24: #include "mandoc.h"
1.1 schwarze 25: #include "roff.h"
26: #include "out.h"
27: #include "html.h"
28:
29: #define ROFF_HTML_ARGS struct html *h, const struct roff_node *n
30:
31: typedef void (*roff_html_pre_fp)(ROFF_HTML_ARGS);
32:
33: static void roff_html_pre_br(ROFF_HTML_ARGS);
1.7 schwarze 34: static void roff_html_pre_ce(ROFF_HTML_ARGS);
1.15 schwarze 35: static void roff_html_pre_ft(ROFF_HTML_ARGS);
1.3 schwarze 36: static void roff_html_pre_sp(ROFF_HTML_ARGS);
1.1 schwarze 37:
38: static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
39: roff_html_pre_br, /* br */
1.7 schwarze 40: roff_html_pre_ce, /* ce */
1.16 ! schwarze 41: roff_html_pre_br, /* fi */
1.15 schwarze 42: roff_html_pre_ft, /* ft */
1.3 schwarze 43: NULL, /* ll */
1.6 schwarze 44: NULL, /* mc */
1.16 ! schwarze 45: roff_html_pre_br, /* nf */
1.10 schwarze 46: NULL, /* po */
1.9 schwarze 47: roff_html_pre_ce, /* rj */
1.3 schwarze 48: roff_html_pre_sp, /* sp */
1.4 schwarze 49: NULL, /* ta */
1.5 schwarze 50: NULL, /* ti */
1.1 schwarze 51: };
52:
53:
54: void
55: roff_html_pre(struct html *h, const struct roff_node *n)
56: {
57: assert(n->tok < ROFF_MAX);
1.2 schwarze 58: if (roff_html_pre_acts[n->tok] != NULL)
59: (*roff_html_pre_acts[n->tok])(h, n);
1.1 schwarze 60: }
61:
62: static void
63: roff_html_pre_br(ROFF_HTML_ARGS)
64: {
1.13 schwarze 65: print_otag(h, TAG_BR, "");
1.7 schwarze 66: }
67:
68: static void
69: roff_html_pre_ce(ROFF_HTML_ARGS)
70: {
71: for (n = n->child->next; n != NULL; n = n->next) {
72: if (n->type == ROFFT_TEXT) {
73: if (n->flags & NODE_LINE)
74: roff_html_pre_br(h, n);
75: print_text(h, n->string);
76: } else
77: roff_html_pre(h, n);
78: }
79: roff_html_pre_br(h, n);
1.15 schwarze 80: }
81:
82: static void
83: roff_html_pre_ft(ROFF_HTML_ARGS)
84: {
85: const char *cp;
86:
87: cp = n->child->string;
88: print_metaf(h, mandoc_font(cp, (int)strlen(cp)));
1.3 schwarze 89: }
90:
91: static void
92: roff_html_pre_sp(ROFF_HTML_ARGS)
93: {
1.12 schwarze 94: print_paragraph(h);
1.1 schwarze 95: }
CVSweb