Skip to content
This repository was archived by the owner on Jan 3, 2018. It is now read-only.

Converting notebooks to html#166

Merged
gvwilson merged 4 commits intoswcarpentry:masterfrom
gvwilson:converting-notebooks-to-html
Nov 28, 2013
Merged

Converting notebooks to html#166
gvwilson merged 4 commits intoswcarpentry:masterfrom
gvwilson:converting-notebooks-to-html

Conversation

@gvwilson
Copy link
Copy Markdown
Contributor

No description provided.

@ahmadia
Copy link
Copy Markdown
Contributor

ahmadia commented Nov 22, 2013

Looks good, I'd prefer for your pattern rule to go from %.ipynb -> %.html instead of %.ipynb -> %.ipynb.html because that is the default way of doing this sort of conversion, but if you've got a preference for the latter, I don't have a strong objection.

With a little more work, I think we will be able to generate static notebook views in gh-pages for rendering bootcamp sites as soon as we retire using gh-pages as a development branch.

@gvwilson
Copy link
Copy Markdown
Contributor Author

On 2013-11-22 1:16 PM, Aron Ahmadia wrote:

Looks good, I'd prefer for your pattern rule to go from %.ipynb ->
%.html instead of %.ipynb -> %.ipynb.html because that is the default
way of doing this sort of conversion, but if you've got a preference
for the latter, I don't have a strong objection.

I'd prefer .html, but looking at how nbconvert's --output option works,
that's going to take more work. Plus, the double suffix clearly signals
the file origin (he said, rationalizing after the fact), so people know
it wasn't generated from a .md or written in HTML in the first place.

@ahmadia
Copy link
Copy Markdown
Contributor

ahmadia commented Nov 23, 2013

I think you want the --to html option if you'd like the filename to come out like that. IPython nbconvert is not much more than a shiny wrapper around pandoc, so understanding how the underlying tool works lends a lot of insight here :)

@gvwilson
Copy link
Copy Markdown
Contributor Author

On 2013-11-23 2:05 PM, Aron Ahmadia wrote:

I think you want the |--to html| option if you'd like the filename to
come out like that. IPython nbconvert is not much more than a shiny
wrapper around |pandoc|, so understanding how the underlying tool
works lends a lot of insight here :)

Fixes to the Makefile are welcome --- if we can get .html instead of
.ipynb.html w/out doing suffix surgery ourselves, that would be a step
forward.
Thanks,
Greg

@gvwilson
Copy link
Copy Markdown
Contributor Author

The --to html option doesn't change the name of the generated file: still get .ipynb.html.

@rgaiacs
Copy link
Copy Markdown

rgaiacs commented Nov 28, 2013

@gvwilson I only get .html when converting.

$ git log -1
commit 1cc95ccbf45db8454b0fbfcec2444f9a423dc2aa
Merge: bac4388 7fe38b3
Author: Greg Wilson <gvwilson@software-carpentry.org>
Date:   Wed Nov 27 18:03:10 2013 -0800

    Merge pull request #178 from gvwilson/tagging-novice-python-lessons

    Tagging novice python lessons
$ python --version
Python 3.3.2
$ ipython --version
2.0.0-dev
$ ipython nbconvert 01-numpy.ipynb 
[NbConvertApp] Using existing profile dir: '/home/raniere/.ipython/profile_default'
[NbConvertApp] Converting notebook 01-numpy.ipynb to html
[NbConvertApp] Support files will be in 01-numpy_files/
[NbConvertApp] Loaded template html_full.tpl
[NbConvertApp] Writing 393842 bytes to 01-numpy.html
$ ipython nbconvert --to html 01-numpy.ipynb 
[NbConvertApp] Using existing profile dir: '/home/raniere/.ipython/profile_default'
[NbConvertApp] Converting notebook 01-numpy.ipynb to html
[NbConvertApp] Support files will be in 01-numpy_files/
[NbConvertApp] Loaded template html_full.tpl
[NbConvertApp] Writing 393842 bytes to 01-numpy.html

@gvwilson
Copy link
Copy Markdown
Contributor Author

Are you putting the output in _site/python/novice/*.html? It looks from
your commands like you're leaving it in the source directory, which
isn't where we want it.
Thanks,
Greg

@rgaiacs
Copy link
Copy Markdown

rgaiacs commented Nov 28, 2013

@gvwilson Sorry about that. Bellow is the diff of some changes that I made to output in _site/python/novice/*.html.

diff --git a/Makefile b/Makefile
index 35bcaaf..3276467 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ NOTEBOOK_SRC = \
    $(wildcard python/novice/*.ipynb) \
    $(wildcard sql/novice/*.ipynb)
 NOTEBOOK_DST = \
-   $(patsubst %,$(OUT)/%.html,$(NOTEBOOK_SRC))
+   $(patsubst %.ipynb,$(OUT)/%.html,$(NOTEBOOK_SRC))

 #-----------------------------------------------------------

@@ -27,9 +27,9 @@ $(NOTEBOOK_DST) : $(OUT)/README.md
 $(OUT)/README.md :
    jekyll -t build -d $(OUT)

-$(OUT)/%.ipynb.html : %.ipynb
+$(OUT)/%.html : %.ipynb
    @mkdir -p $$(dirname $@)
-   ipython nbconvert --output="$(OUT)/$<" "$<"
+   ipython nbconvert --output="$(subst .html,,$@)" "$<"

 ## clean    : clean up
 clean :

@gvwilson
Copy link
Copy Markdown
Contributor Author

Nice fix --- integrated.
G

gvwilson pushed a commit that referenced this pull request Nov 28, 2013
@gvwilson gvwilson merged commit fdc3c03 into swcarpentry:master Nov 28, 2013
@gvwilson gvwilson deleted the converting-notebooks-to-html branch November 28, 2013 15:47
@dmj111 dmj111 mentioned this pull request Dec 10, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants