WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 2 years ago

Last modified 16 months ago

#13340 closed enhancement (wontfix)

wpautop breaks inline MathMl

Reported by: nicholaswilson Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9.2
Component: Formatting Keywords:
Focuses: Cc:

Description

wpautop treats inline <math> tags as block; they in fact may be placed block or inline, with their flow model dependent on the mode or CSS display property.

Trivial to fix; just needs someone to commit the change. Remove "|math" from $allblocks in file wp-includes/formatting.php. math tags on their own will be wrapped in a paragraph, which is fine.

As a very convenient enhancement, please replace on line 210:

     if ($br) {
-        $pee = preg_replace_callback('/<(script|style). ....
+        $pee = preg_replace_callback('/<(script|style|math) ...

to prevent MathML being polluted with breaks (current required workaround people are using is to have the whole block on one line, which is very messy to edit).

Attachments (1)

13340.diff (1.8 KB) - added by wojtek.szkutnik 8 years ago.

Download all attachments as: .zip

Change History (15)

#1 @nicholaswilson
8 years ago

  • Cc nicholas@… added

#2 @wojtek.szkutnik
8 years ago

  • Keywords has-patch added

Adding the patch. All looks pretty straightforward to me, shouldn't break anything.

#3 @wojtek.szkutnik
8 years ago

  • Cc wojtek.szkutnik@… added

#4 @wojtek.szkutnik
8 years ago

  • Keywords gsoc added

#5 @hakre
8 years ago

  • Keywords needs-testing needs-unit-tests added

wpautop() related/informative tickets:

Related: #1706
Related: #2833
Related: #3007
Related: #3833
Related: #4857
Related: #4298
Related: #5250
Related: #6984
Related: #7988
Related: #9437
Related: #10033
Related: #10490
Related: #11678
Related: #12061
Related: #13327

Informative: #7937
Informative: #9744

AutoP tickets get only fixed in very specific situations. In any case they need extensive testing because of backward compabilities and side-effects and therefore normally Unit-Tests.

#6 @nacin
8 years ago

  • Milestone changed from Awaiting Review to 3.1

This looks straightforward.

#7 @nacin
8 years ago

  • Keywords 3.2-early added
  • Milestone changed from 3.1 to Future Release
  • Type changed from defect (bug) to enhancement

Not knowing anything about MatML, I want confirmation before doing anything like this.

enhancements can go to 3.2.

#8 @WraithKenny
6 years ago

  • Keywords wpautop added

#9 @chriscct7
4 years ago

  • Keywords 3.2-early gsoc removed

Can anyone confirm this works per @nacin?

#10 @ericlewis
3 years ago

Can anyone offer boilerplate to reproduce the issue here?

#11 @ericlewis
3 years ago

<math> is a separate markup language which is a subset of XML. It is not supported by modern browsers. It would be odd to support this as a first-class citizen of wpautop().

#12 @ericlewis
2 years ago

  • Keywords has-patch needs-testing needs-unit-tests wpautop removed
  • Milestone Future Release deleted

Closing this out as per my previous comments, feel free to reopen with follow-up if the feature is justified.

#13 @ericlewis
2 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

#14 @hughie.molloy
16 months ago

<math> tag has been a support element in HTML5 since 2011. https://www.w3.org/wiki/HTML/Elements/math Please consider reopening this as it makes a huge difference to inline formatting.

Purposed: http://i.imgur.com/HwB7yvx.png

Current: http://i.imgur.com/18Xtcj2.png

Plain Text: <h3>Quantum quandary</h3>At first sight, magnetic monopoles seem to be incompatible with quantum mechanics. That is because in quantum mechanics, electromagnetic fields have to be described in terms of a scalar potential <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>ϕ</mi></math> and vector potential <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">A</mi></math>. The magnetic field is given by the curl of the vector potential, <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">B</mi><mo>=</mo><mi mathvariant="bold">∇</mi><mo>×</mo><mi mathvariant="bold">A</mi></math>, and it follows from elementary vector calculus that the field must then be sourceless, <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">∇</mi><mo>.</mo><mi mathvariant="bold">B</mi><mo>=</mo><mn>0</mn></math>. In other words, magnetic field lines cannot end. So how can there be magnetic monopoles?

Note: See TracTickets for help on using tickets.