# HG changeset patch # User Paul Boddie # Date 1354459419 -3600 # Node ID 678a687f520be7f71ba0306c9f313579786a0141 # Parent 3ceaae65f98234ddd78db437e7036b7874ecf9c1 Simplified the parsing logic in the macro adjustment function. diff -r 3ceaae65f982 -r 678a687f520b MoinForms.py --- a/MoinForms.py Sun Dec 02 01:40:02 2012 +0100 +++ b/MoinForms.py Sun Dec 02 15:43:39 2012 +0100 @@ -237,22 +237,20 @@ """ result = [] - state = None type = None - for match in form_field_regexp.split(body): + for i, match in enumerate(form_field_regexp.split(body)): + state = i % 3 # Reproduce normal text as is. - if not state: + if state == 0: result.append(match) - state = "TYPE" # Capture the macro type. - elif state == "TYPE": + elif state == 1: type = match - state = "ARGS" # Substitute the macro and modified arguments. @@ -260,7 +258,6 @@ result.append("<>" % (type, ",".join( adjustMacroArguments(parseMacroArguments(match), path) ))) - state = None return "".join(result)