-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
sage-shell-view-mode no longer working #61
Comments
Does not work for me either. I have all of the latex packages installed. Emacs 27.2. |
Do you mean that the inline typesetting does not work ? The rest seems OK (including inline plots...). |
@EmmanuelCharpentier yes, exactly. The inline typesetting does not work. |
I started to look at it. The original author used multithreaded functions to build and display the images. That's a serious pain to debug.... Ssome help from someone more versed in emacs-lisp than I am would be extremely welcome... |
@EmmanuelCharpentier , I started working on an simpler implementation of sage-mode here https://github.com/aikrahguzar/sage-mode where the idea is to basically offload as much as possible to Displaying latex and images is the next thing I want to do but I have the opposite problem that I don't what is happening on the sage. Is there an overview available somewhere of what is needed to get sage to emit latex and png images? I think I know more or less what to do on emacs side (it should be mostly |
The Emacs lisp side is fine; it seems that sage is not sending the "correct" type of the expression to the For example, the following renders correctly: x = var('x')
u = function('u')(x)
de = desolve(diff(u, x) - x * u + 2 * x^2, [u, x], ics=[0,-1])
from sage.repl.rich_output.output_basic import OutputLatex, OutputPlainText
from emacs_sage_shell_view import BackendEmacs
BackendEmacs().display_immediately(OutputPlainText("pretty printing…"), OutputLatex(latex(de).encode())) I don't know why, but pretty much every |
You are right and I figured out why: it is due to this line You can't get latex unless the backend claims to support OutputHtml. BackendEmacs doesn't because BackIPythonCommandLine doesn't. This seems to works for me (I haven't checked if it causes trouble since I don't use sage-shell-view-node anymore but it prints the latex code as expected), class BackendEmacs(BackendIPythonCommandline):
def __init__(self, text=True, plot=True):
super(BackendEmacs, self).__init__()
if text:
self.__text = "latex"
else:
self.__text = None
self.__plot = plot
def default_preferences(self):
return DisplayPreferences(text=self.__text)
def _repr_(self):
return "Emacs babel"
def supported_output(self):
return [OutputLatex , OutputPlainText , OutputHtml , OutputImagePng]
def displayhook(self, plain_text, rich_output):
if self.__plot and isinstance(rich_output, OutputImagePng):
msg = rich_output.png.filename(ext='png')
msg = "BEGIN_PNG:%s:END_PNG" % msg
return ({u'text/plain': msg}, {})
elif isinstance(rich_output, OutputHtml):
text = "BEGIN_TEXT:" + str(plain_text.text.get(), 'utf-8') + ":END_TEXTBEGIN_LATEX:" + \
str(rich_output.latex.get(), 'utf-8') + ":END_LATEX"
return ({'text/plain': text}, {})
else:
return super(BackendEmacs, self).displayhook(plain_text, rich_output) |
Would you propose a patch ?
May I inquire why ?
Do you mean it renders the expected typeset output ? |
Yes, I can do that here in a day or two or someone can beat me to it :)
I wanted to change somethings so at one point I started looking at code and I found it hard to figure out what the code was doing. After some time I realized that it was written at a time when the current
No, it is the code. It would be the job of a function in |
I got #70 to work by:
The issue was that we were getting |
[ Snip... ] Could you submit a "clean" patch ? |
It is coming from |
No, no, no ! Sagemath has a lot of possible uses, and using its output in
These spurious dollars can be intercepted in Patch follows. If I can figure out how to upload it... |
Pull request posted. |
Patch is #72 ... |
I think you missed #71, which also addressed the issue without affecting Sage. However, I did the opposite than you: kept the output from Sage intact, including the |
There isn't a solution to this problem yet? |
The solution is ready for merging: #71 I'm not sure if there are any active maintainers watching this repository though. |
Hi,
the sage-shell-view-mode no longer works for me, using sage-shell-mode 20201225.1011, SageMath version 9.3 (Release Date: 2021-05-09), Emacs 27.2 and dvips 2021.1. Is was working before but at some point it stopped. There is no error message produced of any kind in emacs, just no LaTeX-picture overlay is produced and shown.
The text was updated successfully, but these errors were encountered: