Adapt src/dev-dvi (src/devices/grodvi)
[s-roff.git] / src / devices / grohtml / html-text.h
blobd6e11cd8343487fd7d9444c3f0d5d7efd29753d2
1 // -*- C++ -*-
2 /* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
3 * Free Software Foundation, Inc.
5 * Gaius Mulley (gaius@glam.ac.uk) wrote html-text.h
7 * 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 2, or (at your option) any later
18 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
23 for more details.
25 You should have received a copy of the GNU General Public License along
26 with groff; see the file COPYING. If not, write to the Free Software
27 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
29 #include "html.h"
30 #include "html-table.h"
32 #define STYLE_VERTICAL_SPACE "1em"
35 * supported html dialects.
38 typedef enum {xhtml, html4} html_dialect;
41 * html tags
44 typedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
45 PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG,
46 COLOR_TAG} HTML_TAG;
48 typedef struct tag_definition {
49 HTML_TAG type;
50 void *arg1;
51 int text_emitted;
52 color col;
53 html_indent *indent;
54 tag_definition *next;
55 } tag_definition ;
58 * the state of the current paragraph.
59 * It allows post-html.cpp to request font changes, paragraph start/end
60 * and emits balanced tags with a small amount of peephole optimization.
63 class html_text {
64 public:
65 html_text (simple_output *op, html_dialect d);
66 ~html_text (void);
67 void flush_text (void);
68 void do_emittext (const char *s, int length);
69 void do_italic (void);
70 void do_bold (void);
71 void do_roman (void);
72 void do_tt (void);
73 void do_pre (void);
74 void do_small (void);
75 void do_big (void);
76 void do_para (const char *arg, int space); // used for no indentation
77 void do_para (simple_output *op, const char *arg1,
78 int indentation, int pageoffset, int linelength,
79 int space);
80 void do_sup (void);
81 void do_sub (void);
82 void do_space (void);
83 void do_break (void);
84 void do_newline (void);
85 void do_table (const char *arg);
86 void done_bold (void);
87 void done_italic (void);
88 char *done_para (void);
89 void done_sup (void);
90 void done_sub (void);
91 void done_tt (void);
92 void done_pre (void);
93 void done_small (void);
94 void done_big (void);
95 void do_color (color *c);
96 void done_color (void);
97 int emitted_text (void);
98 int ever_emitted_text (void);
99 int starts_with_space (void);
100 int retrieve_para_space (void);
101 void emit_space (void);
102 int is_in_pre (void);
103 int uses_indent (void);
104 void remove_tag (HTML_TAG tag);
105 void remove_sub_sup (void);
106 void remove_para_align (void);
107 void remove_para_space (void);
108 char *get_alignment (void);
110 private:
111 tag_definition *stackptr; /* the current paragraph state */
112 tag_definition *lastptr; /* the end of the stack */
113 simple_output *out;
114 html_dialect dialect; /* which dialect of html? */
115 int space_emitted; /* just emitted a space? */
116 int current_indentation; /* current .in value */
117 int pageoffset; /* .po value */
118 int linelength; /* current line length */
119 int blank_para; /* have we ever written text? */
120 int start_space; /* does para start with a .sp */
121 html_indent *indent; /* our indent class */
123 int is_present (HTML_TAG t);
124 void end_tag (tag_definition *t);
125 void start_tag (tag_definition *t);
126 void do_para (const char *arg, html_indent *in, int space);
127 void push_para (HTML_TAG t);
128 void push_para (HTML_TAG t, void *arg, html_indent *in);
129 void push_para (color *c);
130 void do_push (tag_definition *p);
131 char *shutdown (HTML_TAG t);
132 void check_emit_text (tag_definition *t);
133 int remove_break (void);
134 void issue_tag (const char *tagname, const char *arg, int space=2);
135 void issue_color_begin (color *c);
136 void remove_def (tag_definition *t);
137 html_indent *remove_indent (HTML_TAG tag);
138 void dump_stack_element (tag_definition *p);
139 void dump_stack (void);