scimax icon indicating copy to clipboard operation
scimax copied to clipboard

ipython results block html file link

Open uliw opened this issue 5 years ago • 4 comments

Hi John,

I just noticed following: If I execute the following pandas statement

#+BEGIN_SRC ipython :results output drawer
os_peak.head()
#+END_SRC

the output will show the dataframe as text, but it will also include a file link to an html file

:results:
# Out [3]: 
# text/plain
:   Core,section,interval(cm)  Depth [mbsf]  Age [Ma]       d34S  d34S error
: 0           1221C 11-3X 0-3        153.40   55.0011  17.516152    0.208391
: 1           1221C 11-3X 5-8        153.45   55.0184  17.575390    0.208391
: 2           1221C 11-3X 5-8        153.45   55.0184  17.680569    0.208391
: 3         1221C 11-3X 10-13        153.50   55.0358  17.737390    0.208391
: 4         1221C 11-3X 15-18        153.55   55.0531  17.886092    0.208391

[[file:/tmp/ob-ipython-htmlm9TN3i.html]]
:end:

is there a way to suppress the inclusion of the file link?

Thanks

Uli

uliw avatar Jul 29 '20 19:07 uliw

I think you can do this with something like this:

#+BEGIN_SRC emacs-lisp (setf (cdr (assoc 'text/html ob-ipython-mime-formatters)) (lambda (_ _) "")) #+END_SRC

jkitchin avatar Jul 29 '20 19:07 jkitchin

Hi John,

yup, that solved the problem. But leaving this snippet in the file wreaks havoc with the notebook export. I tried putting it in a comment section but that didn't work. Is there a way to encapsulate this in a different way?

Cheers

Uli

On Wed, Jul 29, 2020 at 3:50 PM John Kitchin [email protected] wrote:

I think you can do this with something like this:

#+BEGIN_SRC emacs-lisp (setf (cdr (assoc 'text/html ob-ipython-mime-formatters)) (lambda (_ _) "")) #+END_SRC

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jkitchin/scimax/issues/379#issuecomment-665867813, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWSVAQGOG2U2RRQ7ESWBXDR6B4QNANCNFSM4PL6QOVQ .

-- Ulrich G. Wortmann https://www.es.utoronto.ca/people/faculty/wortmann-ulrich/ Dept. of Earth Sciences Fax : 416 978 3938 University of Toronto Phone: 416 978 7084 22 Ursula Franklin Street, Toronto, ON, Canada M5S 3B1

uliw avatar Jul 30 '20 13:07 uliw

If that is the first code block, then yes I think that would happen. I think in that case you can override that by adding this keyword:

#+OX-IPYNB-LANGUAGE: ipython

or you could put it in a section at the end that is tagged :noexport:, or put that code in a .dir-locals.el file perhaps

Or probably just as an org comment:

(setf (cdr (assoc 'text/html ob-ipython-mime-formatters)) (lambda (_ _) "")) <- cursor here, and type C-x C-e

in the org file. Then just remember to put your cursor at the end of the line and type C-x C-e if you close emacs and reopen this file.

You can also put it in your init file, which will make it more permanent.

If you know you only want the plain text results, you can also put something like this in your header I think.

#+BEGIN_SRC ipython :results output drawer :display text/plain

jkitchin avatar Jul 30 '20 14:07 jkitchin

this works best for my case

results output drawer :display text/plain

Thanks!

Uli

On Thu, Jul 30, 2020 at 10:48 AM John Kitchin [email protected] wrote:

If that is the first code block, then yes I think that would happen. I think in that case you can override that by adding this keyword:

#+OX-IPYNB-LANGUAGE: ipython

or you could put it in a section at the end that is tagged :noexport:, or put that code in a .dir-locals.el file perhaps

Or probably just as an org comment: (setf (cdr (assoc 'text/html ob-ipython-mime-formatters)) (lambda (_ _) "")) <- cursor here, and type C-x C-e

in the org file. Then just remember to put your cursor at the end of the line and type C-x C-e if you close emacs and reopen this file.

You can also put it in your init file, which will make it more permanent.

If you know you only want the plain text results, you can also put something like this in your header I think.

#+BEGIN_SRC ipython :results output drawer :display text/plain

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jkitchin/scimax/issues/379#issuecomment-666417961, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWSVAU4GKQREPYUCXVB56LR6GB4ZANCNFSM4PL6QOVQ .

-- Ulrich G. Wortmann https://www.es.utoronto.ca/people/faculty/wortmann-ulrich/ Dept. of Earth Sciences Fax : 416 978 3938 University of Toronto Phone: 416 978 7084 22 Ursula Franklin Street, Toronto, ON, Canada M5S 3B1

uliw avatar Jul 30 '20 15:07 uliw