From 5ef3c828b2a745c9877865907f71f357c3015bca Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 29 Mar 2010 23:03:37 +0000 Subject: [PATCH] Simple characters. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33937 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathChar.cpp | 33 +++++++++++++++++++++++++++++++++ src/mathed/InsetMathChar.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index 4d5fc21120..f11ef5e5d3 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -201,6 +201,39 @@ void InsetMathChar::mathmlize(MathStream & ms) const } +void InsetMathChar::htmlize(HtmlStream & ms) const +{ + std::string entity; + switch (char_) { + case '<': entity = "<"; break; + case '>': entity = ">"; break; + case '&': entity = "&"; 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_ == '>'; diff --git a/src/mathed/InsetMathChar.h b/src/mathed/InsetMathChar.h index 6dba328c4e..65fac82fff 100644 --- a/src/mathed/InsetMathChar.h +++ b/src/mathed/InsetMathChar.h @@ -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; } ///