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 breaks break LaTeX #14564

Closed
EricForgy opened this issue Mar 22, 2019 · 8 comments
Closed

Line breaks break LaTeX #14564

EricForgy opened this issue Mar 22, 2019 · 8 comments
Labels
Needs Testing Needs further testing to be confirmed.

Comments

@EricForgy
Copy link

EricForgy commented Mar 22, 2019

Hi,

I am not a professional blogger, but I like to write an occasional article on mathematical research and I rely heavily on the LaTeX support described here:

https://en.support.wordpress.com/latex/

How can I get this to work with the new editor? 🙏

My old articles still display LaTeX fine, but I haven't figured out how to write a new article.

Thank you

PS:

Please post help requests or ‘how to’ questions in support channels first.

Where are the support channels? 🙏 Found them 👍

Edit: Oh. I realize

$latex E = mc^2$

works fine,

but I used to use

$latex
\displaystyle
E = mc^2$

I guess it is just "\displaystyle" that no longer works. How do I get "\displaystyle" to work or is there another way?

@EricForgy
Copy link
Author

I found my problem, but it seems to highlight an actual issue with Gutenberg 🤔

image

I can get \displaystyle to work now, but I need to put my entire equation on a single line. Newline breaks seems to be broken in Gutenberg when writing LaTeX.

For example,

$latex \displaystyle E = mc^2$

works fine, but

$latex
\displaystyle E = mc^2$

does not work because of the line break. I think line breaks should be allowed. They worked before with the old editor.

Any chance that can be fixed? 🙏

@EricForgy EricForgy changed the title Help with LaTeX Line breaks break LateX Mar 22, 2019
@EricForgy EricForgy changed the title Line breaks break LateX Line breaks break LaTeX Mar 22, 2019
@youknowriad youknowriad added the Needs Testing Needs further testing to be confirmed. label Mar 22, 2019
@youknowriad
Copy link
Contributor

Thanks for the issue.

I think Latex is not a Gutenberg issue as it's WP.com feature or Jetpack. Might be better to open an issue in the Jetpack repository https://github.com/Automattic/jetpack/issues

@aduth
Copy link
Member

aduth commented Mar 25, 2019

Hi @EricForgy ,

@youknowriad is correct that ultimately, the LaTeX feature is provided by either WordPress.com or Jetpack, and isn't directly a core Gutenberg issue.

I noticed that the difference between the new and old editors is that Gutenberg will use an HTML linebreak <br/>, where the previous editor would just use standard newlines. I suppose this is interfering with the feature's ability to convert the LaTeX expression.

As a workaround, you can also consider using the Preformatted block. In my testing, this supports multi-line LaTeX expressions formatted as you've demonstrated in your last comment.

Edit: On further testing, I see that even in the Preformatted block, Enter will insert the HTML linebreak. But if you choose to "Edit as HTML" from the block toolbar More Options menu, you can insert normal line breaks and they will be respected. I'm curious whether the behavior of the Preformatted block shouldn't be changed to treat Enter as simply inserting a normal newline, rather than an HTML <br/>.

@EricForgy
Copy link
Author

EricForgy commented Mar 26, 2019

Hi @youknowriad and @aduth ,

Thank you for your comments. I think I understand what you are saying, but I do still think this is a Gutenberg issue because it is Gutenberg that is treating the line breaks incorrectly for multiline LaTeX equation, whereas the old editor handled them properly.

The Preformatted block workaround would be fine if it were documented in the LaTeX support section and if it handled Enter correctly for multiline equations (like the old editor did).

Any chance to keep this issue open?

Edit: I just noticed the Preformatted block puts a thick grey border around the equations (theme "Nucleare"), which is not really ok. For now, I am sticking to just keeping all my equations as a long single line, but that is suboptimal 🤔

On the positive side, I recently switched from an ancient theme I had for close to 10 years and "Nucleare" renders math quite beautifully, so overall I am still very happy. I do hope this issue gets resolved though 🙏

@aduth
Copy link
Member

aduth commented Mar 26, 2019

@EricForgy One of the objectives of Gutenberg was to start moving away from WordPress' wpautop toward well-structured HTML. It appears your workflow has become a casualty of this, by the fact that <br> in place of a line break is no longer understood by WordPress.com / Jetpack's LaTeX feature (it is not a core feature of WordPress). Personally, I'd suggest that this be opened as a request on the Jetpack repository to improve the implementation of the LaTeX feature to be more tolerant of <br> markup. I do not expect that Gutenberg will stop using <br>.

On a related note, I did some further investigation about the use of <br> in Preformatted, and had landed upon the change introduced in #13799, which both fixes another problem, and expands on the reasons for using <br>.

@ellatrix
Copy link
Member

In addition to #13799, we could also save the preformatted value with normal line breaks (by replacing <br> elements in the onChange handler. I guess it would also make the content a bit easier to read in HTML mode. Worth noting that it would revert nothing of #13799. Previously the line breaks would also be converted to <br> elements if you change the content, and inserted line breaks would be <br> elements as well.

@ellatrix
Copy link
Member

@EricForgy Did this ever work in the new editor? I'm not sure #13799 introduced this at all.

@EricForgy
Copy link
Author

Hi @ellatrix 👋

I'm not sure about anything 😅 It's been a while since I last wrote an article and the old editor was stll available back then. This is the first time for me to use the new editor with LaTeX and experiencing some pains. Maybe it never worked?

If this is really a Jetpack problem, I can try to bug them, but if it could be fixed here, that would be great 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed.
Projects
None yet
Development

No branches or pull requests

4 participants