virtual mode_type currentMode() const { return UNDECIDED_MODE; }
/// returns whether changing mode during latex export is forbidden
virtual bool lockedMode() const { return false; }
+ /// returns whether only ascii chars are allowed during latex export
+ virtual bool asciiOnly() const { return false; }
/// returns whether this inset is allowed in other insets of given mode
virtual bool allowedIn(mode_type) const { return true; }
/**
void CommandInset::write(WriteStream & os) const
{
+ ModeSpecifier specifier(os, currentMode(), lockedMode());
MathEnsurer ensurer(os, needs_math_mode_);
- os << '\\' << name_.c_str();
+ bool const ascii = os.asciiOnly();
+ os.asciiOnly(asciiOnly());
+ os << '\\' << name_;
if (cell(1).size())
os << '[' << cell(1) << ']';
os << '{' << cell(0) << '}';
+ os.asciiOnly(ascii);
}
docstring res;
if (numberedType()) {
if (label_[row] && !nonum_[row])
- res += "\\label{" + label_[row]->getParam("name") + '}';
+ res += "\\label{" +
+ escape(label_[row]->getParam("name")) + '}';
if (nonum_[row] && (type_ != hullMultline))
res += "\\nonumber ";
}
///
void infoize(odocstream & os) const;
///
+ mode_type currentMode() const { return TEXT_MODE; }
+ ///
+ bool lockedMode() const { return true; }
+ ///
+ bool asciiOnly() const { return true; }
+ ///
docstring const screenLabel() const;
///
void validate(LaTeXFeatures & features) const;
#include "support/lstrings.h"
#include "support/textutils.h"
+using lyx::support::escape;
+
namespace lyx {
void InsetMathString::write(WriteStream & os) const
{
if (!os.latex() || os.lockedMode()) {
- os << str_;
+ os << (os.asciiOnly() ? escape(str_) : str_);
return;
}
Encoding const * encoding)
: os_(os), fragile_(fragile), firstitem_(false), latex_(latex),
output_(output), pendingspace_(false), pendingbrace_(false),
- textmode_(false), locked_(0), line_(0), encoding_(encoding)
+ textmode_(false), locked_(0), ascii_(0), line_(0), encoding_(encoding)
{}
WriteStream::WriteStream(odocstream & os)
: os_(os), fragile_(false), firstitem_(false), latex_(false),
output_(wsDefault), pendingspace_(false), pendingbrace_(false),
- textmode_(false), locked_(0), line_(0), encoding_(0)
+ textmode_(false), locked_(0), ascii_(0), line_(0), encoding_(0)
{}
}
+void WriteStream::asciiOnly(bool ascii)
+{
+ ascii_ = ascii;
+}
+
+
WriteStream & operator<<(WriteStream & ws, MathAtom const & at)
{
at->write(ws);
void lockedMode(bool locked);
/// tell whether we are allowed to switch mode when producing latex code
bool lockedMode() const { return locked_; }
+ /// tell whether to use only ascii chars when producing latex code
+ void asciiOnly(bool ascii);
+ /// tell whether to use only ascii chars when producing latex code
+ bool asciiOnly() const { return ascii_; }
/// LaTeX encoding
Encoding const * encoding() const { return encoding_; }
private:
bool textmode_;
/// are we allowed to switch mode when producing latex code?
bool locked_;
+ /// should we use only ascii chars when producing latex code?
+ bool ascii_;
///
int line_;
///