(self, src, language)
return lexer
Get the Pygments lexer.
Get the Pygments lexer.
Get the Pygments lexer .
def get_lexer(self, src, language):
        """Get the Pygments lexer."""

        if language:
            language, lexer_options = self.get_extended_language(language)
        else:
            lexer_options = {}

        # Try and get lexer by the name given.
        try:
            lexer = get_lexer_by_name(language, **lexer_options)
        except Exception:
            lexer = None

        if lexer is None:
            if self.guess_lang:
                try:
                    lexer = guess_lexer(src)
                except Exception:  # pragma: no cover
                    pass
        if lexer is None:
            lexer = get_lexer_by_name('text')
        return lexer
def get_lexer ( self , src , language ) : if language : language , lexer_options = self . get_extended_language ( language ) else : lexer_options = { } # Try and get lexer by the name given. try : lexer = get_lexer_by_name ( language , * * lexer_options ) except Exception : lexer = None if lexer is None : if self . guess_lang : try : lexer = guess_lexer ( src ) except Exception : # pragma: no cover pass if lexer is None : lexer = get_lexer_by_name ( 'text' ) return lexer