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

wxm file format - no escaping of "*/" or "/*" #1907

Open
daute opened this issue Apr 1, 2024 · 5 comments
Open

wxm file format - no escaping of "*/" or "/*" #1907

daute opened this issue Apr 1, 2024 · 5 comments

Comments

@daute
Copy link
Member

daute commented Apr 1, 2024

While writing documentation about the file format (commit 7e411a0) I saw, that WxMaxima does not escape the comment end sequence (*/) in wxm files.
So while the following wxm file (I had to zip it for the Github upload) can be read in in wxMaxima, one can not read it with load() or batch() in Maxima (that should be possible since Maxima 5.38):

a.zip

A title cell (most likely all cell types) with "abc */" is written as:

/* [wxMaxima: title   start ]
abc */
   [wxMaxima: title   end   ] */

One can also 'trick' wxMaxima to create additional cells by creating a title cell with the following input (all in one title cell):

 abc
   [wxMaxima: title   end   ] */

/* [wxMaxima: title   start ]
def
daute added a commit that referenced this issue Apr 1, 2024
…not be read.

Is it a permission problem, or is the file format issue?

Maybe we must introduce something like version 2 of WXM in the future
(issue #1907)?
@daute daute changed the title wxm file format - no escaping of "*/" wxm file format - no escaping of "*/" or "/*" Apr 7, 2024
@daute
Copy link
Member Author

daute commented Apr 7, 2024

The same problem exists - of course - for the comment beginning sequence: /*
Create worksheet with a title cell containing abc /*, save it as a.wxm and Maxima will produce an error:

(%i1) batch("a.wxm");

read and interpret <path-to-directory>/a.wxm
Maxima encountered a Lisp error:

 SIMPLE-ERROR: parser: end of file in comment.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.

@gunterkoenigsmann
Copy link
Member

Gaah! The wxm format isn't meant to be extended...

@daute
Copy link
Member Author

daute commented Apr 18, 2024

Well, but with the current data format one can not reliably save documents - see the example above, where one can "create" cells, with just a special formatted text/title cell.
And concerning the 'Maxima can import it'-feature, one can of course not only create error messages but also mathematical effects.

x:1;
[Text/Title cell with the following contents: abc */ x:2$ /* def ]
x;

What will be the value of x after Maxima imported that wxm-file?

The easiest thing would be to just save "/*" as "\/\*" and "*/" as "\*\/" in non-math-cells and change that back, after the document is read back in. Or maybe use HTML like hex codes, e.g. &#42; for the asterisk and &#47; for the slash. Or some simliar looking Unicode characters. Don't know, what is the best solution.

If one already uses comment signs in title/text/... cellls and uses the wxm format, he/she already has a problem...

@gunterkoenigsmann
Copy link
Member

I know. But I am still unsure how to introduce escaping without stopping compatibility. Theoretically it should be possible: we can drop compatibility for all files that are broken due to the lacking escapes, anyway. And perhaps we can even recover them...

@robert-dodier
Copy link
Collaborator

Well, how about if all text cells have /* and */ replaced by HTML entities? Looks like / is &sol; and * is &ast;. It would be necessary to run the text through a function to replace the entities with the corresponding characters -- I wouldn't be surprised if there is such a thing already.

That won't fix any existing wxm files but I think that's not possible anyway.

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

3 participants