Skip to content
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 - ReST .. code:: directive #6100

Closed
trendelkampschroer opened this issue Jul 9, 2014 · 5 comments
Closed

nbconvert - ReST .. code:: directive #6100

trendelkampschroer opened this issue Jul 9, 2014 · 5 comments
Milestone

Comments

@trendelkampschroer
Copy link

Hi,

I have encountered a problem when converting .ipynb files to .rst. Code cells are marked using the ".. code:: python" directive.

Using sphinx to build html using the .rst files generated via nbconvert fails with the following error.

ERROR: Unknown directive type "code".

.. code:: python

In the sphinx-docs I have found ".. code-block:: python" directive instead.

Is this a bug of nbconvert or am I using an outdated version of sphinx.

I am glad for any suggestions.

Thanks,

Ben

@takluyver
Copy link
Member

The code directive is a standard part of rst:
http://docutils.sourceforge.net/docs/ref/rst/directives.html#code

Sphinx uses code-block instead - there is a reason, but I can't remember it just now. I thought code still worked, but maybe that's not the case. Maybe we need a sphinx-rst template.

@trendelkampschroer
Copy link
Author

Thanks a lot for your quick reply.

Maybe there is also a simple way to modify my rst-template locally so that I get 'code-block' instead of 'code'. Do you have any insight in how this might be achieved?

I'll try to check whether I can convince sphinx to accept the code directive instead of code-block also.

In the worst case I might need to postprocess all the generated .rst files, but it would be nice if that wouldn't be necessary.

Thanks

@trendelkampschroer
Copy link
Author

It was indeed easy to modify rst.tpl. Replacing the 'code' by the 'code-block' directive did the job for me.

Maybe a sphinx-rst.tpl option could be a fix, but it seems strange to me that sphinx doesn't accept 'code' despite it being a standard rst-directive.

@sontek
Copy link

sontek commented Jul 14, 2014

+1. Would love to see this happen --to sphinx or something, would just make life easier.

@sontek
Copy link

sontek commented Jan 2, 2015

Just tried with latest sphinx and it is now accepting .. code:: so this can probably be closed

@ellisonbg ellisonbg added this to the no action milestone Jan 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants