AdvancedHTMLParser.Formatter
index

# Copyright (c) 2015, 2017 Tim Savannah under LGPLv3. 
# See LICENSE (https://gnu.org/licenses/lgpl-3.0.txt) for more information.
#   HTML formatting (HTML->XHTML conversion as well)

 
Modules
       
codecs
sys

 
Classes
       
html.parser.HTMLParser(_markupbase.ParserBase)
AdvancedHTMLFormatter

 
class AdvancedHTMLFormatter(html.parser.HTMLParser)
    A formatter for HTML. Note this does not understand CSS, so if you are enabling preformatted text based on css rules, it will not work.
It does, however, understand "pre", "code" and "script" tags and will not try to format their contents.
 
 
Method resolution order:
AdvancedHTMLFormatter
html.parser.HTMLParser
_markupbase.ParserBase
builtins.object

Methods defined here:
__init__(self, indent=' ', encoding='utf-8')
Create a formatter.
 
@param indent - Either a space/tab/newline that represents one level of indent, or an integer to use that number of spaces
@param encoding - Use this encoding for the document.
feed(self, contents)
feed - Load contents
 
@param contents - HTML contents
getHTML(self)
getHTML - Get the full HTML as contained within this tree, converted to  valid XHTML
    @returns - String
getRoot(self)
getRoot - returns the root Tag 
    @return - AdvancedTag at root. If you provided multiple root nodes, this will be a "holder" with tagName value as constants.INVISIBLE_ROOT_TAG
getRootNodes(self)
getRootNodes - Gets all objects at the "root" (first level; no parent). Use this if you may have multiple roots (not children of <html>)
    Use this method to get objects, for example, in an AJAX request where <html> may not be your root.
 
    Note: If there are multiple root nodes (i.e. no <html> at the top), getRoot will return a special tag. This function automatically
      handles that, and returns all root nodes.
 
    @return list<AdvancedTag> - A list of AdvancedTags which are at the root level of the tree.
parseFile(self, filename)
parseFile - Parses a file and creates the DOM tree and indexes
 
    @param filename <str/file> - A string to a filename or a file object. If file object, it will not be closed, you must close.
parseStr(self, html)
parseStr - Parses a string and creates the DOM tree and indexes.
 
    @param html <str> - valid HTML
setRoot(self, root)
setRoot - Sets the root node, and reprocesses the indexes
 
@param root - AdvancedTag to be new root

 
Data
        __all__ = ('AdvancedHTMLFormatter',)