html-text.h revision 114402
175584Sru// -*- C++ -*-
2114402Sru/* Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
375584Sru *
4114402Sru *  Gaius Mulley (gaius@glam.ac.uk) wrote html-text.h
575584Sru *
675584Sru *  html-text.h
775584Sru *
875584Sru *  provides a state machine interface which generates html text.
975584Sru */
1075584Sru
1175584Sru/*
1275584SruThis file is part of groff.
1375584Sru
1475584Srugroff is free software; you can redistribute it and/or modify it under
1575584Sruthe terms of the GNU General Public License as published by the Free
1675584SruSoftware Foundation; either version 2, or (at your option) any later
1775584Sruversion.
1875584Sru
1975584Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
2075584SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
2175584SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2275584Srufor more details.
2375584Sru
2475584SruYou should have received a copy of the GNU General Public License along
2575584Sruwith groff; see the file COPYING.  If not, write to the Free Software
2675584SruFoundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2775584Sru
2875584Sru#include "html.h"
29104862Sru#include "html-table.h"
3075584Sru
3175584Sru/*
3275584Sru *  html tags
3375584Sru */
3475584Sru
3575584Srutypedef enum {I_TAG, B_TAG, P_TAG, SUB_TAG, SUP_TAG, TT_TAG,
36104862Sru	      PRE_TAG, SMALL_TAG, BIG_TAG, BREAK_TAG,
37104862Sru	      COLOR_TAG} HTML_TAG;
3875584Sru
3975584Srutypedef struct tag_definition {
4075584Sru  HTML_TAG        type;
41104862Sru  void           *arg1;
4275584Sru  int             text_emitted;
43104862Sru  color           col;
44104862Sru  html_indent    *indent;
4575584Sru  tag_definition *next;
4675584Sru} tag_definition ;
4775584Sru
4875584Sru/*
4975584Sru *  the state of the current paragraph.
50114402Sru *  It allows post-html.cpp to request font changes, paragraph start/end
5175584Sru *  and emits balanced tags with a small amount of peephole optimization.
5275584Sru */
5375584Sru
5475584Sruclass html_text {
5575584Srupublic:
56104862Sru         html_text         (simple_output *op);
57104862Sru        ~html_text         (void);
58104862Sru  void   flush_text        (void);
59104862Sru  void   do_emittext       (const char *s, int length);
60104862Sru  void   do_italic         (void);
61104862Sru  void   do_bold           (void);
62104862Sru  void   do_roman          (void);
63104862Sru  void   do_tt             (void);
64104862Sru  void   do_pre            (void);
65104862Sru  void   do_small          (void);
66104862Sru  void   do_big            (void);
67104862Sru  void   do_para           (const char *arg);  // used for no indentation
68104862Sru  void   do_para           (simple_output *op, const char *arg1,
69104862Sru			    int indentation, int pageoffset, int linelength);
70104862Sru  void   do_sup            (void);
71104862Sru  void   do_sub            (void);
72104862Sru  void   do_space          (void);
73104862Sru  void   do_break          (void);
74104862Sru  void   do_newline        (void);
75104862Sru  void   do_table          (const char *arg);
76104862Sru  void   done_bold         (void);
77104862Sru  void   done_italic       (void);
78104862Sru  char  *done_para         (void);
79104862Sru  void   done_sup          (void);
80104862Sru  void   done_sub          (void);
81104862Sru  void   done_tt           (void);
82104862Sru  void   done_pre          (void);
83104862Sru  void   done_small        (void);
84104862Sru  void   done_big          (void);
85104862Sru  void   do_color          (color *c);
86104862Sru  void   done_color        (void);
87104862Sru  int    emitted_text      (void);
88104862Sru  int    ever_emitted_text (void);
89104862Sru  int    starts_with_space (void);
90104862Sru  void   emit_space        (void);
91104862Sru  int    is_in_pre         (void);
92104862Sru  void   remove_tag        (HTML_TAG tag);
93104862Sru  void   remove_sub_sup    (void);
94104862Sru  void   remove_para_align (void);
9575584Sru
9675584Sruprivate:
9775584Sru  tag_definition   *stackptr;    /* the current paragraph state */
9875584Sru  tag_definition   *lastptr;     /* the end of the stack        */
9975584Sru  simple_output    *out;
100104862Sru  int               space_emitted;   /* just emitted a space?   */
101104862Sru  int               current_indentation;   /* current .in value */
102104862Sru  int               pageoffset;            /* .po value         */
103104862Sru  int               linelength;          /* current line length */
104104862Sru  int               blank_para;   /* have we ever written text? */
105104862Sru  int               start_space;  /* does para start with a .sp */
106104862Sru  html_indent      *indent;                 /* our indent class */
10775584Sru
108104862Sru  int    is_present          (HTML_TAG t);
109104862Sru  void   end_tag             (tag_definition *t);
110104862Sru  void   start_tag           (tag_definition *t);
111104862Sru  void   do_para             (const char *arg, html_indent *in);
112104862Sru  void   push_para           (HTML_TAG t);
113104862Sru  void   push_para           (HTML_TAG t, void *arg, html_indent *in);
114104862Sru  void   push_para           (color *c);
115104862Sru  void   do_push             (tag_definition *p);
116104862Sru  char  *shutdown            (HTML_TAG t);
117104862Sru  void   check_emit_text     (tag_definition *t);
118104862Sru  int    remove_break        (void);
119114402Sru  void   issue_tag           (const char *tagname, const char *arg);
120104862Sru  void   issue_color_begin   (color *c);
121104862Sru  void   remove_def          (tag_definition *t);
122104862Sru  html_indent *remove_indent (HTML_TAG tag);
123104862Sru  void   dump_stack_element  (tag_definition *p);
124104862Sru  void   dump_stack          (void);
12575584Sru};
126