Package creoleparser :: Module elements :: Class DefinitionDef
[hide private]
[frames] | no frames]

Class DefinitionDef

source code

 object --+        
          |        
WikiElement --+    
              |    
   BlockElement --+
                  |
                 DefinitionDef

Processes definitions.

>>> definition = DefinitionDef('dd',':',[])
>>> mo1,mo2 = definition.regexp.finditer(":def1a\ndef1b\n:def2\n")
>>> mo1.group(1), mo2.group(1)
('def1a\ndef1b', 'def2')
>>> mo1.group(0), mo2.group(0)
(':def1a\ndef1b\n', ':def2\n')

group(1) of the match object includes all lines from the defintion up to the next definition.

Instance Methods [hide private]
 
__init__(self, tag, token, child_tags)
Constructor for WikiElement objects.
source code
 
re_string(self)
The regular expression pattern that is compiled into self.regexp.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

    Inherited from WikiElement
 
__repr__(self)
repr(x)
source code
 
_build(self, mo, element_store)
Returns a genshi Element that has self.tag as the outermost tag.
source code
 
_process(self, mo, text, wiki_elements, element_store)
Returns genshi Fragments (Elements and text)
source code
Class Variables [hide private]
    Inherited from BlockElement
  append_newline = True
Determines if newlines are appended to Element(s) during processing.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, tag, token, child_tags)
(Constructor)

source code 

Constructor for WikiElement objects.

Subclasses may have other keyword arguments.

Parameters:
  • tag - The xhtml tag associated with the element.
  • token - The character string (or strings) that identifies the element in wiki markup.
  • child_tags - A list of wiki_elements that will be searched for in the body of the element. The order of these elements matters, because if an element is found before the element that encloses it, the enclosing element will never be found. In cases where this imposes limits (e.g, strong and em should be allowed to nest each other), place the conflicting elements in a sublist. The parser will then find which comes first.
Overrides: object.__init__
(inherited documentation)

re_string(self)

source code 

The regular expression pattern that is compiled into self.regexp.

The regular expression must consume the entire wiki element, including the tokens. For block elements, the newline on the last line must be consumed also. group(1) should normally be the entire string inside the tokens. If not, a custom _build method will be needed.

Overrides: WikiElement.re_string
(inherited documentation)