and result of the function escape called with an argument line, substitute the result for i-th element of lines. call the method mark_safe with lines joined into a string, separated by newlines as argument, return the result.
return mark_safe ( '\n' . join ( lines ) )