X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathChar.cpp;h=03bda07cf60475c4ebaae4584ea401c613fccc12;hb=6de3c19fd63f810eed90ef3bc4469faf28e949c2;hp=f11ef5e5d3adc91e1b0bbc9cad68a00725284737;hpb=5ef3c828b2a745c9877865907f71f357c3015bca;p=lyx.git diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index f11ef5e5d3..03bda07cf6 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -18,7 +18,7 @@ #include "MetricsInfo.h" #include "Dimension.h" -#include "Encoding.h" +#include "BufferEncodings.h" #include "LaTeXFeatures.h" #include "TextPainter.h" @@ -140,8 +140,8 @@ void InsetMathChar::write(WriteStream & os) const void InsetMathChar::validate(LaTeXFeatures & features) const { - if (char_ >= 0x80) - encodings.validate(char_, features, true); + if (!isASCII(char_)) + BufferEncodings::validate(char_, features, true); } @@ -172,11 +172,10 @@ void InsetMathChar::mathmlize(MathStream & ms) const case '<': entity = "<"; break; case '>': entity = ">"; break; case '&': entity = "&"; break; - case ' ': - if (!ms.inText()) - break; - entity = " "; - break; + case ' ': { + ms << from_ascii(" "); + return; + } default: break; } @@ -187,14 +186,14 @@ void InsetMathChar::mathmlize(MathStream & ms) const ms << from_ascii(entity); return; } - + if (!entity.empty()) { ms << "" << from_ascii(entity) << ""; return; } char const * type = - (isalpha(char_) || Encodings::isMathAlpha(char_)) + (isAlphaASCII(char_) || Encodings::isMathAlpha(char_)) ? "mi" : "mo"; // we don't use MTag and ETag because we do not want the spacing ms << "<" << type << ">" << char_type(char_) << ""; @@ -208,12 +207,13 @@ void InsetMathChar::htmlize(HtmlStream & ms) const case '<': entity = "<"; break; case '>': entity = ">"; break; case '&': entity = "&"; break; + case ' ': entity = " "; break; default: break; } - bool have_entity = entity.empty(); + bool have_entity = !entity.empty(); - if (ms.inText() || have_entity) { + if (ms.inText()) { if (have_entity) ms << from_ascii(entity); else @@ -221,16 +221,18 @@ void InsetMathChar::htmlize(HtmlStream & ms) const return; } - if (!entity.empty()) { + if (have_entity) { + // an operator, so give some space 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; + if (isAlphaASCII(char_) || Encodings::isMathAlpha(char_)) + // we don't use MTag and ETag because we do not want the spacing + ms << MTag("i") << char_type(char_) << ETag("i"); + else + // an operator, so give some space + ms << " " << char_type(char_) << " "; }