]> git.lyx.org Git - features.git/commitdiff
Simple characters.
authorRichard Heck <rgheck@comcast.net>
Mon, 29 Mar 2010 23:03:37 +0000 (23:03 +0000)
committerRichard Heck <rgheck@comcast.net>
Mon, 29 Mar 2010 23:03:37 +0000 (23:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33937 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathChar.cpp
src/mathed/InsetMathChar.h

index 4d5fc2112031dadbaa92274c6423b77d717cdd49..f11ef5e5d3adc91e1b0bbc9cad68a00725284737 100644 (file)
@@ -201,6 +201,39 @@ void InsetMathChar::mathmlize(MathStream & ms) const
 }
 
 
+void InsetMathChar::htmlize(HtmlStream & ms) const
+{
+       std::string entity;
+       switch (char_) {
+               case '<': entity = "&lt;"; break;
+               case '>': entity = "&gt;"; break;
+               case '&': entity = "&amp;"; break;
+               default: break;
+       }
+       
+       bool have_entity = entity.empty();
+       
+       if (ms.inText() || have_entity) {
+               if (have_entity)
+                       ms << from_ascii(entity);
+               else
+                       ms.os().put(char_);
+               return;
+       }
+       
+       if (!entity.empty()) {
+               ms << ' ' << from_ascii(entity) << ' ';
+               return;
+       }               
+
+       char const * space = 
+               (isalpha(char_) || Encodings::isMathAlpha(char_))
+                       ? "" : " ";
+       // we don't use MTag and ETag because we do not want the spacing
+       ms << space << char_type(char_) << space;       
+}
+
+
 bool InsetMathChar::isRelOp() const
 {
        return char_ == '=' || char_ == '<' || char_ == '>';
index 6dba328c4e3deac9c4aec64a589ad29c72840447..65fac82fffb04c5067ebec2c0d4beb7f9e793068 100644 (file)
@@ -42,6 +42,8 @@ public:
        void octave(OctaveStream & os) const;
        ///
        void mathmlize(MathStream & ms) const;
+       ///
+       void htmlize(HtmlStream & ms) const;
        /// identifies Charinsets
        InsetMathChar const * asCharInset() const { return this; }
        ///