mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
98d1b04160
Another implementation would have been to use the lspace and rspace attributes in MathML, but they require to give the exact spacing before and after the operator instead of relying on rules like TeX. For instance, `$a\mathbin{+}b$` resulted in this MathML output before the patch: ``` <math xmlns='http://www.w3.org/1998/Math/MathML'> <mrow> <mi>a</mi><!-- --> <mi>[mathbin [char + mathalpha]]</mi> <mi>b</mi> </mrow> </math> ``` For comparison, this was the output with LyX 2.3.7 ``` <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <mrow><mi>a</mi><!-- --> <mi>[mathbin [char + mathalpha]] </mi><mi>b</mi> </mrow> </mrow></math> ``` After this patch, it looks like: ``` <math xmlns='http://www.w3.org/1998/Math/MathML'> <mstyle class='math'> <mrow> <mi>a</mi> <mo>+</mo> <mi>b</mi> </mrow> </mstyle> </math> ```
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file InsetMathClass.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author André Pönitz
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef MATH_CLASSINSET_H
|
|
#define MATH_CLASSINSET_H
|
|
|
|
#include "MathClass.h"
|
|
|
|
#include "InsetMathNest.h"
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
/// Support for LaTeX's \\mathxxx class-changing commands
|
|
|
|
class InsetMathClass : public InsetMathNest {
|
|
public:
|
|
///
|
|
InsetMathClass(Buffer * buf, MathClass);
|
|
///
|
|
docstring name() const override;
|
|
///
|
|
MathClass mathClass() const override { return math_class_; }
|
|
/// The default limits value in \c display style
|
|
Limits defaultLimits(bool display) const override;
|
|
/// whether the inset has limit-like sub/superscript
|
|
Limits limits() const override { return limits_; }
|
|
/// sets types of sub/superscripts
|
|
void limits(Limits lim) override { limits_ = lim; }
|
|
///
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
|
///
|
|
void draw(PainterInfo & pi, int x, int y) const override;
|
|
///
|
|
void write(TeXMathStream & os) const override;
|
|
///
|
|
void mathmlize(MathMLStream & ms) const override;
|
|
///
|
|
void infoize(odocstream & os) const override;
|
|
///
|
|
InsetCode lyxCode() const override { return MATH_CLASS_CODE; }
|
|
///
|
|
InsetMathClass * asClassInset() { return this; }
|
|
///
|
|
InsetMathClass const * asClassInset() const override { return this; }
|
|
|
|
private:
|
|
Inset * clone() const override;
|
|
///
|
|
MathClass math_class_;
|
|
///
|
|
Limits limits_ = AUTO_LIMITS;
|
|
};
|
|
|
|
|
|
} // namespace lyx
|
|
#endif
|