{ "info": { "author": "Jiangge Zhang", "author_email": "tonyseek@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "html5lib-truncation\n===================\n\n``html5lib-truncation`` is a html5lib_ filter implementation, which can\ntruncate HTML to specific length in display, but never breaks HTML tags.\n\nThere is a shortcut function, the simplest way to use it:\n\n.. code-block:: python\n\n >>> from html5lib_truncation import truncate_html\n >>>\n >>> html = u'

A very very long link

'\n >>> truncate_html(html, 8)\n u'

A very'\n >>> truncate_html(html, 8, break_words=True)\n u'

A very ve'\n >>> truncate_html(html, 20, end='...')\n u'

A very very...'\n >>> truncate_html(html, 20, end='...', break_words=True)\n u'

A very very lon...'\n\n\n.. _html5lib: https://github.com/html5lib/html5lib-python\n\n\nInstallation\n------------\n\n::\n\n pip install html5lib-truncation\n\nDon't forget to put it into your ``requirements.txt`` or ``setup.py``.\n\n\nAPI Overview\n------------\n\nThe core API of html5lib-truncation is the filter:\n\n.. code-block:: python\n\n import html5lib\n from html5lib_truncation import TruncationFilter\n\n etree = html5lib.parse(u'

A very very long link

')\n walker = html5lib.getTreeWalker('etree')\n\n stream = walker(etree)\n stream = TruncationFilter(stream, 20, end='...', break_words=True)\n\n serializer = html5lib.serializer.HTMLSerializer()\n serialized = serializer.serialize(stream)\n\n print(u''.join(serialized).strip())\n\nThe output is ``

A very very lon...``.\n\n\nIssues\n------\n\nIf you want to report bugs or other issues, please create issues on\n`GitHub Issues `_.\n\n\nContributes\n-----------\n\nYou can send a pull reueqst on\n`GitHub `_.\n\n.. |Build Status| image:: https://img.shields.io/travis/tonyseek/html5lib-truncation.svg?style=flat\n :target: https://travis-ci.org/tonyseek/html5lib-truncation\n :alt: Build Status\n.. |Coverage Status| image:: https://img.shields.io/coveralls/tonyseek/html5lib-truncation.svg?style=flat\n :target: https://coveralls.io/r/tonyseek/html5lib-truncation\n :alt: Coverage Status\n.. |Wheel Status| image:: https://img.shields.io/pypi/wheel/html5lib-truncation.svg?style=flat\n :target: https://warehouse.python.org/project/html5lib-truncation\n :alt: Wheel Status\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/html5lib-truncation.svg?style=flat\n :target: https://pypi.python.org/pypi/html5lib-truncation\n :alt: PyPI Version", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tonyseek/html5lib-truncation", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "html5lib-truncation", "package_url": "https://pypi.org/project/html5lib-truncation/", "platform": "Any", "project_url": "https://pypi.org/project/html5lib-truncation/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/tonyseek/html5lib-truncation" }, "release_url": "https://pypi.org/project/html5lib-truncation/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Truncating HTML with html5lib filter", "version": "0.1.0" }, "last_serial": 1582316, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "01b9926eed1bebe6d6538945697b8d6b", "sha256": "2179c3d04a948aaf4ce8b4472b18fa3b2cb9f4956eb3810942be620faf36a9d3" }, "downloads": -1, "filename": "html5lib_truncation-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "01b9926eed1bebe6d6538945697b8d6b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7998, "upload_time": "2015-03-10T18:51:58", "url": "https://files.pythonhosted.org/packages/ca/96/85470bf06ca3a5fef024aefe29514516871c169e4c42e8e1c2ff81d48513/html5lib_truncation-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7e41e3c92ce9fdd8590c7899415dc056", "sha256": "f69d3b3e31d4e9caef138d4602ed8eb531eaafd94b6f9ee8b4932722cd3d0308" }, "downloads": -1, "filename": "html5lib-truncation-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7e41e3c92ce9fdd8590c7899415dc056", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4430, "upload_time": "2015-03-10T18:51:55", "url": "https://files.pythonhosted.org/packages/cf/0d/d07cc96c60000dfa1afd446b0660e6f3f8ff59ef0d513dafc907f1d3ee60/html5lib-truncation-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "01b9926eed1bebe6d6538945697b8d6b", "sha256": "2179c3d04a948aaf4ce8b4472b18fa3b2cb9f4956eb3810942be620faf36a9d3" }, "downloads": -1, "filename": "html5lib_truncation-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "01b9926eed1bebe6d6538945697b8d6b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7998, "upload_time": "2015-03-10T18:51:58", "url": "https://files.pythonhosted.org/packages/ca/96/85470bf06ca3a5fef024aefe29514516871c169e4c42e8e1c2ff81d48513/html5lib_truncation-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7e41e3c92ce9fdd8590c7899415dc056", "sha256": "f69d3b3e31d4e9caef138d4602ed8eb531eaafd94b6f9ee8b4932722cd3d0308" }, "downloads": -1, "filename": "html5lib-truncation-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7e41e3c92ce9fdd8590c7899415dc056", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4430, "upload_time": "2015-03-10T18:51:55", "url": "https://files.pythonhosted.org/packages/cf/0d/d07cc96c60000dfa1afd446b0660e6f3f8ff59ef0d513dafc907f1d3ee60/html5lib-truncation-0.1.0.tar.gz" } ] }