From b1c1acfdb3f466fc5e385902cd915899df2970c4 Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Mon, 6 Feb 2006 13:06:13 -0500 Subject: Nicer comment bodies --- beweb/beweb/templates/edit_bug.kid | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'beweb') 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 -- cgit