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

Superfluous quote marks in text copied by "Copy as MathML" #1946

Closed
robert-dodier opened this issue Aug 30, 2024 · 19 comments
Closed

Superfluous quote marks in text copied by "Copy as MathML" #1946

robert-dodier opened this issue Aug 30, 2024 · 19 comments

Comments

@robert-dodier
Copy link
Collaborator

Working with wxMaxima 24.08.0 + Linux.

Copying output text as MathML introduces superfluous quote marks. E.g. print("foo") $ in a cell produces output foo as expected. If I highlight foo and right click and select "Copy as MathML", the resulting MathML contains <mo>"foo"</mo>, so it will be displayed with quote marks if pasted into a document. Here is the MathML I get:

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <semantics>
    <mtable>
      <mlabeledtr columnalign="left">
        <mtd>
          <mtext/>
        </mtd>
        <mtd>
          <mo>"foo"</mo>
        </mtd>
      </mlabeledtr>
    </mtable>
  </semantics>
</math>

An example of a wxmx document containing text like that is shown in #1942.

There is a user report that wxMaxima 19.05.7 does not have the superfluous quotes in copied MathML. On looking at the commit log, I think it's possible the quotes were introduced in commit 1db4c41, which says:

commit 1db4c41a0b98998575ff4a047ed27fdf7fce5290
Author: Gunter Königsmann <[email protected]>
Date:   Thu Jul 23 08:13:34 2020 +0200

    Now labels are drawn by a specialized TextCell type
    
    Plus:
      - TextCells now are simple enough for anyone to understand
      - TextCells now use less memory
    
    Contra:
      - We now have more cell types containing more code

The part that's relevant is

@@ -1214,10 +1031,7 @@ wxString TextCell::ToMathML() const
 {
   if(m_displayedText == wxEmptyString)
     return wxEmptyString;
-  wxString text = XMLescape(m_displayedText);
-
-  if ((*m_configuration)->UseUserLabels() && !m_userDefinedLabel.empty())
-    text = XMLescape(wxT("(") + m_userDefinedLabel + wxT(")"));
+  wxString text = XMLescape(ToString());
 
   // If we didn't display a multiplication dot we want to do the same in MathML.
   if (m_isHidden || (((*m_configuration)->HidemultiplicationSign()) && m_isHidableMultSign))

i.e., TextCell::ToString is being called whereas before it was not; from what I can tell, TextCell::ToString is where the quotes get pasted onto the string.

@daute
Copy link
Member

daute commented Aug 31, 2024

Hm. I did a git bisect and that results in b051b1e as the bad commit - but can that be the case? That commit modifies the TeX export? Huh?

@robert-dodier
Copy link
Collaborator Author

Hmm, I don't know what happened with the git bisect -- it doesn't make sense to me either.

I wonder if there is any way to debug the call to TextCell::ToMathML to see what's the effect of calling TextCell::ToString. I don't have a development environment set up, so I can't try it myself.

@robert-dodier
Copy link
Collaborator Author

Also, superfluous quote marks also observed after copying via "Copy" (first item on right button menu) and then pasting into MS Word. The copied text becomes an equation containing "foo".

@gunterkoenigsmann
Copy link
Member

The question is if those quotes are superfluous: Maxima tells us that the text actually is a string so TextCell::ToString() quotes it. If they are I've just added a function GetDisplayedString() that doesn't add quotes.

@robert-dodier
Copy link
Collaborator Author

Gunter, I don't have a wxMaxima development environment, so I can't try the new function. Can you call it from TextCell::ToMathML (i.e., replacing the call to TextCell::ToString with TextCell::GetDisplayedString) and verify that it has the desired effect?

robert-dodier added a commit that referenced this issue Sep 14, 2024
…extCell::ToString.

This is intended to fix issue #1946: Superfluous quote marks in text copied by "Copy as MathML"
@robert-dodier
Copy link
Collaborator Author

I've pushed commit 3046c6d which changes the call to ToString to GetDisplayedString as we were saying. @idealkindom Can you try your notebook again and see if "Copy as MathML" work as you expect?

@idealkindom
Copy link

idealkindom commented Sep 15, 2024 via email

@idealkindom
Copy link

I've pushed commit 3046c6d which changes the call to ToString to GetDisplayedString as we were saying. @idealkindom Can you try your notebook again and see if "Copy as MathML" work as you expect?

I tested with the latest nightly built Maxima portable version including a wxMaxima, but the results are unsatifactory, which may not merged your pull request.
the nightly built maxima protable
MathML pasted in word 2016

@robert-dodier
Copy link
Collaborator Author

Thanks for following up. The log files for the development server show that the new version wasn't built successfully because a test failed. We're trying to figure out what the error is. I think we'll have an answer in a few days -- I'll keep you posted.

@idealkindom
Copy link

idealkindom commented Sep 16, 2024 via email

@robert-dodier
Copy link
Collaborator Author

@idealkindom It appears that the daily build succeeded today (https://wolfgang.dautermann.at/maxima/nightlybuild/). Can you try the new version and see how it works for you? Thanks a lot for your help.

@idealkindom
Copy link

@idealkindom It appears that the daily build succeeded today (https://wolfgang.dautermann.at/maxima/nightlybuild/). Can you try the new version and see how it works for you? Thanks a lot for your help.

Hey,Thanks a lot Robert. Thanks to your persverance, the annoying trivial double quotes are gone, only the asterisc instead of center-dot muplipication operator is left to be done.

Here I attached the screenshot, which is a big step forward to regain the desent function of former version.
WxMaxima_2024-09-22_12-48-37

@robert-dodier
Copy link
Collaborator Author

OK, great. I will close this ticket, and we will keep working on the asterisk problem.

@idealkindom
Copy link

OK, great. I will close this ticket, and we will keep working on the asterisk problem.

In fact, the center-dot displays right in wxMaxima working window but when copied to word as MathML it becomes star.
asterisk_2024-09-22_13-05-31

@robert-dodier
Copy link
Collaborator Author

Yeah, I saw that too. I will try to figure out why the centered dot becomes an asterisk in the copied equations.

@daute
Copy link
Member

daute commented Sep 22, 2024

Hm. Here the dot seems to be okay in the MathML export:
mathml-star-vs-dot

(Can you provide a minimal example? And just paste the XML in a text editor or wxMaxima, like I did?) I tried with subscripts too, but that does not change the dot to a star...

[Yes, the <mo>F</mo> (and %pi and d) is wrong too, that is not an operator, I think, I know where to fix that, but that has nothing to do with the star-vs-dot problem...]

@idealkindom
Copy link

Hm. Here the dot seems to be okay in the MathML export: mathml-star-vs-dot

(Can you provide a minimal example? And just paste the XML in a text editor or wxMaxima, like I did?) I tried with subscripts too, but that does not change the dot to a star...

[Yes, the <mo>F</mo> (and %pi and d) is wrong too, that is not an operator, I think, I know where to fix that, but that has nothing to do with the star-vs-dot problem...]

Hey,Daute, you could just try to copy it as MathML to winword to see the effects.
Also, I'm glad to share a small wxmx file for you to test the problem,you could just accept the last run saved input values during the process.

You will see:

  1. the folding before calculation will unfold when there is input request in the process, which is not elegant and neat compared to version 19.05.7;
    2)Robert Dider fixed the bugs of subscript and nosense double quatoes concerning copying results as MathML to Win word;
    3)the center-dot display well in wxMaxima working windows, but becomes asterisk when copied as MathML and pasted(the last one of those three pasting choice or you could try to figure it out) to Win word processor.
    Ples Just find the example file in the attachment.
    Diaohuan-GB 50010-2010.zip

@gunterkoenigsmann
Copy link
Member

The thing with the asterisks is that the centered dot actually is an asterisk that is replaced by a centered dot, if it is used as an operator, but not, if it is part of a lisp variable name or a comment sign. The new command extracty the text maxima has sent to wxMaxima. Perhaps we need yet another new command that contains part of the conditional-find-and-replace logic, but not other parts of it.

daute added a commit that referenced this issue Sep 22, 2024
This should hopefully fix the asterisk/centered dot part of
issue #1946.
@robert-dodier
Copy link
Collaborator Author

Hi everybody, I've opened a new ticket specifically for the asterisk/centered dot problem. See #1956.

I'll go ahead and close this ticket since the issue which it addresses (superfluous quote marks) appears to be fixed now. In the interest of staying focused, let's just have one topic per ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants