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
nbconvert: Export flavors & PDF writer (ipy dev meeting) #3784
Conversation
There was some discussion about referring to reveal as just "slides" or "presentation", e.g.:
It's essentially the same idea as not mentioning sphinx with the LaTeX book/article flavor. Is that something we still want to do? |
I think it was also considered that reveal would be |
@jhamrick I talked to @ellisonbg about that a couple minutes ago, he prefered Personally I prefer I decided against |
We should talk about it again... I'll bring it up when I show this stuff working |
minutes = hours* |
I agree with @minrk... I prefer
all other slideshows libraries I want to add in the future ;-) |
if not inside IPython core, if I release this flavors as extension, I would be great to have a sintaxis as |
I guess data format isn't what I should have been thinking about, since the whole reason for the subclasses is the ability to configure based on that particular format... I'll change it to slides, one minute... |
@damianavila I guess the question is, does IPython want to have just one type of HTML slides/presentation that it natively supports, or many? There is also going to be the option to use @jdfreder You mean change it to |
yes, and the first of the two |
Hmm, ok. It could be a bit confusing because beamer is LaTeX (and presumably |
I also agree with @minrk. In the end the outcome should be what matters and a presentation is something complete different than a webpage! In this context LaTeX Beamer would be an extreme case of an presentation, even though a tex file. @damianavila deck looks awesome! |
@jhamrick probably IPython will support one type of HTML slides/presentations at the core (@minrk @fperez @ellisonbg @Carreau thoughs?) ... but the proposed syntax ( |
@jakobgager yes, all this js libraries are very powerful, just I need some more time to make them available... they are in my todo list (a very large one... hehe). |
Hey all, I change it so |
@jakobgager Yeah, fair enough. @damianavila I think the idea with templates was that they would be instead of a flavor, rather than in addition to. The analogy Fernando used I believe was that you can order e.g. a hawaiian pizza (flavor), but if you want a hawaiian pizza with spinach you need to just give the restaurant a new recipe of ham+pineapple+spinach (template). |
@jhamrick exactly, that said, |
should all work... |
Don't merge yet |
One thing it is not clear to me... what about the location of the custom template file? I mean, if I wrote a custom template and I want to use it doing |
This will work. There is also IIRC the possibility to add custom search locations.
the worth that can happend is you have to instanciate a loader in your config file:
Advantages are you don't even need to use a template file, you could use a dict loader, or a mondodb loader... it is slightly more complicated that just giving a path, but nbconvert is still a tech preview, and I thing we are already trying to over-engenier it. |
Overwriting this one? https://github.com/jdfreder/ipython/blob/98ef91d1c49a185ff508bb31ba014465b1249df3/IPython/nbconvert/exporters/exporter.py#L111
Oh, I missed that point, you can add
Yeah, maybe in the future we can provide the UI at the command line add your custom template. |
No, because it does not have
You mean template path because you can specify template from CL. actually you can even write a myconfig.py and just do |
Yes, I was talking about the path, sorry to not be clear enough. |
Great... thanks! |
@damianavila You should be able to put it in your cwd once my other PR gets merged ( #3752 )... It seems to be not moving anywhere though Also,
|
@jdfreder Thanks for the info about cwd... I did not know about that PR... I have to look deeper before asking ;-) |
Just rebased, adding @ivanov 's switch to the new tests... |
I am reading this in detail... I will report any doubts soon... |
now needs rebase |
Just rebased |
@@ -1,6 +1,7 @@ | |||
""" | |||
Reveal slide show exporter. | |||
Exporter that exports Basic HTML. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exporter that exports HTML slides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Good enough for me. |
@@ -83,14 +100,24 @@ def _classes_default(self): | |||
|
|||
which will convert mynotebook.ipynb to the default format (probably HTML). | |||
|
|||
You can specify the export format with `--format`. | |||
You can specify the export format with `--to`. | |||
Options include {0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options include ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets formatted below
try_names = [self.template_file + self.template_extension, | ||
self.template_file, | ||
module_name + '_' + self.template_file + self.template_extension, | ||
module_name + self.template_extension] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tell me a use case for this last one? maybe I am tired ;-) but I can't figure it out a use case... thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, ipython nbconvert --to rst notebook1.ipynb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or any other format without flavors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used for the flavor. When you have a default templates like markdown that don't have flavor like 'markdown_foo.tpl'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks to both of you... I was thinking only in "flavored" things... got it!
OK, thanks to all for the clarifications... 👍 to merging ;-) |
@@ -112,6 +140,7 @@ def _classes_default(self): | |||
help="""Writer class used to write the | |||
results of the conversion""") | |||
writer_aliases = {'FilesWriter': 'IPython.nbconvert.writers.files.FilesWriter', | |||
'PDFWriter': 'IPython.nbconvert.writers.pdf.PDFWriter', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This have to be erased because it is no longer more a writer ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh Thank you so much @damianavila for pointing this out! This may be why the tests failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are welcome... now in the morning I'm more attentive ;-)
nbconvert: Export flavors & PDF writer (ipy dev meeting)
Yeaaaaah |
Great! |
+1 for beamer slides flavor output. The recent changes to the template nbconvert backend allowed me to hack my own beamer support. It isn't perfect, but works well enough for me. I'm using the reveal slide metadata info from IPython notebook to guide the latex creation. Also, I'm using the warsaw default theme that makes the section automatically appear at the top of the page so you don't have to worry about titling slides. This template below/ embedded in the bash script, should serve as a decent latex beamer flavor starting point. #!/bin/bash
curdir=$(pwd)
if [ $# != 4 ]
then
echo "usage: $0 author date title notebook"
exit -1
else
author=$1
date=$2
title=$3
notebook=$4
fi
rm -rf tmp
mkdir -p tmp
cd tmp
echo """
((*- extends 'base.tplx' -*))
((* block docclass *))
\documentclass{beamer}
\usetheme{Warsaw}
((* endblock docclass *))
((* block margins *))
((* endblock margins *))
((* block title *))
\title{$title}
((* endblock title *))
((* block date *))
\date{$date}
((* endblock date *))
((* block author *))
\author{$author}
((* endblock author *))
((* block packages *))
((( super() )))
((* endblock packages *))
% Use reveal.js tags to handle skipping/ new slides etc
((* block any_cell *))
((* if cell.metadata.get('slideshow',{}).get('slide_type','-').lower() in ['skip'] *))
((* elif cell.metadata.get('slideshow',{}).get('slide_type','-').lower() in ['slide'] *))
((* if cell.level == 0 -*))
\frame{\section
\frame{
((( super() )))
}
((* elif cell.level == 1 -*))
\section{ ((( cell.source ))) }
\frame{\sectionpage}
((* endif -*))
((* elif cell.metadata.get('slideshow',{}).get('slide_type','-').lower() in ['subslide'] *))
\frame{
((( super() )))
}
((* elif cell.metadata.get('slideshow',{}).get('slide_type','-').lower() in ['fragment'] *))
((( super() )))
((* else *))
((( super() )))
((* endif *))
((* endblock any_cell *))
""" > notebook.tplx
ipython nbconvert --quiet --to=latex \
--template="notebook.tplx" \
--post=PDF "$curdir/$notebook"
# vim:ts=4:sw=4:expandtab |
nbconvert: Export flavors & PDF writer (ipy dev meeting)
Lightweight subclasses reduced in quantity
Added post processors
--format
param is now--to
--post PDF
flag added which creates and uses the new (introduced in this PR)PDFPostProcessor
See requirements listed in dev meeting hackpad:
https://hackpad.com/IPython-Summer-2013-Development-Meeting-D1UR23usGnA