Skip to content
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

How to customize output? #173

Closed
dsblank opened this issue Feb 7, 2019 · 4 comments
Closed

How to customize output? #173

dsblank opened this issue Feb 7, 2019 · 4 comments

Comments

@dsblank
Copy link
Contributor

dsblank commented Feb 7, 2019

We have been using jupytext in a few different manners. Thank you!

Here is a problem we are running into:

We currently turn notebooks into markdown which we include in our documentation. Two problems:

  1. It would be nice to identify a code cell with something like "In:" (and even better, "In [23]:")
  2. It would be nice to identify the output of a cell, and format the output, perhaps with something like:
Out [23]:
'''
<Python Object Representation>
'''

(where the quotes should be back ticks). Currently, the lessthan's and greaterthan's get treated improperly, and it is impossible to see the output as output.

Is there a templating mechanism in jupytext? If not, is it possible to do something like this using jupytext? Thanks for any suggestions!

@mwouts
Copy link
Owner

mwouts commented Feb 8, 2019

Hello Doug, thanks for your feedback!

Well, currently there is no template mechanism in Jupytext. And as you know, Jupytext has a strong focus on the input cells, and on the round trip conversion. At this stage I have no experience with exporting the outputs... Would you expect large objects like a table or a plot to be exported? And imported back into the original notebook ??

I would say that nbconvert might be a adequate approach for what looks like to be a single direction conversion. I'm sure you know already that you can define your own templates and exporters. Also, if you export your notebooks to documentation, you might want to have a look at nbsphinx (see also #119).

@dsblank
Copy link
Contributor Author

dsblank commented Feb 11, 2019

Good points, and thanks for the hints. I don't really need round-trip, so I'll checkout nbconvert. Thanks!

@dsblank dsblank closed this as completed Feb 11, 2019
@mwouts
Copy link
Owner

mwouts commented Feb 11, 2019

Doug, actually I did play with nbconvert in the past. Hopefully the following comments can be useful to you... For one project I did the following:

  • In the notebook, I captured the cell outputs (javascript), and added one more output type (png). I had to do that manually by changing the function called in cells. Then, the cell outputs were displaying as javascript while in the notebook, but would also contain an hidden png version of the plot.
  • Using the flag --NbConvertBase.display_data_priority on nbconvert, I could select png over js when exporting to html

@dsblank
Copy link
Contributor Author

dsblank commented Feb 11, 2019

Thanks for the details! That technique sounds very useful in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants