Juergen Spitzmueller wrote:
Angus Leeming wrote:
Make the addPreview call conditional on "snippet" not being empty:
Thanks, Angus.
Actually, it's not that easy, unfortunately, since snippet is never empty. For
empty insets, it's '$ $'. A check for cell(0).empty() is better, but that
fails for nested empty insets, e.g. $\mbox{}$ as well as for empty arrays,
which both trigger the bug.
I didn't found a way yet to get the contents of a mathinset without any LaTeX
cruft. Even plaintext outputs "\mbox{}" and "\begin{array}...\end{array}".
Any ideas?
None.
Apart from that, could somebody with python knowledge have a look at the
internal reasons of the bug, the calculation of the absurd frac value?
AFAICS, this is done in legacy_lyxpreview2ppm.py.
The relevant code is
ascent = string.atof(match.group(2)) + tp_ascent
descent = string.atof(match.group(3)) - tp_descent
frac = 0.5
if abs(ascent + descent) > 0.1:
frac = ascent / (ascent + descent)
metrics.write("Snippet %s %f\n" % (match.group(1), frac))
Indentation is important to python and I think it's wrong here.
If you line up the "m" of "metrics.write" with the
"i" of "if abs(ascent..." then the metrics info will be written.
I suspect that your impossible value comes from attempting to read past the
end of the metrics file which doesn't actually contain as many lines as are
expected.
The absurd frac value is calculated from this entry in the log file:
Snippet 1 0 0 0
i.e., if ascent and descent are 0.
Thanks,
Jürgen
Angus