[pod] Take into account tabs. 'do ... from text' is now obsolete: pod expression now handle correctly tabs and carriage returns.

This commit is contained in:
Gaetan Delannay 2014-03-06 11:33:47 +01:00
parent e91a160924
commit ff102fbbe8
5 changed files with 1893 additions and 2023 deletions

View file

@ -189,7 +189,7 @@ class Buffer:
def dumpContent(self, content):
'''Dumps string p_content into the buffer.'''
if self.pod:
# Take care of converting line breaks to odf line breaks.
# Take care of converting line breaks and tabs.
content = escapeXml(content, format='odf',
nsText=self.env.namespaces[self.env.NS_TEXT])
else:

View file

@ -89,6 +89,11 @@ f.close()
STYLES_POD_FONTS = '<@style@:font-face @style@:name="PodStarSymbol" ' \
'@svg@:font-family="StarSymbol"/>'
# do ... \n from text(...) is obsolete.
OBSOLETE_RENDER_TEXT = 'Obsolete function. Use a pod expression instead ' \
'(field or track-changed). Now, a pod expression ' \
'handles carriage returns and tabs correctly.'
# ------------------------------------------------------------------------------
class Renderer:
templateTypes = ('odt', 'ods') # Types of POD templates
@ -259,11 +264,8 @@ class Renderer:
stylesMapping, self).run()
def renderText(self, text, encoding='utf-8', stylesMapping={}):
'''Method that can be used (under the name 'text') into a pod template
for inserting a text containing carriage returns.'''
if text == None: text = ''
text = cgi.escape(text).replace('\r\n', '<br/>').replace('\n', '<br/>')
return self.renderXhtml(text, encoding, stylesMapping)
'''Obsolete method.'''
raise Exception(OBSOLETE_RENDER_TEXT)
def evalIfExpression(self, condition, ifTrue, ifFalse):
'''This method implements the method 'test' which is proposed in the

File diff suppressed because it is too large Load diff

View file

@ -340,6 +340,8 @@ class XhtmlEnvironment(XmlEnvironment):
# We remove leading and trailing carriage returns, but not
# whitespace because whitespace may be part of the text to dump.
contentSize = len(content)
# We do not escape carriage returns, because, in XHTML, carriage
# returns are just ignorable white space.
self.dumpString(escapeXml(content))
self.currentContent = u''
# If we are within a table cell, update the total size of cell content.