##// END OF EJS Templates
BUG: For multiline outputs, conditionally prepend a newline if necessary. Move this code to where we actually write the output. Frontends should be able to decide whether to use this or not.
Robert Kern -
Show More
@@ -199,15 +199,6 b' class DisplayHook(Configurable):'
199 actually print or write that to a stream.
199 actually print or write that to a stream.
200 """
200 """
201 result_repr = self.default_formatter(result)
201 result_repr = self.default_formatter(result)
202 if '\n' in result_repr:
203 # So that multi-line strings line up with the left column of
204 # the screen, instead of having the output prompt mess up
205 # their first line.
206 outprompt = str(self.prompt_out)
207 if outprompt and not outprompt.endswith('\n'):
208 # But avoid extraneous empty lines.
209 result_repr = '\n' + result_repr
210
211 extra_formats = []
202 extra_formats = []
212 for f in self.extra_formatters:
203 for f in self.extra_formatters:
213 try:
204 try:
@@ -224,6 +215,18 b' class DisplayHook(Configurable):'
224 # We want to print because we want to always make sure we have a
215 # We want to print because we want to always make sure we have a
225 # newline, even if all the prompt separators are ''. This is the
216 # newline, even if all the prompt separators are ''. This is the
226 # standard IPython behavior.
217 # standard IPython behavior.
218 if '\n' in result_repr:
219 # So that multi-line strings line up with the left column of
220 # the screen, instead of having the output prompt mess up
221 # their first line.
222 # We use the ps_out_str template instead of the expanded prompt
223 # because the expansion may add ANSI escapes that will interfere
224 # with our ability to determine whether or not we should add
225 # a newline.
226 if self.ps_out_str and not self.ps_out_str.endswith('\n'):
227 # But avoid extraneous empty lines.
228 result_repr = '\n' + result_repr
229
227 print >>IPython.utils.io.Term.cout, result_repr
230 print >>IPython.utils.io.Term.cout, result_repr
228
231
229 def update_user_ns(self, result):
232 def update_user_ns(self, result):
General Comments 0
You need to be logged in to leave comments. Login now