@@ 1,5 1,4 @@
# -*- encoding: utf-8 -*-
-#
'''Simple, elegant HTML, XHTML and XML generation.
Constructing your HTML
@@ 11,14 10,14 @@ tags by accessing the tag's attribute on
>>> from html import HTML
>>> h = HTML()
>>> h.p('Hello, world!')
->>> print h # or print(h) in python 3+
+>>> print(h)
<p>Hello, world!</p>
You may supply a tag name and some text contents when creating a HTML
instance:
>>> h = HTML('html', 'text')
->>> print h
+>>> print(h)
<html>text</html>
You may also append text content later using the tag's ``.text()`` method
@@ 32,7 31,7 @@ in the text will be escaped for HTML saf
>>> p.text('more → text', escape=False)
>>> p += ' ... augmented'
>>> h.p
->>> print h
+>>> print(h)
<p>hello, world!<br>more → text ... augmented</p>
<p>
@@ 46,7 45,7 @@ the sub-tags directly on the tag:
>>> l = h.ol
>>> l.li('item 1')
>>> l.li.b('item 2 > 1')
->>> print h
+>>> print(h)
<ol>
<li>item 1</li>
<li><b>item 2 > 1</b></li>
@@ 63,7 62,7 @@ Tag attributes may be passed in as well:
>>> r = t.tr
>>> r.td('column 1')
>>> r.td('column 2')
->>> print t
+>>> print(t)
<table border="1">
<tr><td>column 1</td><td>column 2</td></tr>
<tr><td>column 1</td><td>column 2</td></tr>
@@ 83,13 82,13 @@ You may turn off/on adding newlines by p
>>> l = h.ol(newlines=False)
>>> l.li('item 1')
>>> l.li('item 2')
->>> print h
+>>> print(h)
<ol><li>item 1</li><li>item 2</li></ol>
Since we can't use ``class`` as a keyword, the library recognises ``klass``
as a substitute:
->>> print h.p(content, klass="styled")
+>>> print(h.p(content, klass="styled"))
<p class="styled">content</p>
@@ 148,7 147,7 @@ with the appropriate XHTML minimized tag
>>> h = XHTML()
>>> h.p
>>> h.br
->>> print h
+>>> print(h)
<p></p>
<br />
@@ 163,7 162,7 @@ arbitrary XML using ``html.XML()``:
>>> h = XML('xml')
>>> h.p
>>> h.br('hi there')
->>> print h
+>>> print(h)
<xml>
<p />
<br>hi there</br>
@@ 180,7 179,7 @@ If your tag name isn't a valid Python id
>>> h = XML('xml')
>>> h += XML('some-tag', 'some text')
>>> h += XML('text', 'some text')
->>> print h
+>>> print(h)
<xml>
<some-tag>some text</some-tag>
<text>some text</text>
@@ 190,6 189,8 @@ If your tag name isn't a valid Python id
Version History (in Brief)
--------------------------
+- 1.17 repackage it as "pyhtml" since "html" clashes with the
+ homonymous py3 stdlib module
- 1.16 detect and raise a more useful error when some WSGI frameworks
attempt to call HTML.read(). Also added ability to add new content using
the += operator.
@@ 219,6 220,7 @@ please indicate so at https://www.ohloh.
This code is copyright 2009-2011 eKit.com Inc (http://www.ekit.com/)
See the end of the source file for the license of use.
XHTML support was contributed by Michael Haubenwallner.
+
'''
import cgi