Parsing and Compiling HTML¶
Parse HTML and compile to TALInterpreter intermediate code, using
a TALGenerator.
-
zope.tal.htmltalparser.BOOLEAN_HTML_ATTRS= frozenset(['compact', 'defer', 'checked', 'selected', 'ismap', 'disabled', 'readonly', 'noshade', 'noresize', 'multiple', 'nowrap', 'declare'])¶ List of Boolean attributes in HTML that may be given in minimized form (e.g.
<img ismap>rather than<img ismap="">) From http://www.w3.org/TR/xhtml1/#guidelines (C.10)
-
zope.tal.htmltalparser.EMPTY_HTML_TAGS= frozenset(['isindex', 'img', 'area', 'hr', 'frame', 'meta', 'param', 'basefont', 'base', 'link', 'br', 'input', 'col'])¶ List of HTML tags with an empty content model; these are rendered in minimized form, e.g.
<img />. From http://www.w3.org/TR/xhtml1/#dtds
-
zope.tal.htmltalparser.PARA_LEVEL_HTML_TAGS= frozenset(['h2', 'h3', 'h1', 'h6', 'h4', 'h5', 'p'])¶ List of HTML elements that close open paragraph-level elements and are themselves paragraph-level.
-
zope.tal.htmltalparser.BLOCK_CLOSING_TAG_MAP= {'dd': frozenset(['dd', 'dt']), 'tr': frozenset(['td', 'tr', 'th']), 'li': frozenset(['li']), 'th': frozenset(['td', 'th']), 'dt': frozenset(['dd', 'dt']), 'td': frozenset(['td', 'th'])}¶ Tags that automatically close other tags.
-
zope.tal.htmltalparser.BLOCK_LEVEL_HTML_TAGS= frozenset(['dl', 'blockquote', 'dd', 'noframe', 'tr', 'tbody', 'li', 'ul', 'ol', 'tfoot', 'th', 'table', 'td', 'div', 'dt', 'thead'])¶ List of HTML tags that denote larger sections than paragraphs.
-
zope.tal.htmltalparser.SECTION_LEVEL_HTML_TAGS= frozenset(['dl', 'blockquote', 'th', 'h2', 'h3', 'dd', 'h1', 'h6', 'h4', 'h5', 'table', 'dt', 'div', 'ol', 'ul', 'tr', 'tbody', 'li', 'p', 'tfoot', 'noframe', 'td', 'thead'])¶ Section level HTML tags
-
exception
zope.tal.htmltalparser.NestingError(tagstack, endtag, position=(None, None))[source]¶ Bases:
HTMLParser.HTMLParseErrorException raised when elements aren’t properly nested.
-
exception
zope.tal.htmltalparser.EmptyTagError(tag, position=(None, None))[source]¶ Bases:
zope.tal.htmltalparser.NestingErrorException raised when empty elements have an end tag.
-
exception
zope.tal.htmltalparser.OpenTagError(tagstack, tag, position=(None, None))[source]¶ Bases:
zope.tal.htmltalparser.NestingErrorException raised when a tag is not allowed in another tag.
-
class
zope.tal.htmltalparser.HTMLTALParser(gen=None)[source]¶ Bases:
HTMLParser.HTMLParserParser for HTML.
After you call either
parseFile()andparseString()you can retrieve the compiled program usinggetCode().Parameters: gen (TALGenerator) – The configured (with an expression compiler) code generator to use. If one is not given, a default will be used.