%doc>formatting.myt - library of HTML formatting functions to operate on a TOCElement tree%doc> <%global> import string, re import highlight %global> <%def printtocelement> <%doc>prints a TOCElement as a table of contents item and prints its immediate child items%doc> <%args> item includefile bold = False full = False children = True %args>
% if children:<% m.content() %>
', f, re.S) f = "
" + f + "
" return f %filter> <% m.content() | h%> %method> <%method itemlink trim="both"> <%args> item includefile %args> <% item.description %> %method> <%method codeline trim="both"> <% m.content() %> %method> <%method code autoflush=False> <%args> title = None syntaxtype = 'myghty' html_escape = True %args> <%init> def fix_indent(f): f =string.expandtabs(f, 4) g = '' lines = string.split(f, "\n") whitespace = None for line in lines: if whitespace is None: match = re.match(r"^([ ]*).+", line) if match is not None: whitespace = match.group(1) if whitespace is not None: line = re.sub(r"^%s" % whitespace, "", line) if whitespace is not None or re.search(r"\w", line) is not None: g += (line + "\n") return g.rstrip() content = highlight.highlight(fix_indent(m.content()), html_escape = html_escape, syntaxtype = syntaxtype) %init><% content %>