Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Do not wrap HTML output in <pre> #350

Merged
merged 2 commits into from
Nov 23, 2015
Merged

Do not wrap HTML output in <pre> #350

merged 2 commits into from
Nov 23, 2015

Conversation

novoselt
Copy link
Member

@novoselt novoselt commented Oct 6, 2015

Currently HTML from html command is inserted into a <pre> block which means that you actually don't see real HTML output corresponding to your code. It also leads to extra dances for MathJax, we have our own parser for $ that replaces them with <script> tags. And I could not figure out how to turn on processing of environments. (My use case here: output a sequence "explanation formula explanation formula ..." which works way better in MathJax and LaTeX if each formula is a separate formula, rather than combining everything into a single math object.)

The change here is to wrap into <pre> every block which is NOT html - then we mostly have old behaviour, but HTML processing is now sensible and consistent with cell and cloud interfaces. (In particular, math environments are processed.)

Attaching sample output for before and after.
before
after

@kcrisman
Copy link
Member

kcrisman commented Oct 7, 2015 via email

@novoselt
Copy link
Member Author

novoselt commented Oct 7, 2015

What do you mean if I don't use raw strings? I put raw so that I can write normal LaTeX instead of doubling all slashes.

@kcrisman
Copy link
Member

kcrisman commented Oct 7, 2015

What do you mean if I don't use raw strings? I put raw so that I can
write normal LaTeX instead of doubling all slashes.

What I mean is that maybe that could affect whitespace handling as well. I
don't know, I haven't tried, it was only a quick question.

@novoselt
Copy link
Member Author

novoselt commented Oct 8, 2015

All raw does is preventing escape sequences from being interpreted. Here is the same with double slashes instead. If we can get this and other recent adjustments into coming fresh betas, that would be awesome ;-)
noraw

@novoselt
Copy link
Member Author

Made doctests pass! Also, we are going to make use of proper HTML processing in http://trac.sagemath.org/ticket/19097 and it would be fantastic to have it in 6.10 ;-)

@novoselt
Copy link
Member Author

Wow - it looks like this change also fixed a recurring problem from long ago which was actually quite annoying - if you click to the left of output from a formula in the current notebook (e.g. because you followed traceback directions), everything disappears (and frightens the student, especially on exams). With this commit you will see latex code which may scare uninitiated as well, but at least not like "nothing works!" Please-please-please add it to the next release!

@kcrisman
Copy link
Member

kcrisman commented Oct 13, 2015 via email

@novoselt
Copy link
Member Author

I imagine a couple months, so a couple of weeks is not at all a problem.

@novoselt
Copy link
Member Author

By the way, SageNB has its own "math catcher" that looks for $ and replaces them with script tags. Which means a) we do ourselves MathJax job for no good reason, potentially not handling some corner cases (I definitely had issues with using $, even escaped, in doc strings) and b) the code that one could copy-paste from the browser is not LaTeX anymore, also for no good reason. I've tried to remove it, but got stuck and I think this pre wrapping was the issue. Once it is approved, will try again removing our math_parse or something like that.

@kcrisman
Copy link
Member

Okay, I'm ready to start working on this! Any updates you need or know about on this?

@novoselt
Copy link
Member Author

Not really - the ticket mentioned has been positively reviewed (I've switched it to needs work till SageNB is upgraded) and has a printout showing some advantages of the changes.

@kcrisman
Copy link
Member

This pull request seems to work properly. Can you give me an explicit example of the other thing you said it fixed about clicking on the left? I tried a few things but they didn't work any differently than before.

@novoselt
Copy link
Member Author

Switch a worksheet to "Typeset" with a check box. Enter "matrix(3)" to see a nicely typeset version of it. Click once to the left of the output: it disappears. With the change here you will see the latex code of it, so no impression that "it just does not work at all". As always refreshing the browser cache may be necessary.

@kcrisman
Copy link
Member

I don't see this behavior disappearing. It behaves the same in both of them. Even in a browser I didn't use before for this worksheet! And now I understand what you meant by that comment.

@novoselt
Copy link
Member Author

Interesting. I saw it in Firefox/Iceweasel on Debian Jessie in case it is relevant. In any case my main point here is to stop pre-wrapping because it makes sense and will be consistent across different interfaces and that hopefully you can replicate ;-)

@novoselt
Copy link
Member Author

So - any objections to getting it in?..

@kcrisman
Copy link
Member

No, I was hoping to get @gutow 's in first so he doesn't have to rebase yet again... but I guess maybe that isn't happening, which would be understandable given the time of year.

@gutow
Copy link
Contributor

gutow commented Nov 23, 2015

Sorry folks,

I am really swamped at the moment. I might get to look at things over Thanksgiving break, but the reality is probably not until the holidays or our January short term.

Jonathan

On Nov 22, 2015, at 8:05 PM, kcrisman notifications@github.com wrote:

No, I was hoping to get @gutow https://github.com/gutow 's in first so he doesn't have to rebase yet again... but I guess maybe that isn't happening, which would be understandable given the time of year.


Reply to this email directly or view it on GitHub #350 (comment).

                    Dr. Jonathan H. Gutow

Chemistry Department gutow@uwosh.edu mailto:gutow@uwosh.edu
UW-Oshkosh Office:920-424-1326
800 Algoma Boulevard FAX:920-424-2042
Oshkosh, WI 54901
http://www.uwosh.edu/facstaff/gutow/ http://www.uwosh.edu/facstaff/gutow/

@kcrisman
Copy link
Member

Okay, thanks for that update!

kcrisman added a commit that referenced this pull request Nov 23, 2015
Do not wrap HTML output in <pre>
@kcrisman kcrisman merged commit a59afd9 into sagemath:master Nov 23, 2015
@novoselt
Copy link
Member Author

Thank you!!!

@kcrisman
Copy link
Member

kcrisman commented Dec 3, 2015

@novoselt the Trac ticket is now 'needs review' if you wish to review it... it will need testing in 'real life' before it gets into 6.10, assuming it would get into a beta of that.

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

Successfully merging this pull request may close these issues.

3 participants