OutputForm rebase#1635
Conversation
|
|
||
| def eval_mathml(self, expr, evaluation) -> Expression: | ||
| "MakeBoxes[MathMLForm[expr_], (OutputForm|StandardForm|TraditionalForm)]" | ||
| "MakeBoxes[MathMLForm[expr_], Alternatives[StandardForm,TraditionalForm]]" |
There was a problem hiding this comment.
What's the difference between using | vs Alternatives[]?
There was a problem hiding this comment.
I have seen problems confusing Alternatives with Or, but now I am not able to reproduce it. I can revert it.
There was a problem hiding this comment.
No need to change. I was just curious.
There was a problem hiding this comment.
I have changed all the occurences of Alternatives in favor of using |.
| However, this will not be accepted as input to \Mathics anymore: | ||
| >> [1 2 3] | ||
| : Expression cannot begin with "[1 2 3]" (line 1 of "<test-Formatting Output-28>"). | ||
| : Expression cannot begin with "[1 2 3]" (line 1 of "<test-Formatting Output-29>"). |
There was a problem hiding this comment.
Can we use the more general (and probably more robust) "..." instead of 28/29 here?
There was a problem hiding this comment.
Docpipeline works if I replace the whole line with ..., but not just a part.
There was a problem hiding this comment.
Then let's replace the entire line. This is very fragile, and we use other mechanisms for testing output.
Co-authored-by: R. Bernstein <rocky@users.noreply.github.com>
Co-authored-by: R. Bernstein <rocky@users.noreply.github.com>
Co-authored-by: Juan Mauricio Matera <matera@fisica.unlp.edu.ar>
| latex: | ||
| System`InputForm: 1.09*{}^{\wedge}12 + 3.*I | ||
| System`OutputForm: 1.09\times 10^{12}\text{ + }3. I | ||
| System`OutputForm: '\text{1.09×10${}^{\wedge}$12 + 3. I}' |
There was a problem hiding this comment.
In Wolframscript I am seeing \times used instead of × which I think is more correct. This also occurs many other places in this file.
There was a problem hiding this comment.
Regarding the recent CI failures, I think if we use plain "*", then TeX and LaTeX will convert this to a nice character operator automatically. And I think I have seen this done in Wolframscript output for TeXForm.
There was a problem hiding this comment.
When I build the table, I found some problems with the TeXForm and MathMLForm output produced by WMA: sometimes it just shows errors and fails to produce an output, or the produced output does not compile well in LaTeX or render properly in the browser. The partial solution I found was to pick the current output from Mathics, and generate native WMA tests to compare and improve the cases that make sense to improve.
There was a problem hiding this comment.
Regarding this particular character, I just committed a patch to produce the right LaTeX command.
There was a problem hiding this comment.
I put this in another PR. We can see to load these equivalences from the tables there.
| latex: | ||
| System`InputForm: -1.*{}^{\wedge}-6 | ||
| System`OutputForm: -1.\times 10^{-6} | ||
| System`OutputForm: '\text{-1.×10${}^{\wedge}$-6}' |
There was a problem hiding this comment.
In WolframScript, I am seeing grave and * used:
-\text{1.$\grave{ }$*${}^{\wedge}$-6}There was a problem hiding this comment.
This is the output I get in WolframScript for this test case:
In[1]:= -1. 10^6 //InputForm//TeXForm
Out[1]//TeXForm= \text{-1.*${}^{\wedge}$6}
In[2]:= -1. 10^6 //OutputForm//TeXForm
Out[2]//TeXForm= \text{ 6$\backslash $n-1. 10}
In[3]:= -1. 10^6 //StandardForm//TeXForm
Out[3]//TeXForm= -1.\times 10^6
In[4]:= -1. 10^6 //TraditionalForm//TeXForm
Out[4]//TeXForm= -1.\times 10^6
The main difference in OutputForm comes from the pretty-print-like output, which we currently do not support.
\grave{ } is used to mark the tick character, used in StandardForm for 'Real' numbers:
In[1]:= -1. 10^6 //StandardForm
Out[1]//StandardForm= -1.`*^6
However, as can be seen in the example, it is not used in TeXForm.
|
Overall, there is a big improvement. I am seeing a lot of discrepancies in Let's discuss how to handle. |
|
This is a bit messy, and I think it would have been better to have focused on something smaller, like getting TeXForm working better, before combining that with OutputForm work. However, I think we should commit this and iterate. |
Again, the goal is to establish a framework that works at least as well as our last version, but that allows to make formatting more compatible with WMA. This is why I tryied to avoid fixing some details in our TeXForm implementation, which in comparison with WMA is not too bad... |
I start to put more on the true output of WS in |
The situation though, is that I think some concepts like understanding precedence is missing, and instead we have precedence more hard-coded, which will probably mean there are omissions. And we have hard-coded characters in there. So I expect there will be another pass at this. But this is a good start. LGTM. |
Another pass is coming to handle these aspects.
|
Better is good. |
This PR rebase #1570, including just the changes required to use the new implementation of
OutputForm.MakeBoxes[_, OutputForm]eval_makeboxes_outputformeval_makeboxes_outputforminMakeBoxes[OutputForm[_],_]format_elementin a way that useformas the second argument ofeval_makeboxesifformis a BoxForm.format_test.yamlaccording to the new results, closer to WMA.