Description

An empty line is appended when I use the highlight parser and the code is ended with comment.

Example

   1 int a;

   1 int a; // comment produces extra line
   2 

   1 a = 42 # comment works ok

   1 export A=42

   1 export A=42 # comment produces extra line
   2 

Details

MoinMoin Version

1.9.0

Discussion

The comment of python for highlighting python does not add an empty line

cause

pygments produces (Token.Comment.Single, 'comment\n') for single line comment. In PygmentsFormatter.format of MoinMoin/parser/highlight.py, the result of self.line_re.split(value) is ['comment', '\n', '\']. In here, the last empty string makes an empty line.

correction

   1 for line in self.line_re.split(value):
   2     if line == '\n':
   3         self.add_next_line(line_parts)
   4         line_parts = []
   5         if ttype==Token.Comment.Single: # added
   6             break                       # added
   7         continue

(or remove the last empty string from the result of split?)

Plan


CategoryMoinMoinBug

MoinMoin: MoinMoinBugs/1.9HighlightParserAppendsAnEmptyLineIfEndedWithComment (last edited 2011-04-28 03:44:10 by 59)