html-text.h revision 79543
1// -*- C++ -*-
2/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
3 *
4 *  Gaius Mulley (gaius@glam.ac.uk) wrote html-text.cc
5 *
6 *  html-text.h
7 *
8 *  provides a state machine interface which generates html text.
9 */
10
11/*
12This file is part of groff.
13
14groff is free software; you can redistribute it and/or modify it under
15the terms of the GNU General Public License as published by the Free
16Software Foundation; either version 2, or (at your option) any later
17version.
18
19groff is distributed in the hope that it will be useful, but WITHOUT ANY
20WARRANTY; without even the implied warranty of MERCHANTABILITY or
21FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22for more details.
23
24You should have received a copy of the GNU General Public License along
25with groff; see the file COPYING.  If not, write to the Free Software
26Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27
28#include "html.h"
29
30/*
31 *  html tags
32 */
33
34typedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
35	      PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG, TABLE_TAG} HTML_TAG;
36
37typedef struct tag_definition {
38  HTML_TAG        type;
39  char           *arg1;
40  int             text_emitted;
41  tag_definition *next;
42} tag_definition ;
43
44/*
45 *  the state of the current paragraph.
46 *  It allows post-html.cc to request font changes, paragraph start/end
47 *  and emits balanced tags with a small amount of peephole optimization.
48 */
49
50class html_text {
51public:
52         html_text      (simple_output *op);
53        ~html_text      (void);
54  void   flush_text     (void);
55  void   do_emittext    (char *s, int length);
56  void   do_italic      (void);
57  void   do_bold        (void);
58  void   do_roman       (void);
59  void   do_tt          (void);
60  void   do_pre         (void);
61  void   do_small       (void);
62  void   do_big         (void);
63  void   do_para        (char *arg1);
64  void   do_sup         (void);
65  void   do_sub         (void);
66  void   do_space       (void);
67  void   do_break       (void);
68  void   do_newline     (void);
69  void   do_table       (char *arg);
70  void   done_bold      (void);
71  void   done_italic    (void);
72  char  *done_para      (void);
73  void   done_sup       (void);
74  void   done_sub       (void);
75  void   done_tt        (void);
76  void   done_pre       (void);
77  void   done_small     (void);
78  void   done_big       (void);
79  void   do_indent      (char *arg, int indent, int pageoff, int linelen);
80  int    emitted_text   (void);
81  void   emit_space     (void);
82  int    is_in_pre      (void);
83  void   remove_tag     (HTML_TAG tag);
84  void   remove_sub_sup (void);
85  void   done_table     (void);
86  int    is_in_table    (void);
87
88private:
89  tag_definition   *stackptr;    /* the current paragraph state */
90  tag_definition   *lastptr;     /* the end of the stack        */
91  simple_output    *out;
92  int               space_emitted;
93  int               current_indentation;  /* current .in value */
94  int               pageoffset;           /* .po value         */
95  int               linelength;         /* current line length */
96
97  int    is_present        (HTML_TAG t);
98  void   end_tag           (tag_definition *t);
99  void   start_tag         (tag_definition *t);
100  void   push_para         (HTML_TAG t, char *arg);
101  char  *shutdown          (HTML_TAG t);
102  void   check_emit_text   (tag_definition *t);
103  int    remove_break      (void);
104  void   issue_tag         (char *tagname, char *arg);
105  void   issue_table_begin (tag_definition *t);
106  void   issue_table_end   (void);
107  int    table_is_void     (tag_definition *t);
108  void   remove_def        (tag_definition *t);
109};
110