Skip to content

Fix latex rendering in sage-shell-view #71

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

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions emacs_sage_shell_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

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
Expand All @@ -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"

Expand All @@ -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}, {})
Expand Down
11 changes: 1 addition & 10 deletions sage-shell-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand All @@ -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)
Expand Down