Coder Social home page Coder Social logo

danielfrg / pelican-jupyter Goto Github PK

View Code? Open in Web Editor NEW
423.0 18.0 105.0 414 KB

Pelican plugin for blogging with Jupyter/IPython Notebooks

License: Apache License 2.0

Python 11.29% Jupyter Notebook 87.74% Makefile 0.96%
jupyter-notebook pelican blog

pelican-jupyter's Introduction

NOT MAINTAINED

  • I have not used this project myself on a long time
  • No issues or PRs can be created
  • I have moved on to mkdocs and my mkdocs-jupyter plugin and I recommend to do the same

pelican-jupyter: Pelican plugin for Jupyter Notebooks

pypi build coverage license

Installation

pip install pelican-jupyter

Pelican and Jupyter versions

The main focus is to run with the latest versions of the packages but there is a good chance the plugin will work correctly with older versions of Pelican and Jupyter/. The recommended version of libraries are:

  • pelican>=4
  • notebook>=6
  • nbconvert>=5

Usage

This plugin provides two modes to use Jupyter notebooks in Pelican:

  1. As a new markup language so .ipynb files are recognized as a valid filetype for an article
  2. As a liquid tag based on the liquid tags plugin so notebooks can be included in a regular post using Markdown (.md) files.

Mode A: Markup Mode

On your pelicanconf.py:

MARKUP = ("md", "ipynb")

from pelican_jupyter import markup as nb_markup
PLUGINS = [nb_markup]

IGNORE_FILES = [".ipynb_checkpoints"]

With this mode you need to pass the MD metadata to the plugins with one of this two options:

Option 1: .nbdata metadata file

Place the .ipynb file in the content folder and create a new file with the same name as the ipython notebook with extension .nbdata. For example if you have my_post.ipynb create my_post.nbdata.

The .nbdata should contain the metadata like a regular Markdown based article (note the empty line at the end, you need it):

Title:
Slug:
Date:
Category:
Tags:
Author:
Summary:

You can specify to only include a subset of notebook cells with the Subcells metadata item. It should contain the index (starting at 0) of first and last cell to include (use None for open range). For example, to skip the first two cells:

Subcells: [2, None]

Option 2: Metadata cell in notebook

With this option, the metadata is extracted from the first cell of the notebook (which should be a Markdown cell), this cell is then ignored when the notebook is rendered.

On your pelicanconf.py:

MARKUP = ("md", "ipynb")

from pelican_jupyter import markup as nb_markup
PLUGINS = [nb_markup]
IPYNB_MARKUP_USE_FIRST_CELL = True

IGNORE_FILES = [".ipynb_checkpoints"]

Now, you can put the metadata in the first notebook cell in Markdown mode, like this:

- title: My notebook
- author: John Doe
- date: 2018-05-11
- category: python
- tags: pip

Mode B: Liquid tags

On your pelicanconf.py:

MARKUP = ('md', )

from pelican_jupyter import liquid as nb_liquid
PLUGINS = [nb_liquid]

IGNORE_FILES = [".ipynb_checkpoints"]

After this you can use a liquid tag to include a notebook in any regular markdown article, for example mypost.md:

Title:
Slug:
Date:
Category:
Tags:
Author:
Summary:

{% notebook path/from/content/dir/to/notebook.ipynb %}

Recommend mode?

Personally I like Method A - Option 1 since I write the Notebooks first and then I just add the metadata file and keeps the notebook clean.

The Liquid tag mode provide more flexibility to combine an existing notebook code or output with extra text on a Markdown. You can also combine 2 or more notebooks in this mode. The only problem with the liquid tag mode is that it doesn't generate a summary for the article automatically from the notebook so you have to write it in the source .md file that includes the notebook.s

You can use both modes at the same time but you are probably going to see a exception that prevents conflicts, ignore it.

Note on CSS

If the notebooks look bad on your pelican theme this can help.

There is some issues/conflicts regarding the CSS that the Jupyter Notebook requires and the pelican themes.

I do my best to make the plugin work with every theme but for obvious reasons I cannot guarantee that it will look good in any pelican theme.

Jupyter Notebook is based on bootstrap so you probably will need your theme to be based on that it if you want the html and css to render nicely.

