{ "info": { "author": "Jarno Elonen", "author_email": "elonen@iki.fi", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup :: HTML" ], "description": "# Minimalistic HTML generator for Python 3.6+ with compact syntax\n[![Build Status](https://travis-ci.com/elonen/py_microhtml.svg?branch=master)](https://travis-ci.com/elonen/py_microhtml)\n\nSafely construct valid HTML with Python code. Example:\n\n```python\nfrom microhtml import *\nprint(\n \u1449html(\n \u1449head( \u1449title( 'Test page' )),\n \u1449body( \u1449span( 'Simple example.', class_='example' ))).pretty())\n```\n\nThis prints out a valid, formatted XHTML document:\n```xml\n\n\n \n \n Test page\n \n \n \n Simple example.\n \n\n```\n\nYes, you'll probably need to copy-paste the unicode symbol and yes, you'll want to use a modern editor, but the resulting syntax is very compact and will not collide with your identifiers even with the `import *`.\n\nMinimalism also extends to implementation \u2013 it's _very_ short (<80 lines in v0.3). Check out `microhtml/__init__.py`.\n\nLonger example with more features showcased:\n\n```python\nfrom microhtml import *\n\n# Rendering a non-indented string (result:

Third and last paragraph

)\nraw_html = str(\u1449p(\"Third \", \u1449em(\"and last\"), ' paragraph'))\n\n# Writing a nicely formatted / tidied XHTML document to a file descriptor\nprint(\n \u1449html( lang='en_US' )(\n \u1449head(\u1449title(\"Test page\")),\n \u1449body(\n \u1449p(\"Hi!\", width=123), # 123 becomes \"123\"\n \u1449hr(class_='someclass'), # Reserved words like \"class\" can be written with a trailing underscore\n \u1449p('Literal strings are safely escaped by default.'),\n \u1449rawstr(raw_html), # Use \u1449rawstr() if you don't want escaping\n \u1449tag('applet', code='Bubbles.class', width=350, height=350), # Tag with custom name\n \u1449div(\"custom\", data__custom=\"abc\"), # '__' in attribute names is replaced with '-'\n \u1449div(style='float: right')( # This is how you can type attributes on left and content on right\n \u1449div(style='border: 1px solid black')(\n \u1449a(\"Nested\", href='#anchortest'), '|', 'link')))).pretty())\n```\n\nThis outputs:\n\n```xml\n\n\n \n \n Test page\n \n \n \n

\n Hi!\n

\n
\n

\n Literal strings are safely <em>escaped</em> by default.\n

\n

\n Third and last paragraph\n

\n \n
\n custom\n
\n
\n
\n Nested|link\n
\n
\n \n\n```\n\n## Building\n\nTo build a pypi package, simply issue `make`. It will install a venv, run tests, generate a .pyi (type/syntax completion stub) and build a source package (sdist). Use `make clean` to clean up.\n\n## Alternatives and acknowledgements\n\nIf you find unicode characters in source code a horrendous abomination, and don't mind endless nested `with` expressions, you might prefer [Yattag](http://www.yattag.org/).\n\nUses `tidylib` for pretty printing. Inspiration drawn from `pyhtml` by Cenk Alt\u0131.\n\n## Copyright\n\nCopyright 2019 Jarno Elonen.\nReleased under the MIT license. See LICENSE for details.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/elonen/py_microhtml", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "py-microhtml", "package_url": "https://pypi.org/project/py-microhtml/", "platform": "", "project_url": "https://pypi.org/project/py-microhtml/", "project_urls": { "Homepage": "https://github.com/elonen/py_microhtml" }, "release_url": "https://pypi.org/project/py-microhtml/0.3/", "requires_dist": null, "requires_python": "", "summary": "Minimalistic HTML builder for Python 3.6+ with compact syntax", "version": "0.3" }, "last_serial": 5916763, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ab6516b339369ae7fba7d7ba01319665", "sha256": "0ca6c6ab52d32724c66d8c5cc8d3d7fbdd67d2d4cfaac7e4eb7e72dc0e142a89" }, "downloads": -1, "filename": "py_microhtml-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ab6516b339369ae7fba7d7ba01319665", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4868, "upload_time": "2019-03-24T20:24:00", "url": "https://files.pythonhosted.org/packages/62/8c/12f073e915df8cf9aa2d8cd3c758ea3c41d4b7f65c001fa95fd2cd4d26f3/py_microhtml-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0ed4b4212565f3d8849ada6848c02bc5", "sha256": "7ff5073c1b7eb10e40eb669d2962898338ff25e528e6185ca1c46ec4e17b4b91" }, "downloads": -1, "filename": "py_microhtml-0.1.tar.gz", "has_sig": false, "md5_digest": "0ed4b4212565f3d8849ada6848c02bc5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3973, "upload_time": "2019-03-24T20:24:02", "url": "https://files.pythonhosted.org/packages/48/76/0d30ef844cd2ace8f60cafc0258b506bac10b78b71c015d525dc1aae8631/py_microhtml-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "a91f632bc7aca0fd03d0f332ddedb891", "sha256": "73f0fc1474756d99b1c4130ee13f98972ac3693d0d370d80d38e1034181d8809" }, "downloads": -1, "filename": "py_microhtml-0.2.tar.gz", "has_sig": false, "md5_digest": "a91f632bc7aca0fd03d0f332ddedb891", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5783, "upload_time": "2019-04-21T18:50:38", "url": "https://files.pythonhosted.org/packages/6d/05/d91800c0cf947d28d40fc090ed4a8dba1d5d1f8370fcf1c22e6c0f3327fd/py_microhtml-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "f735e925ce9edd2012b08b973c533429", "sha256": "824188e274de7da287420dcf9ffcef1ccb548f8f1184f3875762e4a690b27c89" }, "downloads": -1, "filename": "py_microhtml-0.3.tar.gz", "has_sig": false, "md5_digest": "f735e925ce9edd2012b08b973c533429", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5923, "upload_time": "2019-10-02T08:28:25", "url": "https://files.pythonhosted.org/packages/a4/af/4d85dc3dfc176a3f3216e1f9f326dea4136b721369edadc844a51140ec6b/py_microhtml-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f735e925ce9edd2012b08b973c533429", "sha256": "824188e274de7da287420dcf9ffcef1ccb548f8f1184f3875762e4a690b27c89" }, "downloads": -1, "filename": "py_microhtml-0.3.tar.gz", "has_sig": false, "md5_digest": "f735e925ce9edd2012b08b973c533429", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5923, "upload_time": "2019-10-02T08:28:25", "url": "https://files.pythonhosted.org/packages/a4/af/4d85dc3dfc176a3f3216e1f9f326dea4136b721369edadc844a51140ec6b/py_microhtml-0.3.tar.gz" } ] }