- if use_html:
- return ("%s%s%s" % (html_colours[colour][0], html_escape(s), html_colours[colour][1]))
- else:
- return ("%s%s%s" % (ansi_colours[colour], s, ansi_colours['end']))
-
-def print_escaped_text(s):
- if use_html:
- print "<pre>%s</pre>" % (s)
- else:
- print s
-
-def print_formatted_text(s):
- if use_html:
- print "<pre>%s</pre>" % (html_escape(s))
- else:
- print s
+ if use_html:
+ return ("%s%s%s" % (html_colours[colour][0], utils.html_escape(s), html_colours[colour][1]))
+ else:
+ return ("%s%s%s" % (ansi_colours[colour], s, ansi_colours['end']))
+
+def escaped_text(s, strip=False):
+ if use_html:
+ if strip:
+ s = s.strip()
+ return "<pre>%s</pre>" % (s)
+ else:
+ return s
+
+def formatted_text(s, strip=False):
+ if use_html:
+ if strip:
+ s = s.strip()
+ return "<pre>%s</pre>" % (utils.html_escape(s))
+ else:
+ return s
+
+def output_row(s):
+ if use_html:
+ return """<tr><td>"""+s+"""</td></tr>"""
+ else:
+ return s
+
+def format_field(k,v):
+ if use_html:
+ return """<tr><td class="key">%s:</td><td class="val">%s</td></tr>"""%(k,v)
+ else:
+ return "%s: %s"%(k,v)
+
+def foldable_output(title, elementnameprefix, content, norow=False):
+ d = {'elementnameprefix':elementnameprefix}
+ if use_html:
+ print """<div id="%(elementnameprefix)s-wrap"><a name="%(elementnameprefix)s" />
+ <table class="infobox rfc822">"""%d
+ headline(title, bodyelement="%(elementnameprefix)s-body"%d)
+ if use_html:
+ print """ <tbody id="%(elementnameprefix)s-body" class="infobody">"""%d
+ if norow:
+ print content
+ else:
+ print output_row(content)
+ if use_html:
+ print """</tbody></table></div>"""