From ac14f6dc3504a0c1058857594b70065727f7bcdb 2012-12-20 04:19:29 From: damianavila Date: 2012-12-20 04:19:29 Subject: [PATCH] Added ipython styling through a method inside the converter. Modified the template to adjust to the new method. Rewritten of some css slyling through reveal_html.css. --- diff --git a/converters/reveal.py b/converters/reveal.py index 522dd63..da2733e 100644 --- a/converters/reveal.py +++ b/converters/reveal.py @@ -3,6 +3,8 @@ from __future__ import absolute_import from converters.html import ConverterHTML from converters.utils import text_cell from converters.utils import highlight, coalesce_streams + +from IPython.utils import path from markdown import markdown import os @@ -181,6 +183,39 @@ class ConverterReveal(ConverterHTML): f.write(self.output) return os.path.abspath(outfile) + def header_body(self): + """Return the body of the header as a list of strings.""" + + from pygments.formatters import HtmlFormatter + + header = [] + static = os.path.join(path.get_ipython_package_dir(), + 'frontend', 'html', 'notebook', 'static', + ) + here = os.path.split(os.path.realpath(__file__))[0] + css = os.path.join(static, 'css') + for sheet in [ + # do we need jquery and prettify? + # os.path.join(static, 'jquery', 'css', 'themes', 'base', + # 'jquery-ui.min.css'), + # os.path.join(static, 'prettify', 'prettify.css'), + os.path.join(css, 'boilerplate.css'), + os.path.join(css, 'fbm.css'), + os.path.join(css, 'notebook.css'), + os.path.join(css, 'renderedhtml.css'), + # our overrides: + os.path.join(here, '..', 'css', 'reveal_html.css'), + ]: + header.extend(self._stylesheet(sheet)) + + # pygments css + pygments_css = HtmlFormatter().get_style_defs('.highlight') + header.extend(['']) + header.extend(self.in_tag('style', pygments_css, + dict(type='"text/css"'))) + + return header + def template_read(self): "read the reveal_template.html" here = os.path.split(os.path.realpath(__file__))[0] @@ -200,8 +235,11 @@ class ConverterReveal(ConverterHTML): def optional_header(self): optional_header_body = self.template_split() - return optional_header_body[0] + #return optional_header_body[0] + return ['', '', ''] + \ + optional_header_body[0] + self.header_body() + \ + ['', ''] def optional_footer(self): optional_footer_body = self.template_split() - return optional_footer_body[1] \ No newline at end of file + return optional_footer_body[1] + ['', ''] \ No newline at end of file diff --git a/css/ipython.css b/css/ipython.css deleted file mode 100644 index c44ac2b..0000000 --- a/css/ipython.css +++ /dev/null @@ -1,739 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/css/reveal_html.css b/css/reveal_html.css new file mode 100644 index 0000000..f87449f --- /dev/null +++ b/css/reveal_html.css @@ -0,0 +1,27 @@ +/* Overrides of notebook CSS for static HTML export + +*/ + +.reveal { + font-size: 20px; +} +.reveal pre { +width: 100%; +padding: 0.2em; +margin: 0px auto; +font-size: 0.8em; +box-shadow: 0px 0px 0px rgba(0, 0, 0, 0); +} +div.prompt { +width: 11ex; +padding: 0.0em; +margin: 0px; +font-family: monospace; +} +div.output_subarea { +padding: 0.0em 0.0em 0.0em 0.0em; +} +div.output_prompt { + /* 5px right shift to account for margin in parent container */ + margin: 0 5px 0 -5px; +} diff --git a/templates/reveal_base.html b/templates/reveal_base.html index dfcf1d5..f5b2365 100644 --- a/templates/reveal_base.html +++ b/templates/reveal_base.html @@ -1,6 +1,4 @@ - - - + @@ -10,8 +8,6 @@ - - @@ -24,8 +20,6 @@ - - %slides% @@ -46,8 +40,6 @@ // Optional libraries used to extend on reveal.js dependencies: [ { src: 'reveal/lib/js/classList.js', condition: function() { return !document.body.classList; } }, - { src: 'reveal/plugin/markdown/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, - { src: 'reveal/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'reveal/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: 'reveal/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }, { src: 'reveal/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }, @@ -63,5 +55,4 @@ }); - - +