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 |
General Comments 0
You need to be logged in to leave comments.
Login now