Closed iimog closed 2 years ago
Please include actual code in triple back ticks or links to notebooks instead of screenshots, since otherwise I will literally have to retype everything in your examples above just to test it. That means, of course, that I won't test it.
I'll fix this today in any case, as follows:
OK, a quick observation is that Julia uses the tabular latex environment. This is something that has absolutely nothing to do with KaTeX or MathJax -- it's not part of math mode in latex itself. It's something that can only be meaningfully rendered using an actual latex engine. So clearly the text/latex output from Julia is only ever meant to be used by nbconvert on the backend, and simply can't be meaningful in a purely frontend context (without a full latex compiler).
So for nice latex-style output, one needs either to run latex on the backend, to use something massive like https://www.swiftlatex.com/ (latex in web assembly), or to (slightly) change the Julia and R kernels to generate latex that can be used both on the frontend and in nbconvert. I won't do any of those things any time soon.
Thanks a lot @williamstein for looking into this so quickly. Here is the code for testing:
using DataFrames
DataFrame(a=[1,2],b=[2,3])
The notebook is here.
I totally get that any heavy changes to the latex engine are out of scope for this issue. I hope there is a more pragmatic solution for now. Anyway, I appreciate your work and support, and I love using Cocalc.
Thanks for your encouragement and code!
Regarding latex, I do think it might be best to fully properly render latex output -- as an option for users, just because it can look very nice. I did work improving our pdfjs integration recently, and have been thinking about maybe using that -- so latex would really get run and displayed nicely using pdfjs (which is a pdf viewer implemented in javascript). That's how %latex in Sage worksheets works, except that used a png image, and how the old %latex worked in the 2007 Sage notebook (also a png image). pdfjs would look much better.
Hi, These changes will be live in an hour or two, and impact both the app and https://cocalc.com/share
Note that a hard constraint with https://cocalc.com/share is that anything there be 100% safe against XSS attacks, so for there we are rendering plain text instead of HTML for Julia and R, since plain text is much better than HTML after sanitization. It would be nice to render text/latex (which can be done safely), but unfortunately using {tabular} just doesn't really work yet.
Once this is live, let me know if you run into other situations where mime type priorities should be changed.
Awesome! :tada: Thank you so much. I can confirm that tables are nicely displayed again for both Julia and R. Prioritizing security for shared notebooks and thus falling back to plain text there, makes a lot of sense.
Prioritizing security for shared notebooks and thus falling back to plain text there, makes a lot of sense.
Thanks. I view this is temporary, of course... security first, but then do something better (still not sure what in this case though).
For the Sage kernel, the latex output is much better than the HTML, since it outputs this:
<html>\(\displaystyle \frac{2}{3}\)</html>
and isn't supposed to be in the DOM. So annoyingly, which is best depends on the kernel...
When using notebooks with the
julia
orR
kernels output is generated with multiple mime types (text/html
,text/latex
,text/markdown
,text/plain
). In both kernels, html used to be the default for display. This way, the output (particularly tables) looked great in the browser. Now injulia
notebooks, latex seems to have higher priority than html, which does not look nice. When I force theIJulia
kernel to not produce latex output, I get the html rendered. See screenshot:When I use R, plain text seems to be the preferred output in any case. As seen when I just switch the kernel to R:
I think, this is related to #5764 and the changes were introduced in https://github.com/sagemathinc/cocalc/commit/e0e10a2482bd0fa72eb032305457c6e51fdb4094
It would be great to get the old rendering behavior (preferring html for both
R
andjulia
) back.