]> git.lyx.org Git - lyx.git/blobdiff - src/output_xhtml.h
Resave SpellcheckerUi.ui in qt 4.4 designer
[lyx.git] / src / output_xhtml.h
index 251f174b8d683740c7f873fd8861ecbdeab3faa7..4c389bd0aabfa1683d4b713c74262b12dda71c7a 100644 (file)
@@ -17,7 +17,6 @@
 #include "support/strfwd.h"
 
 #include <deque>
-#include <vector>
 
 namespace lyx {
 
@@ -84,6 +83,9 @@ struct CompTag {
        std::string attr_;
 };
 
+// trivial struct for output of newlines
+struct CR{};
+
 } // namespace html
 
 class XHTMLStream {
@@ -91,8 +93,6 @@ public:
        ///
        explicit XHTMLStream(odocstream & os);
        ///
-       void cr();
-       ///
        odocstream & os() { return os_; }
        ///
        // int & tab() { return tab_; }
@@ -101,6 +101,12 @@ public:
        /// \return false if there are open font tags we could not close.
        /// because they are "blocked" by open non-font tags on the stack.
        bool closeFontTags();
+       /// call at start of paragraph. sets a mark so we know what tags
+       /// to close at the end. 
+       void startParagraph();
+       /// call at end of paragraph to clear that mark. note that this
+       /// will also close any tags still open. 
+       void endParagraph();
        ///
        XHTMLStream & operator<<(docstring const &);
        ///
@@ -110,17 +116,24 @@ public:
        ///
        XHTMLStream & operator<<(int);
        ///
+       XHTMLStream & operator<<(char);
+       ///
        XHTMLStream & operator<<(html::StartTag const &);
        ///
        XHTMLStream & operator<<(html::EndTag const &);
        ///
        XHTMLStream & operator<<(html::CompTag const &);
-       /// A trivial struct that functions as a stream modifier.
-       /// << NextRaw() causes the next string-like thing sent to the
-       /// stream not to be escaped.
-       struct NextRaw {};
        ///
-       XHTMLStream & operator<<(NextRaw const &);
+       XHTMLStream & operator<<(html::CR const &);
+       ///
+       enum EscapeSettings {
+               ESCAPE_NONE,
+               ESCAPE_AND, // meaning &
+               ESCAPE_ALL  // meaning <, >, &, at present
+       };
+       /// Sets what we are going to escape on the NEXT write.
+       /// Everything is reset for the next time.
+       XHTMLStream & operator<<(EscapeSettings);
 private:
        ///
        void clearTagDeque();
@@ -131,17 +144,13 @@ private:
        ///
        odocstream & os_;
        ///
-       // int tab_;
-       ///
-       typedef std::deque<html::StartTag> TagDeque;
-       ///
-       typedef std::vector<html::StartTag> TagStack;
+       typedef std::deque<html::StartTag> TagStack;
        /// holds start tags until we know there is content in them.
-       TagDeque pending_tags_;
+       TagStack pending_tags_;
        /// remembers the history, so we can make sure we nest properly.
        TagStack tag_stack_;
        /// 
-       bool nextraw_;
+       EscapeSettings escape_;
 };
 
 ///
@@ -156,16 +165,16 @@ std::string alignmentToCSS(LyXAlignment align);
 
 namespace html {
 ///
-docstring escapeChar(char_type c);
+docstring escapeChar(char_type c, XHTMLStream::EscapeSettings e);
 /// converts a string to a form safe for links, etc
-docstring htmlize(docstring const & str);
+docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e);
 /// cleans \param str for use as an atttribute by replacing
 /// all non-alnum by "_"
 docstring cleanAttr(docstring const & str);
 ///
-std::string escapeChar(char c);
+std::string escapeChar(char c, XHTMLStream::EscapeSettings e);
 /// 
-std::string htmlize(std::string const & str);
+std::string htmlize(std::string const & str, XHTMLStream::EscapeSettings e);
 /// 
 std::string cleanAttr(std::string const & str);