From b8982309132fb7ea96fe20fc286acc6f28dddfff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Dietrich?= Date: Fri, 7 Feb 2014 23:08:23 +0100 Subject: [PATCH] Make python code collapsible: - Remove unused code: https://github.com/getpelican/pelican-plugins/issues/140 - Add javascript and CSS to header to toggle code areas - load jinja2 template from file --- liquid_tags/notebook.py | 60 +++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/liquid_tags/notebook.py b/liquid_tags/notebook.py index 8b45d5d..2dce5e4 100644 --- a/liquid_tags/notebook.py +++ b/liquid_tags/notebook.py @@ -112,6 +112,14 @@ pre.ipynb { } img.anim_icon{padding:0; border:0; vertical-align:middle; -webkit-box-shadow:none; -box-shadow:none} + +div.collapseheader { + width=100%; + background-color:#d3d3d3; + padding: 2px; + cursor: pointer; + font-family:"Helvetica Neue",Helvetica,Arial,sans-serif; +} @@ -134,6 +142,23 @@ init_mathjax = function() { } init_mathjax(); + + + + """ CSS_WRAPPER = """ @@ -171,36 +196,6 @@ class SubCell(Transformer): return nbc, resources -#---------------------------------------------------------------------- -# Customize the html template: -# This changes the
 tags in basic_html.tpl to 
-
{{output.text |ansi2html}}
- -{%- endblock stream_stdout %} - -{% block stream_stderr -%} -
-
{{output.text |ansi2html}}
-
-{%- endblock stream_stderr %} - -{% block pyerr -%} -
-
{{super()}}
-
-{%- endblock pyerr %} - -{%- block data_text %} -
{{output.text | ansi2html}}
-{%- endblock -%} -"""}) - #---------------------------------------------------------------------- # Custom highlighter: @@ -254,10 +249,9 @@ def notebook(preprocessor, tag, markup): {'enabled':True, 'start':start, 'end':end}}) exporter = HTMLExporter(config=c, - template_file='basic', + template_file='pelicanhtml', filters={'highlight2html': custom_highlighter}, - transformers=[SubCell], - extra_loaders=[pelican_loader]) + transformers=[SubCell]) # read and parse the notebook with open(nb_path) as f: