From: Aaron Bentley Date: Mon, 6 Feb 2006 18:06:13 +0000 (-0500) Subject: Nicer comment bodies X-Git-Tag: 1.0.0~219 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b1c1acfdb3f466fc5e385902cd915899df2970c4;p=be.git Nicer comment bodies --- diff --git a/beweb/beweb/templates/edit_bug.kid b/beweb/beweb/templates/edit_bug.kid index 89c4208..206f4ba 100644 --- a/beweb/beweb/templates/edit_bug.kid +++ b/beweb/beweb/templates/edit_bug.kid @@ -27,6 +27,34 @@ def select_among(name, options, default, display_names=None): display_name)) output.append("") return XML("".join(output)) + +def to_unix(text): + skip_newline = False + for ch in text: + if ch not in ('\r', '\n'): + yield ch + else: + if ch == '\n': + if skip_newline: + continue + else: + skip_newline = True + yield '\n' + +def soft_text(text): + translations = {'\n': '
\n', '&': '&', '\x3c': '<', + '\x3e': '>'} + for ch in to_unix(text): + if ch == ' ' and first_space is True: + yield ' ' + first_space = ch in (' ') + try: + yield translations[ch] + except KeyError: + yield ch +def soft_pre(text): + return XML('
'+ + ''.join(soft_text(text))+'
') ?> @@ -50,7 +78,7 @@ def select_among(name, options, default, display_names=None): From${comment.From} Date${time_to_str(comment.date)} -
${comment.body}
+
Edit