(self, lines)
return text.split("\n")
Match and store Fenced Code Blocks in the HtmlStash.
Match and store Fenced Code Blocks in the HtmlStash.
Match and store Fenced Code Blocks in the HtmlStash .
def run(self, lines):
        """ Match and store Fenced Code Blocks in the HtmlStash. """

        # Check for code hilite extension
        if not self.checked_for_codehilite:
            for ext in self.markdown.registeredExtensions:
                if isinstance(ext, CodeHiliteExtension):
                    self.codehilite_conf = ext.config
                    break

            self.checked_for_codehilite = True

        text = "\n".join(lines)
        while 1:
            m = FENCED_BLOCK_RE.search(text)
            if m:
                lang = ''
                if m.group('lang'):
                    lang = LANG_TAG % m.group('lang')

                # If config is not empty, then the codehighlite extension
                # is enabled, so we call it to highlite the code
                if self.codehilite_conf:
                    highliter = CodeHilite(m.group('code'),
                            linenos=self.codehilite_conf['force_linenos'][0],
                            guess_lang=self.codehilite_conf['guess_lang'][0],
                            css_class=self.codehilite_conf['css_class'][0],
                            style=self.codehilite_conf['pygments_style'][0],
                            lang=(m.group('lang') or None),
                            noclasses=self.codehilite_conf['noclasses'][0])

                    code = highliter.hilite()
                else:
                    code = CODE_WRAP % (lang, self._escape(m.group('code')))

                placeholder = self.markdown.htmlStash.store(code, safe=True)
                text = '%s\n%s\n%s'% (text[:m.start()], placeholder, text[m.end():])
            else:
                break
        return text.split("\n")
def run ( self , lines ) : # Check for code hilite extension if not self . checked_for_codehilite : for ext in self . markdown . registeredExtensions : if isinstance ( ext , CodeHiliteExtension ) : self . codehilite_conf = ext . config break self . checked_for_codehilite = True text = "\n" . join ( lines ) while 1 : m = FENCED_BLOCK_RE . search ( text ) if m : lang = '' if m . group ( 'lang' ) : lang = LANG_TAG % m . group ( 'lang' ) # If config is not empty, then the codehighlite extension # is enabled, so we call it to highlite the code if self . codehilite_conf : highliter = CodeHilite ( m . group ( 'code' ) , linenos = self . codehilite_conf [ 'force_linenos' ] [ 0 ] , guess_lang = self . codehilite_conf [ 'guess_lang' ] [ 0 ] , css_class = self . codehilite_conf [ 'css_class' ] [ 0 ] , style = self . codehilite_conf [ 'pygments_style' ] [ 0 ] , lang = ( m . group ( 'lang' ) or None ) , noclasses = self . codehilite_conf [ 'noclasses' ] [ 0 ] ) code = highliter . hilite ( ) else : code = CODE_WRAP % ( lang , self . _escape ( m . group ( 'code' ) ) ) placeholder = self . markdown . htmlStash . store ( code , safe = True ) text = '%s\n%s\n%s' % ( text [ : m . start ( ) ] , placeholder , text [ m . end ( ) : ] ) else : break return text . split ( "\n" )