I try to inject only the necessary CSS by removing Jupyter's bootstrap code and only injecting the extra CSS code. In some cases but fixes are needed, I recommend looking at how my theme fixes them.

You can suppress the inclusion of any Notebook CSS entirely by setting IPYNB_SKIP_CSS=True, this allows more flexibility on the pelican theme.

The IPYNB_EXPORT_TEMPLATE option is another great way of extending the output natively using Jupyter nbconvert.

Settings

Note: If you are using the Liquid mode you need to set the variables like this inside the pelicanconf.py.

LIQUID_CONFIGS = (("IPYNB_EXPORT_TEMPLATE", "notebook.tpl", ""), )

If you are using the Markup mode then just add this variables to your pelicanconf.py.

Setting Description
IPYNB_FIX_CSS = True [markup and liquid] Do not apply any of the plugins "fixes" to the Jupyter CSS use all the default Jupyter CSS.
IPYNB_SKIP_CSS = False [markup and liquid] Do not include (at all) the notebook CSS in the generated output. This is usefull if you want to include it yourself in the theme.
IPYNB_PREPROCESSORS [markup and liquid] A list of nbconvert preprocessors to be used when generating the HTML output.
IPYNB_EXPORT_TEMPLATE [markup and liquid] Path to nbconvert export template (relative to project root). For example: Create a custom template that extends from the basic template and adds some custom CSS and JavaScript, more info here docs and example here.
IPYNB_STOP_SUMMARY_TAGS = [('div', ('class', 'input')), ('div', ('class', 'output')), ('h2', ('id', 'Header-2'))] [markup only] List of tuples with the html tag and attribute (python HTMLParser format) that are used to stop the summary creation, this is useful to generate valid/shorter summaries.
IPYNB_GENERATE_SUMMARY = True [markup only] Create a summary based on the notebook content. Every notebook can still use the sSummary from the metadata to overwrite this.
IPYNB_EXTEND_STOP_SUMMARY_TAGS [markup only] List of tuples to extend the default IPYNB_STOP_SUMMARY_TAGS.
IPYNB_NB_SAVE_AS [markup only] If you want to make the original notebook available set this variable in a is similar way to the default pelican ARTICLE_SAVE_AS setting. This will also add a metadata field nb_path which can be used in the theme. e.g. blog/{date:%Y}/{date:%m}/{date:%d}/{slug}/notebook.ipynb
IPYNB_COLORSCHEME [markup only] Change the pygments colorscheme used for syntax highlighting
IGNORE_FILES = ['.ipynb_checkpoints'] [Pelican setting useful for markup] Prevents pelican from trying to parse notebook checkpoint files.

Example template for IPYNB_EXPORT_TEMPLATE:

{%- extends 'basic.tpl' -%}

