-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Handle carriage return characters ("\r") in HTML notebook output. #1659
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
Conversation
|
To reproduce: should produce: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"effect of" or "effect from" probably, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. "effect of" is what I intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want to make this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
Thanks for bringing this up; we have the same problem on aleph.sagemath.org with our use of the IPython messaging protocol. |
|
I had a look at the save/restore, and it's a bit problematic. When we write the ipynb to JSON, we use I do want to make a point of discouraging actually using terminal-centric behaviors in the notebook ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check depended on fixConsole stripping \r. You will have to make a different fix that prevents creation of the HTML element if there is no text to display.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I ran into is that you have to do something now if text == '\r', is the last line of the pre-existing content needs to be erased, so you can't just return anymore in that case. The line removal could be done later, I suppose, if all we had was '\r', but care would need to be taken to not throw the '\r' away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right - the check needs to be later, then.
Note that there is only one problem case:
Creating a new div, with no content, so that's the situation to fix. If it enters the 'append to latest ouput' block, the problem is already avoided.
|
After PR #1663, this should load from saves properly without further changes. |
…nts -- but only when there wasn't already something there.
|
I think I've corrected the test in which to not add a div when the content is empty. This merged with #1663 also fixes the saving/loading issue. Thanks for helping with this! |
Handle carriage return characters ("\r") in HTML notebook output.
|
thanks, merged. |
|
Crap - I merged this prematurely, and it caused a pretty critical failure (try |
|
Hang on, I've just understood this issue. So if there's a percentage counter that gets overwritten 100 times, we store every percentage, separated by |
|
Correct, the notebook structure is a transcript of what actually happened, excluding any UI-specific interpretation. This is a difference between We could store the transformed output, but we would have to be careful that we do not store the escaped HTML output (we had this bug before). If we make that change, then we must do fixCR always on the raw text and before fixConsole, because we would be saving the results of fixCR, and must never save the results of fixConsole. |
|
I'd side with removing overwritten content at some point before saving. Even if we'd rather they didn't, people are going to use |
|
Do you want to add that as a criterion for PR #1674 (note that this one is already closed)? |
|
I think it does make sense to do, my main point is that I don't think it's worth the effort. If someone does feel like doing it, they are welcome, but must be very careful with the points I mentioned. |
Handle carriage return characters ("\r") in HTML notebook output.
caused critical problems with subprocess output. See `!ls` for an example.
It does not currently save/restore notebooks correctly. Any pointers on that?