##// END OF EJS Templates
Use _default method instead of redefining trait
Thomas Kluyver -
Show More
@@ -1,90 +1,89 b''
1 """LaTeX Exporter class"""
1 """LaTeX Exporter class"""
2
2
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
5 #
5 #
6 # Distributed under the terms of the Modified BSD License.
6 # Distributed under the terms of the Modified BSD License.
7 #
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 # Stdlib imports
15 # Stdlib imports
16 import os
16 import os
17
17
18 # IPython imports
18 # IPython imports
19 from IPython.utils.traitlets import Unicode
19 from IPython.utils.traitlets import Unicode
20 from IPython.config import Config
20 from IPython.config import Config
21
21
22 from IPython.nbconvert import filters, preprocessors
22 from IPython.nbconvert import filters, preprocessors
23 from .templateexporter import TemplateExporter
23 from .templateexporter import TemplateExporter
24
24
25 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
26 # Classes and functions
26 # Classes and functions
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28
28
29 class LatexExporter(TemplateExporter):
29 class LatexExporter(TemplateExporter):
30 """
30 """
31 Exports to a Latex template. Inherit from this class if your template is
31 Exports to a Latex template. Inherit from this class if your template is
32 LaTeX based and you need custom tranformers/filters. Inherit from it if
32 LaTeX based and you need custom tranformers/filters. Inherit from it if
33 you are writing your own HTML template and need custom tranformers/filters.
33 you are writing your own HTML template and need custom tranformers/filters.
34 If you don't need custom tranformers/filters, just change the
34 If you don't need custom tranformers/filters, just change the
35 'template_file' config option. Place your template in the special "/latex"
35 'template_file' config option. Place your template in the special "/latex"
36 subfolder of the "../templates" folder.
36 subfolder of the "../templates" folder.
37 """
37 """
38
38
39 def _file_extension_default(self):
39 def _file_extension_default(self):
40 return 'tex'
40 return 'tex'
41
41
42 def _template_file_default(self):
42 def _template_file_default(self):
43 return 'article'
43 return 'article'
44
44
45 #Latex constants
45 #Latex constants
46 def _default_template_path_default(self):
46 def _default_template_path_default(self):
47 return os.path.join("..", "templates", "latex")
47 return os.path.join("..", "templates", "latex")
48
48
49 template_skeleton_path = Unicode(
49 def _template_skeleton_path_default(self):
50 os.path.join("..", "templates", "latex", "skeleton"), config=True,
50 return os.path.join("..", "templates", "latex", "skeleton")
51 help="Path where the template skeleton files are located.")
52
51
53 #Special Jinja2 syntax that will not conflict when exporting latex.
52 #Special Jinja2 syntax that will not conflict when exporting latex.
54 jinja_comment_block_start = Unicode("((=", config=True)
53 jinja_comment_block_start = Unicode("((=", config=True)
55 jinja_comment_block_end = Unicode("=))", config=True)
54 jinja_comment_block_end = Unicode("=))", config=True)
56 jinja_variable_block_start = Unicode("(((", config=True)
55 jinja_variable_block_start = Unicode("(((", config=True)
57 jinja_variable_block_end = Unicode(")))", config=True)
56 jinja_variable_block_end = Unicode(")))", config=True)
58 jinja_logic_block_start = Unicode("((*", config=True)
57 jinja_logic_block_start = Unicode("((*", config=True)
59 jinja_logic_block_end = Unicode("*))", config=True)
58 jinja_logic_block_end = Unicode("*))", config=True)
60
59
61 #Extension that the template files use.
60 #Extension that the template files use.
62 template_extension = Unicode(".tplx", config=True)
61 template_extension = Unicode(".tplx", config=True)
63
62
64 output_mimetype = 'text/latex'
63 output_mimetype = 'text/latex'
65
64
66
65
67 @property
66 @property
68 def default_config(self):
67 def default_config(self):
69 c = Config({
68 c = Config({
70 'NbConvertBase': {
69 'NbConvertBase': {
71 'display_data_priority' : ['latex', 'pdf', 'png', 'jpg', 'svg', 'jpeg', 'text']
70 'display_data_priority' : ['latex', 'pdf', 'png', 'jpg', 'svg', 'jpeg', 'text']
72 },
71 },
73 'ExtractOutputPreprocessor': {
72 'ExtractOutputPreprocessor': {
74 'enabled':True
73 'enabled':True
75 },
74 },
76 'SVG2PDFPreprocessor': {
75 'SVG2PDFPreprocessor': {
77 'enabled':True
76 'enabled':True
78 },
77 },
79 'LatexPreprocessor': {
78 'LatexPreprocessor': {
80 'enabled':True
79 'enabled':True
81 },
80 },
82 'SphinxPreprocessor': {
81 'SphinxPreprocessor': {
83 'enabled':True
82 'enabled':True
84 },
83 },
85 'HighlightMagicsPreprocessor': {
84 'HighlightMagicsPreprocessor': {
86 'enabled':True
85 'enabled':True
87 }
86 }
88 })
87 })
89 c.merge(super(LatexExporter,self).default_config)
88 c.merge(super(LatexExporter,self).default_config)
90 return c
89 return c
General Comments 0
You need to be logged in to leave comments. Login now