annotate MoinMoin/formatter/text_plain.py @ 6103:500f68d3e2fd

remove our own usage of python_compatibility module
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 06 Sep 2016 01:00:25 +0200
parents 666e359493f5
children
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - "text/plain" Formatter
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
5 @copyright: 2000-2002 Juergen Hermann <jh@web.de>
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
6 2007 by Timo Sirainen <tss@iki.fi>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9
661
19ef5f9fff84 moved formatter.base to formatter.__init__
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 407
diff changeset
10 from MoinMoin.formatter import FormatterBase
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
12
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 class Formatter(FormatterBase):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 Send plain text data.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 hardspace = u' '
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20 def __init__(self, request, **kw):
1182
5de0dc972701 removed deprecated usage of apply()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 999
diff changeset
21 FormatterBase.__init__(self, request, **kw)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 self._in_code_area = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 self._in_code_line = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 self._code_area_state = [0, -1, -1, 0]
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
25 self._lists = []
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 self._url = None
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
27 self._text = None # XXX does not work with links in headings!!!!!
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
28 self._text_stack = []
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
29 self._skip_text = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
30 self._wrap_skip_text = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
31 self._textbuf = ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
32 self._indent = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
33 self._listitem_on = []
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
34 self._empty_line_count = 2
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
35 self._paragraph_ended = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
36 self._paragraph_skip_begin = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 def startDocument(self, pagename):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
39 line = u'\n'.rjust(len(pagename) + 2, u'*')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
40 return self.wrap(u"%s %s \n%s" % (line, pagename, line))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
42 def endContent(self):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
43 return self.flush(True)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 def sysmsg(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
46 return self.wrap((u'\n\n*** ', u' ***\n\n')[not on])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 def pagelink(self, on, pagename='', page=None, **kw):
1182
5de0dc972701 removed deprecated usage of apply()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 999
diff changeset
49 FormatterBase.pagelink(self, on, pagename, page, **kw)
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
50 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
51 if not self._textbuf or self._textbuf[-1] in ('\n', ' '):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
52 result = self.wrap(u'<')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
53 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
54 result = self.wrap(u' <')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
55 self.text_on(True)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
56 self.add_missing_space()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
57 return result
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
58 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
59 linktext = self._text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
60 self.text_off()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
61 orig_pagename = pagename
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
62 if pagename.find('/'):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
63 pagename = pagename.replace('/', '.')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
64 pagename += '.txt'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
65 if linktext == orig_pagename:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
66 return self.wrap(u'%s>' % pagename)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
67 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
68 return self.wrap(u'%s> [%s]' % (linktext, pagename))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
69
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
70 def interwikilink(self, on, interwiki='', pagename='', **kw):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
71 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
72 self.add_missing_space()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
73 self._url = u"%s:%s" % (interwiki, pagename)
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
74 self.text_on()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
75 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
76 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
77 text = self._text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
78 self.text_off()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
79 if text == self._url:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
80 result = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
82 result = self.wrap(u' [%s]' % (self._url))
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
83 self._url = None
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
84 return result
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 661
diff changeset
85
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86 def url(self, on, url='', css=None, **kw):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
88 self.add_missing_space()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
89 self._url = url
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
90 self.text_on()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
91 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
92 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
93 text = self._text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
94 self.text_off()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
95 if text == self._url or 'mailto:' + text == self._url:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
96 result = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
97 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
98 result = self.wrap(u' [%s]' % (self._url))
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
99 self._url = None
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
100 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
101
2701
398af77c7ede fixed attachment_link api - it now has a 'on' parameter like most of the other methods
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
102 def attachment_link(self, on, url=None, **kw):
398af77c7ede fixed attachment_link api - it now has a 'on' parameter like most of the other methods
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
103 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
104 if 'title' in kw and kw['title']:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
105 if kw['title'] != url:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
106 return self.wrap(u'[attachment:%s ' % url)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
107 return self.wrap(u'[attachment:')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
108 return self.wrap(']')
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
109
163
b19525bf0cf6 fixed MoinMoinBugs/HighlightingBreaksAttachmentLink and some more attachment bugs
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 0
diff changeset
110 def attachment_image(self, url, **kw):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
111 title = ''
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
112 for a in (u'title', u'html__title', u'alt', u'html_alt'):
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1182
diff changeset
113 if a in kw:
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
114 title = ':' + kw[a]
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
115 return self.wrap("[image:%s%s]" % (url, title))
163
b19525bf0cf6 fixed MoinMoinBugs/HighlightingBreaksAttachmentLink and some more attachment bugs
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 0
diff changeset
116
b19525bf0cf6 fixed MoinMoinBugs/HighlightingBreaksAttachmentLink and some more attachment bugs
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 0
diff changeset
117 def attachment_drawing(self, url, text, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
118 return self.wrap("[drawing:%s]" % text)
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 661
diff changeset
119
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
120 def text(self, text, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
121 if self._text is not None:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
122 self._text += text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
123 if self._wrap_skip_text:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
124 return ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
125 return self.wrap(text)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
126
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
127 def rule(self, size=0, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
128 size = min(size, 10)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
129 ch = u"---~=*+#####"[size]
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
130 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
131 result = self.wrap((ch * (79 - self._indent)))
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
132 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
133 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
134
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
135 def strong(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
136 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
137 self.add_missing_space()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
138 return self.wrap(u'*')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
139
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
140 def emphasis(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
141 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
142 self.add_missing_space()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
143 return self.wrap(u'/')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
144
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
145 def highlight(self, on, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
146 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
147
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
148 def number_list(self, on, type=None, start=None, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
149 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
150 if self._lists:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
151 # No empty lines between sublists
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
152 self._paragraph_ended = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
153 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
154 self._lists.append(0)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
155 self._listitem_on.append(False)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
156 elif self._lists:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
157 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
158 num = self._lists.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
159 listitem_on = self._listitem_on.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
160 if listitem_on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
161 prefix = ' %d. ' % (num)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
162 self._indent -= len(prefix)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
163 return ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
164
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
165 def bullet_list(self, on, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
166 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
167 if self._lists:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
168 # No empty lines between sublists
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
169 self._paragraph_ended = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
170 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
171 self._lists.append(-1)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
172 self._listitem_on.append(False)
5748
666e359493f5 text plain formatter: fix bullet_list, see number_list
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5662
diff changeset
173 elif self._lists:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
174 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
175 self._lists.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
176 listitem_on = self._listitem_on.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
177 if listitem_on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
178 self._indent -= 3
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
179 return ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
180
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
181 def listitem(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
182 self._paragraph_ended = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
183 if not on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
184 # we can't rely on this
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
185 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
186 return ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
187
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
188 result = ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
189 num = self._lists.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
190 listitem_on = self._listitem_on.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
191 if listitem_on and on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
192 # we didn't receive on=False for previous listitem
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
193 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
194 if num >= 0:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
195 prefix = ' %d. ' % (num)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
196 self._indent -= len(prefix)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
197 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
198 self._indent -= 3
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
199
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
200 if num >= 0:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
201 num += 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
202 prefix = ' %d. ' % (num)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
203 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
204 # FIXME: also before tables, at leat in LDA.Sieve.txt
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
205 prefix = ' * '
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
206 self._lists.append(num)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
207 self._listitem_on.append(on)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
208
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
209 result += self.wrap(prefix)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
210 self._indent += len(prefix)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
211 self._paragraph_skip_begin = True
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
212 return result
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 661
diff changeset
213
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
214 def sup(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
215 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
216 return self.wrap(u'^')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
217 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
218 return ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
219
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
220 def sub(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
221 return self.wrap(u'_')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
222
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
223 def strike(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
224 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
225 self.add_missing_space()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
226 return self.wrap(u'__')
217
98df82a31b87 Added strike() to non HTML formatters. PLEASE REVIEW the xml_docbook FORMATTER!
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 163
diff changeset
227
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
228 def code(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
229 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
230 self.add_missing_space()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
231 return self.wrap(u"'")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
232
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
233 def preformatted(self, on, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
234 FormatterBase.preformatted(self, on)
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
235 snip = u'%s\n' % u'---%<'.ljust(78 - self._indent, u'-')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
236 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
237 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
238 return self.wrap(snip)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
239 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
240 if self._textbuf and not self._textbuf.endswith('\n'):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
241 self._textbuf += '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
242 result = self.wrap(snip)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
243 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
244 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
245
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
246 def small(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
247 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
248 self.add_missing_space()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
249 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
250
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
251 def big(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
252 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
253 self.add_missing_space()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
254 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
255
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
256 def code_area(self, on, code_id, code_type='code', show=0, start=-1,
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
257 step=-1, msg=None):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
258 snip = u'%s\n' % u'---CodeArea'.ljust(78 - self._indent, u'-')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
259 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
260 self.paragraph_begin()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
261 self._in_code_area = 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
262 self._in_code_line = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
263 self._code_area_state = [show, start, step, start]
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
264 return self.wrap(snip)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
265 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
266 if self._in_code_line:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
267 return self.wrap(self.code_line(0) + snip)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
268 result = self.wrap(snip)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
269 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
270 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
271
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
272 def code_line(self, on):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
273 res = u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
274 if not on or (on and self._in_code_line):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
275 res += u'\n'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
276 if on:
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
277 if self._code_area_state[0] > 0:
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
278 res += u' %4d ' % self._code_area_state[3]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
279 self._code_area_state[3] += self._code_area_state[2]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
280 self._in_code_line = on != 0
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
281 return self.wrap(res)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
282
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
283 def code_token(self, on, tok_type):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
284 return ""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
285
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
286 def add_missing_space(self):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
287 if self._textbuf and self._textbuf[-1].isalnum():
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
288 self._textbuf += ' '
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
289
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
290 def paragraph(self, on, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
291 FormatterBase.paragraph(self, on)
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
292 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
293 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
294 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
295 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
296 return ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
297
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
298 def linebreak(self, preformatted=1):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
299 return self.wrap(u'\n')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
300
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
301 def smiley(self, text):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
302 return self.wrap(text)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
303
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
304 def heading(self, on, depth, **kw):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
305 if on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
306 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
307 self.text_on()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
308 result = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
309 else:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
310 if depth == 1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
311 ch = u'='
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
312 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
313 ch = u'-'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
314
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
315 result = u'\n%s\n' % (ch * len(self._text))
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
316 self.text_off()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
317 result = self.wrap(result)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
318 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
319 return result
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
320
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
321 def get_table_sep(self, col_widths):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
322 result = ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
323 for width in col_widths:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
324 result += '+' + ('-' * width)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
325 return result + '+\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
326
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
327 def fix_col_widths(self):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
328 min_widths = self._table_column_min_len
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
329 max_widths = self._table_column_max_len
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
330 max_len = sum(max_widths)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
331 # take the needed space equally from all columns
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
332 count = len(max_widths)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
333 idx, skip = 0, 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
334 available_len = 79 - count - 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
335 while max_len > available_len:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
336 if max_widths[idx] > min_widths[idx]:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
337 max_widths[idx] -= 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
338 max_len -= 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
339 skip = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
340 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
341 skip += 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
342 if skip == count:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
343 # there are only too wide columns
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
344 break
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
345 if idx == count - 1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
346 idx = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
347 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
348 idx += 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
349 return max_widths
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
350
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
351 def table(self, on, attrs={}, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
352 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
353 self._table = []
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
354 self._table_column_min_len = []
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
355 self._table_column_max_len = []
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
356 result = self.flush(True)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
357 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
358 result = u''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
359 col_widths = self.fix_col_widths()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
360 for row in self._table:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
361 result += self.get_table_sep(col_widths)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
362 more = True
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
363 while more:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
364 more = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
365 num = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
366 result += '|'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
367 for col in row:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
368 # break at next LF
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
369 lf_idx = col.find('\n')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
370 if lf_idx != -1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
371 more = True
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
372 col_len = lf_idx
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
373 next_idx = lf_idx + 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
374 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
375 col_len = len(col)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
376 next_idx = col_len
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
377 # possibly break earlier if we need to wrap
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
378 if col_len > col_widths[num]:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
379 idx = col.rfind(' ', 0, col_widths[num])
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
380 if idx == -1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
381 idx = col.find(' ', col_widths[num])
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
382 if idx != -1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
383 col_len = idx
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
384 next_idx = idx + 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
385 more = True
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
386 result += ' ' + col[:col_len]
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
387 result += (' ' * (col_widths[num] - col_len - 1)) + '|'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
388 row[num] = col[next_idx:]
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
389 num += 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
390 result += '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
391 result += self.get_table_sep(col_widths)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
392 self._table = None
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
393 self._table_column_min_len = None
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
394 self._table_column_max_len = None
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
395 self._empty_line_count = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
396 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
397 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
398
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
399 def table_row(self, on, attrs={}, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
400 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
401 self._table.append([])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
402 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
404 def table_cell(self, on, attrs={}, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
405 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
406 self.text_on()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
407 self._wrap_skip_text = True
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
408 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
409 # keep track of the longest word and the longest line in the cell
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
410 self._text = self._text.strip()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
411 max_line_len = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
412 max_word_len = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
413 for line in self._text.split('\n'):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
414 if len(line) > max_line_len:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
415 max_line_len = len(line)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
416 for word in self._text.split(' '):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
417 if len(word) > max_word_len:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
418 max_word_len = len(word)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
419 # one preceding and trailing cell whitespace
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
420 max_word_len += 2
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
421 max_line_len += 2
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
422
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
423 rownum = len(self._table) - 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
424 colnum = len(self._table[rownum])
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
425 if len(self._table_column_max_len) <= colnum:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
426 self._table_column_min_len.append(max_word_len)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
427 self._table_column_max_len.append(max_line_len)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
428 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
429 if max_word_len > self._table_column_min_len[colnum]:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
430 self._table_column_min_len[colnum] = max_word_len
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
431 if self._table_column_max_len[colnum] < max_line_len:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
432 self._table_column_max_len[colnum] = max_line_len
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
433 self._table[rownum].append(self._text)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
434 self.text_off()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
435 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
436
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
437 def underline(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
438 return self.wrap(u'_')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
439
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
440 def definition_list(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
441 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
442 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
443 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
444 self.paragraph_end()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
445 return u''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
446
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
447 def definition_term(self, on, compact=0, **kw):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
448 result = u''
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
449 #if not compact:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
450 # result = result + u'\n'
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
451 if not on:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
452 result = result + u':'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
453 return self.wrap(result)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
454
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
455 def definition_desc(self, on, **kw):
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
456 if on:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
457 self._indent += 2
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
458 self.paragraph_begin()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
459 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
460 self.paragraph_end()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
461 self._textbuf += '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
462 self._indent -= 2
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
463 return ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
464
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
465 def image(self, src=None, **kw):
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
466 for a in (u'title', u'html__title', u'alt', u'html_alt'):
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1182
diff changeset
467 if a in kw:
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
468 return self.wrap(kw[a] + ' [' + src + ']')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
469 return self.wrap('[' + src + ']')
2713
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
470
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
471 def lang(self, on, lang_name):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
472 return ''
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 219
diff changeset
473
5662
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
474 def paragraph_begin(self):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
475 if self._paragraph_ended:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
476 self._textbuf += '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
477 elif not self._paragraph_skip_begin:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
478 if self._textbuf and not self._textbuf.endswith('\n'):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
479 self._textbuf += '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
480 self._paragraph_ended = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
481 self._paragraph_skip_begin = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
482
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
483 def paragraph_end(self):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
484 if self._textbuf and not self._textbuf.endswith('\n'):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
485 self._textbuf += '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
486 self._paragraph_ended = True
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
487
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
488 def wrap(self, text):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
489 if not text:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
490 return ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
491 if self._wrap_skip_text:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
492 # we're inside table
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
493 #self._text += 'w{' + text + '}'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
494 self._text += text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
495 return ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
496
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
497 self._paragraph_ended = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
498 self._paragraph_skip_begin = False
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
499
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
500 # add indents after all LFs. kind of dirty to split twice though..
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
501 lines = text.split('\n')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
502 text = lines.pop(0)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
503 while lines:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
504 text += '\n%s%s' % (' ' * self._indent, lines.pop(0))
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
505
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
506 if not self._textbuf or self._textbuf.endswith('\n'):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
507 self._textbuf += ' ' * self._indent
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
508 self._textbuf += text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
509
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
510 lines = self._textbuf.split('\n')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
511 self._textbuf = ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
512 text = ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
513 while lines:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
514 self._textbuf += lines.pop(0)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
515 if lines:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
516 # LFs found
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
517 text += self.flush(True)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
518 if len(self._textbuf) > 80 and \
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
519 self._textbuf.find(' ', self._indent) != -1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
520 # wrap time
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
521 text += self.flush(False)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
522 return text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
523
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
524 def flush(self, addlf):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
525 result = ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
526
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
527 while len(self._textbuf) >= 80:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
528 # need to wrap
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
529 last_space = self._textbuf.rfind(' ', self._indent, 80)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
530 if last_space == -1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
531 # a long line. split at the next possible space
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
532 last_space = self._textbuf.find(' ', self._indent)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
533 if last_space == -1:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
534 break
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
535 result += self._textbuf[:last_space] + '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
536 self._empty_line_count = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
537 self._textbuf = ' ' * self._indent + self._textbuf[last_space + 1:]
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
538 self._textbuf = self._textbuf.rstrip()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
539
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
540 if not self._textbuf:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
541 if not addlf:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
542 return result
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
543 self._empty_line_count += 1
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
544 if self._empty_line_count >= 2:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
545 return result
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
546 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
547 self._empty_line_count = 0
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
548
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
549 if addlf:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
550 result += self._textbuf + '\n'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
551 self._textbuf = ''
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
552 return result
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
553
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
554 def text_on(self, skip_text=False):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
555 if self._text is None:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
556 self._text_stack.append(None)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
557 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
558 self._text_stack.append(self._text)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
559 #self._text_stack.append('[' + self._text + ']')
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
560 self._text_stack.append(self._skip_text)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
561 self._text_stack.append(self._wrap_skip_text)
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
562 self._text = ""
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
563 self._skip_text = skip_text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
564 if skip_text:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
565 self._wrap_skip_text = True
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
566
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
567 def text_off(self):
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
568 prev_skip_text = self._skip_text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
569 self._wrap_skip_text = self._text_stack.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
570 self._skip_text = self._text_stack.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
571 old_text = self._text_stack.pop()
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
572 if old_text is None:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
573 self._text = None
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
574 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
575 if not prev_skip_text:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
576 #self._text = 'o#' + old_text + '#|#' + self._text + '#'
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
577 self._text = old_text + self._text
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
578 else:
64d0629dd835 formatter.text_plain: improved text formatter, see FeatureRequests/TextPlainFormatterRewrite thanks to Pascal Volk and Timo Sirainen. This fixes many issues of this formatter.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5284
diff changeset
579 self._text = old_text