emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
934 stars 92 forks source link

strange characters in the output when there's errors #465

Closed yitang closed 1 year ago

yitang commented 1 year ago

Thanks for providing this useful package that enables me to stick with org-mode.

I'm having one small issue I started to see when using emacs-jupyter but it might not relate to it at all.

as the below screenshot shows, there are some strange characters, "^[[0;32m" for example, in the output block. it only happens when there's error. image

what's the possible causes of it? and how to keep the error message clean and useful?

Thanks,

Panadestein commented 1 year ago

I had a similar problem, and fixed it with this org-mode hook:

(use-package org
  :straight t
  :init
  (defun display-ansi-colors ()
    "Fixes kernel output in emacs-jupyter"
    (ansi-color-apply-on-region (point-min) (point-max)))
  :hook
  (org-mode . (lambda () ( (add-hook 'org-babel-after-execute-hook #'display-ansi-colors)))))
yitang commented 1 year ago

@Panadestein it solves the problem. thank you for your help!

akirakyle commented 1 year ago

This is the same issues as #380 which was fixed in this commit, so you might want to remove the work around once you upgrade past that commit.