-
Notifications
You must be signed in to change notification settings - Fork 1
The DOM Rendering Process
While they probably could (it's Python), HTME does not aim to allow users to create totally arbitrary HTML. The idea is to allow users to express the DOM of any valid HTML5 document, so users actually build something closer to an AST that we serialize into HTML.
HTME elements and engines are always serialized according to a set of simple, deterministic rules that make it easy to always know exactly what the output will be.
The subset of the HTML5 syntax that HTME uses allows us to support inline SVG and MathML without having to differentiate between HTML and XML trees. The signatures, operators and methods are the same, and the code that HTME generates uses the same syntax and style, whether it is HTML, SVG or MathML output.
HTML and XML are different, but the HTML5 spec requires vendors to parse any inline XML a little differently, which makes it possible to use one simple syntax for both.
The W3C HTML5 Syntax Specification is clear that tag names, even those for foreign elements, may be written with any mix of lowercase and uppercase letters.
HTME outputs all (HTML5, SVG and MathML) tag names in lowercase.
Attribute names are always spelled in lowercase, and each attribute is delimited from the tag name and any other attributes by a single space.
See The Attribute Rendering Process in the wiki for more information on how attributes are rendered.
Void elements do not use a closing slash. It is not required.
Foreign elements use a closing slash if the element is self-closing (if it has no children and no closing tag, but could potentially have them).
The output does not use a space before the closing slash at the end of self-closing foreign elements. This was apparently only required with very old browsers (like Netscape Era).
HTME never introduces insignificant whitespace. Unless the user includes a newline in a text node, the output is a single line of HTML.
HTML5 and the SVG spec both define A, SCRIPT, STYLE and TITLE elements, but they are indistinct in HTME.
We put all of the HTML5, SVG and MathML tag names in one big namespace and do not have to worry about what context an A element appears in. The syntax HTME uses for each type of element works perfectly in either case.
HTME cannot generate legit, standalone XML files. That is beyond the scope of the library. The focus is only HTML5 with inline SVG and MathML.
We hope devs will be encouraged to create Python routines that generate cool vector graphics for icons, borders, text effects et cetera that can be used in pages and apps. These routines can be wrapped in magic elements, so it is easy to generate cool stuff like floral dividers, iconic background patterns and advanced text animations.
HTME | The Hypertext Markup Engine | Simple, Pythonic HTML Code Generation for Python 2 or 3
To learn to use HTME, read these articles (in this order):