23 char *fontstack[SSIZE];
37 typedef struct Goobie Goobie;
41 void (*f)(Goobie*, char*);
42 void (*ef)(Goobie*, char*);
48 typedef void Action(Goobie*, char*);
56 Action g_list, g_listend;
58 Action g_fpush, g_fpop;
59 Action g_indent, g_exdent;
63 Action g_table, g_tableend, g_caption, g_captionend;
68 "!--", g_ignore, g_unexpected,
69 "!doctype", g_ignore, g_unexpected,
70 "a", g_ignore, g_ignore,
71 "address", g_display, g_displayend,
73 "base", g_ignore, g_unexpected,
74 "blink", g_ignore, g_ignore,
75 "blockquote", g_ignore, g_ignore,
76 "body", g_ignore, g_ignore,
77 "br", g_br, g_unexpected,
78 "caption", g_caption, g_captionend,
79 "center", g_ignore, g_ignore,
80 "cite", g_ignore, g_ignore,
81 "code", g_ignore, g_ignore,
82 "dd", g_ignore, g_unexpected,
83 "dfn", g_ignore, g_ignore,
84 "dir", g_list, g_listend,
85 "dl", g_indent, g_exdent,
86 "dt", g_dt, g_unexpected,
87 "em", g_ignore, g_ignore,
88 "font", g_ignore, g_ignore,
89 "form", g_ignore, g_ignore,
96 "head", g_ignore, g_ignore,
97 "hr", g_hr, g_unexpected,
98 "html", g_ignore, g_ignore,
100 "input", g_ignore, g_unexpected,
101 "img", g_ignore, g_unexpected,
102 "isindex", g_ignore, g_unexpected,
103 "kbd", g_fpush, g_fpop,
104 "key", g_ignore, g_ignore,
105 "li", g_li, g_unexpected,
106 "link", g_ignore, g_unexpected,
107 "listing", g_ignore, g_ignore,
108 "menu", g_list, g_listend,
109 "meta", g_ignore, g_unexpected,
110 "nextid", g_ignore, g_unexpected,
111 "ol", g_list, g_listend,
112 "option", g_ignore, g_unexpected,
114 "plaintext", g_ignore, g_unexpected,
115 "pre", g_pre, g_displayend,
116 "samp", g_ignore, g_ignore,
117 "select", g_ignore, g_ignore,
118 "strong", g_ignore, g_ignore,
119 "table", g_table, g_tableend,
120 "textarea", g_ignore, g_ignore,
121 "title", g_title, g_ignore,
122 "tt", g_fpush, g_fpop,
123 "u", g_ignore, g_ignore,
124 "ul", g_list, g_listend,
125 "var", g_ignore, g_ignore,
126 "xmp", g_ignore, g_ignore,
130 typedef struct Entity Entity;
139 "#SPACE", L' ', "#RS", L'\n', "#RE", L'\r', "quot", L'"',
140 "AElig", L'Æ', "Aacute", L'Á', "Acirc", L'Â', "Agrave", L'À', "Aring", L'Å',
141 "Atilde", L'Ã', "Auml", L'Ä', "Ccedil", L'Ç', "ETH", L'Ð', "Eacute", L'É',
142 "Ecirc", L'Ê', "Egrave", L'È', "Euml", L'Ë', "Iacute", L'Í', "Icirc", L'Î',
143 "Igrave", L'Ì', "Iuml", L'Ï', "Ntilde", L'Ñ', "Oacute", L'Ó', "Ocirc", L'Ô',
144 "Ograve", L'Ò', "Oslash", L'Ø', "Otilde", L'Õ', "Ouml", L'Ö', "THORN", L'Þ',
145 "Uacute", L'Ú', "Ucirc", L'Û', "Ugrave", L'Ù', "Uuml", L'Ü', "Yacute", L'Ý',
146 "aacute", L'á', "acirc", L'â', "aelig", L'æ', "agrave", L'à', "amp", L'&',
147 "aring", L'å', "atilde", L'ã', "auml", L'ä', "ccedil", L'ç', "eacute", L'é',
148 "ecirc", L'ê', "egrave", L'è', "eth", L'ð', "euml", L'ë', "gt", L'>',
149 "iacute", L'í', "icirc", L'î', "igrave", L'ì', "iuml", L'ï', "lt", L'<',
150 "ntilde", L'ñ', "oacute", L'ó', "ocirc", L'ô', "ograve", L'ò', "oslash", L'ø',
151 "otilde", L'õ', "ouml", L'ö', "szlig", L'ß', "thorn", L'þ', "uacute", L'ú',
152 "ucirc", L'û', "ugrave", L'ù', "uuml", L'ü', "yacute", L'ý', "yuml", L'ÿ',
157 cistrcmp(char *a, char *b)
173 readupto(char *buf, int n, char d, char notme)
196 Bprint(&out, "<%s", buf);
210 if(readupto(buf, sizeof(buf), '>', '<') < 0){
211 Bprint(&out, "<%s", buf);
220 arg = strchr(type, ' ');
222 arg = strchr(type, '\r');
224 arg = strchr(type, '\n');
227 for(g = gtab; g->name; g++)
228 if(cistrcmp(type, g->name) == 0){
244 Bprint(&out, "<%s %s>\n", type, arg);
246 Bprint(&out, "<%s>\n", type);
254 Binit(&in, 0, OREAD);
255 Binit(&out, 1, OWRITE);
279 /* can't emit leading spaces in filled troff docs */
286 if(!inpre && isascii(c) && isspace(c) && pos > 80){
305 if(readupto(buf, sizeof(buf), ';', '\n') < 0){
306 Bprint(&out, "&%s", buf);
309 for(e = pl_entity; e->name; e++)
310 if(strcmp(buf, e->name) == 0){
311 Bprint(&out, "%C", e->value);
316 if(isascii(c) && isprint(c)){
321 Bprint(&out, "&%s;", buf);
325 * whitespace is not significant to HTML, but newlines
326 * and leading spaces are significant to troff.
345 * print at start of line
348 printsol(char *fmt, ...)
359 Bvprint(&out, fmt, arg);
365 g_ignore(Goobie *g, char *arg)
371 g_unexpected(Goobie *g, char *arg)
374 fprint(2, "unexpected %s ending\n", g->name);
378 g_title(Goobie *g, char *arg)
381 printsol(".TL\n", g->name);
385 g_p(Goobie *g, char *arg)
388 printsol(".LP\n", g->name);
392 g_h(Goobie *g, char *arg)
395 printsol(".SH %c\n", g->name[1]);
399 g_list(Goobie *g, char *arg)
406 liststack[lsp].type = Lordered;
407 liststack[lsp].ord = 0;
410 liststack[lsp].type = Lunordered;
418 g_br(Goobie *g, char *arg)
425 g_li(Goobie *g, char *arg)
428 if(lsp <= 0 || lsp > SSIZE){
429 printsol(".IP \\(bu\n");
432 switch(liststack[lsp-1].type){
434 printsol(".IP \\(bu\n");
437 printsol(".IP %d\n", ++liststack[lsp-1].ord);
443 g_listend(Goobie *g, char *arg)
452 g_display(Goobie *g, char *arg)
459 g_pre(Goobie *g, char *arg)
467 g_displayend(Goobie *g, char *arg)
475 g_fpush(Goobie *g, char *arg)
479 fontstack[fsp] = font;
493 Bprint(&out, "\\f%s", font);
497 g_fpop(Goobie *g, char *arg)
502 font = fontstack[fsp];
506 Bprint(&out, "\\f%s", font);
510 g_indent(Goobie *g, char *arg)
517 g_exdent(Goobie *g, char *arg)
524 g_dt(Goobie *g, char *arg)
532 g_hr(Goobie *g, char *arg)
536 printsol("\\l'5i'\n");
542 <caption><font size="+1"><b>Cumulative Class Data</b></font></caption>
543 <tr><th rowspan=2>DOSE<br>mg/kg</th><th colspan=2>PARALYSIS</th><th colspan=2>DEATH</th>
545 <tr><th width=80>Number</th><th width=80>Percent</th><th width=80>Number</th><th width=80>Percent</th>
548 <td>0.1</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
551 <td>0.2</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
554 <td>0.3</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
557 <td>0.4</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
560 <td>0.5</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
563 <td>0.6</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
566 <td>0.7</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
569 <td>0.8</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
572 <td>0.8 oral</td><td><br></td> <td><br></td> <td><br></td> <td><br></td>
578 g_table(Goobie *g, char *arg)
581 printsol(".TS\ncenter ;\n");
585 g_tableend(Goobie *g, char *arg)
592 g_caption(Goobie *g, char *arg)
598 g_captionend(Goobie *g, char *arg)