{ "info": { "author": "Cameron Simpson", "author_email": "cs@zip.com.au", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "HTML transcription functions.\n=============================\n\nMalformed markup is enraging. Therefore, when I must generate HTML I construct a token structure using natural Python objects (strings, lists, dicts) and use this module to transcribe them to syntacticly correct HTML. This also avoids lots of tedious and error prone entity escaping.\n\nA \"token\" in this scheme is:\n\n* a string: transcribed safely to HTML, eg \"some text here\"\n\n* an int or float: transcribed safely to HTML, eg 1 or 2.5.\n\n* a sequence: an HTML tag: element 0 is the tag name, element 1 (if a mapping) is the element attributes, any further elements are enclosed tokens, eg: ['H1', {'align': 'centre'}, 'Heading Text']\n\n - because a string like \"&foo\" gets its \"&\" transcribed into the entity \"&\", a single element list whose tag begins with \"&\" encodes an entity, example: [\"<\"]\n\n* a preformed token object with .tag (a string) and .attrs (a mapping) attributes\n\nCore functions:\n---------------\n\n* ``transcribe(*tokens)``: a generator yielding strings comprising HTML\n\n* ``xtranscribe(*tokens)``: a generator yielding strings comprising XHTML\n\n* ``attrquote(s)``: quote the string ``s`` for use as a tag attribute according to HTML 4.01 section 3.2.2\n\n* ``nbsp(s)``: convert ``s`` to nonbreaking text: generator yielding tokens with whitespace converted to   entities\n\nConvenience routines:\n---------------------\n\n* ``transcribe_s(*tokens)``: convert ``tokens`` into a string containing HTML\n\n* ``xtranscribe_s(*tokens)``: convert ``tokens`` into a string containing XHTML\n\nObsolete:\n---------\n* tok2s: transcribe tokens to a string; trivial wrapper for puttok\n* puttok: transcribe tokens to a file\n* text2s: transcribe a string to an HTML-safe string; trivial wrapper for puttext\n* puttext: transcribe a string as HTML-safe text to a file\n\nExample::\n\n from cs.html import transcribe, transcribe_s, xtranscribe, puttok\n [...]\n table = ['TABLE', {'width': '80%'},\n ['TR',\n ['TD', 'a truism'],\n ['TD', '1 < 2']\n ]\n ['TR',\n ['TD', 'a couple'],\n ['TD', 'A & B']\n ]\n ]\n prose_with_table = [\n 'Here is a line with a line break.', ['BR'],\n 'Here is a trite table:',\n table,\n ]\n [...]\n print('Here is the table's HTML:', transcribe_s(table))\n [...]\n # write HTML tokens to a file\n for s in transcribe(['H1', {'align': 'left'}, 'Prose'], *prose_with_table):\n fp.write(s)\n [...]\n # write XHTML tokens to a file\n for s in xtranscribe(*prose_with_table):\n fp.write(s)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/cameron_simpson/css/commits/all", "keywords": "python2,python3", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "cs.html", "package_url": "https://pypi.org/project/cs.html/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/cs.html/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/cameron_simpson/css/commits/all" }, "release_url": "https://pypi.org/project/cs.html/20160828/", "requires_dist": null, "requires_python": null, "summary": "easy HTML and XHTML transcription", "version": "20160828" }, "last_serial": 2309044, "releases": { "20150117.2": [ { "comment_text": "", "digests": { "md5": "e399c9bf0f436be082f05a5c98bb41cd", "sha256": "1a1573ffd93a832d1b3d5a38c8a71fc6464f6c8873e88e583e710b5989f11951" }, "downloads": -1, "filename": "cs.html-20150117.2.tar.gz", "has_sig": false, "md5_digest": "e399c9bf0f436be082f05a5c98bb41cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3019, "upload_time": "2015-01-18T06:15:16", "url": "https://files.pythonhosted.org/packages/cb/dd/b342f8875bd3fdbc5a26253c39589f149e3063724b765af8d35d2dd7f179/cs.html-20150117.2.tar.gz" } ], "20150721": [ { "comment_text": "", "digests": { "md5": "c15bfba2cf1c73bdfb728de4f1fb7872", "sha256": "0ed36eda20b526a03c9860d31646740ae0daf8953c9332ea5cde899b7debaf97" }, "downloads": -1, "filename": "cs.html-20150721.tar.gz", "has_sig": false, "md5_digest": "c15bfba2cf1c73bdfb728de4f1fb7872", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4295, "upload_time": "2015-07-21T02:59:20", "url": "https://files.pythonhosted.org/packages/86/4a/ff73b9e99b242aa1377ce6bbbacf6ad11ab1bb368b7ea1e7211b954341f4/cs.html-20150721.tar.gz" } ], "20150727.1": [ { "comment_text": "", "digests": { "md5": "13e8e64b8f87f7b1d82189e1d9a5993a", "sha256": "07ee0e11ecd1e8217beb853c93d62cb7cbfe0721b7d9006d1d772a10a1adf63f" }, "downloads": -1, "filename": "cs.html-20150727.1.tar.gz", "has_sig": false, "md5_digest": "13e8e64b8f87f7b1d82189e1d9a5993a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5329, "upload_time": "2016-08-28T04:28:37", "url": "https://files.pythonhosted.org/packages/e7/93/7b1addabb5c84918aff81c45744261ccc01162188d8584effc13fc0f619d/cs.html-20150727.1.tar.gz" } ], "20160828": [ { "comment_text": "", "digests": { "md5": "4105090eb6a48d882c397b0062f2769b", "sha256": "922bc765d288675576f193aa4c5018ecf0902dd4a9e573fbce2cb98e788065f4" }, "downloads": -1, "filename": "cs.html-20160828.tar.gz", "has_sig": false, "md5_digest": "4105090eb6a48d882c397b0062f2769b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5330, "upload_time": "2016-08-28T06:05:42", "url": "https://files.pythonhosted.org/packages/60/6b/8fe5444a5da94edceb55c700b2aede2e903a3636668ac96233c7064c16c6/cs.html-20160828.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4105090eb6a48d882c397b0062f2769b", "sha256": "922bc765d288675576f193aa4c5018ecf0902dd4a9e573fbce2cb98e788065f4" }, "downloads": -1, "filename": "cs.html-20160828.tar.gz", "has_sig": false, "md5_digest": "4105090eb6a48d882c397b0062f2769b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5330, "upload_time": "2016-08-28T06:05:42", "url": "https://files.pythonhosted.org/packages/60/6b/8fe5444a5da94edceb55c700b2aede2e903a3636668ac96233c7064c16c6/cs.html-20160828.tar.gz" } ] }