Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
MoinMoin.parser._creole.Parser Class Reference

List of all members.

Public Member Functions

def __init__
def parse_inline
def parse_block
def parse

Public Attributes

 raw
 root
 cur
 text

Static Public Attributes

tuple pre_escape_re = re.compile(Rules.pre_escape, re.M | re.X)
tuple link_re = re.compile('|'.join([Rules.image, Rules.linebreak, Rules.char]), re.X | re.U)
tuple item_re = re.compile(Rules.item, re.X | re.U | re.M)
tuple cell_re = re.compile(Rules.cell, re.X | re.U)
tuple block_re
tuple inline_re

Private Member Functions

def _upto
def _url_repl
def _link_repl
def _macro_repl
def _image_repl
def _separator_repl
def _item_repl
def _list_repl
def _head_repl
def _text_repl
def _table_repl
def _pre_repl
def _line_repl
def _code_repl
def _emph_repl
def _strong_repl
def _break_repl
def _escape_repl
def _char_repl
def _replace

Static Private Attributes

 _url_target_repl = _url_repl
 _url_proto_repl = _url_repl
 _escaped_url = _url_repl
 _link_target_repl = _link_repl
 _link_text_repl = _link_repl
 _macro_name_repl = _macro_repl
 _macro_args_repl = _macro_repl
 _macro_text_repl = _macro_repl
 _image_target_repl = _image_repl
 _image_text_repl = _image_repl
 _item_text_repl = _item_repl
 _item_head_repl = _item_repl
 _head_head_repl = _head_repl
 _head_text_repl = _head_repl
 _break_repl = _text_repl
 _pre_text_repl = _pre_repl
 _pre_head_repl = _pre_repl
 _pre_kind_repl = _pre_repl
 _code_text_repl = _code_repl
 _code_head_repl = _code_repl

Detailed Description

Parse the raw text and create a document object
that can be converted into output using Emitter.

Definition at line 121 of file _creole.py.


Constructor & Destructor Documentation

def MoinMoin.parser._creole.Parser.__init__ (   self,
  raw 
)

Definition at line 140 of file _creole.py.

00140 
00141     def __init__(self, raw):
00142         self.raw = raw
00143         self.root = DocNode('document', None)
00144         self.cur = self.root        # The most recent document node
00145         self.text = None            # The node to add inline characters to


Member Function Documentation

def MoinMoin.parser._creole.Parser._break_repl (   self,
  groups 
) [private]

Definition at line 339 of file _creole.py.

00339 
00340     def _break_repl(self, groups):
00341         DocNode('break', self.cur, None)
00342         self.text = None

def MoinMoin.parser._creole.Parser._char_repl (   self,
  groups 
) [private]

Definition at line 348 of file _creole.py.

00348 
00349     def _char_repl(self, groups):
00350         if self.text is None:
00351             self.text = DocNode('text', self.cur, u'')
00352         self.text.content += groups.get('char', u'')

def MoinMoin.parser._creole.Parser._code_repl (   self,
  groups 
) [private]

Definition at line 319 of file _creole.py.

00319 
00320     def _code_repl(self, groups):
00321         DocNode('code', self.cur, groups.get('code_text', u'').strip())
        self.text = None
def MoinMoin.parser._creole.Parser._emph_repl (   self,
  groups 
) [private]

Definition at line 325 of file _creole.py.

00325 
00326     def _emph_repl(self, groups):
00327         if self.cur.kind != 'emphasis':
00328             self.cur = DocNode('emphasis', self.cur)
00329         else:
00330             self.cur = self._upto(self.cur, ('emphasis', )).parent
00331         self.text = None

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._escape_repl (   self,
  groups 
) [private]

Definition at line 343 of file _creole.py.

00343 
00344     def _escape_repl(self, groups):
00345         if self.text is None:
00346             self.text = DocNode('text', self.cur, u'')
00347         self.text.content += groups.get('escaped_char', u'')

