python 从jupyter笔记本转换为降价

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 从jupyter笔记本转换为降价相关的知识,希望对你有一定的参考价值。

{% extends 'display_priority.tpl' %}

{%- block header -%}
---
layout: post
title: "{{resources['metadata']['name']}}"
tags:
    - python
    - notebook
---
{%- endblock header -%}

{% block in_prompt %}
**In [{{ cell.prompt_number }}]:**
{% endblock in_prompt %}

{% block output_prompt %}
{%- endblock output_prompt %}

{% block input %}
{{ '{% highlight python %}' }}
{{ cell.input }}
{{ '{% endhighlight %}' }}
{% endblock input %}

{% block pyerr %}
{{ super() }}
{% endblock pyerr %}

{% block traceback_line %}
{{ line | indent | strip_ansi }}
{% endblock traceback_line %}

{% block pyout %}

{% block data_priority scoped %}
{{ super() }}
{% endblock %}
{% endblock pyout %}

{% block stream %}
{{ output.text | indent }}
{% endblock stream %}

{% block data_svg %}
![svg]({{ output.svg_filename | path2support }})
{% endblock data_svg %}

{% block data_png %}
![png]({{ output.png_filename | path2support }})
{% endblock data_png %}

{% block data_jpg %}
![jpeg]({{ output.jpeg_filename | path2support }})
{% endblock data_jpg %}

{% block data_latex %}
{{ output.latex }}
{% endblock data_latex %}

{% block data_html scoped %}
{{ output.html }}
{% endblock data_html %}

{% block data_text scoped %}
{{ output.text | indent }}
{% endblock data_text %}

{% block markdowncell scoped %}
{{ cell.source | wrap_text(80) }}
{% endblock markdowncell %}


{% block headingcell scoped %}
{{ '#' * cell.level }} {{ cell.source | replace('\n', ' ') }}
{% endblock headingcell %}

{% block unknowncell scoped %}
unknown type  {{ cell.type }}
{% endblock unknowncell %}
try:
    from urllib.parse import quote  # Py 3
except ImportError:
    from urllib2 import quote  # Py 2
import os
import sys


BLOG_DIR = os.environ['BLOG_DIR']
# BLOG_DIR = '/Users/cscorley/git/cscorley.github.io/'

f = None
for arg in sys.argv:
    if arg.endswith('.ipynb'):
        f = arg.split('.ipynb')[0]
        break


c = get_config()
c.NbConvertApp.export_format = 'markdown'
c.MarkdownExporter.template_path = ['/Users/cscorley/.ipython/templates']
c.MarkdownExporter.template_file = 'jekyll'
#c.Exporter.file_extension = 'md'

def path2support(path):
    """Turn a file path into a URL"""
    parts = path.split(os.path.sep)
    return '{{ site.baseurl}}notebooks/' + '/'.join(quote(part) for part in parts)

c.MarkdownExporter.filters = {'path2support': path2support}

if f:
    c.NbConvertApp.output_base = f.lower().replace(' ', '-')
    c.FilesWriter.build_directory = BLOG_DIR + '/notebooks'

以上是关于python 从jupyter笔记本转换为降价的主要内容,如果未能解决你的问题,请参考以下文章

如何将jupyter笔记本转换为幻灯片

可以从降价链接控制 Jupyter 中的绘图图吗?

如何将IPython v3笔记本转换为Jupyter v4?

将Jupyter笔记本转换为PDF - 在PATH上找不到pdflatex

Jupyter Notebook Markdown 未显示在 GitHub 中

Jupyter 笔记本无法转换为 pdf 文件