forked from kirbs-/hide_code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhide_code_pdf_exporter.py
More file actions
25 lines (20 loc) · 879 Bytes
/
Copy pathhide_code_pdf_exporter.py
File metadata and controls
25 lines (20 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
import os.path
from traitlets.config import Config
from nbconvert.exporters.pdf import PDFExporter
from traitlets.log import get_logger
class HideCodePDFExporter(PDFExporter):
def __init__(self, config=None, **kw):
# self.register_preprocessor('hide_code.HideCodePreprocessor', True)
super(HideCodePDFExporter, self).__init__(config, **kw)
self.preprocessors = ['hide_code.HideCodePreprocessor']
self._init_preprocessors()
def _template_file_default(self):
return 'hide_code_article'
@property
def template_path(self):
"""
We want to inherit from HTML template, and have template under
`./templates/` so append it to the search path. (see next section)
"""
return super(HideCodePDFExporter, self).template_path + [os.path.join(os.path.dirname(__file__), "Templates")]