Logo Search packages:      
Sourcecode: zine version File versions  Download package

def markdown_parser::markdown::Markdown::_applyPattern (   self,
  line,
  pattern,
  patternIndex 
) [private]

Given a pattern name, this function checks if the line
fits the pattern, creates the necessary elements, and returns
back a list consisting of NanoDom elements and/or strings.

@param line: the text to be processed
@param pattern: the pattern to be checked

@returns: the appropriate newly created NanoDom element if the
  pattern matches, None otherwise.

Definition at line 1618 of file markdown.py.

01618                                                         :

        """ Given a pattern name, this function checks if the line
        fits the pattern, creates the necessary elements, and returns
        back a list consisting of NanoDom elements and/or strings.

        @param line: the text to be processed
        @param pattern: the pattern to be checked

        @returns: the appropriate newly created NanoDom element if the
                  pattern matches, None otherwise.
        """

        # match the line to pattern's pre-compiled reg exp.
        # if no match, move on.



        m = pattern.getCompiledRegExp().match(line)
        if not m:
            return None

        # if we got a match let the pattern make us a NanoDom node
        # if it doesn't, move on
        node = pattern.handleMatch(m, self.doc)

        # check if any of this nodes have children that need processing

        if isinstance(node, Element):

            if not node.nodeName in ["code", "pre"]:
                for child in node.childNodes:
                    if isinstance(child, TextNode):

                        result = self._handleInlineWrapper(child.value, patternIndex+1)

                        if result:

                            if result == [child]:
                                continue

                            result.reverse()
                            #to make insertion easier

                            position = node.childNodes.index(child)

                            node.removeChild(child)

                            for item in result:

                                if isinstance(item, (str, unicode)):
                                    if len(item) > 0:
                                        node.insertChild(position,
                                             self.doc.createTextNode(item))
                                else:
                                    node.insertChild(position, item)




        if node:
            # Those are in the reverse order!
            return ( m.groups()[-1], # the string to the left
                     node,           # the new node
                     m.group(1))     # the string to the right of the match

        else:
            return None

    def convert (self, source = None):


Generated by  Doxygen 1.6.0   Back to index