def MoinMoin.parser._creole.Parser._head_repl (   self,
  groups 
) [private]

Definition at line 254 of file _creole.py.

00254 
00255     def _head_repl(self, groups):
00256         self.cur = self._upto(self.cur, ('document', 'section', 'blockquote'))
00257         node = DocNode('header', self.cur, groups.get('head_text', '').strip())
        node.level = len(groups.get('head_head', ' '))

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._image_repl (   self,
  groups 
) [private]
Handles images and attachemnts included in the page.

Definition at line 206 of file _creole.py.

00206 
00207     def _image_repl(self, groups):
00208         """Handles images and attachemnts included in the page."""
00209 
00210         target = groups.get('image_target', '').strip()
00211         text = (groups.get('image_text', '') or '').strip()
00212         node = DocNode("image", self.cur, target)
00213         DocNode('text', node, text or node.content)
        self.text = None
def MoinMoin.parser._creole.Parser._item_repl (   self,
  groups 
) [private]

Definition at line 221 of file _creole.py.

00221 
00222     def _item_repl(self, groups):
00223         bullet = groups.get('item_head', u'')
00224         text = groups.get('item_text', u'')
00225         if bullet[-1] == '#':
00226             kind = 'number_list'
00227         else:
00228             kind = 'bullet_list'
00229         level = len(bullet)
00230         lst = self.cur
00231         # Find a list of the same kind and level up the tree
00232         while (lst and
00233                    not (lst.kind in ('number_list', 'bullet_list') and
00234                         lst.level == level) and
00235                     not lst.kind in ('document', 'section', 'blockquote')):
00236             lst = lst.parent
00237         if lst and lst.kind == kind:
00238             self.cur = lst
00239         else:
00240             # Create a new level of list
00241             self.cur = self._upto(self.cur,
00242                 ('list_item', 'document', 'section', 'blockquote'))
00243             self.cur = DocNode(kind, self.cur)
00244             self.cur.level = level
00245         self.cur = DocNode('list_item', self.cur)
00246         self.parse_inline(text)
        self.text = None

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._line_repl (   self,
  groups 
) [private]

Definition at line 316 of file _creole.py.

00316 
00317     def _line_repl(self, groups):
00318         self.cur = self._upto(self.cur, ('document', 'section', 'blockquote'))

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._link_repl (   self,
  groups 
) [private]
Handle all kinds of links.

Definition at line 178 of file _creole.py.

00178 
00179     def _link_repl(self, groups):
00180         """Handle all kinds of links."""
00181 
00182         target = groups.get('link_target', '')
00183         text = (groups.get('link_text', '') or '').strip()
00184         parent = self.cur
00185         self.cur = DocNode('link', self.cur)
00186         self.cur.content = target
00187         self.text = None
00188         re.sub(self.link_re, self._replace, text)
00189         self.cur = parent
        self.text = None

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._list_repl (   self,
  groups 
) [private]

Definition at line 250 of file _creole.py.

00250 
00251     def _list_repl(self, groups):
00252         text = groups.get('list', u'')
00253         self.item_re.sub(self._replace, text)

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._macro_repl (   self,
  groups 
) [private]
Handles macros using the placeholder syntax.

Definition at line 193 of file _creole.py.

00193 
00194     def _macro_repl(self, groups):
00195         """Handles macros using the placeholder syntax."""
00196 
00197         name = groups.get('macro_name', '')
00198         text = (groups.get('macro_text', '') or '').strip()
00199         node = DocNode('macro', self.cur, name)
00200         node.args = groups.get('macro_args', '') or ''
00201         DocNode('text', node, text or name)
        self.text = None
def MoinMoin.parser._creole.Parser._pre_repl (   self,
  groups 
) [private]

Definition at line 302 of file _creole.py.

