class documentation

class OldParseTreeBuilder(object): (source)

View In Hierarchy

This class supplies an alternative for xml.etree.ElementTree.TreeBuilder which cleans up the tree on the fly while building it. The main use is to normalize the tree that is produced by the editor widget, but it can also be used on other "dirty" interfaces.

This builder takes care of the following issues:

  • ~~Inline tags ('emphasis', 'strong', 'h', etc.) can not span multiple lines~~ (refactored out to `TextBuffer.get_parsetree()`)
  • Tags can not contain only whitespace
  • Tags can not be empty (with the exception of the 'img' tag)
  • ~~There should be an empty line before each 'h', 'p' or 'pre' (with the exception of the first tag in the tree)~~
  • The 'p' and 'pre' elements should always end with a newline ('\n') --> all block elements must end in newline
  • ~~Each 'p', 'pre' and 'h' should be postfixed with a newline ('\n') (as a results 'p' and 'pre' are followed by an empty line, the 'h' does not end in a newline itself, so it is different)~~
  • ~~Newlines ('\n') after a <li> alement are removed (optional)~~
  • The element '_ignore_' is silently ignored
Method __init__ Undocumented
Method append Undocumented
Method close Undocumented
Method data Undocumented
Method end Undocumented
Method start Undocumented
Method _append_to_previous Add text before current element
Method _flush Undocumented
Instance Variable _data Undocumented
Instance Variable _last Undocumented
Instance Variable _last_char Undocumented
Instance Variable _stack Undocumented
Instance Variable _tail Undocumented
def __init__(self, remove_newlines_after_li=True): (source)

Undocumented

def append(self, tag, text): (source)

Undocumented

def close(self): (source)

Undocumented

def data(self, text): (source)

Undocumented

def end(self, tag): (source)

Undocumented

def start(self, tag, attrib=None): (source)

Undocumented

def _append_to_previous(self, text): (source)
Add text before current element
def _flush(self): (source)

Undocumented

_data: list = (source)

Undocumented

_last = (source)

Undocumented

_last_char = (source)

Undocumented

_stack: list = (source)

Undocumented

_tail: bool = (source)

Undocumented