<div dir="ltr">Ok, For last question I think I found answer here: <div><br></div><div><a href="http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Notebook/Importing%20Notebooks.ipynb">http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Notebook/Importing%20Notebooks.ipynb</a><br></div><div><br></div><div><br></div><div>I will let you know if I will encounter any problems.</div><div><br></div><div>Best,</div><div>Rafal</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-18 17:58 GMT+01:00 Rafał Skolasiński <span dir="ltr"><<a href="mailto:rjtskolasinski@gmail.com" target="_blank">rjtskolasinski@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi guys, <div><br></div><div>Thanks for extensive response! </div><div><br></div><div>In my output there is not need to be any imports. Output files will be only htmls to be put into edX course.</div><div><br></div><div>The need of splitting notebook into few output files comes from making it as friendly as possible to creators of the course content. </div><div>In principle they could write every unit in a separate notebook - but, because units together build a subsection of the course which describes one topic, it's more convenient to write them in one notebooks and separate by the largest headings. </div><div><br></div><div>I tested how converting to html, that is already provided in nbconvert, is accepted by edX and it went quite well. I only needed to change two things in the output file (<span style="font-size:13px"> </span><span style="font-size:13px">change path to the folders with figures and remove 'end of paragraph' symbol ) .</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px"><br></span></div><div>In this situation maybe what Matthias proposed is a way to go:</div><div class="gmail_extra"><div class="gmail_quote"><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span><div></div></span><div>that's up to how you want to design your exporter. </div><div>You can either have a preprocessor that split the notebooks in chunks and do the conversion after. </div><div>So virtually running nbconvert N times on n chucks of the notebook.</div></div></div></blockquote><div><br></div><div><br></div></span><div>Then for example I could have in the notebook to export sth like that:</div><div><br></div><div><Heading 1 cell> first_unit_name </Heading 1 cell> </div><div><br></div><div>Cells with stuff for first unit</div><div><br></div><div><br></div><div><Heading 2 cell> second_unit_name </Heading 2 cell> <br></div><div><br></div><div>Cells with stuff for second unit</div><div><br></div><div>etc...</div><div><br></div><div>And with the output I would see first_unit_name.html and second_unit_name.html </div><div>where content of each of them would look like it would be created only from notebook</div><div>containing cells with corresponding content.</div><div><br></div><div><br></div><div>Later I would like for example kick out every cells with python code leaving only their output (but this is for a later stage of development, after having the splitting going well). </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Oh, I have one question about the preprocessors. I found little old post <a href="https://blog.safaribooksonline.com/2013/12/18/ipython-notebook-plugins/" target="_blank">https://blog.safaribooksonline.com/2013/12/18/ipython-notebook-plugins/</a> about how to write custom plugins to nbconvert. Despite the fact that Jonathan was using transformers instead of preprocessors it worked when I changed config file only from:</div><div><br></div><div><div>C = get_config()</div><div>c.Exporter.transformers = [‘exclude_transformer.ExcludeTransformer’]</div></div><div><br></div><div>to: </div><div><div>c = get_config()</div><div>c.Exporter.preprocessors = ["exclude_transformer.ExcludeTransformer"]</div></div><div><br></div><div><br></div><div><br></div><div>But when I tried to change usage of Transformer into Preprocessor:</div><div>from <a href="http://pastebin.com/rQufqzUr" target="_blank">http://pastebin.com/rQufqzUr</a> into <a href="http://pastebin.com/Q8mgaYAJ" target="_blank">http://pastebin.com/Q8mgaYAJ</a></div><div><br></div><div>(correcting ofc line in config into c.Exporter.preprocessors = ["exclude_preprocessor.ExcludePreprocessor"])</div><div><br></div><div>I got the following error: <a href="http://pastebin.com/MSAHR2PP" target="_blank">http://pastebin.com/MSAHR2PP</a></div><div><br></div><div>Any idea why?</div><div><br></div><div><br></div><div>Oh... And one more question :). While writing some code I love to test things interactively (this is why I loved ipython so much). </div><div>Is there any easy way to play in ipython notebook with other notebook that goes as argument into all converter arguments?</div><div><br></div><div>Like I would like to see by hand what every worksheet in code like here <a href="http://pastebin.com/rQufqzUr" target="_blank">http://pastebin.com/rQufqzUr</a> contains. </div><div><br></div><div><br></div><div>Best,</div><div>Rafal</div><div><div class="h5"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span><div></div><blockquote type="cite"><div dir="ltr"><div>Should my custom exporter class inherit from a TemplateExporter? Or maybe separation into files should happen at this level?</div></div></blockquote><div><br></div></span><div>You are not obliged to, but I think you should at least inherit Exporter if you like your custom one to be accepted by nbconvert. </div><div>The architecture is not really meant to export into many files, except  for the resources file (Png, Svg) that do into a separate folder. </div><div><br></div><div>If you write your custom writer then your Exporter can most likely produce many file that would be written at once. </div><span><div><br></div><blockquote type="cite"><div dir="ltr"><div><br></div><div>And last, once I will have my exporter class will it be enough to specify which exporter should be used in config file and provide config to nbconvert via <span style="color:rgb(0,0,0);font-family:Consolas,'Deja Vu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:0.95em;letter-spacing:0.015em;line-height:15.960000038147px;background-color:rgb(248,248,248)">--config mycfg.py ?</span></div></div></blockquote><div><br></div></span><div>Yes that should be enough., any trait lets of your custom class should be automatically set to the value of the config.</div><span><br><blockquote type="cite"><div dir="ltr"><div><span style="color:rgb(0,0,0);font-family:Consolas,'Deja Vu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:0.95em;letter-spacing:0.015em;line-height:15.960000038147px;background-color:rgb(248,248,248)"><br></span></div><div>Thanks for all your help!</div></div></blockquote><div><br></div></span><div>Feel free to send us feedback on what you think of the APi or what limitation there is. </div><div><br></div><div>Thanks !</div><span><font color="#888888"><div><br></div><div>-- </div></font></span><span><div>M</div><div><br></div><br><blockquote type="cite"><div dir="ltr"><div><br></div><div>Best,</div><div>Rafal</div><div><br></div><div>P.S. If there are any useful guides or FAQs about writing custom converters that would be very helpful. I looked for some on my own but didn't have much luck.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-16 23:13 GMT+01:00 Thomas Kluyver <span dir="ltr"><<a href="mailto:takowl@gmail.com" target="_blank">takowl@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Hi Rafał,</div><span><div class="gmail_extra"><br><div class="gmail_quote">On 16 December 2014 at 13:40, Rafał Skolasiński <span dir="ltr"><<a href="mailto:rjtskolasinski@gmail.com" target="_blank">rjtskolasinski@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Unfortunately each unit must go into separate html file and here comes my first question: what is the easiest way to force nbconverter to export one notebook into few html files (let's say Heading 1 will start every unit and at the same time will be the name of it)? </blockquote></div><br></div></span><div class="gmail_extra">I think you will need to make a custom exporter - nbconvert supports different output formats with exporter classes, which you can find here: <a href="https://github.com/ipython/ipython/tree/master/IPython/nbconvert/exporters" target="_blank">https://github.com/ipython/ipython/tree/master/IPython/nbconvert/exporters</a><br><br></div><div class="gmail_extra">Your case will be a bit trickier than most of those examples, because all the TemplateExporter subclasses assume that they are writing a single main output file. But there's no reason that an exporter class couldn't write several files from one notebook.<span><font color="#888888"><br><br>Thomas<br></font></span></div></div>
<br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div></div>
_______________________________________________<br>IPython-dev mailing list<br><a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br><a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br></blockquote></span></div><br></div><br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div></div></div></div></div>
</blockquote></div></div>