{ "info": { "author": "Armin Ronacher", "author_email": "armin.ronacher@active-4.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup :: HTML" ], "description": "MarkupSafe\n==========\n\nImplements a unicode subclass that supports HTML strings:\n\n.. code-block:: python\n\n >>> from markupsafe import Markup, escape\n >>> escape(\"\")\n Markup(u'<script>alert(document.cookie);</script>')\n >>> tmpl = Markup(\"%s\")\n >>> tmpl % \"Peter > Lustig\"\n Markup(u'Peter > Lustig')\n\nIf you want to make an object unicode that is not yet unicode\nbut don't want to lose the taint information, you can use the\n``soft_unicode`` function. (On Python 3 you can also use ``soft_str`` which\nis a different name for the same function).\n\n.. code-block:: python\n\n >>> from markupsafe import soft_unicode\n >>> soft_unicode(42)\n u'42'\n >>> soft_unicode(Markup('foo'))\n Markup(u'foo')\n\nHTML Representations\n--------------------\n\nObjects can customize their HTML markup equivalent by overriding\nthe ``__html__`` function:\n\n.. code-block:: python\n\n >>> class Foo(object):\n ... def __html__(self):\n ... return 'Nice'\n ...\n >>> escape(Foo())\n Markup(u'Nice')\n >>> Markup(Foo())\n Markup(u'Nice')\n\nSilent Escapes\n--------------\n\nSince MarkupSafe 0.10 there is now also a separate escape function\ncalled ``escape_silent`` that returns an empty string for ``None`` for\nconsistency with other systems that return empty strings for ``None``\nwhen escaping (for instance Pylons' webhelpers).\n\nIf you also want to use this for the escape method of the Markup\nobject, you can create your own subclass that does that:\n\n.. code-block:: python\n\n from markupsafe import Markup, escape_silent as escape\n\n class SilentMarkup(Markup):\n __slots__ = ()\n\n @classmethod\n def escape(cls, s):\n return cls(escape(s))\n\nNew-Style String Formatting\n---------------------------\n\nStarting with MarkupSafe 0.21 new style string formats from Python 2.6 and\n3.x are now fully supported. Previously the escape behavior of those\nfunctions was spotty at best. The new implementations operates under the\nfollowing algorithm:\n\n1. if an object has an ``__html_format__`` method it is called as\n replacement for ``__format__`` with the format specifier. It either\n has to return a string or markup object.\n2. if an object has an ``__html__`` method it is called.\n3. otherwise the default format system of Python kicks in and the result\n is HTML escaped.\n\nHere is how you can implement your own formatting:\n\n.. code-block:: python\n\n class User(object):\n\n def __init__(self, id, username):\n self.id = id\n self.username = username\n\n def __html_format__(self, format_spec):\n if format_spec == 'link':\n return Markup('{1}').format(\n self.id,\n self.__html__(),\n )\n elif format_spec:\n raise ValueError('Invalid format spec')\n return self.__html__()\n\n def __html__(self):\n return Markup('{0}').format(self.username)\n\nAnd to format that user:\n\n.. code-block:: python\n\n >>> user = User(1, 'foo')\n >>> Markup('
User: {0:link}').format(user)\n Markup(u'
User: foo')\n\nMarkupsafe supports Python 2.6, 2.7 and Python 3.3 and higher.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pallets/markupsafe", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "MarkupSafe-slow", "package_url": "https://pypi.org/project/MarkupSafe-slow/", "platform": "", "project_url": "https://pypi.org/project/MarkupSafe-slow/", "project_urls": { "Homepage": "http://github.com/pallets/markupsafe" }, "release_url": "https://pypi.org/project/MarkupSafe-slow/1.0/", "requires_dist": null, "requires_python": "", "summary": "Implements a XML/HTML/XHTML Markup safe string for Python", "version": "1.0" }, "last_serial": 2848634, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "491ea72a620e81828b9b48cebb504653", "sha256": "91ccafbe1628e720d2c5a8270d94b6059260b802b2d9718da8653e2d92ab7600" }, "downloads": -1, "filename": "MarkupSafe_slow-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "491ea72a620e81828b9b48cebb504653", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14750, "upload_time": "2017-05-03T09:40:08", "url": "https://files.pythonhosted.org/packages/78/84/8fca6ced4dd544af10a44aaf2aef869d043e72f37e5105f6e123d1270e27/MarkupSafe_slow-1.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "491ea72a620e81828b9b48cebb504653", "sha256": "91ccafbe1628e720d2c5a8270d94b6059260b802b2d9718da8653e2d92ab7600" }, "downloads": -1, "filename": "MarkupSafe_slow-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "491ea72a620e81828b9b48cebb504653", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14750, "upload_time": "2017-05-03T09:40:08", "url": "https://files.pythonhosted.org/packages/78/84/8fca6ced4dd544af10a44aaf2aef869d043e72f37e5105f6e123d1270e27/MarkupSafe_slow-1.0-py2.py3-none-any.whl" } ] }