def handleMatch (self, m):
        """Add the class attribute to the generated <a> element"""

        ## Build the <a> element using the parent class
        elm = LinkPattern.handleMatch (self, m)

        ## Return the <a> element
        return add_class (elm, self.config)
Exemple #2
0
 def handleMatch(self, m):
     # get node
     node = LinkPattern.handleMatch(self, m)
     # get link href
     src = node.attrib.get('href')
     # if link is in assets process and update node with new url
     output_asset = self.asset_processor.asset_urlparse(src)
     if output_asset:
         node.attrib['href'] = output_asset
     return node
    def handleMatch (self, m):
        """Add the class attribute to the generated <a> element"""

        ## Build the <a> element using the parent class
        elm = LinkPattern.handleMatch (self, m)

        ## Add the appropriate class attribute
        m = re.match ('^https?://', elm.get ('href'))
        elm.set ('class',
                 m and self.config ['external-class']
                   or self.config ['internal-class'])

        ## Return the <a> element
        return elm
    def handleMatch(self, m):
        """Add the class attribute to the generated <a> element"""

        ## Build the <a> element using the parent class
        elm = LinkPattern.handleMatch(self, m)

        ## Add the appropriate class attribute
        m = re.match('^https?://', elm.get('href'))
        elm.set(
            'class', m and self.config['external-class']
            or self.config['internal-class'])

        ## Return the <a> element
        return elm
Exemple #5
0
    def handleMatch(self, m):
        node = LinkPattern.handleMatch(self, m)
        # check 'src' to ensure it is local
        src = node.attrib.get('href')
        scheme, netloc, path, params, query, fragment = urlparse(src)
        if scheme or netloc:
            return node

        if path.endswith('.md'):
            path = path[:-3]
        path_parts = path.split('/')
        if path_parts[-1] == 'index':
            path_parts = path_parts[:-1]
        current_path = self.requested_path[:]
        for path_part in path_parts:
            if path_part == '.' or path_part == '..':
                path_parts = path_parts[1:]
                current_path = current_path[:-1]

        url = url_for('blog_index', path='/'.join(current_path + path_parts),
                      _external=True, _anchor=fragment)
        node.set('href', url)
        return node
Exemple #6
0
    def handleMatch(self, m):
        node = LinkPattern.handleMatch(self, m)

        node.set('target', '_blank')

        return node