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!
Related
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.
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 have been checking out some terminal to svg recorders like termtosvg written in Python and svg-term-cli in Typescript.
I installed termtosvg and recorded a small terminal session to keep in my README as a demo. However github doesn't render it. Strangely it renders all the svg animations that termtosvg has.
svg-term-cli is using Rawgit to render, but I don't want to use it as it will be taken down.
I made a small repository for testing purposes here. I downloaded one svg from termtosvg, one from svg-term-cli and one of my own and put it in docs folder in the repo. And linked to them from my README.md.
Issue
The svg animation from svg-term-cli renders in README however the other two don't.
NOTE:
Inside docs folder I can clearly see Github rendering the animated svgs.
I'd like to use termtosvg and not svg-term-cli.
Why is this happening? How do I make README render my animated svg.
I had a chat with the creators of termtosvg and found out that termtosvg uses animation tags which GitHub considers as scripts thereby removing them. That's why we see just a black screen and no animation when we try to link svgs output by termtosvg.
svg-term-cli and the shark animation on the other hand uses CSS to achieve the same thing which GitHub doesn't seem to have an issue with. That's why they get rendered.
Possible workarounds:
Using github.io to host the images and link that to README as that seems to work.
Using Rawgit. But keeping in mind that it will be taken down soon.
The more research I do, the more grim the outlook becomes.
I am trying to Flat Save, or Static Save a webpage with Python. This means merging all the styles to inline properties, and changing all links to absolute URLs.
I've tried nearly every free conversion website, api, and even libraries on github. None are that impressive. The best python implementation I could find for flattening styles is https://github.com/davecranwell/inline-styler. I adapted that slightly for Flask, but the generated file isn't that great. Here's how it looks:
Obviously, it should look better. Here's what it should look like:
https://dzwonsemrish7.cloudfront.net/items/3U302I3Y1H0J1h1Z0t1V/Screen%20Shot%202012-12-19%20at%205.51.44%20PM.png?v=2d0e3d26
It seems like a neverending struggle dealing with Malformed html, unrecognized CSS properties, Unicode errors, etc. So does anyone have a suggestion on a better way to do this? I understand I can go to file -> save in my local browser, but when I am trying to do this en mass, and extract a particular xpath that's not really viable.
It looks like Evernote's web clipper uses iFrames, but that seems more complicated than I think it should be. But at least the clippings look decent on Evernote.
After walking away for a while, I managed to install a ruby library that flattens the CSS much much better than anything else I've used. It's the library behind the very slow web interface here http://premailer.dialect.ca/
Thank goodness they released the source on Github, it's the best hands down.
https://github.com/alexdunae/premailer
It flattens styles, creates absolute urls, works with a URL or string, and can even create plain text email templates. Very impressed with this library.
Update Nov 2013
I ended up writing my own bookmarklet that works purely client side. It is compatible with Webkit and FireFox only. It recurses through each node and adds inline styles then sends the flattened HTML to the clippy.in API to save to the user's dashboard.
Client Side Bookmarklet
It sounds like inline styles might be a deal-breaker for you, but if not, I suggest taking another look at Evernote Web Clipper. The desktop app has an Export HTML feature for web clips. The output is a bit messy as you'd expect with inline styles, but I've found the markup to be a reliable representation of the saved page.
Regarding inline vs. external styles, for something like this I don't see any way around inline if you're doing a lot of pages from different sites where class names would have conflicting style rules.
You mentioned that Web Clipper uses iFrames, but I haven't found this to be the case for the HTML output. You'd likely have to embed the static page as an iFrame if you're re-publishing on another site (legally I assume), but otherwise that shouldn't be an issue.
Some automation would certainly help so you could go straight from the browser to the HTML output, and perhaps for relocating the saved images to a single repo with updated src links in the HTML. If you end up working on something like this, I'd be grateful to try it out myself.
I am currently using AsciiDoc for documenting my software projects because it supports PDF and HTML help generation. I am currently running it through Cygwin so that the a2x toolchain functions properly. This works well for me but is a pain to setup on other Windows computers. I have been looking for alternative methods and recently revisited Sphinx. Noticing that it now produces HTML help files I gave it a try and it seems to work well in the small tests I performed.
My question is, is there a way to specify map id's for context sensitive help in the text so that my Windows programs can call the proper help API and the file is launched and opened to the desired location?
In AsciiDoc I am using pass::[<?dbhh topicname="_about" topicid="801"?>]. By using these constructs a context.h and alias.h are generated along with the other HTML help files (context sensitive help information).
I do not know about AcsiiDoc much, but in Sphinx you can reference arbitrary locations by placing anchors where you need them. See :ref: role.