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, std::string const & attr)
64 : tag_(tag), attr_(attr) {}
66 docstring asTag() const;
77 explicit XHTMLStream(odocstream & os);
81 odocstream & os() { return os_; }
83 // int & tab() { return tab_; }
84 /// closes any font tags that are eligible to be closed,
85 /// i.e., last on the tag_stack_.
86 /// \return false if there are open font tags we could not close.
87 /// because they are "blocked" by open non-font tags on the stack.
90 XHTMLStream & operator<<(docstring const &);
92 XHTMLStream & operator<<(const char *);
94 XHTMLStream & operator<<(char_type);
96 XHTMLStream & operator<<(StartTag const &);
98 XHTMLStream & operator<<(EndTag const &);
100 XHTMLStream & operator<<(CompTag const &);
103 void clearTagDeque();
105 bool isTagOpen(std::string const &);
111 typedef std::deque<StartTag> TagDeque;
113 typedef std::vector<StartTag> TagStack;
114 /// holds start tags until we know there is content in them.
115 TagDeque pending_tags_;
116 /// remembers the history, so we can make sure we nest properly.
121 void xhtmlParagraphs(Text const & text,
124 OutputParams const & runparams);
128 docstring escapeChar(char_type c);
129 /// converts a string to a form safe for links, etc
130 docstring htmlize(docstring const & str);
133 /// \return true if tag was opened, false if not
134 bool openTag(odocstream & os, std::string const & tag,
135 std::string const & attr);
136 /// \return true if tag was opened, false if not
137 bool closeTag(odocstream & os, std::string const & tag);