diff --git a/examples/Notebook/Using nbconvert as a Library.ipynb b/examples/Notebook/Using nbconvert as a Library.ipynb index 31e58ca..63b3601 100644 --- a/examples/Notebook/Using nbconvert as a Library.ipynb +++ b/examples/Notebook/Using nbconvert as a Library.ipynb @@ -32,19 +32,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
 Warning, Do use 1.0 or 1.x branch and not master naming have changed.
\n", - "\n", - "
 Warning, NbConvert is a Tech-Preview, API will change within the next 6 month.
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ "Credit, Jonathan Freder (@jdfreder on github)\n", "\n", "
\n", - " ![nbca](files/nbconvert_arch.png)\n", + " ![nbca](images/nbconvert_arch.png)\n", "
" ] }, @@ -84,7 +75,7 @@ "source": [ "import requests\n", "response = requests.get('http://jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb')\n", - "response.content[0:60]+'...'" + "response.text[0:60]+'...'" ] }, { @@ -113,10 +104,9 @@ { "data": { "text/plain": [ - "{u'cell_type': u'heading',\n", - " u'level': 1,\n", - " u'metadata': {},\n", - " u'source': u'XKCD plots in Matplotlib'}" + "{'cell_type': 'markdown',\n", + " 'metadata': {},\n", + " 'source': '# XKCD plots in Matplotlib'}" ] }, "execution_count": 2, @@ -125,9 +115,9 @@ } ], "source": [ - "from IPython.nbformat import current as nbformat\n", - "jake_notebook = nbformat.reads_json(response.content)\n", - "jake_notebook.worksheets[0].cells[0]" + "from IPython import nbformat\n", + "jake_notebook = nbformat.reads(response.text, as_version=4)\n", + "jake_notebook.cells[0]" ] }, { @@ -155,34 +145,23 @@ }, "outputs": [], "source": [ - "import IPython.nbconvert" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ "from IPython.config import Config\n", "from IPython.nbconvert import HTMLExporter\n", "\n", "## I use `basic` here to have less boilerplate and headers in the HTML.\n", "## we'll see later how to pass config to exporters.\n", - "exportHtml = HTMLExporter(config=Config({'HTMLExporter':{'default_template':'basic'}}))" + "html_exporter = HTMLExporter(config=Config({'HTMLExporter':{'default_template':'basic'}}))" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "(body, resources) = exportHtml.from_notebook_node(jake_notebook)" + "(body, resources) = html_exporter.from_notebook_node(jake_notebook)" ] }, { @@ -199,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": { "collapsed": false }, @@ -208,22 +187,22 @@ "name": "stdout", "output_type": "stream", "text": [ - "['inlining', 'output_extension', 'metadata']\n", + "['raw_mimetypes', 'inlining', 'metadata', 'output_extension']\n", "defaultdict(None, {'name': 'Notebook'})\n", - "html\n" + ".html\n" ] } ], "source": [ - "print resources.keys()\n", - "print resources['metadata']\n", - "print resources['output_extension']\n", + "print([key for key in resources ])\n", + "print(resources['metadata'])\n", + "print(resources['output_extension'])\n", "# print resources['inlining'] # too lng to be shown" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": { "collapsed": false }, @@ -232,20 +211,32 @@ "name": "stdout", "output_type": "stream", "text": [ + "\n", + "\n", + "\n", "\n", - "
\n", - "

XKCD plots in Matplotlib

\n", - "
\n", + "\n", + "Notebook\n", + "\n", + "\n", + "\n", "\n", - "
\n", - "

