void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const
{
// we store this, because it is much easier
- has_limits_ = hasLimits(mi.base.font);
+ has_limits_ = hasLimits(mi.base.font.style());
// Compute metrics of the available cells
Dimension dim0;
}
-bool InsetMathScript::hasLimits(FontInfo const & font) const
+bool InsetMathScript::hasLimits(MathStyle const & style) const
{
if (nuc().empty())
return false;
Limits const lim = nuc().back()->limits() == AUTO_LIMITS
- ? nuc().back()->defaultLimits(font.style() == DISPLAY_STYLE)
+ ? nuc().back()->defaultLimits(style == DISPLAY_STYLE)
: nuc().back()->limits();
LASSERT(lim != AUTO_LIMITS, return false);
return lim == LIMITS;
{
bool d = hasDown() && !down().empty();
bool u = hasUp() && !up().empty();
- // FIXME: the MathMLStream should be able to give us this information
- bool l = has_limits_;
+ bool has_limits = hasLimits(ms.getFontMathStyle());
+ if (!d && !u)
+ return;
+
+ const char * tag = nullptr;
if (u && d)
- ms << MTag(l ? "munderover" : "msubsup");
+ tag = has_limits ? "munderover" : "msubsup";
else if (u)
- ms << MTag(l ? "mover" : "msup");
+ tag = has_limits ? "mover" : "msup";
else if (d)
- ms << MTag(l ? "munder" : "msub");
+ tag = has_limits ? "munder" : "msub";
+
+ ms << MTag(tag);
if (!nuc().empty())
- ms << MTag("mrow") << nuc() << ETag("mrow");
+ ms << nuc();
else
- ms << "<" << from_ascii(ms.namespacedTag("mrow")) << " />";
+ // TODO: is this empty <mrow> required?
+ ms << CTag("mrow");
- if (u && d)
- ms << MTag("mrow") << down() << ETag("mrow")
- << MTag("mrow") << up() << ETag("mrow")
- << ETag(l ? "munderover" : "msubsup");
- else if (u)
- ms << MTag("mrow") << up() << ETag("mrow") << ETag(l ? "mover" : "msup");
- else if (d)
- ms << MTag("mrow") << down() << ETag("mrow") << ETag(l ? "munder" : "msub");
+ // No need to wrap these in an <mrow>, as it's done by MathExtern.
+ // More details in https://www.lyx.org/trac/ticket/12221#comment:10.
+ if (d)
+ ms << down();
+ if (u)
+ ms << up();
+
+ ms << ETag(tag);
}