InsetQuote works again.

Is this simple stream modifier thing OK?


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32112 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-11-19 23:29:07 +00:00
parent 6d4db0ee44
commit 603b94966a
4 changed files with 48 additions and 15 deletions

View File

@ -26,6 +26,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"
@ -688,31 +689,32 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetSpace::xhtml(odocstream & os, OutputParams const &) const docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
{ {
string output;
switch (params_.kind) { switch (params_.kind) {
case InsetSpaceParams::NORMAL: case InsetSpaceParams::NORMAL:
os << " "; output = " ";
break; break;
case InsetSpaceParams::ENSKIP: case InsetSpaceParams::ENSKIP:
case InsetSpaceParams::ENSPACE: case InsetSpaceParams::ENSPACE:
os << "&ensp;"; output ="&ensp;";
break; break;
case InsetSpaceParams::QQUAD: case InsetSpaceParams::QQUAD:
os << "&emsp;"; output ="&emsp;";
case InsetSpaceParams::THICK: case InsetSpaceParams::THICK:
case InsetSpaceParams::QUAD: case InsetSpaceParams::QUAD:
os << "&emsp;"; output ="&emsp;";
break; break;
case InsetSpaceParams::THIN: case InsetSpaceParams::THIN:
os << "&thinsp;"; output ="&thinsp;";
break; break;
case InsetSpaceParams::PROTECTED: case InsetSpaceParams::PROTECTED:
case InsetSpaceParams::MEDIUM: case InsetSpaceParams::MEDIUM:
case InsetSpaceParams::NEGTHIN: case InsetSpaceParams::NEGTHIN:
case InsetSpaceParams::NEGMEDIUM: case InsetSpaceParams::NEGMEDIUM:
case InsetSpaceParams::NEGTHICK: case InsetSpaceParams::NEGTHICK:
os << "&nbsp;"; output ="&nbsp;";
break; break;
case InsetSpaceParams::HFILL: case InsetSpaceParams::HFILL:
case InsetSpaceParams::HFILL_PROTECTED: case InsetSpaceParams::HFILL_PROTECTED:
@ -722,14 +724,17 @@ docstring InsetSpace::xhtml(odocstream & os, OutputParams const &) const
case InsetSpaceParams::RIGHTARROWFILL: case InsetSpaceParams::RIGHTARROWFILL:
case InsetSpaceParams::UPBRACEFILL: case InsetSpaceParams::UPBRACEFILL:
case InsetSpaceParams::DOWNBRACEFILL: case InsetSpaceParams::DOWNBRACEFILL:
// FIXME Can we do anything with those in HTML? // FIXME XHTML
os << '\n'; // Can we do anything with those in HTML?
break; break;
case InsetSpaceParams::CUSTOM: case InsetSpaceParams::CUSTOM:
case InsetSpaceParams::CUSTOM_PROTECTED: case InsetSpaceParams::CUSTOM_PROTECTED:
// FIXME Probably we could do some sort of blank span? // FIXME XHTML
os << '\n'; // Probably we could do some sort of blank span?
break;
} }
// don't escape the entities!
xs << XHTMLStream::NextRaw() << from_ascii(output);
return docstring(); return docstring();
} }

View File

@ -129,7 +129,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(odocstream &, OutputParams const &) const; docstring xhtml(XHTMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;
/// the string that is passed to the TOC /// the string that is passed to the TOC

View File

@ -187,7 +187,11 @@ void XHTMLStream::clearTagDeque()
XHTMLStream & XHTMLStream::operator<<(docstring const & d) XHTMLStream & XHTMLStream::operator<<(docstring const & d)
{ {
clearTagDeque(); clearTagDeque();
os_ << html::htmlize(d); if (nextraw_) {
os_ << d;
nextraw_ = false;
} else
os_ << html::htmlize(d);
return *this; return *this;
} }
@ -195,7 +199,12 @@ XHTMLStream & XHTMLStream::operator<<(docstring const & d)
XHTMLStream & XHTMLStream::operator<<(const char * s) XHTMLStream & XHTMLStream::operator<<(const char * s)
{ {
clearTagDeque(); clearTagDeque();
os_ << html::htmlize(from_ascii(s)); docstring const d = from_ascii(s);
if (nextraw_) {
os_ << d;
nextraw_ = false;
} else
os_ << html::htmlize(d);
return *this; return *this;
} }
@ -203,7 +212,18 @@ XHTMLStream & XHTMLStream::operator<<(const char * s)
XHTMLStream & XHTMLStream::operator<<(char_type c) XHTMLStream & XHTMLStream::operator<<(char_type c)
{ {
clearTagDeque(); clearTagDeque();
os_ << html::escapeChar(c); if (nextraw_) {
os_ << c;
nextraw_ = false;
} else
os_ << html::escapeChar(c);
return *this;
}
XHTMLStream & XHTMLStream::operator<<(NextRaw const &)
{
nextraw_ = true;
return *this; return *this;
} }

View File

@ -101,6 +101,12 @@ public:
XHTMLStream & operator<<(EndTag const &); XHTMLStream & operator<<(EndTag const &);
/// ///
XHTMLStream & operator<<(CompTag const &); XHTMLStream & operator<<(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 &);
private: private:
/// ///
void clearTagDeque(); void clearTagDeque();
@ -120,6 +126,8 @@ private:
TagDeque pending_tags_; TagDeque pending_tags_;
/// remembers the history, so we can make sure we nest properly. /// remembers the history, so we can make sure we nest properly.
TagStack tag_stack_; TagStack tag_stack_;
///
bool nextraw_;
}; };
/// ///