Skip to content

Commit

Permalink
Merge pull request #71 from apresta/fix-latex
Browse files Browse the repository at this point in the history
Fix latex rendering in sage-shell-view
  • Loading branch information
EmmanuelCharpentier authored Jun 9, 2023
2 parents 80fbb4e + 2140de1 commit c3ea00d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
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

0 comments on commit c3ea00d

Please sign in to comment.