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"
28 StartTag(std::string const & tag, std::string const & attr,
29 bool keepempty = false)
30 : tag_(tag), attr_(attr), keepempty_(keepempty) {}
32 docstring asTag() const;
34 docstring asEndTag() const;
39 /// whether to keep things like "<tag></tag>" or discard them
40 /// you would want this for td, e.g, but maybe not for a div
47 EndTag(std::string tag) : tag_(tag) {}
49 docstring asEndTag() const;
58 CompTag(std::string const & tag, std::string const & attr)
59 : tag_(tag), attr_(attr) {}
61 docstring asTag() const;
72 explicit XHTMLStream(odocstream & os);
76 odocstream & os() { return os_; }
78 // int & tab() { return tab_; }
79 /// closes any font tags that are eligible to be closed,
80 /// i.e., last on the tag_stack_.
81 /// \return false if there are open font tags we could not close.
82 /// because they are "blocked" by open non-font tags on the stack.
85 XHTMLStream & operator<<(docstring const &);
87 XHTMLStream & operator<<(char_type);
89 XHTMLStream & operator<<(StartTag const &);
91 XHTMLStream & operator<<(EndTag const &);
93 XHTMLStream & operator<<(CompTag const &);
98 bool isTagOpen(std::string const &);
104 typedef std::deque<StartTag> TagDeque;
106 typedef std::vector<StartTag> TagStack;
107 /// holds start tags until we know there is content in them.
108 TagDeque pending_tags_;
109 /// remembers the history, so we can make sure we nest properly.
114 void xhtmlParagraphs(Text const & text,
117 OutputParams const & runparams);
121 docstring escapeChar(char_type c);
122 /// converts a string to a form safe for links, etc
123 docstring htmlize(docstring const & str);
126 /// \return true if tag was opened, false if not
127 bool openTag(odocstream & os, std::string const & tag,
128 std::string const & attr);
129 /// \return true if tag was opened, false if not
130 bool closeTag(odocstream & os, std::string const & tag);