00302 
00303     def _pre_repl(self, groups):
00304         self.cur = self._upto(self.cur, ('document', 'section', 'blockquote'))
00305         kind = groups.get('pre_kind', None)
00306         text = groups.get('pre_text', u'')
00307         def remove_tilde(m):
00308             return m.group('indent') + m.group('rest')
00309         text = self.pre_escape_re.sub(remove_tilde, text)
00310         node = DocNode('preformatted', self.cur, text)
00311         node.sect = kind or ''
        self.text = None

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._replace (   self,
  match 
) [private]
Invoke appropriate _*_repl method. Called for every matched group.

Definition at line 353 of file _creole.py.

00353 
00354     def _replace(self, match):
00355         """Invoke appropriate _*_repl method. Called for every matched group."""
00356 
00357         groups = match.groupdict()
00358         for name, text in groups.iteritems():
00359             if text is not None:
00360                 replace = getattr(self, '_%s_repl' % name)
00361                 replace(groups)
00362                 return

Here is the caller graph for this function:

def MoinMoin.parser._creole.Parser._separator_repl (   self,
  groups 
) [private]

Definition at line 217 of file _creole.py.

00217 
00218     def _separator_repl(self, groups):
00219         self.cur = self._upto(self.cur, ('document', 'section', 'blockquote'))
00220         DocNode('separator', self.cur)

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._strong_repl (   self,
  groups 
) [private]

Definition at line 332 of file _creole.py.

00332 
00333     def _strong_repl(self, groups):
00334         if self.cur.kind != 'strong':
00335             self.cur = DocNode('strong', self.cur)
00336         else:
00337             self.cur = self._upto(self.cur, ('strong', )).parent
00338         self.text = None

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._table_repl (   self,
  groups 
) [private]

Definition at line 278 of file _creole.py.

00278 
00279     def _table_repl(self, groups):
00280         row = groups.get('table', '|').strip()
00281         self.cur = self._upto(self.cur, (
00282             'table', 'document', 'section', 'blockquote'))
00283         if self.cur.kind != 'table':
00284             self.cur = DocNode('table', self.cur)
00285         tb = self.cur
00286         tr = DocNode('table_row', tb)
00287 
00288         text = ''
00289         for m in self.cell_re.finditer(row):
00290             cell = m.group('cell')
00291             if cell:
00292                 self.cur = DocNode('table_cell', tr)
00293                 self.text = None
00294                 self.parse_inline(cell)
00295             else:
00296                 cell = m.group('head')
00297                 self.cur = DocNode('table_head', tr)
00298                 self.text = DocNode('text', self.cur, u'')
00299                 self.text.content = cell.strip('=')
00300         self.cur = tb
00301         self.text = None

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._text_repl (   self,
  groups 
) [private]

Definition at line 261 of file _creole.py.

00261 
00262     def _text_repl(self, groups):
00263         text = groups.get('text', '')
00264         if self.cur.kind in ('table', 'table_row', 'bullet_list',
00265             'number_list'):
00266             self.cur = self._upto(self.cur,
00267                 ('document', 'section', 'blockquote'))
00268         if self.cur.kind in ('document', 'section', 'blockquote'):
00269             self.cur = DocNode('paragraph', self.cur)
00270         else:
00271             text = u' ' + text
00272         self.parse_inline(text)
00273         if groups.get('break') and self.cur.kind in ('paragraph',
00274             'emphasis', 'strong', 'code'):
00275             DocNode('break', self.cur, '')
        self.text = None

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser._upto (   self,
  node,
  kinds 
) [private]
Look up the tree to the first occurence
of one of the listed kinds of nodes or root.
Start at the node node.

Definition at line 146 of file _creole.py.

00146 
00147     def _upto(self, node, kinds):
00148         """
00149         Look up the tree to the first occurence
00150         of one of the listed kinds of nodes or root.
00151         Start at the node node.
00152         """
00153         while node.parent is not None and not node.kind in kinds:
00154             node = node.parent
00155         return node

Here is the caller graph for this function:

