diff MoinMoin/formatter/text_html_percent.py @ 3077:66d35649ca99

add 'percent' kw to getText (must be True when using result as left side of % operator), refactored some code, better comments (ported from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 22 Feb 2008 22:35:46 +0100
parents
children a7c1680aeaa0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/formatter/text_html_percent.py	Fri Feb 22 22:35:46 2008 +0100
@@ -0,0 +1,24 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - a special text/html formatter used by the i18n system
+    
+    If texts translated by the i18n system are used on the left side of a
+    % operator, any markup-generated % char (e.g. in links to non-ASCII page
+    names (%XX%XX%XX)) needs to get escaped (%%XX%%XX%%XX).
+
+    Everything else is as in the text/html formatter.
+
+    @copyright: 2007 MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.formatter.text_html import Formatter as TextHtmlFormatter
+
+class Formatter(TextHtmlFormatter):
+
+    def _open(self, tag, newline=False, attr=None, allowed_attrs=None, **kw):
+        """ Escape % signs in tags, see also text_html.Formatter._open. """
+        tagstr = TextHtmlFormatter._open(self, tag, newline, attr, allowed_attrs, **kw)
+        return tagstr.replace('%', '%%')
+
+    # override more methods, if needed