mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.22k stars 1.16k forks source link

MathJax_Preview causes extra line break in Firefox within list items #1555

Closed pkra closed 8 years ago

pkra commented 8 years ago

From a user report elsewhere.

If one starts a list item <li> with a mathjax alignment structure, the equations will become vertically centered with respect to the list item in Chrome and top aligned in Firefox. You can see this in https://cdi2tp.math.tecnico.ulisboa.pt/enunciados/ExameAsol2015160627.php if you open the second collapsed <details>.

Firefox:

Firefox

Chrome

Chrome

I haven't had a chance to take a closer look, so labeling it investigate.

cebola2 commented 8 years ago

I have created a more minimal example that exhibits the same behavior. There are no

in this case hence the title for this issue seems to be a misnomer. See https://math.tecnico.ulisboa.pt/teste

dpvc commented 8 years ago

The issue is that Firefox and Chrome treat the empty MathJax_Preview span that precedes the typeset math differently in this situation. In Firefox, the empty span is treated as in-line material and so the block level expression needs to start a new line following that material. In Chrome, the fact that the span is empty seems to be taken into account and Chrome puts the block-level material at the top of the list item.

If the MathJax_Preview span is removed, Firefox's output is the same as Chrome's. So adding he following

<script type="text/x-mathjax-config">
if (MathJax.Hub.Borwser.isFirefox) {
  Mathjax.Hub.Queue(function () {
    var previews = document.querySelectAll(".MathJax_Preview");
    for (var i = 0, m = previews.length; i < m; i++) {
      previews[i].parentNode.removeChild(previews[i]);
    }
  });
}
</script>

to the page somewhere before the script that loads MathJax.js should clear up the issue.

@pkra, do we want to think about removing the previews ourselves? There are reasons these weren't removed which we can discuss if you want to consider it.

pkra commented 8 years ago

@pkra, do we want to think about removing the previews ourselves?

Yes, let's discuss this at the next F2F.

dpvc commented 8 years ago

Actually, it turns out that setting display:none also has the desired effect, so that might be the better approach.

pkra commented 8 years ago

:+1:

dpvc commented 8 years ago

@pkra, do we want to add this to 2.7, since the change is minimal?

pkra commented 8 years ago

@dpvc sounds good to me.

dpvc commented 8 years ago

==> In testsuite

MathMLToDisplay/issue1555.html

dpvc commented 8 years ago

==> Merged