class Visitor(object): (source)
Known subclasses: zim.export.template.HeadingSplitter
, zim.formats.DumperClass
ParseTree.visit()
.Method | append |
Convenience function to open a tag, append text and close it immediatly. |
Method | end |
No summary |
Method | start |
Start formatted region |
Method | text |
Append text @param text: text to be appended as string @implementation: optional for subclasses |
zim.export.template.HeadingSplitter
, zim.formats.DumperClass
Convenience function to open a tag, append text and close it immediatly.
Can raise VisitorStop
or VisitorSkip
, see start() for the conditions.
Parameters | |
tag | the tag name |
attrib | optional dict with attributes |
text | formatted text |
Unknown Field: implementation | |
optional for subclasses, default implementation calls start() , text() , and end() |
zim.export.template.HeadingSplitter
, zim.formats.DumperClass
Parameters | |
tag | the tag name |
Raises | |
AssertionError | when tag does not match current state |
Unknown Field: implementation | |
optional for subclasses |
zim.export.template.HeadingSplitter
, zim.formats.DumperClass
Start formatted region
Visitor objects can raise two exceptions in this method to influence the tree traversal:
VisitorStop
will cancel the current parsing, but without raising an error. So code implementing a visit method should catch this.VisitorSkip
can be raised when the visitor wants to skip a node, and should prevent the implementation from further decending into this nodeParameters | |
tag | the tag name |
attrib | optional dict with attributes |
Note | |
If the visitor modifies the attrib dict on nodes, this will modify the tree. If this is not intended, the implementation needs to take care to copy the attrib to break the reference. | |
Unknown Field: implementation | |
optional for subclasses |
zim.export.template.HeadingSplitter
, zim.formats.DumperClass
Parameters | |
text | text to be appended as string |
Unknown Field: implementation | |
optional for subclasses |