4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef OUTPUT_XHTML_H
13 #define OUTPUT_XHTML_H
15 #include "support/docstream.h"
26 // Inspiration for the *Tag structs and for XHTMLStream
27 // came from MathStream and its cousins.
31 StartTag(std::string const & tag) : tag_(tag) {}
33 StartTag(std::string const & tag, std::string const & attr,
34 bool keepempty = false)
35 : tag_(tag), attr_(attr), keepempty_(keepempty) {}
37 docstring asTag() const;
39 docstring asEndTag() const;
44 /// whether to keep things like "<tag></tag>" or discard them
45 /// you would want this for td, e.g, but maybe not for a div
52 EndTag(std::string tag) : tag_(tag) {}
54 docstring asEndTag() const;
63 CompTag(std::string const & tag)
66 CompTag(std::string const & tag, std::string const & attr)
67 : tag_(tag), attr_(attr) {}
69 docstring asTag() const;
80 explicit XHTMLStream(odocstream & os);
84 odocstream & os() { return os_; }
86 // int & tab() { return tab_; }
87 /// closes any font tags that are eligible to be closed,
88 /// i.e., last on the tag_stack_.
89 /// \return false if there are open font tags we could not close.
90 /// because they are "blocked" by open non-font tags on the stack.
93 XHTMLStream & operator<<(docstring const &);
95 XHTMLStream & operator<<(const char *);
97 XHTMLStream & operator<<(char_type);
99 XHTMLStream & operator<<(StartTag const &);
101 XHTMLStream & operator<<(EndTag const &);
103 XHTMLStream & operator<<(CompTag const &);
106 void clearTagDeque();
108 bool isTagOpen(std::string const &);
110 void writeError(std::string const &);
116 typedef std::deque<StartTag> TagDeque;
118 typedef std::vector<StartTag> TagStack;
119 /// holds start tags until we know there is content in them.
120 TagDeque pending_tags_;
121 /// remembers the history, so we can make sure we nest properly.
126 void xhtmlParagraphs(Text const & text,
129 OutputParams const & runparams);
133 docstring escapeChar(char_type c);
134 /// converts a string to a form safe for links, etc
135 docstring htmlize(docstring const & str);
138 /// \return true if tag was opened, false if not
139 bool openTag(odocstream & os, std::string const & tag,
140 std::string const & attr);
141 /// \return true if tag was opened, false if not
142 bool closeTag(odocstream & os, std::string const & tag);