1.1 --- a/parser.py Mon Apr 23 19:35:29 2012 +0200
1.2 +++ b/parser.py Mon Apr 23 22:55:08 2012 +0200
1.3 @@ -254,9 +254,13 @@
1.4
1.5 return rows
1.6
1.7 -def translate_content(text):
1.8 +def translate_content(text, sectiontype=None):
1.9
1.10 - "Return a translation of the given 'text'."
1.11 + """
1.12 + Return a translation of the given 'text'. If the optional 'sectiontype' is
1.13 + specified, the translation may be modified to a form appropriate to the
1.14 + section being translated.
1.15 + """
1.16
1.17 parts = []
1.18
1.19 @@ -264,7 +268,14 @@
1.20 for match in content_regexp.finditer(text):
1.21 start, end = match.span()
1.22 parts.append(text[last:start])
1.23 - parts.append(translate_content_match(match))
1.24 +
1.25 + # Handle unformatted sections.
1.26 +
1.27 + if sectiontype in ("code", "noformat"):
1.28 + parts.append(match.group())
1.29 + else:
1.30 + parts.append(translate_content_match(match))
1.31 +
1.32 last = end
1.33
1.34 parts.append(text[last:])
1.35 @@ -378,7 +389,7 @@
1.36 print >>out, "##", options
1.37 else:
1.38 print >>out, "{{{",
1.39 - print >>out, translate_content(text),
1.40 + print >>out, translate_content(text, sectiontype),
1.41 print >>out, "}}}"
1.42 print >>out
1.43
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tests/test_sections.txt Mon Apr 23 22:55:08 2012 +0200
2.3 @@ -0,0 +1,15 @@
2.4 +{quote}
2.5 +This is quoted content.
2.6 +{quote}
2.7 +
2.8 +Later on, we might provide a list of child pages:
2.9 +
2.10 +{children}
2.11 +
2.12 +Sadly, whether these markers define sections or not depends on the content, not
2.13 +general syntactic features. So, if we list the child pages again...
2.14 +
2.15 +{children}
2.16 +
2.17 +...we don't want the last paragraph to be in a special section, but then we have
2.18 +to know that the "children" macro does not define a section.