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 6.0+ handles templates in a new way #1

Open
txoof opened this issue Sep 28, 2020 · 2 comments
Open

nbconvert 6.0+ handles templates in a new way #1

txoof opened this issue Sep 28, 2020 · 2 comments

Comments

@txoof
Copy link
Owner

txoof commented Sep 28, 2020

nbconvert requires a directory in ~/.local/share/jupyter/nbconvert/templates/ with two files that describe the template actions.

Need to rewrite the nbconvert script to handle this for future versions

conf.json

{
    "base_template": "base",
    "mimetypes": {
        "text/x-python": true
    }
}

index.py.j2

{%- extends 'null.j2' -%}

## set to python3
{%- block header -%}
#!/usr/bin/env python3
# coding: utf-8
{% endblock header %}

## remove cell counts entirely
{% block in_prompt %}
{% if resources.global_content_filter.include_input_prompt -%}
{% endif %}
{% endblock in_prompt %}

## remove markdown cells entirely
{% block markdowncell %}
{% endblock markdowncell %}

{% block input %}
{{ cell.source | ipython2python }}
{% endblock input %}


## remove magic statement completely
{% block codecell %}
{{'' if "get_ipython" in super() else super() }}
{% endblock codecell%}
@txoof
Copy link
Owner Author

txoof commented Sep 28, 2020

More information found here

and here

@txoof
Copy link
Owner Author

txoof commented Oct 1, 2020

And is resolved here

rewrite python script to simplify?

write bash script that is dead simple or just start using !jupyter-nbconvert --to python --template my_template foo.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant