Indent text by prepending a given prefix to each line.
(self, text, prefix=' ')
| 1227 | return ''.join(ch + '\b' + ch for ch in text) |
| 1228 | |
| 1229 | def indent(self, text, prefix=' '): |
| 1230 | """Indent text by prepending a given prefix to each line.""" |
| 1231 | if not text: return '' |
| 1232 | lines = [prefix + line for line in text.split('\n')] |
| 1233 | if lines: lines[-1] = lines[-1].rstrip() |
| 1234 | return '\n'.join(lines) |
| 1235 | |
| 1236 | def section(self, title, contents): |
| 1237 | """Format a section with a given heading.""" |