This notebook originally appeared as a blog post at \n", + " /*!\n", + "*\n", + "* Twitter Bootstrap\n", + "*\n", + "*/\n", + "/*! normalize.css v3.0.2 | MIT License | git.io/normalize */\n", + "html {\n", + " fon...\n" ] } ], "source": [ "# Part of the body, here the first Heading\n", "start = body.index('

`_\n", + "Perambulations `__\n", "by Jake Vanderplas.\n", "\n", - " *Update: the matplotlib pull request has been merged! See* `*This\n", - "post* `_\n", + ".. raw:: html\n", + "\n", + " \n", + "\n", + "*Update: the matplotlib pull request has been merged! See* `*This\n", + "post* `__\n", "*for a description of the XKCD functionality now built-in to\n", "matplotlib!*\n", "\n", "One of the problems I've had with typical matplotlib figures is that\n", "everything in them is so precise, so perfect. For an example of what I\n", "mean, take a look at this figure:\n", - "In[1]:\n", + "\n", ".. code:: python\n", "\n", " from IPython.display import Image\n", @@ -320,41 +314,37 @@ "\n", "\n", "\n", - "\n", - "\n", ".. image:: output_3_0.png\n", "\n", "\n", "\n", "Sometimes when showing schematic plots, this is the type of figure I\n", "want to display. But drawing it by hand is a pain: I'd rather just use\n", - "matplotlib. The problem is, matplotlib is a bit...\n", + "matpl...\n", "[.....]\n", - "owing schematic plots, this is the type of figure I\n", + "mage:: output_3_0.png\n", + "\n", + "\n", + "\n", + "Sometimes when showing schematic plots, this is the type of figure I\n", "want to display. But drawing it by hand is a pain: I'd rather just use\n", "matplotlib. The problem is, matplotlib is a bit too precise. Attempting\n", "to duplicate this figure in matplotlib leads to something like this:\n", - "In[2]:\n", + "\n", ".. code:: python\n", "\n", " Image('http://jakevdp.github.com/figures/mpl_version.png')\n", "\n", "\n", "\n", - "\n", - "\n", - ".. image:: output_5_0.png\n", - "\n", - "\n", - "\n", - "It just doesn'...\n" + ".. image:...\n" ] } ], "source": [ - "print body[:970]+'...'\n", - "print '[.....]'\n", - "print body[800:1200]+'...'" + "print(body[:970]+'...')\n", + "print('[.....]')\n", + "print(body[800:1200]+'...')" ] }, { @@ -381,7 +371,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": { "collapsed": false }, @@ -389,28 +379,20 @@ { "data": { "text/plain": [ - "[u'output_13_1.text',\n", - " u'output_18_0.text',\n", - " u'output_3_0.text',\n", - " u'output_18_1.png',\n", - " u'output_12_0.text',\n", - " u'output_5_0.text',\n", - " u'output_5_0.png',\n", - " u'output_13_1.png',\n", - " u'output_16_0.text',\n", - " u'output_13_0.text',\n", - " u'output_18_1.text',\n", - " u'output_3_0.png',\n", - " u'output_16_0.png']" + "['output_5_0.png',\n", + " 'output_16_0.png',\n", + " 'output_13_1.png',\n", + " 'output_18_1.png',\n", + " 'output_3_0.png']" ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "resources['outputs'].keys()" + "list(resources['outputs'])" ] }, { @@ -428,7 +410,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": { "collapsed": false }, @@ -934,10 +916,10 @@ "RU5ErkJggg==\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -987,7 +969,7 @@ "\n", " - Get the notebook data and other required files. (you are responsible for that)\n", " - Feed them to the exporter that will\n", - " - sequentially feed the data to a number of `Transformers`. Transformer only act on the **structure**\n", + " - sequentially feed the data to a number of `Preprocessors`. Preprocessor only act on the **structure**\n", " of the notebook, and have access to it all. \n", " - feed the notebook through the jinja templating engine\n", " - the use templates are configurable.\n", @@ -1000,20 +982,20 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Here we'll be interested in the `Transformers`. Each `Transformer` is applied successively and in order on the notebook before going through the conversion process.\n", + "Here we'll be interested in the `Preprocessors`. Each `Preprocessor` is applied successively and in order on the notebook before going through the conversion process.\n", "\n", - "We provide some transformer that do some modification on the notebook structure by default.\n", - "One of them, the `ExtractOutputTransformer` is responsible for crawling notebook,\n", + "We provide some preprocessor that do some modification on the notebook structure by default.\n", + "One of them, the `ExtractOutputPreprocessor` is responsible for crawling notebook,\n", "finding all the figures, and put them into the resources directory, as well as choosing the key\n", "(`filename_xx_y.extension`) that can replace the figure in the template.\n", "\n", "\n", - "The `ExtractOutputTransformer` is special in the fact that it **should** be availlable on all `Exporter`s, but is just inactive by default on some exporter." + "The `ExtractOutputPreprocessor` is special in the fact that it **should** be availlable on all `Exporter`s, but is just inactive by default on some exporter." ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": { "collapsed": false }, @@ -1021,23 +1003,25 @@ { "data": { "text/plain": [ - "[,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ]" + "[.wrappedfunc>,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ]" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "# second transformer shoudl be Instance of ExtractFigureTransformer\n", - "exportHtml._transformers # 3rd one shouel be " + "# 3rd one should be \n", + "html_exporter._preprocessors" ] }, { @@ -1047,14 +1031,14 @@ "To enable it we will use IPython configuration/Traitlets system. If you are have already set some IPython configuration options, \n", "this will look pretty familiar to you. Configuration option are always of the form:\n", "\n", - " ClassName.attribute_name = value\n", + " ClassName.attribute_name = value\n", " \n", - "A few ways exist to create such config, like reading a config file in your profile, but you can also do it programatically usign a dictionary. Let's create such a config object, and see the difference if we pass it to our `HtmlExporter`" + "A few ways exist to create such config, like reading a config file in your profile, but you can also do it programatically usign a dictionary. Let's create such a config object, and see the difference if we pass it to our `HTMLExporter`" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": { "collapsed": false }, @@ -1064,31 +1048,23 @@ "output_type": "stream", "text": [ "resources without the \"figures\" key :\n", - "['inlining', 'output_extension', 'metadata']\n", + "['raw_mimetypes', 'inlining', 'metadata', 'output_extension']\n", "\n", - "Here we have one more field \n", - "['outputs', 'inlining', 'output_extension', 'metadata']\n" + "Here we have one more field\n", + "['outputs', 'raw_mimetypes', 'inlining', 'metadata', 'output_extension']\n" ] }, { "data": { "text/plain": [ - "[u'output_13_1.text',\n", - " u'output_18_0.text',\n", - " u'output_3_0.text',\n", - " u'output_18_1.png',\n", - " u'output_12_0.text',\n", - " u'output_5_0.text',\n", - " u'output_5_0.png',\n", - " u'output_13_1.png',\n", - " u'output_16_0.text',\n", - " u'output_13_0.text',\n", - " u'output_18_1.text',\n", - " u'output_3_0.png',\n", - " u'output_16_0.png']" + "['output_5_0.png',\n", + " 'output_16_0.png',\n", + " 'output_13_1.png',\n", + " 'output_18_1.png',\n", + " 'output_3_0.png']" ] }, - "execution_count": 13, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -1097,22 +1073,22 @@ "from IPython.config import Config\n", "\n", "c = Config({\n", - " 'ExtractOutputTransformer':{'enabled':True}\n", + " 'ExtractOutputPreprocessor':{'enabled':True}\n", " })\n", "\n", - "exportHtml = HTMLExporter()\n", - "exportHtml_and_figs = HTMLExporter(config=c)\n", + "exportHTML = HTMLExporter()\n", + "exportHTML_and_figs = HTMLExporter(config=c)\n", "\n", - "(_, resources) = exportHtml.from_notebook_node(jake_notebook)\n", - "(_, resources_with_fig) = exportHtml_and_figs.from_notebook_node(jake_notebook)\n", + "(_, resources) = exportHTML.from_notebook_node(jake_notebook)\n", + "(_, resources_with_fig) = exportHTML_and_figs.from_notebook_node(jake_notebook)\n", "\n", - "print 'resources without the \"figures\" key :'\n", - "print resources.keys()\n", + "print('resources without the \"figures\" key :')\n", + "print(list(resources))\n", "\n", - "print ''\n", - "print 'Here we have one more field '\n", - "print resources_with_fig.keys()\n", - "resources_with_fig['outputs'].keys() " + "print('')\n", + "print('Here we have one more field')\n", + "print(list(resources_with_fig))\n", + "list(resources_with_fig['outputs'])" ] }, { @@ -1126,27 +1102,27 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### Custom transformer" + "#### Custom Preprocessor" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Of course you can imagine many transformation that you would like to apply to a notebook. This is one of the reason we provide a way to register your own transformers that will be applied to the notebook after the default ones.\n", + "Of course you can imagine many transformation that you would like to apply to a notebook. This is one of the reason we provide a way to register your own preprocessors that will be applied to the notebook after the default ones.\n", "\n", - "To do so you'll have to pass an ordered list of `Transformer`s to the Exporter constructor. \n", + "To do so you'll have to pass an ordered list of `Preprocessor`s to the Exporter constructor. \n", "\n", - "But what is an transformer ? Transformer can be either *decorated function* for dead-simple `Transformer`s that apply\n", + "But what is an preprocessor ? Preprocessor can be either *decorated function* for dead-simple `Preprocessor`s that apply\n", "independently to each cell, for more advance transformation that support configurability You have to inherit from\n", - "`Transformer` and define a `call` method as we'll see below.\n", + "`Preprocessor` and define a `call` method as we'll see below.\n", "\n", "All transforers have a magic attribute that allows it to be activated/disactivate from the config dict." ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": { "collapsed": false }, @@ -1157,27 +1133,29 @@ "text": [ "Four relevant docstring\n", "=============================\n", - " A configurable transformer\n", + " A configurable preprocessor\n", "\n", " Inherit from this class if you wish to have configurability for your\n", - " transformer.\n", + " preprocessor.\n", "\n", - " Any configurable traitlets this class exposed will be configurable in profiles\n", - " using c.SubClassName.atribute=value\n", + " Any configurable traitlets this class exposed will be configurable in\n", + " profiles using c.SubClassName.attribute = value\n", "\n", - " you can overwrite transform_cell to apply a transformation independently on each cell\n", - " or __call__ if you prefer your own logic. See corresponding docstring for informations.\n", + " you can overwrite :meth:`preprocess_cell` to apply a transformation\n", + " independently on each cell or :meth:`preprocess` if you prefer your own\n", + " logic. See corresponding docstring for informations.\n", "\n", " Disabled by default and can be enabled via the config by\n", - " 'c.YourTransformerName.enabled = True'\n", + " 'c.YourPreprocessorName.enabled = True'\n", " \n", "=============================\n", "\n", - " Transformation to apply on each notebook.\n", + " Preprocessing to apply on each notebook.\n", " \n", - " You should return modified nb, resources.\n", - " If you wish to apply your transform on each cell, you might want to \n", - " overwrite transform_cell method instead.\n", + " Must return modified nb, resources.\n", + " \n", + " If you wish to apply your preprocessing to each cell, you might want\n", + " to override preprocess_cell method instead.\n", " \n", " Parameters\n", " ----------\n", @@ -1185,12 +1163,12 @@ " Notebook being converted\n", " resources : dictionary\n", " Additional resources used in the conversion process. Allows\n", - " transformers to pass variables into the Jinja engine.\n", + " preprocessors to pass variables into the Jinja engine.\n", " \n", "=============================\n", "\n", - " Overwrite if you want to apply a transformation on each cell. You \n", - " should return modified cell and resource dictionary.\n", + " Override if you want to apply some preprocessing to each cell.\n", + " Must return modified cell and resource dictionary.\n", " \n", " Parameters\n", " ----------\n", @@ -1198,7 +1176,7 @@ " Notebook cell being processed\n", " resources : dictionary\n", " Additional resources used in the conversion process. Allows\n", - " transformers to pass variables into the Jinja engine.\n", + " preprocessors to pass variables into the Jinja engine.\n", " index : int\n", " Index of the cell being processed\n", " \n", @@ -1207,16 +1185,16 @@ } ], "source": [ - "from IPython.nbconvert.transformers import Transformer\n", + "from IPython.nbconvert.preprocessors import Preprocessor\n", "import IPython.config\n", - "print \"Four relevant docstring\"\n", - "print '============================='\n", - "print Transformer.__doc__\n", - "print '============================='\n", - "print Transformer.call.__doc__\n", - "print '============================='\n", - "print Transformer.transform_cell.__doc__\n", - "print '============================='" + "print(\"Four relevant docstring\")\n", + "print('=============================')\n", + "print(Preprocessor.__doc__)\n", + "print('=============================')\n", + "print(Preprocessor.preprocess.__doc__)\n", + "print('=============================')\n", + "print(Preprocessor.preprocess_cell.__doc__)\n", + "print('=============================')" ] }, { @@ -1224,7 +1202,7 @@ "metadata": {}, "source": [ "***\n", - "We don't provide convenient method to be aplied on each worksheet as the **data structure** for worksheet will be removed. (not the worksheet functionnality, which is still on it's way)\n", + "We don't provide convenient method to be aplied on each worksheet as the **data structure** for worksheet will be removed. (not the worksheet functionality, which is still on it's way)\n", "***" ] }, @@ -1239,14 +1217,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "I'll now demonstrate a specific example [requested](https://github.com/ipython/nbconvert/pull/137#issuecomment-18658235) while nbconvert 2 was beeing developped. The ability to exclude cell from the conversion process based on their index. \n", + "I'll now demonstrate a specific example [requested](https://github.com/ipython/nbconvert/pull/137#issuecomment-18658235) while nbconvert 2 was being developed. The ability to exclude cell from the conversion process based on their index. \n", "\n", "I'll let you imagin how to inject cell, if what you just want is to happend static content at the beginning/end of a notebook, plese refer to templating section, it will be much easier and cleaner." ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": { "collapsed": false }, @@ -1257,71 +1235,66 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "class PelicanSubCell(Transformer):\n", - " \"\"\"A Pelican specific transformer to remove somme of the cells of a notebook\"\"\"\n", + "class PelicanSubCell(Preprocessor):\n", + " \"\"\"A Pelican specific preprocessor to remove somme of the cells of a notebook\"\"\"\n", " \n", " # I could also read the cells from nbc.metadata.pelican is someone wrote a JS extension\n", " # But I'll stay with configurable value. \n", " start = Integer(0, config=True, help=\"first cell of notebook to be converted\")\n", " end = Integer(-1, config=True, help=\"last cell of notebook to be converted\")\n", " \n", - " def call(self, nb, resources):\n", + " def preprocess(self, nb, resources):\n", "\n", " #nbc = deepcopy(nb)\n", " nbc = nb\n", - " # don't print in real transformer !!!\n", - " print \"I'll keep only cells from \", self.start, \"to \", self.end, \"\\n\\n\"\n", - " for worksheet in nbc.worksheets :\n", - " cells = worksheet.cells[:]\n", - " worksheet.cells = cells[self.start:self.end] \n", + " # don't print in real preprocessor !!!\n", + " print(\"I'll keep only cells from \", self.start, \"to \", self.end, \"\\n\\n\")\n", + " nbc.cells = nb.cells[self.start:self.end] \n", " return nbc, resources" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# I create this on the fly, but this could be loaded from a DB, and config object support merging...\n", - "c = Config({\n", - " 'PelicanSubCell':{\n", - " 'enabled':True,\n", - " 'start':4,\n", - " 'end':6,\n", - " }\n", - " })" + "c = Config()\n", + "c.PelicanSubCell.enabled = True\n", + "c.PelicanSubCell.start = 4\n", + "c.PelicanSubCell.end = 6" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "I'm creating a pelican exporter that take `PelicanSubCell` extra transformers and a `config` object as parameter. This might seem redundant, but with configuration system you'll see that one can register an inactive transformer on all exporters and activate it at will form its config files and command line. " + "I'm creating a pelican exporter that take `PelicanSubCell` extra preprocessors and a `config` object as parameter. This might seem redundant, but with configuration system you'll see that one can register an inactive preprocessor on all exporters and activate it at will form its config files and command line. " ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "pelican = RSTExporter(transformers=[PelicanSubCell], config=c)" + "pelican = RSTExporter(preprocessors=[PelicanSubCell], config=c)" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": { "collapsed": false }, @@ -1338,15 +1311,13 @@ "want to display. But drawing it by hand is a pain: I'd rather just use\n", "matplotlib. The problem is, matplotlib is a bit too precise. Attempting\n", "to duplicate this figure in matplotlib leads to something like this:\n", - "In[2]:\n", + "\n", ".. code:: python\n", "\n", " Image('http://jakevdp.github.com/figures/mpl_version.png')\n", "\n", "\n", "\n", - "\n", - "\n", ".. image:: output_5_0.png\n", "\n", "\n", @@ -1355,80 +1326,7 @@ } ], "source": [ - "print pelican.from_notebook_node(jake_notebook)[0]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Programatic example of extending templates / cutom filters" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "from IPython.nbconvert.filters.highlight import _pygment_highlight\n", - "from pygments.formatters import HtmlFormatter\n", - "\n", - "from IPython.nbconvert.exporters import HTMLExporter\n", - "from IPython.config import Config\n", - "\n", - "from IPython.nbformat import current as nbformat" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here we define a dustom 'highlight' filter that apply a custom class to code in css. We register this filter with a already existing name, so it will replace the default one." - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "def my_highlight(source, language='ipython'):\n", - " formatter = HtmlFormatter(cssclass='highlight-ipynb')\n", - " return _pygment_highlight(source, formatter, language)\n", - " \n", - "c = Config({'CSSHtmlHeaderTransformer':\n", - " {'enabled':False, 'highlight_class':'highlight-ipynb'}})\n", - "\n", - "exportHtml = HTMLExporter( config=c , filters={'highlight2html': my_highlight} )\n", - "(body,resources) = exportHtml.from_notebook_node(jake_notebook)" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "u'\n", "

\n", "FOOOOOOOOTEEEEER\n", "\n" @@ -1459,9 +1357,9 @@ "source": [ "from jinja2 import DictLoader\n", "\n", - "dl = DictLoader({'html_full.tpl': \n", + "dl = DictLoader({'full.tpl': \n", "\"\"\"\n", - "{%- extends 'html_basic.tpl' -%} \n", + "{%- extends 'basic.tpl' -%} \n", "\n", "{% block footer %}\n", "FOOOOOOOOTEEEEER\n", @@ -1469,10 +1367,10 @@ "\"\"\"})\n", "\n", "\n", - "exportHtml = HTMLExporter( config=None , filters={'highlight': my_highlight}, extra_loaders=[dl] )\n", - "(body,resources) = exportHtml.from_notebook_node(jake_notebook)\n", + "exportHTML = HTMLExporter(extra_loaders=[dl])\n", + "(body,resources) = exportHTML.from_notebook_node(jake_notebook)\n", "for l in body.split('\\n')[-4:]:\n", - " print l" + " print(l)" ] }, { @@ -1501,7 +1399,7 @@ "metadata": {}, "source": [ "
\n", - "

As @Mbussonn requested... easieeeeer! Deploy your Nikola site with just a click in the IPython notebook! http://t.co/860sJunZvj cc @ralsina

— Dami\u00e1n Avila (@damian_avila) August 21, 2013
\n", + "

As @Mbussonn requested... easieeeeer! Deploy your Nikola site with just a click in the IPython notebook! http://t.co/860sJunZvj cc @ralsina

— Damián Avila (@damian_avila) August 21, 2013
\n", "
" ] }, @@ -1525,18 +1423,26 @@ "source": [ "Jinja blocks use `{% %}`by default which does not play nicely with $\\LaTeX$, hence thoses are replaced by `((* *))` in latex templates." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [] } ], - "metadata": {}, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.2" + } + }, "nbformat": 4, "nbformat_minor": 0 } \ No newline at end of file