Page MenuHomePhabricator

Can't copy and paste MathML equations
Closed, ResolvedPublic

Description

From T131177#2343273 :

This change means that it is no longer possible to copy and paste math (from Chrome at least). It might help to make the SVG fallback an actual inline image, but I can't even seem to get that to copy and paste.

I know a lot of people that copy and paste equations from Wikimedia sites (WP and WB) as a quick and easy way of displaying them in presentations and the like, and this is going to break that.

We think that this is fixed with the fix of T136709, but we are keeping this open in case there are any problems.

Event Timeline

Interestingly, when copying from Microsoft Edge to Word 2016, the math appears correctly, just as it used to. When pasting from any other browser into Word, either nothing appears in place of the math, or a white square appears instead.

So this is really a browser issue at its heart, but users are going to blame us, since it worked before the change to SVG.

AFAIK, Microsoft Edge and FF with the MathML plugin enabled are the only two that really support MathML, so you are really copying the original, in-lined MathML.

I assure you I'm not :) I'm copying the SVG fallback, which seems to be rendered as an inline image in Edge. When I remove the MathML from the DOM, I still copy the same thing.

I assure you I'm not :) I'm copying the SVG fallback, which seems to be rendered as an inline image in Edge. When I remove the MathML from the DOM, I still copy the same thing.

Ah, yes, sorry, there's an exception for Edge in the code-base to provide the SVG directly.

TTO renamed this task from Inlined SVG images to Can't copy and paste MathML equations.Jun 1 2016, 8:52 AM

Change title to reflect the problem at hand.

@Danny_B I agree that this is a dupe. I don't know how to merge it, but I think @mobrovac can do that.

Hungryce raised the priority of this task from Medium to High.Jun 1 2016, 11:36 PM

T136709: "Make math using MathML / SVG / PNG mode print properly" is set to high and as that is likely a duplicate I am setting this to high too.

Fixing T136709 may fix the issue in some browsers, but I don't think it will fix it in others.

@TTO that is true, but both are the same problems just that one has a possible solution that will not work in all browsers. Conversion to <img> or inline SVG which is the other possible solution should fix both problems so we should discuss. it together

@Danny_B I agree that this is a dupe. I don't know how to merge it, but I think @mobrovac can do that.

On T136709 page in the menu you can choose "Merge Duplicates in", fill in this task number (T136672), hit Select and submit the form.

GWicke added a subscriber: GWicke.

Re-opening this task to make sure that we test copy/paste after the resolution to T136709 is deployed in the next hours. The fix to that issue moves the SVG to a regular <img> tag, which has a good chance of fixing the copy/paste issue as well.

@Physikerwelt since you've got Windows, can you try to c/p a formula SVG render to Word from wikibooks as they've already got the fix?

Hungryce claimed this task.

@GWicke this was closed because it is a duplicate of T136709. It was suggested here to use the img tag as well as there and as they were similar problems and solutions they were merged. If that is fixed so is this, if this is not fixed, then it is not either. Because of this, I am closing this once again.

@Hungryce, printing and copy/paste are two slightly different problems. It is possible that the same change fixes both (and it sounds like this might be the case for at least some browsers), but it's not a given.

We should have at least one task open to make sure that this is fully tested & not forgotten. I'm going to use this task for that purpose, as it is more focused on copy/paste. If you feel strongly about using T136709 instead, then please re-open that one instead.

Sorry @GWicke, I did not know if you understand what was going on. I am happy to use this.

No, it does not work. Or at least it does not work well. If you just C&P to word, you don't get a word equation object but an image. And since MS Word does not support SVG (on windows) you get something that does not scale very well.
One workaround is to copy the MathML to Mathematica and thereafter from Mathematica to word.
That way you get an equation that you can edit using the word equation editor.

@Physikerwelt I did not think you would get a word equation in PNG mode either. I can't say what to do about no SVG support in MS word; I don't use Word myself, but I can see how that might be a problem. Has anyone tried sending that to Microsoft?

I think we should extend the documentation with best practices for C&P to diverse tools. Maybe we can extend the MathML copy addon in way that it also supports the MSO MathML variant.

@Physikerwelt I don't know how that is done but I think that is a good idea.

Physikerwelt claimed this task.

Ok. I got it. It works really nice.
You need the MathML copy addon you click on a formula-> Copy MathML -> insert in the word document -> Context menu -> Just use the text... and voila you get a mircosoft word equation object

@Physikerwelt I think there needs to be some documentation that that is recommended for copying equations with the intent of editing them

I started with a screencast http://youtu.be/FDMfT27zE54?hd=1 (you need to switch to highres to see something)

No, it does not work. Or at least it does not work well. If you just C&P to word, you don't get a word equation object but an image. And since MS Word does not support SVG (on windows) you get something that does not scale very well.

So, is Word picking up a bitmap representation from the clipboard? Is the formula still legible?

@GWicke with my setup it's ok. But C&P images to word is always good for suprises, so this not a general statement at all and only a single data point.
I think using the MathML copy addon (as described above) is the recommended way.

Another data point: Pasting a mix of text & formulas from Chrome to Google docs results in this mess:

pasted_file (1×1 px, 157 KB)

Copy/pasting just the fomula image results in a bitmap copy in Google Docs.

Using the g(Math) plugin for google docs in combination with the MathML copy addon let's you edit the equations you copy. https://youtu.be/KKwF6IKRkHU?hd=1

Using the g(Math) plugin for google docs in combination with the MathML copy addon let's you edit the equations you copy. http://youtu.be/cir4061sJjs?hd=1

It's interesting that both Word & Google Docs actually consume LaTeX & not MathML. If we wanted to make the LaTeX source accessible without plugins, then we could probably rig up a context menu that supports copying the math image's title or alt attribute to the clipboard.

Almost, in Word I was using MathML and for the g(Math) plugin Tex. But I like the idea to create a context menu. Are there other elements (beside math) that already have a custom context menu?

@TTO, would you consider the current level of copy & paste support to be acceptable?

Not really :( Using a common browser-word processor combination, it still fails:

The SVGs are selectable now, so this is after the update to change them into inline images.

@TTO I can't see your photo.

Sorry, the original upload of the video contained material that shouldn't have been included, and I had to remove it.

@TTO I saw the video. Copying from Wikipedia to Word did not work before (I was often frustrated about that). Check out my video to copy equations as editable word equations.