Back to index

moin  1.9.0~rc2
Public Member Functions | Static Private Attributes
MoinMoin.action.SlideShow.WikiSlideParser Class Reference

List of all members.

Public Member Functions

def parse

Static Private Attributes

tuple _heading_pattern = re.compile(r""" # TODO: check, mhz found bug here (?P<skip>{{{(?:.*\n)+?}}}) | # Match headings level 1 (?P<heading>^=\s(?P<text>.*)\s=$\n?) """, re.MULTILINE | re.UNICODE | re.VERBOSE)

Detailed Description

Parse slides using wiki format

Typical usage::
    for title, start, end in WikiSlideParser().parse(text):
        slides.append((title, start, end))

If you want to override this parser, you can add 'slideshow_wiki'
parser plugin, that provides a SlideParser class.

Definition at line 29 of file SlideShow.py.


Member Function Documentation

Parse slide data in text

Wiki slides are defined by the headings, ignoring the text
before the first heading. This parser finds all headings,
skipping headings in preformatted code areas.

Returns an iterator over slide data. For each slide, a tuple
(title, bodyStart, bodyEnd) is returned. bodyStart and bodyEnd
are indexes into text.

Definition at line 46 of file SlideShow.py.

00046 
00047     def parse(self, text):
00048         """ Parse slide data in text
00049 
00050         Wiki slides are defined by the headings, ignoring the text
00051         before the first heading. This parser finds all headings,
00052         skipping headings in preformatted code areas.
00053 
00054         Returns an iterator over slide data. For each slide, a tuple
00055         (title, bodyStart, bodyEnd) is returned. bodyStart and bodyEnd
00056         are indexes into text.
00057         """
00058         matches = [match for match in self._heading_pattern.finditer(text)
00059                    if match.start('skip') == -1]
00060 
00061         for i in range(len(matches)):
00062             title = matches[i].group('text').strip()
00063             bodyStart = matches[i].end('heading')
00064             try:
00065                 bodyEnd = matches[i + 1].start('heading')
00066             except IndexError:
00067                 bodyEnd = len(text)
00068             yield title, bodyStart, bodyEnd
00069 


Member Data Documentation

tuple MoinMoin.action.SlideShow.WikiSlideParser._heading_pattern = re.compile(r""" # TODO: check, mhz found bug here (?P<skip>{{{(?:.*\n)+?}}}) | # Match headings level 1 (?P<heading>^=\s(?P<text>.*)\s=$\n?) """, re.MULTILINE | re.UNICODE | re.VERBOSE) [static, private]

Definition at line 39 of file SlideShow.py.


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