Adapt src/dev-html (src/devices/grohtml)
[s-roff.git] / src / dev-html / html-text.h
blob12ff4e9e637b1c389bd2e157e3cc50ab59c92525
1 /*@ Provides a state machine interface which generates html text.
3 * Copyright (c) 2014 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
5 * Copyright (C) 2000 - 2005, 2007
6 * Free Software Foundation, Inc.
8 * Gaius Mulley (gaius@glam.ac.uk) wrote html-text.h
9 */
11 * groff is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2, or (at your option) any later
14 * version.
16 * groff is distributed in the hope that it will be useful, but WITHOUT ANY
17 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with groff; see the file COPYING. If not, write to the Free Software
23 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
25 #ifndef _HTML_TEXT_H
26 #define _HTML_TEXT_H
28 #include "html.h"
30 #include "html-table.h"
33 * supported html dialects.
36 typedef enum {xhtml, html4} html_dialect;
39 * html tags
42 typedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
43 PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG,
44 COLOR_TAG} HTML_TAG;
46 typedef struct tag_definition {
47 HTML_TAG type;
48 void *arg1;
49 int text_emitted;
50 color col;
51 html_indent *indent;
52 tag_definition *next;
53 } 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.
61 class html_text {
62 public:
63 html_text (simple_output *op, html_dialect d);
64 ~html_text (void);
65 void flush_text (void);
66 void do_emittext (const char *s, int length);
67 void do_italic (void);
68 void do_bold (void);
69 void do_roman (void);
70 void do_tt (void);
71 void do_pre (void);
72 void do_small (void);
73 void do_big (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,
77 int space);
78 void do_sup (void);
79 void do_sub (void);
80 void do_space (void);
81 void do_break (void);
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);
87 void done_sup (void);
88 void done_sub (void);
89 void done_tt (void);
90 void done_pre (void);
91 void done_small (void);
92 void done_big (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);
108 private:
109 tag_definition *stackptr; /* the current paragraph state */
110 tag_definition *lastptr; /* the end of the stack */
111 simple_output *out;
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);
140 #endif // _HTML_TEXT_H
141 // s-it2-mode