﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9883	the linebreaks filter strips leading and trailing whitespace from paragraphs	Antti Kaihola	Keith Bussell	"The documentation for linebreaks says:
{{{
Replaces line breaks in plain text with appropriate HTML; a single newline becomes an HTML
line break (<br />) and a new line followed by a blank line becomes a paragraph break (</p>).

For example:
  {{ value|linebreaks }}
If value is Joel\nis a slug, the output will be <p>Joel<br>is a slug</p>.
}}}

However, {{{ {{value|linebreaks}} }}} does more than that: it strips leading whitespace from the first line and trailing whitespace from the last line of every paragraph:

{{{
>>> linebreaks('  one  \n  two  \n  three  \n  four  \n\n  eins  \n  zwei  \n  drei  \n')
<p>one  <br />  two  <br />  three  <br />  four</p>

<p>eins  <br />  zwei  <br />  drei</p>
}}}

I admit this rarely is a problem, but I see no reason why it should be doing that (and not mention it in the docs).

My obscure use case is outputting monospace text where some tables are laid out using the {{{'NO-BREAK SPACE' (U+00A0)}}} Unicode character, which Python's {{{.strip()}}} happily strips away. If a paragraph starts with a table and the first row is indented, the output is misformatted. Using {{{linebreaksbr}}} or converting {{{U+00A0}}} to {{{&nbsp;}}} are my possible work-arounds, but it would been nice if the Django documentation had warned me :)"		closed	Template system	dev		fixed			Accepted	1	0	1	1	0	0
