ParserMarket/NoCamelCase2/DisplaysNone

When I implemented the nocamelcase2 parser on our MoinMoin 1.9.2 implementation, it had the effect of leaving a residual "None" at the end of each nocamelcase parser block. If the parser was applied to the entire page, the word None appeared at the end of the page. I never fully understood why this was happening but I did find a workaround fix.

Example:

{{{#!nocamelcase 
'''Don't Use:''' MessageBox

'''Instead Use:''' InvMessageBox / InvErrorBox
}}}

Displays:

Don't Use: MessageBox

Instead Use: InvMessageBox / InvErrorBox

None

Note the extraneous "None". Yech.

My "Fix"

Here is the nocamelcase2.py parser to prevent this from happening:

## NoCamelCase2 - Written by Vangelis Livadiotis - Adapted from "NoCamelCase by FlorianFesti"
## Tested with MoinMoin 1.7.2 
## By no means a perfect plugin (it expects the comment "# CamelCase wiki words" in tne text_moin_wiki.py file)
## - but it works!
## 04-11-08
##
### BDB 10/26/2010 - fixed so that "None" is not emitted to screen 

from MoinMoin.parser import text_moin_wiki as wiki
import re

class Parser(wiki.Parser):

    def __init__(self, raw, request, **kw):
        wiki.Parser.scan_rules = re.sub(r"\)\|\(\?P<word>.*(.|\n)*# CamelCase wiki words", "",self.scan_rules)
        self.word_rule = ''
        wiki.Parser.__init__(self, raw, request, **kw)

    def format(self, formatter, inhibit_p=False):
        self.scan_rules = re.sub(r"\)\|\(\?P<word>.*(.|\n)*# CamelCase wiki words", "",self.scan_rules)
        self.scan_re = re.compile(self.scan_rules, re.UNICODE|re.VERBOSE)
        err = wiki.Parser.format(self, formatter, inhibit_p=False)
        if err:
            self.request.write(err)

Note: After thinking about it, I came up with a better fix (above) and removed my ugly hack. If you want to see my ugly hack, look at the prior version of this page.

MoinMoin: ParserMarket/NoCamelCase2/DisplaysNone (last edited 2010-10-26 19:35:44 by BobbyBaucom)