code2htmlmixin.py
"""
Mixin class to provide HTML output functionality.
Intended to be attached to objects derived from Parser, and
which therefore have a TokenList _tlist attribute.
Library Version 1.1
Copyright 2013 Paul Griffiths
Email: mail@paulgriffiths.net
Distributed under the terms of the GNU General Public License.
http://www.gnu.org/licenses/
"""
class Code2HTMLMixin():
"""
Mixin class for code-to-HTML scanners.
"""
def __init__(self):
"""
Class initializer.
"""
pass
def __str__(self):
"""
Overrides the string conversion to return a <pre></pre>
wrapped block of HTML containing the marked-up and escaped
tokens.
"""
return "<pre>\n%s</pre>\n" % self._tlist.read(decorated=True,
html=True)