2 /* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
4 * Gaius Mulley (gaius@glam.ac.uk) wrote html-text.cc
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 2, or (at your option) any later
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 along
25 with groff; see the file COPYING. If not, write to the Free Software
26 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 #include "html-table.h"
35 typedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
36 PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG,
39 typedef struct tag_definition {
49 * the state of the current paragraph.
50 * It allows post-html.cc to request font changes, paragraph start/end
51 * and emits balanced tags with a small amount of peephole optimization.
56 html_text (simple_output *op);
58 void flush_text (void);
59 void do_emittext (const char *s, int length);
60 void do_italic (void);
67 void do_para (const char *arg); // used for no indentation
68 void do_para (simple_output *op, const char *arg1,
69 int indentation, int pageoffset, int linelength);
74 void do_newline (void);
75 void do_table (const char *arg);
76 void done_bold (void);
77 void done_italic (void);
78 char *done_para (void);
83 void done_small (void);
85 void do_color (color *c);
86 void done_color (void);
87 int emitted_text (void);
88 int ever_emitted_text (void);
89 int starts_with_space (void);
90 void emit_space (void);
92 void remove_tag (HTML_TAG tag);
93 void remove_sub_sup (void);
94 void remove_para_align (void);
97 tag_definition *stackptr; /* the current paragraph state */
98 tag_definition *lastptr; /* the end of the stack */
100 int space_emitted; /* just emitted a space? */
101 int current_indentation; /* current .in value */
102 int pageoffset; /* .po value */
103 int linelength; /* current line length */
104 int blank_para; /* have we ever written text? */
105 int start_space; /* does para start with a .sp */
106 html_indent *indent; /* our indent class */
108 int is_present (HTML_TAG t);
109 void end_tag (tag_definition *t);
110 void start_tag (tag_definition *t);
111 void do_para (const char *arg, html_indent *in);
112 void push_para (HTML_TAG t);
113 void push_para (HTML_TAG t, void *arg, html_indent *in);
114 void push_para (color *c);
115 void do_push (tag_definition *p);
116 char *shutdown (HTML_TAG t);
117 void check_emit_text (tag_definition *t);
118 int remove_break (void);
119 void issue_tag (char *tagname, char *arg);
120 void issue_color_begin (color *c);
121 void remove_def (tag_definition *t);
122 html_indent *remove_indent (HTML_TAG tag);
123 void dump_stack_element (tag_definition *p);
124 void dump_stack (void);