~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/parser/text_diff.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: iso-8859-1 -*-
2
2
"""
3
 
    MoinMoin - diff/patch Parser
4
 
 
5
 
    DEPRECATED compatibility wrapper calling the highlight parser.
6
 
 
7
 
    This is to support (deprecated) existing syntax like:
8
 
    {{{#!diff ...
9
 
    ...
10
 
    }}}
11
 
 
12
 
    It is equivalent to the new way to highlight code:
13
 
    {{{#!highlight diff ...
14
 
    ...
15
 
    }}}
16
 
 
17
 
    @copyright: 2008 MoinMoin:ThomasWaldmann
 
3
    MoinMoin - Diff Parser - highlights diff tool output
 
4
 
 
5
    @copyright: 2006 Emilio Lopes, inspired by previous work
 
6
                done by Fabien Ninoles and Juergen Hermann
18
7
    @license: GNU GPL, see COPYING for details.
19
8
"""
20
9
 
21
 
from MoinMoin.parser.highlight import Parser as HighlightParser
22
 
from MoinMoin.parser.highlight import Dependencies
23
 
 
24
 
class Parser(HighlightParser):
25
 
    parsername = 'diff'  # Lexer name pygments recognizes
26
 
    extensions = [] # this is only a compatibility wrapper, we have declared
27
 
                    # support for this extension in the HighlightParser, so
28
 
                    # moin will call that directly
 
10
from MoinMoin.parser._ParserBase import ParserBase
 
11
 
 
12
class Parser(ParserBase):
 
13
    parsername = "ColorizedDiff"
 
14
    extensions = ['.diff', '.patch', ]
 
15
    Dependencies = []
 
16
 
 
17
    def setupRules(self):
 
18
        ParserBase.setupRules(self)
 
19
 
 
20
        self.addRule("Comment", r'^(diff .*?)$')
 
21
        self.addRule("Comment", r'^(\*\*\* .*?)$')
 
22
        self.addRule("Comment", r'^(--- .*?)$')
 
23
        self.addRule("Comment", r'^(\+\+\+ .*?)$')
 
24
        self.addRule("Comment", r'^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* *$')
 
25
 
 
26
        self.addRule("DiffSeparator", r'^(@@ .*?)$')
 
27
        self.addRule("DiffSeparator", r'^--- *$')
 
28
 
 
29
        self.addRule("DiffAdded", r'^(\+.*?)$')
 
30
        self.addRule("DiffRemoved", r'^(-.*?)$')
 
31
        self.addRule("DiffAdded", r'^(>.*?)$')
 
32
        self.addRule("DiffRemoved", r'^(<.*?)$')
 
33
        self.addRule("DiffChanged", r'^(!.*?)$')
 
34
 
 
35
        self.addRuleFormat("DiffAdded")
 
36
        self.addRuleFormat("DiffRemoved")
 
37
        self.addRuleFormat("DiffChanged")
 
38
        self.addRuleFormat("DiffSeparator")
29
39