changeset 5624:ed7044b59397

parser/highlight.py: More proper fix of MoinMoinBugs/LineNumberSpansForProcessInstructionsMissed (previous fix broke line number switching js).
author Eugene Syromyatnikov <evgsyr@gmail.com>
date Wed, 10 Mar 2010 05:20:47 +0300
parents 527bc2b8e4b1
children 78f1be3c8777
files MoinMoin/parser/highlight.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/highlight.py	Wed Mar 10 04:35:07 2010 +0300
+++ b/MoinMoin/parser/highlight.py	Wed Mar 10 05:20:47 2010 +0300
@@ -101,9 +101,6 @@
         result = self.result
         self.lineno = self.start_line
 
-        for lineno in range(1, self.start_line + 1):
-            result.append(fmt.line_anchordef(lineno))
-
         for ttype, value in tokensource:
             class_ = self.get_class(ttype)
             if value:
@@ -159,6 +156,11 @@
     def format(self, formatter):
         _ = self.request.getText
         fmt = PygmentsFormatter(formatter, start_line=self.start_line)
+
+        # adding line number anchors for process instruction lines
+        for lineno in range(1, self.num_start + 1):
+            fmt.result.append(formatter.line_anchordef(lineno))
+
         fmt.result.append(formatter.div(1, css_class="highlight %s" % self.syntax))
         self._code_id = hash_new('sha1', self.raw.encode(config.charset)).hexdigest()
         msg = None
@@ -181,6 +183,7 @@
                                                                                                                "highlight_help_page": url
                                                                                                               }
                 lexer = pygments.lexers.TextLexer()
+
         fmt.result.append(formatter.code_area(1, self._code_id, self.parsername, self.show_nums, self.num_start, self.num_step, msg))
         pygments.highlight(self.raw, lexer, fmt)
         fmt.result.append(formatter.code_area(0, self._code_id))