Created
January 10, 2016 01:35
-
-
Save maclandrol/ad0c4ec49be8b891d444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modification of config created here: https://gist.github.com/cscorley/9144544 | |
try: | |
from urllib.parse import quote # Py 3 | |
except ImportError: | |
from urllib2 import quote # Py 2 | |
import os | |
import sys | |
from settings import template_path, template_file, build_dir, rel_img_path | |
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 = [template_path] # point this to your jekyll template file | |
c.MarkdownExporter.template_file = template_file | |
#c.Application.verbose_crash=True | |
# modify this function to point your images to a custom path | |
# by default this saves all images to a directory 'images' in the root of the blog directory | |
def path2support(path): | |
"""Turn a file path into a URL""" | |
print '{{ site.baseurl }}'+ quote(os.path.join(rel_img_path, path)) | |
return '{{ site.baseurl }}'+ quote(os.path.join(rel_img_path, path)) | |
c.MarkdownExporter.filters = {'path2support': path2support} | |
if f: | |
c.NbConvertApp.output_base = os.path.basename(f).lower().replace(' ', '-') | |
c.FilesWriter.build_directory = build_dir # point this to your build directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'markdown.tpl' %} | |
{%- block header -%} | |
--- | |
layout: post | |
title: "{{resources['metadata']['name']}}" | |
tags: | |
- python | |
- notebook | |
--- | |
{%- endblock header -%} | |
{% block in_prompt %} | |
**In [{{ cell.execution_count }}]:** | |
{% endblock in_prompt %} | |
{% block output_prompt %} | |
{%- endblock output_prompt %} | |
{% block input %} | |
{{ '{% highlight python %}' }} | |
{{ cell.source }} | |
{{ '{% 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 data_svg %} | |
![svg]({{ output.metadata.filenames['image/svg+xml'] | path2support }}) | |
{% endblock data_svg %} | |
{% block data_png %} | |
![png]({{ output.metadata.filenames['image/png'] | path2support }}) | |
{% endblock data_png %} | |
{% block data_jpg %} | |
![jpeg]({{ output.metadata.filenames['image/jpeg'] | path2support }}) | |
{% endblock data_jpg %} | |
{% 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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#template directory | |
template_path ='/home/manu/.ipython/templates' | |
#template file | |
template_file = 'jekyll' | |
#build directory | |
build_dir = '/home/manu/Documents/Projects/Programmation/GithubRepos/maclandrol.github.io/_drafts' | |
#relative image folder path (to blog root) | |
rel_img_path = '/public/images/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment