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?

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))

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

Reply via email to