{ "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[](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
\nThird 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 Hi!\n
\n\n Literal strings are safely <em>escaped</em> by default.\n
\n\n Third and last paragraph\n
\n