From 3a2c100a1251c0b1b1f4d993001074e2dc457909 Mon Sep 17 00:00:00 2001 From: Alessandro Presta Date: Sun, 9 Apr 2023 17:48:25 +0000 Subject: [PATCH 1/2] Fix latex rendering in sage-shell-view --- emacs_sage_shell_view.py | 8 ++++++-- sage-shell-view.el | 11 +---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/emacs_sage_shell_view.py b/emacs_sage_shell_view.py index 81203f6..c7d21cb 100644 --- a/emacs_sage_shell_view.py +++ b/emacs_sage_shell_view.py @@ -23,7 +23,8 @@ # along with this program. If not, see . from emacs_sage_shell import ip -from sage.repl.rich_output.output_basic import OutputLatex +from sage.repl.rich_output.output_basic import OutputLatex, OutputPlainText +from sage.repl.rich_output.output_browser import OutputHtml from sage.repl.rich_output.output_catalog import OutputImagePng from sage.repl.rich_output.preferences import DisplayPreferences @@ -43,6 +44,9 @@ def __init__(self, text=True, plot=True): def default_preferences(self): return DisplayPreferences(text=self.__text) + def supported_output(self): + return [OutputLatex , OutputPlainText , OutputHtml , OutputImagePng] + def _repr_(self): return "Emacs babel" @@ -52,7 +56,7 @@ def displayhook(self, plain_text, rich_output): msg = "BEGIN_PNG:%s:END_PNG" % msg return ({u'text/plain': msg}, {}) - elif isinstance(rich_output, OutputLatex): + 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}, {}) diff --git a/sage-shell-view.el b/sage-shell-view.el index 8a46e8c..c7ca07f 100644 --- a/sage-shell-view.el +++ b/sage-shell-view.el @@ -170,11 +170,6 @@ computes the resolution automatically." :group 'sage-shell-view :type 'string) -(defcustom sage-shell-view-latex-math-environment "math" - "Math environment for LaTeX." - :group 'sage-shell-view - :type 'string) - (defvar sage-shell-view-scale 1.0 "Scale used when converting from PDF/PS to PNG.") @@ -198,17 +193,13 @@ computes the resolution automatically." %s \\begin{document} \\begin{preview} -\\begin{%s} %s -\\end{%s} \\end{preview} \\end{document} " sage-shell-view-latex-documentclass sage-shell-view-latex-preamble - sage-shell-view-latex-math-environment - math-expr - sage-shell-view-latex-math-environment)) + math-expr)) (defun sage-shell-view-dir-name () (sage-shell-edit--set-and-make-temp-dir) From 2140de10311b60e31c447a8367dc77e9c82514f3 Mon Sep 17 00:00:00 2001 From: Alessandro Presta Date: Mon, 10 Apr 2023 14:24:35 +0000 Subject: [PATCH 2/2] Remove unneeded spaces --- emacs_sage_shell_view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emacs_sage_shell_view.py b/emacs_sage_shell_view.py index c7d21cb..f30a838 100644 --- a/emacs_sage_shell_view.py +++ b/emacs_sage_shell_view.py @@ -45,7 +45,7 @@ def default_preferences(self): return DisplayPreferences(text=self.__text) def supported_output(self): - return [OutputLatex , OutputPlainText , OutputHtml , OutputImagePng] + return [OutputLatex, OutputPlainText, OutputHtml, OutputImagePng] def _repr_(self): return "Emacs babel"