Skip to content

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

@robert-dodier

Description

@robert-dodier

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 <gunter@peterpall.de>
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions