leforestier / yattag

Python library to generate HTML or XML in a readable, concise and pythonic way.
333 stars 31 forks source link

'>' and '<' as text with intendation #32

Closed hansronald closed 7 years ago

hansronald commented 7 years ago

Is there a workaround that indent() interprets '>' and '<' as non closed tags?

This example code yields the error "in tokenize raise XMLTokenError("Unrecognized XML token near %s" % repr(string[:100])) yattag.indentation.XMLTokenError: Unrecognized XML token near '> 1'"

from yattag import Doc from yattag import indent doc, tag, text = Doc().tagtext()

with tag('b'): doc.asis('2 > 1')

print indent(doc.getvalue())