Skip to content

Commit

Permalink
Moved ipycalcExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
JWock82 committed Oct 17, 2022
1 parent e3edfed commit 9d522d6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
37 changes: 30 additions & 7 deletions ipycalc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,15 +624,38 @@ def funit(value, precision=None):
# If no non-numeric characters were found we're dealing with a unitless value
return latex_value

#%%
"""
Set up the nbconvert exporter for the ipycalc template.
"""

from nbconvert.exporters import WebPDFExporter

class ipycalcExporter(WebPDFExporter):
"""
A custom PDF exporter for ipycalc.
"""

custom_template_name = 'ipycalc'
pkg_dir = os.path.dirname(__file__)
template_dir = os.path.join(pkg_dir, custom_template_name)

@property
def extra_template_basedirs(self):
return super()._default_extra_template_basedirs() + [self.template_dir]

def _template_name_default(self):
return os.path.join(self.pkg_dir, self.custom_template_name)

# @register_line_magic
# @needs_local_scope
def print_calc(line, local_ns):
# def print_calc(line, local_ns):

line = line.strip()
# line = line.strip()

if line == '':
dir = local_ns['_dh'][0] + '\\ipycalc_Notebook.pdf'
else:
dir = line
# if line == '':
# dir = local_ns['_dh'][0] + '\\ipycalc_Notebook.pdf'
# else:
# dir = line

exec('!jupyter nbconvert \'' + dir + '\' --to=ipycalc')
# exec('!jupyter nbconvert \'' + dir + '\' --to=ipycalc')
23 changes: 0 additions & 23 deletions ipycalc/exporter.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
entry_points={
'nbconvert.exporters': [
'ipycalc = ipycalc.exporter:ipycalcExporter',
'ipycalc = ipycalc:ipycalcExporter',
]
}
)

0 comments on commit 9d522d6

Please sign in to comment.