diff --git a/IPython/core/magics/code.py b/IPython/core/magics/code.py index 4f1574d..834ca51 100644 --- a/IPython/core/magics/code.py +++ b/IPython/core/magics/code.py @@ -153,7 +153,9 @@ def strip_initial_indent(lines): for line in it: if line.startswith(indent): - yield line[len(indent):] + yield line[len(indent) :] + elif line in ("\n", "\r\n") or len(line) == 0: + yield line else: # Less indented than the first line - stop dedenting yield line