changeset 5428:82b60084aaf3

Fix for MoinMoinBugs/LineNumberAnchorsInPreformattedText (plain ext parser)
author Eugene Syromyatnikov <evgsyr@gmail.com>
date Fri, 15 Jan 2010 03:24:46 +0300
parents cd2696f05fc5
children 4d3f51792160
files MoinMoin/parser/text.py
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/text.py	Fri Jan 15 03:22:06 2010 +0300
+++ b/MoinMoin/parser/text.py	Fri Jan 15 03:24:46 2010 +0300
@@ -27,9 +27,25 @@
         self.request = request
         self.form = request.form
         self._ = request.getText
+        self.start_line = kw.get('start_line', 0)
 
     def format(self, formatter):
         """ Send the text. """
+
+        self.lines = self.raw.expandtabs().split('\n')
+        if self.lines[-1] == '':
+            del self.lines[-1]
+
+        self.lineno = self.start_line
+
         self.request.write(formatter.preformatted(1))
-        self.request.write(formatter.text(self.raw.expandtabs()))
+
+        for line in self.lines:
+            if self.lineno != self.start_line:
+                self.request.write(formatter.text('\n'))
+
+            self.lineno += 1
+            self.request.write(formatter.line_anchordef(self.lineno))
+            self.request.write(formatter.text(line))
+
         self.request.write(formatter.preformatted(0))