view MoinMoin/parser/text_diff.py @ 1128:52b85612832f

rename ParserBase module to get it out from parser.modules list (it is no plugin)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 03 Aug 2006 22:45:05 +0200
parents 8effe95df6f0
children bb2e053067fb
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - Diff Parser - highlights diff tool output

    @copyright: 2006 by Emilio Lopes, inspired by previous work
                done by Fabien Ninoles and Jürgen Hermann
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin.parser._ParserBase import ParserBase

class Parser(ParserBase):
    parsername = "ColorizedDiff"
    extensions = ['.diff', '.patch', ]
    Dependencies = []

    def setupRules(self):
        ParserBase.setupRules(self)

        self.addRule("Comment", r'^(diff .*?)$')
        self.addRule("Comment", r'^(\*\*\* .*?)$')
        self.addRule("Comment", r'^(--- .*?)$')
        self.addRule("Comment", r'^(\+\+\+ .*?)$')
        self.addRule("Comment", r'^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* *$')

        self.addRule("DiffSeparator", r'^(@@ .*?)$')
        self.addRule("DiffSeparator", r'^--- *$')

        self.addRule("DiffAdded", r'^(\+.*?)$')
        self.addRule("DiffRemoved", r'^(-.*?)$')
        self.addRule("DiffAdded", r'^(>.*?)$')
        self.addRule("DiffRemoved", r'^(<.*?)$')
        self.addRule("DiffChanged", r'^(!.*?)$')

        self.addRuleFormat("DiffAdded")
        self.addRuleFormat("DiffRemoved")
        self.addRuleFormat("DiffChanged")
        self.addRuleFormat("DiffSeparator")