euporie.core.lexers

Relating to lexers.

Functions

detect_lexer([text, path, language])

Detect the pygments lexer for a file.

get_lexer_by_name(_alias, **options)

Return an instance of a Lexer subclass that has alias in its aliases list.

get_lexer_for_filename(_fn[, code])

Get a lexer for a filename.

guess_lexer(_text, **options)

Return a Lexer subclass instance that's guessed from the text in text.

guess_lexer_for_filename(_fn, _text, **options)

As guess_lexer(), but only lexers which have a pattern in filenames or alias_filenames that matches filename are taken into consideration.

Exceptions

ClassNotFound

Raised if one of the lookup functions didn't find a matching class.

euporie.core.lexers.detect_lexer(text: str = '', path: Path | None = None, language: str = '') PygmentsLexerCls | None

Detect the pygments lexer for a file.