]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/groff/src/devices/grohtml/html-text.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / groff / src / devices / grohtml / html-text.h
1 // -*- C++ -*-
2 /* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
3  * Free Software Foundation, Inc.
4  *
5  *  Gaius Mulley (gaius@glam.ac.uk) wrote html-text.h
6  *
7  *  html-text.h
8  *
9  *  provides a state machine interface which generates html text.
10  */
11
12 /*
13 This file is part of groff.
14
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.
19
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.
24
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. */
28
29 #include "html.h"
30 #include "html-table.h"
31
32 #define STYLE_VERTICAL_SPACE "1em"
33
34 /*
35  *  html tags
36  */
37
38 typedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
39               PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG,
40               COLOR_TAG} HTML_TAG;
41
42 typedef struct tag_definition {
43   HTML_TAG        type;
44   void           *arg1;
45   int             text_emitted;
46   color           col;
47   html_indent    *indent;
48   tag_definition *next;
49 } tag_definition ;
50
51 /*
52  *  the state of the current paragraph.
53  *  It allows post-html.cpp to request font changes, paragraph start/end
54  *  and emits balanced tags with a small amount of peephole optimization.
55  */
56
57 class html_text {
58 public:
59          html_text         (simple_output *op);
60         ~html_text         (void);
61   void   flush_text        (void);
62   void   do_emittext       (const char *s, int length);
63   void   do_italic         (void);
64   void   do_bold           (void);
65   void   do_roman          (void);
66   void   do_tt             (void);
67   void   do_pre            (void);
68   void   do_small          (void);
69   void   do_big            (void);
70   void   do_para           (const char *arg, int space); // used for no indentation
71   void   do_para           (simple_output *op, const char *arg1,
72                             int indentation, int pageoffset, int linelength,
73                             int space);
74   void   do_sup            (void);
75   void   do_sub            (void);
76   void   do_space          (void);
77   void   do_break          (void);
78   void   do_newline        (void);
79   void   do_table          (const char *arg);
80   void   done_bold         (void);
81   void   done_italic       (void);
82   char  *done_para         (void);
83   void   done_sup          (void);
84   void   done_sub          (void);
85   void   done_tt           (void);
86   void   done_pre          (void);
87   void   done_small        (void);
88   void   done_big          (void);
89   void   do_color          (color *c);
90   void   done_color        (void);
91   int    emitted_text      (void);
92   int    ever_emitted_text (void);
93   int    starts_with_space (void);
94   int    retrieve_para_space (void);
95   void   emit_space        (void);
96   int    is_in_pre         (void);
97   int    uses_indent       (void);
98   void   remove_tag        (HTML_TAG tag);
99   void   remove_sub_sup    (void);
100   void   remove_para_align (void);
101   void   remove_para_space (void);
102   char  *get_alignment     (void);
103
104 private:
105   tag_definition   *stackptr;    /* the current paragraph state */
106   tag_definition   *lastptr;     /* the end of the stack        */
107   simple_output    *out;
108   int               space_emitted;   /* just emitted a space?   */
109   int               current_indentation;   /* current .in value */
110   int               pageoffset;            /* .po value         */
111   int               linelength;          /* current line length */
112   int               blank_para;   /* have we ever written text? */
113   int               start_space;  /* does para start with a .sp */
114   html_indent      *indent;                 /* our indent class */
115
116   int    is_present          (HTML_TAG t);
117   void   end_tag             (tag_definition *t);
118   void   start_tag           (tag_definition *t);
119   void   do_para             (const char *arg, html_indent *in, int space);
120   void   push_para           (HTML_TAG t);
121   void   push_para           (HTML_TAG t, void *arg, html_indent *in);
122   void   push_para           (color *c);
123   void   do_push             (tag_definition *p);
124   char  *shutdown            (HTML_TAG t);
125   void   check_emit_text     (tag_definition *t);
126   int    remove_break        (void);
127   void   issue_tag           (const char *tagname, const char *arg, int space=2);
128   void   issue_color_begin   (color *c);
129   void   remove_def          (tag_definition *t);
130   html_indent *remove_indent (HTML_TAG tag);
131   void   dump_stack_element  (tag_definition *p);
132   void   dump_stack          (void);
133 };