def MoinMoin.parser._creole.Parser._url_repl (   self,
  groups 
) [private]
Handle raw urls in text.

Definition at line 159 of file _creole.py.

00159 
00160     def _url_repl(self, groups):
00161         """Handle raw urls in text."""
00162 
00163         if not groups.get('escaped_url'):
00164             # this url is NOT escaped
00165             target = groups.get('url_target', '')
00166             node = DocNode('link', self.cur)
00167             node.content = target
00168             DocNode('text', node, node.content)
00169             self.text = None
00170         else:
00171             # this url is escaped, we render it as text
00172             if self.text is None:
00173                 self.text = DocNode('text', self.cur, u'')
            self.text.content += groups.get('url_target')
Parse the text given as self.raw and return DOM tree.

Definition at line 373 of file _creole.py.

00373 
00374     def parse(self):
00375         """Parse the text given as self.raw and return DOM tree."""
00376 
00377         self.parse_block(self.raw)
00378         return self.root

Here is the call graph for this function:

def MoinMoin.parser._creole.Parser.parse_block (   self,
  raw 
)
Recognize block elements.

Definition at line 368 of file _creole.py.

00368 
00369     def parse_block(self, raw):
00370         """Recognize block elements."""
00371 
00372         re.sub(self.block_re, self._replace, raw)

Here is the call graph for this function:

Here is the caller graph for this function:

Recognize inline elements inside blocks.

Definition at line 363 of file _creole.py.

00363 
00364     def parse_inline(self, raw):
00365         """Recognize inline elements inside blocks."""
00366 
00367         re.sub(self.inline_re, self._replace, raw)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 276 of file _creole.py.

Definition at line 323 of file _creole.py.

Definition at line 322 of file _creole.py.

Definition at line 176 of file _creole.py.

Definition at line 258 of file _creole.py.

Definition at line 259 of file _creole.py.

Definition at line 214 of file _creole.py.

Definition at line 215 of file _creole.py.

Definition at line 248 of file _creole.py.

Definition at line 247 of file _creole.py.

Definition at line 190 of file _creole.py.

Definition at line 191 of file _creole.py.

Definition at line 203 of file _creole.py.

Definition at line 202 of file _creole.py.

Definition at line 204 of file _creole.py.

Definition at line 313 of file _creole.py.

Definition at line 314 of file _creole.py.

Definition at line 312 of file _creole.py.

Definition at line 175 of file _creole.py.

Definition at line 174 of file _creole.py.

Initial value:
re.compile('|'.join([Rules.line, Rules.head, Rules.separator,
        Rules.pre, Rules.list, Rules.table, Rules.text]), re.X | re.U | re.M)

Definition at line 133 of file _creole.py.

tuple MoinMoin.parser._creole.Parser.cell_re = re.compile(Rules.cell, re.X | re.U) [static]

Definition at line 131 of file _creole.py.

Definition at line 143 of file _creole.py.

Initial value:
re.compile('|'.join([Rules.link, Rules.url, Rules.macro,
        Rules.code, Rules.image, Rules.strong, Rules.emph, Rules.linebreak,
        Rules.escape, Rules.char]), re.X | re.U)

Definition at line 136 of file _creole.py.

tuple MoinMoin.parser._creole.Parser.item_re = re.compile(Rules.item, re.X | re.U | re.M) [static]

Definition at line 130 of file _creole.py.

tuple MoinMoin.parser._creole.Parser.link_re = re.compile('|'.join([Rules.image, Rules.linebreak, Rules.char]), re.X | re.U) [static]

Definition at line 129 of file _creole.py.

tuple MoinMoin.parser._creole.Parser.pre_escape_re = re.compile(Rules.pre_escape, re.M | re.X) [static]

Definition at line 128 of file _creole.py.

Definition at line 141 of file _creole.py.

Definition at line 142 of file _creole.py.

Definition at line 144 of file _creole.py.


The documentation for this class was generated from the following file: