equal
deleted
inserted
replaced
20 # import Zope3 interfaces |
20 # import Zope3 interfaces |
21 |
21 |
22 # import local interfaces |
22 # import local interfaces |
23 |
23 |
24 # import Zope3 packages |
24 # import Zope3 packages |
|
25 from zope.app import zapi |
|
26 from zope.component import createObject |
25 |
27 |
26 # import local packages |
28 # import local packages |
|
29 from request import getRequest |
27 |
30 |
28 |
31 |
29 def textStart(text, length, max=0): |
32 def textStart(text, length, max=0): |
30 """Get first words of given text with maximum given length |
33 """Get first words of given text with maximum given length |
31 |
34 |
43 while (index > 0) and (result[index] != ' '): |
46 while (index > 0) and (result[index] != ' '): |
44 index -= 1 |
47 index -= 1 |
45 if (index > 0) and (text_length > index + max): |
48 if (index > 0) and (text_length > index + max): |
46 return result[:index] + '…' |
49 return result[:index] + '…' |
47 return text |
50 return text |
|
51 |
|
52 |
|
53 def textToHTML(text, renderer='zope.source.plaintext', request=None): |
|
54 if request is None: |
|
55 request = getRequest() |
|
56 formatter = createObject(renderer, text) |
|
57 renderer = zapi.queryMultiAdapter((formatter, request), name=u'') |
|
58 return renderer.render() |