{ "info": { "author": "Richard Jones", "author_email": "rjones@ekit-inc.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 3", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup :: HTML" ], "description": "Simple, elegant HTML, XHTML and XML generation.\n\nConstructing your HTML\n----------------------\n\nTo construct HTML start with an instance of ``html.HTML()``. Add\ntags by accessing the tag's attribute on that object. For example:\n\n>>> from html import HTML\n>>> h = HTML()\n>>> h.p('Hello, world!')\n>>> print h # or print(h) in python 3+\n

Hello, world!

\n\nYou may supply a tag name and some text contents when creating a HTML\ninstance:\n\n>>> h = HTML('html', 'text')\n>>> print h\ntext\n\nYou may also append text content later using the tag's ``.text()`` method\nor using augmented addition ``+=``. Any HTML-specific characters (``<>&\"``)\nin the text will be escaped for HTML safety as appropriate unless\n``escape=False`` is passed. Each of the following examples uses a new\n``HTML`` instance:\n\n>>> p = h.p('hello world!\\n')\n>>> p.br\n>>> p.text('more → text', escape=False)\n>>> p += ' ... augmented'\n>>> h.p\n>>> print h\n

hello, world!
more → text ... augmented

\n

\n\nNote also that the top-level ``HTML`` object adds newlines between tags by\ndefault. Finally in the above you'll see an empty paragraph tag - tags with\nno contents get no closing tag.\n\nIf the tag should have sub-tags you have two options. You may either add\nthe sub-tags directly on the tag:\n\n>>> l = h.ol\n>>> l.li('item 1')\n>>> l.li.b('item 2 > 1')\n>>> print h\n

    \n
  1. item 1
  2. \n
  3. item 2 > 1
  4. \n
\n\nNote that the default behavior with lists (and tables) is to add newlines\nbetween sub-tags to generate a nicer output. You can also see in that\nexample the chaining of tags in ``l.li.b``.\n\nTag attributes may be passed in as well:\n\n>>> t = h.table(border='1')\n>>> for i in range(2):\n>>> r = t.tr\n>>> r.td('column 1')\n>>> r.td('column 2')\n>>> print t\n\n\n\n
column 1column 2
column 1column 2
\n\nA variation on the above is to use a tag as a context variable. The\nfollowing is functionally identical to the first list construction but\nwith a slightly different sytax emphasising the HTML structure:\n\n>>> with h.ol as l:\n... l.li('item 1')\n... l.li.b('item 2 > 1')\n\nYou may turn off/on adding newlines by passing ``newlines=False`` or\n``True`` to the tag (or ``HTML`` instance) at creation time:\n\n>>> l = h.ol(newlines=False)\n>>> l.li('item 1')\n>>> l.li('item 2')\n>>> print h\n
  1. item 1
  2. item 2
\n\nSince we can't use ``class`` as a keyword, the library recognises ``klass``\nas a substitute:\n\n>>> print h.p(content, klass=\"styled\")\n

content

\n\n\nUnicode\n-------\n\n``HTML`` will work with either regular strings **or** unicode strings, but\nnot **both at the same time**.\n\nObtain the final unicode string by calling ``unicode()`` on the ``HTML``\ninstance:\n\n>>> h = HTML()\n>>> h.p(u'Some Euro: \u20ac1.14')\n>>> unicode(h)\nu'

Some Euro: \u20ac1.14

'\n\nIf (under Python 2.x) you add non-unicode strings or attempt to get the\nresultant HTML source through any means other than ``unicode()`` then you\nwill most likely get one of the following errors raised:\n\nUnicodeDecodeError\n Probably means you've added non-unicode strings to your HTML.\nUnicodeEncodeError\n Probably means you're trying to get the resultant HTML using ``print``\n or ``str()`` (or ``%s``).\n\n\nHow generation works\n--------------------\n\nThe HTML document is generated when the ``HTML`` instance is \"stringified\".\nThis could be done either by invoking ``str()`` on it, or just printing it.\nIt may also be returned directly as the \"iterable content\" from a WSGI app\nfunction.\n\nYou may also render any tag or sub-tag at any time by stringifying it.\n\nTags with no contents (either text or sub-tags) will have no closing tag.\nThere is no \"special list\" of tags that must always have closing tags, so\nif you need to force a closing tag you'll need to provide some content,\neven if it's just a single space character.\n\nRendering doesn't affect the HTML document's state, so you can add to or\notherwise manipulate the HTML after you've stringified it.\n\n\nCreating XHTML\n--------------\n\nTo construct XHTML start with an instance of ``html.XHTML()`` and use it\nas you would an ``HTML`` instance. Empty elements will now be rendered\nwith the appropriate XHTML minimized tag syntax. For example:\n\n>>> from html import XHTML\n>>> h = XHTML()\n>>> h.p\n>>> h.br\n>>> print h\n

\n
\n\n\nCreating XML\n------------\n\nA slight tweak to the ``html.XHTML()`` implementation allows us to generate\narbitrary XML using ``html.XML()``:\n\n>>> from html import XML\n>>> h = XML('xml')\n>>> h.p\n>>> h.br('hi there')\n>>> print h\n\n

\n
hi there
\n\n\n\nTags with difficult names\n-------------------------\n\nIf your tag name isn't a valid Python identifier name, or if it's called\n\"text\" or \"raw_text\" you can add your tag slightly more manually:\n\n>>> from html import XML\n>>> h = XML('xml')\n>>> h += XML('some-tag', 'some text')\n>>> h += XML('text', 'some text')\n>>> print h\n\nsome text\nsome text\n\n\n\nVersion History (in Brief)\n--------------------------\n\n- 1.16 detect and raise a more useful error when some WSGI frameworks\n attempt to call HTML.read(). Also added ability to add new content using\n the += operator.\n- 1.15 fix Python 3 compatibility (unit tests)\n- 1.14 added plain XML support\n- 1.13 allow adding (X)HTML instances (tags) as new document content\n- 1.12 fix handling of XHTML empty tags when generating unicode\n output (thanks Carsten Eggers)\n- 1.11 remove setuptools dependency\n- 1.10 support plain ol' distutils again\n- 1.9 added unicode support for Python 2.x\n- 1.8 added Python 3 compatibility\n- 1.7 added Python 2.5 compatibility and escape argument to tag\n construction\n- 1.6 added .raw_text() and and WSGI compatibility\n- 1.5 added XHTML support\n- 1.3 added more documentation, more tests\n- 1.2 added special-case klass / class attribute\n- 1.1 added escaping control\n- 1.0 was the initial release\n\n----\n\nI would be interested to know whether this module is useful - if you use it\nplease indicate so at https://www.ohloh.net/p/pyhtml\n\nThis code is copyright 2009-2011 eKit.com Inc (http://www.ekit.com/)\nSee the end of the source file for the license of use.\nXHTML support was contributed by Michael Haubenwallner.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/html", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "html", "package_url": "https://pypi.org/project/html/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/html/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/html" }, "release_url": "https://pypi.org/project/html/1.16/", "requires_dist": null, "requires_python": null, "summary": "simple, elegant HTML, XHTML and XML generation", "version": "1.16" }, "last_serial": 635302, "releases": { "0.4.0": [], "1.0": [ { "comment_text": "", "digests": { "md5": "948478f84d61128723822f933af37bdf", "sha256": "2344d9ef6d8663288e234b50894f313982e4c159f6b7700e4461c2ca8f5c3862" }, "downloads": -1, "filename": "html-1.0.tar.gz", "has_sig": true, "md5_digest": "948478f84d61128723822f933af37bdf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3547, "upload_time": "2009-09-17T03:30:50", "url": "https://files.pythonhosted.org/packages/cf/91/fb9cab8036ef982e3114284aa21c1530a5734531207a63828e9ae5900fd6/html-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "52c2dd7527ea12291dfb553f7f4df2b7", "sha256": "b87d1e53937fb4a36166e5c524b88d52801695fa8237365cfe8ba476d0f7a961" }, "downloads": -1, "filename": "html-1.1.tar.gz", "has_sig": true, "md5_digest": "52c2dd7527ea12291dfb553f7f4df2b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3873, "upload_time": "2009-09-17T04:07:51", "url": "https://files.pythonhosted.org/packages/97/b9/87f36685f0c8b441d8f2e4fa9125c31cc92fd8dafd5006dbdaca539b0bbb/html-1.1.tar.gz" } ], "1.10": [ { "comment_text": "", "digests": { "md5": "cf0696dfc0ad3239f7f53cd44324b88b", "sha256": "822150d1bc153bb0c1a367cb40730c3f9caac757e48d6daa8bebf6031c29b848" }, "downloads": -1, "filename": "html-1.10.tar.gz", "has_sig": true, "md5_digest": "cf0696dfc0ad3239f7f53cd44324b88b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7316, "upload_time": "2010-03-26T07:06:49", "url": "https://files.pythonhosted.org/packages/56/34/4e391506d44b59a2ca53d70bd84beccb4d46bdcae05493e1a5331daf13f8/html-1.10.tar.gz" } ], "1.11": [ { "comment_text": "", "digests": { "md5": "ee7bc5acff5b8a280e1e5a7eec58eeb0", "sha256": "998ccd5bd2a67861d22c1331cbe10e9be75e2a6fc6a9e1731312e490afca6d1a" }, "downloads": -1, "filename": "html-1.11.tar.gz", "has_sig": true, "md5_digest": "ee7bc5acff5b8a280e1e5a7eec58eeb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6556, "upload_time": "2010-03-26T09:27:26", "url": "https://files.pythonhosted.org/packages/cb/60/48dd78dc1619ea4b5c4b2fb4015c56062704d8d33bd11af25231a54462c1/html-1.11.tar.gz" } ], "1.12": [ { "comment_text": "", "digests": { "md5": "1738923dfd952b6553df6dc2ca4c063c", "sha256": "7884283b2e0fc02a2d16f8a2ec161e005b1271449627de91edb6f0c198d6f4f6" }, "downloads": -1, "filename": "html-1.12.tar.gz", "has_sig": false, "md5_digest": "1738923dfd952b6553df6dc2ca4c063c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6652, "upload_time": "2010-09-07T05:54:17", "url": "https://files.pythonhosted.org/packages/b1/42/fdce4183759bd28409482e3a9384d06f53697f3e2283dc89e3309ce22c48/html-1.12.tar.gz" } ], "1.13": [ { "comment_text": "", "digests": { "md5": "ac9a029f966c324bdcbc2adfddc4a474", "sha256": "4b618cce6be4b815908a24da1e17a1e15427e49ecf83b56ca3bf3bf75746ab2e" }, "downloads": -1, "filename": "html-1.13.tar.gz", "has_sig": true, "md5_digest": "ac9a029f966c324bdcbc2adfddc4a474", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6680, "upload_time": "2010-10-07T06:51:41", "url": "https://files.pythonhosted.org/packages/65/62/71a23361b6e4ede75f55717e802eee730638bb0a2399259445afa814d15a/html-1.13.tar.gz" } ], "1.14": [ { "comment_text": "", "digests": { "md5": "c0d8dfac23b5f10f977755c878ae16a0", "sha256": "5184b3c025c9054193fa85594551b9877c4c381e79fab99bd6cf279d29052d66" }, "downloads": -1, "filename": "html-1.14.tar.gz", "has_sig": false, "md5_digest": "c0d8dfac23b5f10f977755c878ae16a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6863, "upload_time": "2011-06-24T02:48:43", "url": "https://files.pythonhosted.org/packages/8e/f4/a3baef36283c460c91bf0fc08d303419c96a64fb9f6127d590d33a615e80/html-1.14.tar.gz" } ], "1.15": [ { "comment_text": "", "digests": { "md5": "10d474b5b65634cff9968b526b958678", "sha256": "a69a4526c92b846adc8677b0a63ac7056e34409504e21b0a495c5fbec9acd8df" }, "downloads": -1, "filename": "html-1.15.tar.gz", "has_sig": false, "md5_digest": "10d474b5b65634cff9968b526b958678", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6936, "upload_time": "2011-06-28T13:26:07", "url": "https://files.pythonhosted.org/packages/f0/8d/e7932a499dc8f83037bd00fdd6024b6f49165c933b521a08d894c20c1733/html-1.15.tar.gz" } ], "1.16": [ { "comment_text": "", "digests": { "md5": "39b9db7cdcc84607828be021172d441f", "sha256": "ebc768f23b54a71350d731a75f2ef3a4a4dbdad9ae68d58b527664b66088e456" }, "downloads": -1, "filename": "html-1.16.tar.gz", "has_sig": false, "md5_digest": "39b9db7cdcc84607828be021172d441f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7639, "upload_time": "2011-06-29T11:29:33", "url": "https://files.pythonhosted.org/packages/4a/df/0e3d22d50ee43274eb5116f49972a164d853bb3ab305a69a0540b6292252/html-1.16.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "112d43d079f4346b09dd652e8d5dd88e", "sha256": "c2fce08d629ef9fcbbd38eadc7b3ddaa27843757410c42edda5124a8208bab98" }, "downloads": -1, "filename": "html-1.2.tar.gz", "has_sig": true, "md5_digest": "112d43d079f4346b09dd652e8d5dd88e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4009, "upload_time": "2009-09-17T05:56:23", "url": "https://files.pythonhosted.org/packages/61/7a/461b8135497411ed549540f2365789df3cd053fc7a2da1e49c9a59e9741c/html-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "46cee2b6d5ebb76e34db24691d4a4d2b", "sha256": "0d9b64a1dc218ee520f994c47b37eb7a3cdafda0b18d372947342dbe8b987498" }, "downloads": -1, "filename": "html-1.3.tar.gz", "has_sig": true, "md5_digest": "46cee2b6d5ebb76e34db24691d4a4d2b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4659, "upload_time": "2009-09-17T06:16:44", "url": "https://files.pythonhosted.org/packages/66/de/0dc694da0aafc0cc8a4bd73da0186dbff9875c3e5458a7af78b099a14bd8/html-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "a55d77e68053173ffc824f80b50d7dc9", "sha256": "08d018b80106ef2747bffc648ba8db565ff9ee75a962b70cb2b4ff13697faab1" }, "downloads": -1, "filename": "html-1.4.tar.gz", "has_sig": true, "md5_digest": "a55d77e68053173ffc824f80b50d7dc9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4667, "upload_time": "2009-09-17T09:00:42", "url": "https://files.pythonhosted.org/packages/73/64/56c185fa5d5bf8c655001d91cc6e191e689b5709ab7ec7b2458cd3f83172/html-1.4.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "0f8dfd58353d57d4523f2edb56552224", "sha256": "47850fe7ad92fb0507641f4062879caa0d68123a444f59b558e3e92820c0098c" }, "downloads": -1, "filename": "html-1.5.tar.gz", "has_sig": true, "md5_digest": "0f8dfd58353d57d4523f2edb56552224", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5121, "upload_time": "2009-09-18T02:33:39", "url": "https://files.pythonhosted.org/packages/2e/79/cf632a80dd6bc3ab9ce3a4c86f52fa78ee9f29d3e4900c4600faf90e69aa/html-1.5.tar.gz" } ], "1.6": [ { "comment_text": "", "digests": { "md5": "1fa21b10a30da4fc555d139a9c0bbbde", "sha256": "8b83df5451929c9ac3cf409e7edb779818826a7bf31d14f7786c69d35cfeab67" }, "downloads": -1, "filename": "html-1.6.tar.gz", "has_sig": true, "md5_digest": "1fa21b10a30da4fc555d139a9c0bbbde", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5489, "upload_time": "2009-09-21T11:48:27", "url": "https://files.pythonhosted.org/packages/ba/96/559c53c5f9c92d1fd2b96908a40f24a72c937d9bac3122a7c6c6bfd405bf/html-1.6.tar.gz" } ], "1.7": [ { "comment_text": "", "digests": { "md5": "688c9ad1f074bec1c9504c0e2390d32d", "sha256": "5886408008f1c3462d9d445cbd1aa39fe6cfa86df85c88d6a0ed91c317891c05" }, "downloads": -1, "filename": "html-1.7.tar.gz", "has_sig": true, "md5_digest": "688c9ad1f074bec1c9504c0e2390d32d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5053, "upload_time": "2009-10-14T01:10:57", "url": "https://files.pythonhosted.org/packages/6d/3c/178a611933fec85fee9314cda8ad18e79e4b9563e937b29bca1b9162ef11/html-1.7.tar.gz" }, { "comment_text": "", "digests": { "md5": "4b6a2a738d32842fa17ba1b80503d0fb", "sha256": "0b201e1f3531a798301768238bbab90370a65b9ae7dbe46ecc9295b5d29e07f5" }, "downloads": -1, "filename": "html-1.7.zip", "has_sig": false, "md5_digest": "4b6a2a738d32842fa17ba1b80503d0fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5788, "upload_time": "2010-01-15T00:23:51", "url": "https://files.pythonhosted.org/packages/0c/36/769940564b4a199a4ac0064b330e1404ee5535aa81f522b00548e3668708/html-1.7.zip" } ], "1.8": [ { "comment_text": "", "digests": { "md5": "b83d98b2734dcc0398b533448a169bf7", "sha256": "484063e652d3dd9b1b96967a178294eea034c14fcadc853357777352a2701f0d" }, "downloads": -1, "filename": "html-1.8.tar.bz2", "has_sig": false, "md5_digest": "b83d98b2734dcc0398b533448a169bf7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5288, "upload_time": "2010-01-15T00:29:34", "url": "https://files.pythonhosted.org/packages/f8/ae/9369b32f8c9d76aa473f97aebe9911fd00555bb8ff2b4c0b0071b2871322/html-1.8.tar.bz2" }, { "comment_text": "", "digests": { "md5": "d55c77c4fb553419a6a2b02ff45b9995", "sha256": "cb86b453ab148266a485434f01ea1a55ce1185d5044aa4646ed93f8a60e8053b" }, "downloads": -1, "filename": "html-1.8.tar.gz", "has_sig": false, "md5_digest": "d55c77c4fb553419a6a2b02ff45b9995", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6985, "upload_time": "2010-03-26T05:50:29", "url": "https://files.pythonhosted.org/packages/0e/1c/eca1585a6d6d4aa8414245b9aa13217f5d2aabee82f27e3f24a6579620c5/html-1.8.tar.gz" }, { "comment_text": "", "digests": { "md5": "84da4f7c51892cc22885b7880991a6f8", "sha256": "393251d590788a4a616988c8f623de0c72b0f2fddbeecf85b0c8f4fe3579a3ea" }, "downloads": -1, "filename": "html-1.8.zip", "has_sig": false, "md5_digest": "84da4f7c51892cc22885b7880991a6f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5860, "upload_time": "2010-01-15T00:28:59", "url": "https://files.pythonhosted.org/packages/0f/44/0beb51a5f4c7727f9830b3fb5e35ffd7c1e329f44bc400cc87b236803c96/html-1.8.zip" } ], "1.9": [ { "comment_text": "", "digests": { "md5": "5c5226d0b9c13c6a54f21b8d76a3f331", "sha256": "08df6767c8fc805cd446e1cc79597aaf4f3b42bdb52d3aeb1e0f58189e4c3d38" }, "downloads": -1, "filename": "html-1.9.tar.gz", "has_sig": true, "md5_digest": "5c5226d0b9c13c6a54f21b8d76a3f331", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7060, "upload_time": "2010-03-26T06:00:09", "url": "https://files.pythonhosted.org/packages/d2/df/a641ca3ee63f30d8f4e2d0a5f9dda9ad7927015c2b289d424ca19fad558f/html-1.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "39b9db7cdcc84607828be021172d441f", "sha256": "ebc768f23b54a71350d731a75f2ef3a4a4dbdad9ae68d58b527664b66088e456" }, "downloads": -1, "filename": "html-1.16.tar.gz", "has_sig": false, "md5_digest": "39b9db7cdcc84607828be021172d441f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7639, "upload_time": "2011-06-29T11:29:33", "url": "https://files.pythonhosted.org/packages/4a/df/0e3d22d50ee43274eb5116f49972a164d853bb3ab305a69a0540b6292252/html-1.16.tar.gz" } ] }