* src/devices/grohtml/post-html.cc (html_printer::emit_raw,
[s-roff.git] / src / devices / grohtml / html-text.h
blobe3073cfa2c74f8bd35f943670162fa2e8dc60606
1 // -*- C++ -*-
2 /* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
4 * Gaius Mulley (gaius@glam.ac.uk) wrote html-text.cc
6 * html-text.h
8 * provides a state machine interface which generates html text.
9 */
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
17 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
22 for more details.
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. */
28 #include "html.h"
31 * html tags
34 typedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
35 PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG, TABLE_TAG,
36 COLOR_TAG} HTML_TAG;
38 typedef struct tag_definition {
39 HTML_TAG type;
40 void *arg1;
41 int text_emitted;
42 color col;
43 tag_definition *next;
44 } tag_definition ;
47 * the state of the current paragraph.
48 * It allows post-html.cc to request font changes, paragraph start/end
49 * and emits balanced tags with a small amount of peephole optimization.
52 class html_text {
53 public:
54 html_text (simple_output *op);
55 ~html_text (void);
56 void flush_text (void);
57 void do_emittext (const char *s, int length);
58 void do_italic (void);
59 void do_bold (void);
60 void do_roman (void);
61 void do_tt (void);
62 void do_pre (void);
63 void do_small (void);
64 void do_big (void);
65 void do_para (const char *arg1);
66 void do_sup (void);
67 void do_sub (void);
68 void do_space (void);
69 void do_break (void);
70 void do_newline (void);
71 void do_table (const char *arg);
72 void done_bold (void);
73 void done_italic (void);
74 char *done_para (void);
75 void done_sup (void);
76 void done_sub (void);
77 void done_tt (void);
78 void done_pre (void);
79 void done_small (void);
80 void done_big (void);
81 void do_indent (const char *arg, int indent, int pageoff, int linelen);
82 void do_color (color *c);
83 void done_color (void);
84 int emitted_text (void);
85 void emit_space (void);
86 int is_in_pre (void);
87 void remove_tag (HTML_TAG tag);
88 void remove_sub_sup (void);
89 void done_table (void);
90 int is_in_table (void);
92 private:
93 tag_definition *stackptr; /* the current paragraph state */
94 tag_definition *lastptr; /* the end of the stack */
95 simple_output *out;
96 int space_emitted;
97 int current_indentation; /* current .in value */
98 int pageoffset; /* .po value */
99 int linelength; /* current line length */
101 int is_present (HTML_TAG t);
102 void end_tag (tag_definition *t);
103 void start_tag (tag_definition *t);
104 void push_para (HTML_TAG t, void *arg);
105 void push_para (HTML_TAG t);
106 void push_para (color *c);
107 void do_push (tag_definition *p);
108 char *shutdown (HTML_TAG t);
109 void check_emit_text (tag_definition *t);
110 int remove_break (void);
111 void issue_tag (char *tagname, char *arg);
112 void issue_color_begin (color *c);
113 void issue_table_begin (char *arg);
114 void issue_table_end (void);
115 int table_is_void (tag_definition *t);
116 void remove_def (tag_definition *t);
117 void dump_stack_element (tag_definition *p);
118 void dump_stack (void);