##// END OF EJS Templates
add a coalesce stream transformer
Matthias BUSSONNIER -
Show More
@@ -129,6 +129,7 b' class ConverterTemplate(Configurable):'
129 self.preprocessors.append(transformer)
129 self.preprocessors.append(transformer)
130
130
131 ## for compat, remove later
131 ## for compat, remove later
132 self.preprocessors.append(trans.coalesce_streams)
132 self.preprocessors.append(trans.ExtractFigureTransformer(config=config))
133 self.preprocessors.append(trans.ExtractFigureTransformer(config=config))
133 self.preprocessors.append(trans.RevealHelpTransformer(config=config))
134 self.preprocessors.append(trans.RevealHelpTransformer(config=config))
134 self.preprocessors.append(trans.CSSHtmlHeaderTransformer(config=config))
135 self.preprocessors.append(trans.CSSHtmlHeaderTransformer(config=config))
@@ -74,6 +74,33 b' def haspyout_transformer(cell, other, count):'
74 break
74 break
75 return cell, other
75 return cell, other
76
76
77 @cell_preprocessor
78 def coalesce_streams(cell, other, count):
79 """merge consecutive sequences of stream output into single stream
80
81 to prevent extra newlines inserted at flush calls
82
83 TODO: handle \r deletion
84 """
85
86 outputs = cell.get('outputs', None)
87 if not outputs:
88 return cell, other
89 new_outputs = []
90 last = outputs[0]
91 new_outputs = [last]
92 for output in outputs[1:]:
93 if (output.output_type == 'stream' and
94 last.output_type == 'stream' and
95 last.stream == output.stream
96 ):
97 last.text += output.text
98 else:
99 new_outputs.append(output)
100
101 cell.outputs = new_outputs
102 return cell, other
103
77
104
78 # todo, make the key part configurable.
105 # todo, make the key part configurable.
79
106
@@ -234,12 +261,12 b' class RevealHelpTransformer(ConfigurableTransformers):'
234
261
235
262
236 class CSSHtmlHeaderTransformer(ActivatableTransformer):
263 class CSSHtmlHeaderTransformer(ActivatableTransformer):
237
264
238 def __call__(self, nb, resources):
265 def __call__(self, nb, resources):
239 """Fetch and add css to the resource dict
266 """Fetch and add css to the resource dict
240
267
241 Fetch css from IPython adn Pygment to add at the beginning
268 Fetch css from IPython adn Pygment to add at the beginning
242 of the html files.
269 of the html files.
243
270
244 Add this css in resources in the "inlining.css" key
271 Add this css in resources in the "inlining.css" key
245 """
272 """
General Comments 0
You need to be logged in to leave comments. Login now