1.1 --- a/MoinShare.py Sat Jun 16 20:33:46 2012 +0200
1.2 +++ b/MoinShare.py Sat Jun 16 23:56:29 2012 +0200
1.3 @@ -81,18 +81,38 @@
1.4
1.5 """
1.6 Return fragments from the given 'regions', each having the form
1.7 - (arguments, body text).
1.8 + (format, arguments, body text).
1.9 """
1.10
1.11 fragments = []
1.12
1.13 for region in regions:
1.14 - body = region.lstrip("{").rstrip("}")
1.15 + body = region.lstrip("{").rstrip("}").lstrip()
1.16 if body.startswith(fragment_prelude):
1.17 arguments, body = body[len(fragment_prelude):].split("\n", 1)
1.18 +
1.19 + # Get any parser/format declaration.
1.20 +
1.21 + if arguments and not arguments[0].isspace():
1.22 + format, arguments = arguments.split(None, 1)
1.23 + else:
1.24 + format = None
1.25 +
1.26 + # Get the attributes/arguments for the region.
1.27 +
1.28 attributes = parseAttributes(arguments, False)
1.29 +
1.30 + # If the format is the MoinShare attribute, move it into the
1.31 + # dictionary.
1.32 +
1.33 + if format.lower() == fragment_attribute:
1.34 + attributes[fragment_attribute] = True
1.35 + format = None
1.36 +
1.37 + # Only collect appropriate regions.
1.38 +
1.39 if attributes.has_key(fragment_attribute):
1.40 - fragments.append((attributes, body))
1.41 + fragments.append((format, attributes, body))
1.42
1.43 return fragments
1.44