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

Class ListItem

source code

 object --+    
          |    
WikiElement --+
              |
             ListItem

Matches the current list item.

Everything up to the next same-level list item is matched.

>>> list_item = ListItem('li',[],'#*')
>>> mo = list_item.regexp.search("*one\n**one.1\n**one.2\n*two\n")
>>> mo.group(2)
'one\n**one.1\n**one.2'
>>> mo.group(0)
'*one\n**one.1\n**one.2'
Instance Methods [hide private]
 
__init__(self, tag, child_tags, list_tokens)
Constructor for list items.
source code
 
re_string(self)
The regular expression pattern that is compiled into self.regexp.
source code
 
_build(self, mo, element_store)
Returns a genshi Element that has self.tag as the outermost tag.
source code

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

    Inherited from WikiElement
 
__repr__(self)
repr(x)
source code
 
_process(self, mo, text, wiki_elements, element_store)
Returns genshi Fragments (Elements and text)
source code
Class Variables [hide private]
  append_newline = False
Determines if newlines are appended to Element(s) during processing.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

Constructor for list items.

:parameters"
list_tokens
A string that includes the tokens used for lists
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__

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)

_build(self, mo, element_store)

source code 

Returns a genshi Element that has self.tag as the outermost tag.

This methods if called exclusively by _process

Parameters:
  • mo - match object, usually the one returned by self.regexp.search(s)
Overrides: WikiElement._build
(inherited documentation)