def keep_spacing(value, autoescape=True):
autoescape = autoescape and not isinstance(value, SafeData)<EOL>value = normalize_newlines(value)<EOL>if autoescape:<EOL><INDENT>value = escape(value)<EOL><DEDENT>return mark_safe(value.replace('<STR_LIT:U+0020>', '<STR_LIT>').replace('<STR_LIT:\n>', '<STR_LIT>'))<EOL>
When a given `str` contains multiple spaces it keeps first space and others are replaces by &nbsp;. Newlines
converts into HTML's <br>.