diff --git a/converters/jinja_filters.py b/converters/jinja_filters.py index a3c4716..fbd792a 100755 --- a/converters/jinja_filters.py +++ b/converters/jinja_filters.py @@ -19,7 +19,7 @@ from .utils import markdown2latex from .utils import highlight2latex from .utils import get_lines -from converters.config import GlobalConfigurable +from .config import GlobalConfigurable from IPython.config.configurable import Configurable from IPython.utils.traitlets import List diff --git a/converters/latex_transformer.py b/converters/latex_transformer.py index 339c707..033940d 100644 --- a/converters/latex_transformer.py +++ b/converters/latex_transformer.py @@ -2,12 +2,13 @@ Module that allows latex output notebooks to be conditioned before they are converted. """ +from __future__ import absolute_import # Configurable traitlets from IPython.utils.traitlets import Unicode, Bool # Needed to override transformer -from converters.transformers import (ActivatableTransformer) +from .transformers import (ActivatableTransformer) class LatexTransformer(ActivatableTransformer): """ diff --git a/converters/sphinx_transformer.py b/converters/sphinx_transformer.py index 82c17d1..843cff8 100644 --- a/converters/sphinx_transformer.py +++ b/converters/sphinx_transformer.py @@ -2,6 +2,7 @@ Module that allows custom Sphinx parameters to be set on the notebook and on the 'other' object passed into Jinja. """ +from __future__ import absolute_import # Used to find Sphinx package location import sphinx @@ -20,7 +21,7 @@ from IPython.utils.traitlets import Unicode, Bool from pygments.formatters import LatexFormatter # Needed to override transformer -from converters.transformers import (ActivatableTransformer) +from .transformers import (ActivatableTransformer) class SphinxTransformer(ActivatableTransformer): """ diff --git a/converters/template.py b/converters/template.py index 2db2ad5..b0c4017 100755 --- a/converters/template.py +++ b/converters/template.py @@ -6,6 +6,9 @@ that uses Jinja2 to convert notebook files into different format. You can register both pre-transformers that will act on the notebook format befor conversion and jinja filter that would then be availlable in the templates """ + +from __future__ import absolute_import + #----------------------------------------------------------------------------- # Copyright (c) 2013, the IPython Development Team. # @@ -18,10 +21,12 @@ befor conversion and jinja filter that would then be availlable in the templates # Imports #----------------------------------------------------------------------------- -from __future__ import print_function, absolute_import +from __future__ import print_function +from __future__ import absolute_import # Stdlib imports import io +import os # IPython imports from IPython.utils.traitlets import MetaHasTraits @@ -35,16 +40,16 @@ from jinja2 import Environment, FileSystemLoader # local import (pre-transformers) -import converters.transformers as trans -from converters.sphinx_transformer import (SphinxTransformer) -from converters.latex_transformer import (LatexTransformer) +from . import transformers as trans +from .sphinx_transformer import (SphinxTransformer) +from .latex_transformer import (LatexTransformer) # some jinja filters -from converters.jinja_filters import (python_comment, indent, +from .jinja_filters import (python_comment, indent, rm_fake, remove_ansi, markdown, highlight, highlight2latex, ansi2html, markdown2latex, get_lines, escape_tex, FilterDataType) -from converters.utils import markdown2rst +from .utils import markdown2rst import textwrap @@ -62,16 +67,19 @@ def wrap(text, width=100): env = Environment( loader=FileSystemLoader([ - './templates/', - './templates/skeleton/', + os.path.dirname(os.path.realpath(__file__))+'/../templates/', + os.path.dirname(os.path.realpath(__file__))+'/../templates/skeleton/', ]), extensions=['jinja2.ext.loopcontrols'] ) +print(os.path.dirname(os.path.realpath(__file__))+'/../templates/') + + texenv = Environment( loader=FileSystemLoader([ - './templates/tex/', - './templates/skeleton/tex/', + os.path.dirname(os.path.realpath(__file__))+'/../templates/tex/', + os.path.dirname(os.path.realpath(__file__))+'/../templates/skeleton/tex/', ]), extensions=['jinja2.ext.loopcontrols'] ) diff --git a/converters/transformers.py b/converters/transformers.py index 8b95b8d..31e3704 100755 --- a/converters/transformers.py +++ b/converters/transformers.py @@ -6,12 +6,12 @@ It exposes convenient classes to inherit from to access configurability as well as decorator to simplify tasks. """ -from __future__ import print_function +from __future__ import print_function, absolute_import from IPython.config.configurable import Configurable from IPython.utils.traitlets import Unicode, Bool, Dict, List -from converters.config import GlobalConfigurable +from .config import GlobalConfigurable class ConfigurableTransformers(GlobalConfigurable): """ A configurable transformer diff --git a/templates/basichtml.tpl b/templates/basichtml.tpl index 89052a5..7410453 100644 --- a/templates/basichtml.tpl +++ b/templates/basichtml.tpl @@ -16,7 +16,7 @@ {% block output_group -%}