fields: automatically create paragraphs on blank lines in comment fields

This commit is contained in:
Frédéric Péters 2012-12-28 09:35:23 +01:00 committed by Thomas NOEL
parent 56371c4ccb
commit a935bb65a5
1 changed files with 9 additions and 2 deletions

View File

@ -15,6 +15,7 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import time
import re
try:
import elementtree.ElementTree as ET
@ -359,13 +360,19 @@ class CommentField(Field):
extra_css_class = ' class="%s"' % self.extra_css_class
else:
extra_css_class = ''
if '<p' in self.label:
if '\n\n' in self.label:
label = '<p>' + re.sub('\n\n+', '</p>\n<p>', self.label) + '</p>'
else:
label = self.label
if '<p' in label:
enclosing_tag = 'div'
else:
enclosing_tag = 'p'
form.widgets.append(HtmlWidget(
htmltext('<%s%s>%s</%s>' % (enclosing_tag, extra_css_class,
self.label, enclosing_tag))))
label, enclosing_tag))))
def add_to_view_form(self, *args):
pass