Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line break in inline p in Safari only #1982

Closed
davidfarmer opened this issue Apr 19, 2018 · 10 comments
Closed

Line break in inline p in Safari only #1982

davidfarmer opened this issue Apr 19, 2018 · 10 comments
Labels
Accepted Issue has been reproduced by MathJax team Browser Bug Fixed Test Available v2.7

Comments

@davidfarmer
Copy link

When I have inline math inside a p styled inline, an extra line break occurs.
In up-to-date Safari only: it is fine in Firefox and Chrome on a MathBook Pro.

This page illustrates the problem:

https://aimath.org/~farmer/print/mathjaxinsafari.html

What you should see is that in the inline p, when I write
Suppose (x) is a number.
there is a line break before the "x".

I tried (unsuccessfully) to add some CSS to inline style the MathJax spans.
(Even if it worked, I don't think that is a great solution, but I could do it temporarily.)

@mitchkeller
Copy link

Mobile Safari on iOS is also impacted by this, and thus Chrome on iOS is also exhibiting the behavior.

@Alex-Jordan
Copy link

If I set the math renderer to Preview HTML, MathML, or Plain Source, and then reload the page, the line break goes away.

I see the line break if the math renderer is HTML-CSS, Common HTML, or SVG. And also if it is one of these things and I change the renderer to one of the first three things but do not refresh the page.

@nealeyoung
Copy link

@pkra
Copy link
Contributor

pkra commented Apr 24, 2018

Looks like a Safari bug (not present in recent WebKit).

Using inline-block instead of inline for the container should avoid this.

@nealeyoung
Copy link

Can anyone suggest a workaround (maybe using css) in the meantime?

@davidfarmer
Copy link
Author

@nealeyoung on your page I don't think it makes sense for your p paragraphs to be styled inline.
Removing that css (so the p defaults to block) should not change the appearance of the page.
(That is, remove line 1056, which has the selector
#content .inline-first-p > p:first-child
)

If you wanted to have the statement of the lemma start on the same line as the word "Lemma",
then you would set everything to be inline. That is the look I want, but it seems that I can't
have that and also use Safari.

But if you can't change that css, then there does not seem to be any way to fix it.

@nealeyoung
Copy link

Thanks. Yes, I would like what you suggested in your middle paragraph ("Lemma" on same line as following paragraph.) I can change the CSS, but, just as you surmise, if I remove that inline styling, I won't get the effect I want. I've fallen back to floating the "Lemma" left, which works okay most of the time, but sometimes does not have correct vertical alignment (baseline is off).

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Browser Bug labels May 29, 2018
@dpvc
Copy link
Member

dpvc commented Jun 6, 2018

The problem has to do with the fact that MathJax uses elements with display set to block-level values in order to measure the em and ex sizes and the container width. Such elements should introduce a line break, but in the past, and with other browsers, inserting these and then removing them before the page is repainted did not cause a permanent line break. Apparently recent versions of WebKit have changed that behavior.

I have worked out another mechanism for doing the measuring (see PR #2006). It has one minor downside, but should resolve the issues here. Unfortunately, there is no easy patch to get the new behavior now so you will have to wait until the next release of MathJax for this. If you are not using automatic line break in your math, it might be possible to use some CSS to avoid the problem for now (by disabling the measuring of the container width, which is the tricky bit). If you want that, I'll see if I can work that out.

@dpvc dpvc added this to the MathJax v2.7.5 milestone Jul 6, 2018
dpvc added a commit that referenced this issue Jul 9, 2018
Avoid line breaks for inline math in in WebKit. #1982
@dpvc dpvc added Test Needed Merged Merged into develop branch labels Jul 9, 2018
@dpvc dpvc closed this as completed Jul 9, 2018
dpvc added a commit to mathjax/MathJax-test that referenced this issue Jul 10, 2018
@dpvc
Copy link
Member

dpvc commented Jul 10, 2018

==> In testsuite
MathMLToDisplay/issue1982.html

@dpvc dpvc added Fixed v2.7 and removed Merged Merged into develop branch labels Feb 10, 2020
@dcts
Copy link

dcts commented Oct 14, 2021

Adding white-space: nowrap; to the p tag styling solved the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Browser Bug Fixed Test Available v2.7
Projects
None yet
Development

No branches or pull requests

7 participants