##// END OF EJS Templates
Unecessary re-coding, inherits from base now.
Jonathan Frederic -
Show More
@@ -13,31 +13,19 b' class LatexTransformer(ActivatableTransformer):'
13 """
13 """
14 Converter for latex destined documents.
14 Converter for latex destined documents.
15 """
15 """
16
16
17 def __call__(self, nb, other):
17 def cell_transform(self, cell, other, index):
18 """
19 Entrypoint
20
21 nb - Input notebook
22 other - Maps to 'resources' in Jinja
23 """
24
25 # Only run if enabled.
26 if self.enabled:
27 return self.Transform(nb, other)
28
29 def Transform(self, nb, other):
30 """
18 """
31 Transform the notebook to make it compatible with markdown2latex.
19 Apply a transformation on each cell,
20
21 receive the current cell, the resource dict and the index of current cell as parameter.
22
23 Returns modified cell and resource dict.
32 """
24 """
33
25 if hasattr(cell, "source") and cell.cell_type == "markdown":
34 #Fix the markdown in every markdown cell.
26 cell.source = self.remove_math_space(cell.source)
35 for sheet in nb.worksheets:
27 return cell, other
36 for cell in sheet.cells:
28
37 if hasattr(cell, "source") and cell.cell_type == "markdown":
38 cell.source = self.remove_math_space(cell.source)
39 return nb, other
40
41 def remove_math_space(self, text):
29 def remove_math_space(self, text):
42 """
30 """
43 Remove the space between latex math commands and enclosing $ symbols.
31 Remove the space between latex math commands and enclosing $ symbols.
@@ -136,4 +124,4 b' class LatexTransformer(ActivatableTransformer):'
136 mathblock = mathblock[1:len(mathblock)-2]
124 mathblock = mathblock[1:len(mathblock)-2]
137 output += "$" + mathblock.strip() + "$"
125 output += "$" + mathblock.strip() + "$"
138 return output
126 return output
139 No newline at end of file
127
General Comments 0
You need to be logged in to leave comments. Login now