##// END OF EJS Templates
Fixed all broken references, refactored some stuff here and there,...
Fixed all broken references, refactored some stuff here and there, standardized nomenclature. Ready to test...

File last commit:

r10624:bfa8f97c
r10624:bfa8f97c
Show More
csshtmlheader.py
57 lines | 1.9 KiB | text/x-python | PythonLexer
from .activatable import ActivatableTransformer
class CSSHtmlHeaderTransformer(ActivatableTransformer):
def __call__(self, nb, resources):
"""Fetch and add css to the resource dict
Fetch css from IPython adn Pygment to add at the beginning
of the html files.
Add this css in resources in the "inlining.css" key
"""
resources['inlining'] = {}
resources['inlining']['css'] = self.header
return nb, resources
header = []
def __init__(self, config=None, **kw):
super(CSSHtmlHeaderTransformer, self).__init__(config=config, **kw)
if self.enabled :
self.regen_header()
def regen_header(self):
## lazy load asa this might not be use in many transformers
import os
from IPython.utils import path
import io
from pygments.formatters import HtmlFormatter
header = []
static = os.path.join(path.get_ipython_package_dir(),
'frontend', 'html', 'notebook', 'static',
)
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'),
os.path.join(css, 'style.min.css'),
]:
try:
with io.open(sheet, encoding='utf-8') as f:
s = f.read()
header.append(s)
except IOError:
# new version of ipython with style.min.css, pass
pass
pygments_css = HtmlFormatter().get_style_defs('.highlight')
header.append(pygments_css)
self.header = header