{% block header %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<style type="text/css">
div.code_cell {
    border: 2px solid red;
}
</style>
{%- endblock header %}

pelican-jupyter's People

Contributors

andreagrandi avatar ashwinvis avatar astrofrog avatar bamieh avatar birdsarah avatar croach avatar danielfrg avatar florianwilhelm avatar fredcallaway avatar gepcel avatar ivanov avatar jakevdp avatar jeankossaifi avatar jreiberkyle avatar leemengtw avatar lucas-c avatar luizirber avatar maartenscholl avatar matthewgilbert avatar matthewryanscott avatar mfitzp avatar nayyarv avatar peijunz avatar peterwittek avatar ronanpaixao avatar schneiderfelipe avatar sornars avatar soxofaan avatar timstaley avatar zhuoqiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pelican-jupyter's Issues

liquid-tags like usage

Thanks for providing this cool pelican plugin which seems to be the only Jupyter/IPython plugin that works with never versions of IPython. Have you ever considered merging this with the liquid-style tags plugin plugin? Or to put this another way, would it be possible to use your technique of reading an ipynb file inside regular markdown article with a syntax like {% notebook filename.ipynb %}? This way, it would not be necessary to provide a .ipynb-meta and the usage of your plugin would feel more natural. Or maybe there are certain technical reasons that prevent this?

Summary contains broken HTML

Summary creation does not work for me. There seem to be multiple issues:

  • The summary is created without the notebook CSS, so the cells are not rendered nicely
  • More importantly, the summary stops after some <div> start tags, without ever closing them, breaking my layout.
  • Specifying a summary in the ipynb-meta files is not possible (it is read, but then overridden with the generated summary.

| TypeError: 'bool' object is not callable

Unfortunately, I have no idea how to debug this error. The entire log reads:

**[jslater@norma josephcslater]$** *make html*
/Users/jslater/Library/Python/3.5/bin/pelican /Users/jslater/websites/josephcslater/content -o /Users/jslater/websites/josephcslater/josephcslater.github.io -s /Users/jslater/websites/josephcslater/pelicanconf.py 
ERROR: Could not process ./SymPy_Multiple_Eqn_solution.ipynb
  | TypeError: 'bool' object is not callable
Done: Processed 6 articles, 5 drafts, 0 pages and 0 hidden pages in 0.98 seconds.

I've had to add the .txt extension to these files to be able to upload them.

SymPy_Multiple_Eqn_solution.ipynb-meta.txt
SymPy_Multiple_Eqn_solution.ipynb.txt

Cryptic "WARNING: Could not process" warning

Hi. Thanks for the plugin!

I'm seeing an error sometimes when running make:

$ make html
[ ! -d /Users/terry/dark-matter/www/output ] || find /Users/terry/dark-matter/www/output -mindepth 1 -delete
pelican /Users/terry/dark-matter/www/content -o /Users/terry/dark-matter/www/output -s /Users/terry/dark-matter/www/pelicanconf.py
WARNING: Could not process notebooks/Using the new new code.ipynb
'title'
WARNING: Unable to find ParseResult(scheme='', netloc='', path=u'notebooks/Using%20the%20new%20new%20code.ipynb', params='', query='', fragment=''), skipping url replacement
Done: Processed 96 article(s), 0 draft(s) and 2 page(s) in 5.92 seconds.

It looks like the error message is being produced in generators.py in the main Pelican code. However, I'm guessing that something called by this plugin is raising an exception using old-school Python, passing a string ("title") to raise.

In my markdown source, I have

Instead see [How to use the new new code](|filename|notebooks/Using the new new code.ipynb).

I'm wondering if this is a known issue, or if I should go digging.

I can use the plugin successfully on quite a few other iPython Notebook files (including ones with spaces in their names). This error was happening to me earlier today, then mysteriously went away. Now it's happening again, on another .ipynb file.

BTW, I do have a Title in my .ipynb-meta file.

If I manually run ipython nbconvert Using\ the\ new\ new\ code.ipynb the HTML that is generated has a syntactically valid <title>Using the new new code</title> tag.

Thanks for any help!

UnicodeDecodeError in markup.py

There is a bug in markup.py handling of Unicode filenames and files.

If I have a non-ASCII character in a filename, I get this error message:

ERROR: Could not process <filename>
  | UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 201: ordinal not in range(128)

And if I have a non-ASCII character in the contents, I get this:

ERROR: Could not process <filename>
  | UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 201: ordinal not in range(128)

I have tracked the errors and soon will submit a PR.

Markdown list items

Markdown list items do not render properly for me, eg:

- one
- two
- three

does not look like

  • one
  • two
  • three

They are simply rendered as dashes. Can anyone replicate this, or is it just me?

The readme Installation need more clarify

Thanks your guys work. I just have tried the project, and found that i do not need to rename the project folder name , just normal import it like another pelican plugin to do as the same.

MARKUP = ('md', 'ipynb')

# the plugin
PLUGIN_PATHS = ['myplugins']

PLUGINS = ['pelican_javascript', 'extract_toc', 'render_math', 'pelican_ipynb.markup']

so the installation section just point that to install the pelican plugin normally and need the

MARKUP = ('md', 'ipynb')

config , it will be more clarify.

ipynb-meta files require slug field to be detected by markup.py

Not all blogs care to slugify their URLs and are happy to use the title of the post as the URL. Currently markup.py does not process .ipynb-meta files unless they have the slug field present and assumes that the post is using liquid tags instead, forcing the user to use the .md extension for their ipython notebook metadata and raising an exception during the build process.

I believe that using the slug field should be optional.

Relative import fails

The relative import does not seem to work for me. In my pelican project I when I start the devserver I get the following error:

% make devserver
/home/stefan/projects/pelican_test/develop_server.sh restart
Stale PID, deleting
Stale PID, deleting
Starting up Pelican and pelican.server
DEBUG: Adding current directory to system path
DEBUG: Temporarily adding PLUGIN_PATH to system path
DEBUG: Loading plugin `ipythonnb`
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pelican/server.py", line 18, in <module>
    httpd = socketserver.TCPServer(("", PORT), Handler)
  File "/usr/lib/python2.7/SocketServer.py", line 408, in __init__
    self.server_bind()
  File "/usr/lib/python2.7/SocketServer.py", line 419, in server_bind
    self.socket.bind(self.server_address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
Traceback (most recent call last):
  File "/usr/local/bin/pelican", line 9, in <module>
    load_entry_point('pelican==3.2.2', 'console_scripts', 'pelican')()
  File "/usr/local/lib/python2.7/dist-packages/pelican/__init__.py", line 317, in main
    pelican = get_instance(args)
  File "/usr/local/lib/python2.7/dist-packages/pelican/__init__.py", line 311, in get_instance
    return cls(settings)
  File "/usr/local/lib/python2.7/dist-packages/pelican/__init__.py", line 51, in __init__
    self.init_plugins()
  File "/usr/local/lib/python2.7/dist-packages/pelican/__init__.py", line 69, in init_plugins
    plugin = __import__(plugin, globals(), locals(), str('module'))
  File "/home/stefan/projects/pelican_test/plugins/ipythonnb.py", line 12, in <module>
    raise e
ValueError: Attempted relative import in non-package
Pelican didn't start. Is the pelican package installed?
make: *** [devserver] Error 1

This is my folder structure:

% tree
.
โ”œโ”€โ”€ content
โ”‚ย ย  โ”œโ”€โ”€ pages
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ....
โ”‚ย ย  โ”œโ”€โ”€ TestNotebook.ipynb
โ”‚ย ย  โ””โ”€โ”€ TestNotebook.ipynb-meta

โ”œโ”€โ”€ plugins
โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”œโ”€โ”€ ipythonnb.py
โ”‚ย ย  โ”œโ”€โ”€ ipythonnb.pyc
โ”‚ย ย  โ””โ”€โ”€ nbconverter
โ”‚ย ย      โ”œโ”€โ”€ base.py
โ”‚ย ย      โ”œโ”€โ”€ base.pyc
โ”‚ย ย      โ”œโ”€โ”€ html.py
โ”‚ย ย      โ”œโ”€โ”€ html.pyc
โ”‚ย ย      โ”œโ”€โ”€ __init__.py
โ”‚ย ย      โ”œโ”€โ”€ __init__.pyc
โ”‚ย ย      โ”œโ”€โ”€ lexers.py
โ”‚ย ย      โ”œโ”€โ”€ lexers.pyc
โ”‚ย ย      โ”œโ”€โ”€ utils.py
โ”‚ย ย      โ””โ”€โ”€ utils.pyc

When I use the absolute import it works.

Page Build Failure

I've been getting the following page build failure.

The page build failed with the following error:

The submodule registered for `./plugins/ipynb` could not be cloned. Make sure it's using https:// and that it's a public repo. For more information, see https://help.github.com/articles/page-build-failed-invalid-submodule.

I've tried publishing from multiple devices and I get the same problem.
Here's my repo: https://github.com/WolfHoward/WolfHoward.github.io

Any help with this would be greatly appreciated.

summary in *.ipynb-meta file ignored

If article.summary is referenced in a template, the summary is not the summary in *.ipynb-meta file. The first cell of the notebook was used in its place.

I discovered this when I added a template for inserting twitter card meta tags: see the template example here

After setting self.settings['summary'] = metadata['summary'] I get the expected behavior.

I submitted a pull request.

'_pygments_highlight' is not defined

Hi, I have Pygments installed, but get an error

WARNING: Could not process ./2014-11-29-test-notebook.ipynb
global name '_pygments_highlight' is not defined

Updates:

You can duplicate this in IPython, using the line #27 in ipynb.py

In [2]: from IPython.nbconvert.filters.highlight import _pygments_highlight
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-703783dd7ab9> in <module>()
----> 1 from IPython.nbconvert.filters.highlight import _pygments_highlight

ImportError: cannot import name _pygments_highlight

Woops, looks like I have an aged IPython version.

ipython -V
1.2.1

Although I checked running from IPython.nbconvert.filters.highlight import _pygment_highlight in IPython and it doesn't error. This is for the IPython version > 2.0. Why would it fail inside of the ipynb plugin and not IPython notebook?

Ran pip install ipython[all] too.

I downloaded the newest release on Github, tar xvfz ipython-2.1.0.tar.gz, cd ipython-2.1.0/, python setup.py install, and it didn't fix. I double-checked by uninstalling pip uninstall ipython. Confirmed it was gone, then reran python setup.py install, and it returns 1.2.1 instead of 2.1.0. Maybe IPython didnt update their internal version number with the release?

Anyway, besides a version number issue that may be unrelated, I don't see why the try from IPython.nbconvert.filters.highlight import _pygment_highlight would fail when I can run it in IPython?

Mathjax macro not included

I'm having a problem getting latex to render using pelican-ipynb. It looks like the mathjax macro isn't getting inserted into the output html file. When I run nbconvert on the notebook outside of pelican, the mathjax macro is included and the latex renders. I noticed the command line nbconvert uses the "full" template while the ipynb.nb file uses "basic" when it configures the HTMLExporter.

Here is where I'm very puzzled: when I change the ipynb.py code to use template_file="full" in line 204, I still get the same behavior where the mathjax template is not included.

I'm not familiar enough with the Pelican machinery to guess if some other processing might strip it out...

UnicodeDecodeError with Jupyter Notebooks Having Code Cells

I was using a python 2.7 virtualenv and the ipynb plugin for converting jupyter notebooks to html with pelican.

With some .ipynb notebooks (python 2.7 kernel) in the pelican content folder I tried running pelican content. I was receiving the error "UnicodeDecodeError: 'ascii' codec can't decade byte 0xc2 in position 333: ordinal not in range(128)." The error only occurred for jupyter notebooks that had code cells in them, the pure markdown notebooks were fine.

I found this SO question and added the following at the top of the pelicanconf.py file under from __future__ import __unicode_literals :

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

This seems to have fixed the issue, but I don't really understand why.

Also sorry if this is the wrong place to be logging this. I'm a noob.

EDIT: added link to SO question.

Installation differs from readme

I think the installation section in the readme has a small error, or at least didn't work for me. The procedure that worked follows this:

Put the plugin (__init__.py and ipythonnb.py) inside pelican_project/other_plugins/ipythonnb folder.

Then in the pelicanconf.py:

MARKUP = ('md', 'ipynb')

PLUGIN_PATH = './other_plugins'
PLUGINS = ['ipythonnb']

Plot not rendering correctly

I'm encountering a strange condition where the embedded png of a plot seems to be truncated and mixed with what looks like CSS code in the rendered output. Inspecting the html, it looks like the png has a bunch of CSS appended. I haven't been able to create a simple example yet.

Conflicts with typogrify

I had set TYPOGRIFY = True in my pelicanconf.py only to find that it breaks some functionality of ipynb posts. Specifcally, typogrify applies <span> elements to parts of the inline CSS, which ends up breaking those styles as well as MathJax. That is probably a bug in typogrify, but I thought I'd point it out here.

Obviously the easiest way to fix the issue is to disable typogrify.

Support for python3

Hence I'm using pelican with python3, I have to downgrade entire stack if I want to use your plugin. Please add support for py3. =)

AttributeError: 'module' object has no attribute 'register'

Can not compile. Based on this issue with org_pandoc_reader, I believe it's a problem with the newer versions of pelican. I get the following error when attempting to compile

Traceback (most recent call last):                                                                                        
    File "/usr/bin/pelican", line 9, in <module>                                                                              
        load_entry_point('pelican==3.6.3', 'console_scripts', 'pelican')()                                                    
    File "/usr/lib/python2.7/dist-packages/pelican/__init__.py", line 386, in main                                            
        pelican, settings = get_instance(args)                                                                                
    File "/usr/lib/python2.7/dist-packages/pelican/__init__.py", line 380, in get_instance                                    
        return cls(settings), settings                                                                                        
    File "/usr/lib/python2.7/dist-packages/pelican/__init__.py", line 57, in __init__                                         
        self.init_plugins()                                                                                                   
    File "/usr/lib/python2.7/dist-packages/pelican/__init__.py", line 84, in init_plugins                                     
        plugin.register()                                                                                                   
AttributeError: 'module' object has no attribute 'register'

BeautifulSoup invocation erroneously alters the resulting html

this bit of code seems to be harmful.

I have observed it producing from this:

line with a line break (so ending with a double space)  
line without a line break

the following erroneous html:

line with a line break (so ending with a double space)<br>
line without a line break</br>

(note the </br> tag). This results in large extra empty space added to a text with a lot of line breaks.

Include a notebook from a remote location

Hi,

it would be very useful if the {% notebook path/from/content/dir/to/notebook.ipynb %} tag could include an .ipynb from an external location like {% notebook https://github.com/andreagrandi/ml-pima-notebook/blob/master/PimaIndiansDiabetes.ipynb %} so I could keep my project separate by the code.

Is it something already supported or that could be implemented in the future?

Cheers

A very simple approach for the ipynb format support.

Please checkout this fork , I just have study this project , and found that the pelican have the auto-generator summay inner machnism , so we do not need do that any more, and read the metadata recommend use the nbformat library.

and we really do not need handle the css issue, just drop it out , and let the user do there blog default css configuration.

ERROR: Could not process .\with-meta-file.ipynb | ValueError: embedded null byte

when i run pelican content --debug, the information show as follow:

ERROR: Could not process .\with-meta-file.ipynb
  | ValueError: embedded null byte
  |___
  | Traceback (most recent call last):
  |   File "d:\venv\blogenv\lib\site-packages\pelican\generators.py", line 523,
in generate_context
  |     context_sender=self)
  |   File "d:\venv\blogenv\lib\site-packages\pelican\readers.py", line 526, in
read_file
  |     content, reader_metadata = reader.read(path)
  |   File "D:\blog\plugins\ipynb\markup.py", line 81, in read
  |     content, info = get_html_from_filepath(filepath)
  |   File "D:\blog\plugins\ipynb\core.py", line 91, in get_html_from_filepath
  |     content, info = exporter.from_filename(filepath)
  |   File "d:\venv\blogenv\lib\site-packages\nbconvert\exporters\exporter.py",
line 171, in from_filename
  |     resources['metadata']['modified_date'] = modified_date.strftime(text.dat
e_format)
  | ValueError: embedded null byte

Bokeh plots are not working

I have a few Bokeh plots which work on the notebook. When I use the plugin (markup mode - option 1) the plots are just ignored in the output.

I'm not sure if I'm doing something wrong (the plots do work on the notebook), the plugin does not work with Bokeh or if I need to modify something for it to work.

Any ideas?

Fix for attempting to encode already encoded strings

Hi,

Thanks for the awesome plug in. Yesterday, when trying to push a change to my blog, I noticed an error. After debugging, what happened was that the plug in was trying to encode strings that were already encoded, and causing a UnicodeEncodeError.

The fix is simple:

patch.txt

Basically: if there's an encoderror in those lines, it's because it's trying to encode before decoding.

metadata editing

Hello,
nice work.

Do you know if metadata editing is going to be supported directly from IPython in some future?

Regards.

Enhancement

Awesome plugin, got me up and running in seconds

I modified it slightly (https://github.com/anemes/pelican-ipythonnb) so that it

  1. Hides the code cells by default and make the interpreter In [1] be a link to toggle code cell visibility.
  2. Strips code cells from the HTML that begin with #HIDE.

Use outside of pelican

First of all, Thank you for the awesome plugin.
I was wondering if this can be used with a blog not using pelican. Just using the plugins to general HTML from a notebook & using them in another website ?

Html Parsing Bug

I'm attempting to convert an ipython notebook to html but there seems to be an issue parsing the json image component of a notebook.

selection_014

It appears that the string is being improperly escaped

selection_015

I believe it has something to do with when the text is parsed using BeautifulSoup but have been unable to pin down exactly what the issue is. I have a repo which has a single blog post where the issue is occuring.

https://github.com/MatthewGilbert/blogbug

Suppress CSS output

Would it be possible to get a configuration variable for disabling the output of CSS (or at least for disabling the Pygments CSS)? I have a mix of notebooks and other code on my site and am using Pygments for the syntax highlighting โ€” but it doesn't seem to be possible to override the theme applied to ipynb (without using lots of !important flags).

The ability to disable syntax highlighting completely (to support using JS-based highlighting options) would also be nice.

Do not make data mandatory in metadata

If you don't mention the "Date" field, you get:

Could not process xxx.ipynb
  | Exception: Could not find metadata in `.ipynb-meta`, inside `.ipynb` or external `.md` file.

But pelican provides a feature to avoid writing them automatically use the filesystem date instead. You should allow that.

something wrong with the &apos escape

When there are single quote characters in the notebook outputs, nbconvert converts them to "&apos;", which is fine. But the pelican-ipythonnb converts the "&apos;" to "&amp; apos;".
So the single quote character in the notebook outputs ends up to "&amp; apos;" in the html source code, and "& apos" in the chrome display.

Looks like the single quote is converted twice.
Cannot locate where does the convertion happen.

Multiple notebooks failing

I was successful in creating and deploying the website with a single ipython post. Each notebook works properly when I remove the other one (although one will not embed images). I have tried adding a second ipython notebook post and I am getting an error (from $make html):
CRITICAL: File myproject/output/.html is to be overwritten

*** Fixed by moving the new post into a seperate folder

Processing fails [pelican 3.3.0]

I think I have everything set up as instructed, but I get this error:

$ pelican -s pelicanconf.py
WARNING: Could not process posts/2013/11/test.ipynb
custom_highlighter() got an unexpected keyword argument 'metadata'
Done: Processed 0 articles and 0 pages in 0.22 seconds.

# maye at lunatic in ~/Dropbox/src/blog on git:gh-pages x [23:22:53]

My content folder:

$ ll
total 56
-rw-r--r--  1 maye  staff  17519 Nov 29 22:59 test.ipynb
-rw-r--r--@ 1 maye  staff    182 Nov 29 23:16 test.ipynb-meta
-rw-r--r--@ 1 maye  staff    100 Nov 29 00:45 welcome-all.md.old

# maye at lunatic in ~/Dropbox/src/blog/content/posts/2013/11 on git:gh-pages x [23:19:12]

The content of test.ipynb-meta:

$ cat test.ipynb-meta
Title: Testing Notebook blogging
Slug: testing-notebook-blogging
Date: 2013-11-29
Category: Coding
Tags: notebook
Author: K.-Michael Aye
Summary: Just trying out the notebook plugin

The relevant parts of pelicanconf.py:

MARKUP = ('md', 'ipynb')

PLUGIN_PATH = './plugins'
PLUGINS = ('ipythonnb',)

Here's the output of running pelican with the --debug option:

DEBUG: Adding current directory to system path
DEBUG: Temporarily adding PLUGIN_PATH to system path
DEBUG: Loading plugin `ipythonnb`
DEBUG: Registering plugin `ipythonnb`
DEBUG: Restoring system path
DEBUG: Missing dependencies for asc
DEBUG: template list: [u'!simple/archives.html', u'!simple/article.html', u'!simple/author.html', u'!simple/authors.html', u'!simple/base.html', u'!simple/categories.html', u'!simple/category.html', u'!simple/gosquared.html', u'!simple/index.html', u'!simple/page.html', u'!simple/pagination.html', u'!simple/tag.html', u'!simple/tags.html', u'!simple/translations.html', u'_includes/after_footer.html', u'_includes/analytics.html', u'_includes/article.html', u'_includes/article_infos.html', u'_includes/article_time.html', u'_includes/disqus_script.html', u'_includes/disqus_thread.html', u'_includes/footer.html', u'_includes/github.html', u'_includes/header.html', u'_includes/links.html', u'_includes/navigation.html', u'_includes/pagination.html', u'_includes/piwik.html', u'_includes/sidebar.html', u'_includes/social.html', u'archives.html', u'article.html', u'author.html', u'authors.html', u'base.html', u'categories.html', u'category.html', u'gosquared.html', u'index.html', u'page.html', u'pagination.html', u'tag.html', u'tags.html', u'translations.html']
DEBUG: template list: [u'!simple/archives.html', u'!simple/article.html', u'!simple/author.html', u'!simple/authors.html', u'!simple/base.html', u'!simple/categories.html', u'!simple/category.html', u'!simple/gosquared.html', u'!simple/index.html', u'!simple/page.html', u'!simple/pagination.html', u'!simple/tag.html', u'!simple/tags.html', u'!simple/translations.html', u'_includes/after_footer.html', u'_includes/analytics.html', u'_includes/article.html', u'_includes/article_infos.html', u'_includes/article_time.html', u'_includes/disqus_script.html', u'_includes/disqus_thread.html', u'_includes/footer.html', u'_includes/github.html', u'_includes/header.html', u'_includes/links.html', u'_includes/navigation.html', u'_includes/pagination.html', u'_includes/piwik.html', u'_includes/sidebar.html', u'_includes/social.html', u'archives.html', u'article.html', u'author.html', u'authors.html', u'base.html', u'categories.html', u'category.html', u'gosquared.html', u'index.html', u'page.html', u'pagination.html', u'tag.html', u'tags.html', u'translations.html']
DEBUG: template list: [u'!simple/archives.html', u'!simple/article.html', u'!simple/author.html', u'!simple/authors.html', u'!simple/base.html', u'!simple/categories.html', u'!simple/category.html', u'!simple/gosquared.html', u'!simple/index.html', u'!simple/page.html', u'!simple/pagination.html', u'!simple/tag.html', u'!simple/tags.html', u'!simple/translations.html', u'_includes/after_footer.html', u'_includes/analytics.html', u'_includes/article.html', u'_includes/article_infos.html', u'_includes/article_time.html', u'_includes/disqus_script.html', u'_includes/disqus_thread.html', u'_includes/footer.html', u'_includes/github.html', u'_includes/header.html', u'_includes/links.html', u'_includes/navigation.html', u'_includes/pagination.html', u'_includes/piwik.html', u'_includes/sidebar.html', u'_includes/social.html', u'archives.html', u'article.html', u'author.html', u'authors.html', u'base.html', u'categories.html', u'category.html', u'gosquared.html', u'index.html', u'page.html', u'pagination.html', u'tag.html', u'tags.html', u'translations.html']
DEBUG: read file posts/2013/11/test.ipynb -> Article
DEBUG: signal <blinker.base.NamedSignal object at 0x102182ed0; u'article_generator_preread'>.send(<pelican.generators.ArticlesGenerator object at 0x103888b10>)
WARNING: Could not process posts/2013/11/test.ipynb
custom_highlighter() got an unexpected keyword argument 'metadata'
-> writing /Users/maye/Dropbox/src/blog/output/index.html
-> writing /Users/maye/Dropbox/src/blog/output/tags.html
-> writing /Users/maye/Dropbox/src/blog/output/categories.html
-> writing /Users/maye/Dropbox/src/blog/output/authors.html
-> writing /Users/maye/Dropbox/src/blog/output/archives.html
Done: Processed 0 articles and 0 pages in 0.21 seconds.

Add support for nbextensions and image attachments

Some nbextensions modules are very useful, like python-markdown that allows you to include inline Python code in Markdown cells.

I have added a support for nbextensions in my fork of pelican-ipynb. One problem though is that it uses shell command to run the conversion code. Let me know if there is a better way to do this or otherwise merge my fork.

I have also added a feature to copy attachment images into the output directory.

Exception: Could not find metadata in `.ipynb-meta`, inside `.ipynb` or external `.md` file.

Hello, I got these warnings and error when I ran "sudo make html".

WARNING: PLUGIN_PATH setting has been replaced by PLUGIN_PATHS, moving it to the new setting name.
WARNING: Defining PLUGIN_PATHS setting as string has been deprecated (should be a list)
ERROR: Could not process notebook/test.ipynb
  | Exception: Could not find metadata in `.ipynb-meta`, inside `.ipynb` or external `.md` file.
Done: Processed 2 articles, 0 drafts, 0 pages and 0 hidden pages in 0.20 seconds.

Here are my settings and environment

  • pelican 3.6.3
  • jupyter 4.0.6
  • nbconvert 4.1.0
  • beautifulsoup4 4.4.1
content
    notebook
        test.ipynb
        test.ipynb-meta
plugins
    ipynb
        __init__.py
        ...

In the pelicanconf.py:

...
MARKUP = ('md', 'ipynb')

PLUGIN_PATH = './plugins'
PLUGINS = ['ipynb.markup']

I tried to solve the problem but I couldn't. When I write "PLUGIN_PATHS = ['./plugins']" the warnings are gone but still get that error. Any idea? Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.