2 /* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009
3 * Free Software Foundation, Inc.
5 * Gaius Mulley (gaius@glam.ac.uk) wrote html-text.h
9 * provides a state machine interface which generates html text.
13 This file is part of groff.
15 groff is free software; you can redistribute it and/or modify it under
16 the terms of the GNU General Public License as published by the Free
17 Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
20 groff is distributed in the hope that it will be useful, but WITHOUT ANY
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>. */
29 #include "html-table.h"
31 #define STYLE_VERTICAL_SPACE "1em"
34 * supported html dialects.
37 typedef enum {xhtml, html4} html_dialect;
43 typedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
44 PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG,
47 typedef struct tag_definition {
57 * the state of the current paragraph.
58 * It allows post-html.cpp to request font changes, paragraph start/end
59 * and emits balanced tags with a small amount of peephole optimization.
64 html_text (simple_output *op, html_dialect d);
66 void flush_text (void);
67 void do_emittext (const char *s, int length);
68 void do_italic (void);
75 void do_para (const char *arg, int space); // used for no indentation
76 void do_para (simple_output *op, const char *arg1,
77 int indentation, int pageoffset, int linelength,
83 void do_newline (void);
84 void do_table (const char *arg);
85 void done_bold (void);
86 void done_italic (void);
87 char *done_para (void);
92 void done_small (void);
94 void do_color (color *c);
95 void done_color (void);
96 int emitted_text (void);
97 int ever_emitted_text (void);
98 int starts_with_space (void);
99 int retrieve_para_space (void);
100 void emit_space (void);
101 int is_in_pre (void);
102 int uses_indent (void);
103 void remove_tag (HTML_TAG tag);
104 void remove_sub_sup (void);
105 void remove_para_align (void);
106 void remove_para_space (void);
107 char *get_alignment (void);
110 tag_definition *stackptr; /* the current paragraph state */
111 tag_definition *lastptr; /* the end of the stack */
113 html_dialect dialect; /* which dialect of html? */
114 int space_emitted; /* just emitted a space? */
115 int current_indentation; /* current .in value */
116 int pageoffset; /* .po value */
117 int linelength; /* current line length */
118 int blank_para; /* have we ever written text? */
119 int start_space; /* does para start with a .sp */
120 html_indent *indent; /* our indent class */
122 int is_present (HTML_TAG t);
123 void end_tag (tag_definition *t);
124 void start_tag (tag_definition *t);
125 void do_para (const char *arg, html_indent *in, int space);
126 void push_para (HTML_TAG t);
127 void push_para (HTML_TAG t, void *arg, html_indent *in);
128 void push_para (color *c);
129 void do_push (tag_definition *p);
130 char *shutdown (HTML_TAG t);
131 void check_emit_text (tag_definition *t);
132 int remove_break (void);
133 void issue_tag (const char *tagname, const char *arg, int space=2);
134 void issue_color_begin (color *c);
135 void remove_def (tag_definition *t);
136 html_indent *remove_indent (HTML_TAG tag);
137 void dump_stack_element (tag_definition *p);
138 void dump_stack (void);