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