), stacklevel=2)
first = indentfirst
- s += u'\n' # this quirk is necessary for splitlines method
indention = u' ' * width
+ newline = u'\n'
- def _unescape(val):
- '''
- Unescape any strings that were escaped due to concatenation. If the
- value passed is not a Markup instance, return the original value.
- '''
- try:
- return Markup(val.unescape())
- except AttributeError:
- # s was not a Markup instance
- return val
+ if isinstance(s, Markup):
+ indention = Markup(indention)
+ newline = Markup(newline)
+
+ s += newline # this quirk is necessary for splitlines method
if blank:
- rv = _unescape((u'\n' + indention).join(s.splitlines()))
+ rv = (newline + indention).join(s.splitlines())
else:
lines = s.splitlines()
rv = lines.pop(0)
if lines:
- rv += u'\n' + u'\n'.join(
+ rv += newline + newline.join(
indention + line if line else line for line in lines
)
- rv = _unescape(rv)
if first:
rv = indention + rv