Changeset 3720
- Timestamp:
- 05/27/08 01:33:19 (6 months ago)
- Files:
-
- emailprocessormacro/0.10/emailprocessor.py (modified) (3 diffs)
- emailprocessormacro/0.11/emailprocessor.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
emailprocessormacro/0.10/emailprocessor.py
r3716 r3720 18 18 """Email wrapping formatter 19 19 20 This macro takes an email message and will wrap lines to 72 characters. 21 It will also put the emails inside a preformatted block. 20 This macro takes an email message and will wrap lines to 21 72 characters (default), or a length specified. It will 22 also put the emails inside a preformatted block. 22 23 23 24 Invocation: … … 26 27 <email stuff here> 27 28 }}} 29 To wrap to a specified length, the line imediately following 30 the invocation should contain `cols: ` followed by the number 31 of columns at wich we wrap. For example: 32 {{{ 33 #!email 34 cols: 40 35 <email stuff here> 36 }}} 37 It is important that the `cols:` starts at the beginning of 38 the line and that only a number follows it. 28 39 29 40 """ … … 35 46 36 47 def render_macro(self, req, name, content): 37 text = content and wrap(content, cols=72) or '' 48 text = '' 49 if content: 50 lines = content.split('\n') 51 if lines[0].startswith('cols:'): 52 try: 53 width = int(lines[0][5:].strip()) 54 lines.pop(0) 55 except ValueError: 56 width = 72 57 else: 58 width = 72 59 text = wrap('\n'.join(lines), cols=width) 38 60 return Markup("<pre class='wiki'>%s</pre>" % escape(text)) 39 emailprocessormacro/0.11/emailprocessor.py
r3043 r3720 18 18 """Email wrapping formatter 19 19 20 This macro takes an email message and will wrap lines to 72 characters. 21 It will also put the emails inside a preformatted block. 20 This macro takes an email message and will wrap lines to 21 72 characters (default), or a length specified. It will 22 also put the emails inside a preformatted block. 22 23 23 24 Invocation: … … 26 27 <email stuff here> 27 28 }}} 29 To wrap to a specified length, the line imediately following 30 the invocation should contain `cols: ` followed by the number 31 of columns at wich we wrap. For example: 32 {{{ 33 #!email 34 cols: 40 35 <email stuff here> 36 }}} 37 It is important that the `cols:` starts at the beginning of 38 the line and that only a number follows it. 28 39 29 40 """ … … 35 46 36 47 def expand_macro(self, formatter, name, args): 37 text = args and wrap(args, cols=72) or '' 48 text = '' 49 if args: 50 lines = args.split('\n') 51 if lines[0].startswith('cols:'): 52 try: 53 width = int(lines[0][5:].strip()) 54 lines.pop(0) 55 except ValueError: 56 width = 72 57 else: 58 width = 72 59 text = wrap('\n'.join(lines), cols=width) 38 60 return '<pre class="wiki">%s</pre>' % escape(text) 39 61
