I searched a lot for this issue but didn't come to any straight to the point answer, so I am turning to you here and hopefully someone can help direct me to the right path at least.
The issue is simple, I have normal jupyter Nb and I would like to share it with others by sending them html format file. Using the normal !jupyter nbconvert --to html mynotebook.ipynbwill get the html export, but recently I started getting output with very wide screen (it uses the monitor screen).
How can I change the output screen size to maintain the same configurations even after exporting it to html?
In case my explanation wasn't clear I will add pictures:
notebook before exporting:
After exporting:
I don't want to create any special template, I just want to maintain the same parameters before exporting i.e. the width of the cells (inputs and outputs). Most of the answers I found here was talking about creating my own template or running some css code (both I don't have knowledge in...). Is there a ready to use template or argument that I can use to maintain the same layout?
I ran into the same issue. I think the problem might be that --to html uses the Jupyter Lab template by default. Once I added --template classic to my call to nbconvert the resulting HTML-file was much smaller and resembled the actual Jupyter notebook much more closely.
Related
Here is an example page of the Tensorflow documentation:
https://www.tensorflow.org/probability/examples/A_Tour_of_TensorFlow_Probability
Here is the source of that page: Link
How is the Jupyter notebook converted into the HTML website? I think the collapsible code blocks and the table of contents on the right look really nice. I want to do the same thing with my Jupyter notebooks (or at least get some inspiration).
I couldn't find the script which converts the notebooks nor the CSS or template, which Tensorflow uses.
The "flag" which created the collapsible code cell is ##title Import { display-mode: "form" }, but I could not find reference for that.
Some ressources:
Description of the usage of the script which generates the API documentation: Link
There is tool called nbfmt, which can format notebook, but as I understand it can only update the code style, but does not convert it: Link
I've found _book.yaml and _index.yaml in some repositories, which might indicate bookdown.
Note that I'm not looking for an answer on how to create a collapsible code cell or a table of contents, but how Tensorflow did it. I know that there are already answers for the other two questions out there.
Thanks in advance!
As you've discovered, the tools the TF docs team use are all available on GitHub, including nbconvert, nbfmt, etc. There are also some localisation tools.
Mostly, the system works at the notebook -> markdown level, but it also generates reference docs for code -> html. These are all un-styled, "plain" content. Some YAML is also generated for navigation. In theory, these outputs can be published anywhere.
Once the content is generated, the hosting/publishing platform it's served from is a proprietary system unfortunately. You can see the same system is used on developers.google.com, firebase.google.com, cloud.google.com, quantumai.google, developer.android.com and many more (check out the page layouts, custom HTML elements, etc), but it's not available outside of Google.
If you have any specific questions about the tooling, you can find us over on GitHub in the tensorflow/docs repo. Feel free to ask, we'll help if we can!
I am using Jupyter notebooks with jupyter-contrib-nbextensions and I can fold sections as well as code blocks in them. I want to know if there is a way to preserve the folding feature when the notebook is exported to html. Currently when I export to html, I can't fold anything. The notebook becomes cumbersome to handle if it's long, even if there's a table of contents. I'll appreciate any ideas in this regard. Thanks!
Interesting need. I briefly looked into this. Looks like the nbextensions don't have that capability. I think there are perhaps two choices, both of which would require quite some work:
Take the html file and convert it to some form that would allow cascading style sheets and then manually implement folding
If you are looking to do this repeatedly and have the skills, then you could look at the nbextensions code and try to change it to make it fold
If you find any other options or solutions, post it here.
According to the docs for the "Collapsible Headings"-extension in nbextensions, you should be able to export a foldable html-file by using the html_ch format:
jupyter nbconvert --to html_ch FILE.ipynb
I am using jupyter and jupyter-nbconvert to create a html presentation. However, I have some cells that produce an output image that I want to share on a separate slide. Is it possible to redirect the output of one cell to its own slide?
You might want to consider using Damian Vila's Jupyter extension RISE. It provides some of the control you need for how cells are displayed in slides.
It is flagged by the latest Jupyter (3.6) as possibly not compatible, but I've seen no problems using it so far.
I'm interested in placing a javascript powered graph into my jupyter notebook file as a div. This website uses a code magic approach, and pasting the graph code directly in a jupyter notebook cell:
http://blog.thedataincubator.com/2015/08/embedding-d3-in-an-ipython-notebook/
However, as many of such javascript powered graphs are lengthy, I think it would be desirable to simply call the javascript file that contains the graph's code, and subsequently appending it as a div in jupyter notebook. It sounds simple enough, but with all the path crisscrossing I have confused myself and I'm not sure what approaches I have tried are working or not.
I tried:
%%javascript
require.config({
paths: {
graph: 'filepath.js'
}
});
This did not throw any errors, but when I could't append any divs. I'm thinking perhaps the issue is actually the way data is linked between python and the js file. The above link uses an approach that points the data to window.vizObj={} I wonder if there are no simpler solutions?
Also, There is a converter library: http://mpld3.github.io/. Of course, I'm not against that, but for the sake of illustration, (and pride) I would kind of like to get to the bottom of this. Please feel free to share any/all thoughts on this matter.
If possible, please upload a jupyter notebook file so I can see how one goes about appending a js graph into jupyter notebook from a js file, and how the data is pointed. Any type of graph is ok, maybe a simple d3.js line graph.
Just do it from python
from IPython.core.display import Javascript
_filepath = 'filepath.js'
with open(_filepath, 'r') as _jscript:
code = _jscript.read()
Javascript(code)
I am using Ipython Notebook and I would like to save the notebook as pdf. When a notebook contains html figures in markdown mode I cannot export them
In example:
<img src='http://draftingmanuals.tpub.com/14262/img/14262_140_2.jpg'>
represents the following:
However, when I download the notebook as PDF via LaTeX (pdf) the result is without the figure:
Is this a bug or can I avoid this somehow?
This is not really a bug, but a known limitation. Actually there are two issues in your example:
the raw html <img> tag gets stripped when the markdown cells are converted by pandoc to latex (see pandoc docu).
you link to a remote image, which is (currently) not downloaded prior to the conversion.
Thus, it is a bit tricky to get what you desire. The first issue may be overcome by means of a custom filter and custom template. For the second, you may need a custom preprocessor.
Alternatively, you could use python with urllib (e.g. Downloading a picture via urllib and python) and matplotlib to display this image. Such embedded images are converted fine.