Pygments
Available lexers
« Back To IndexContents
- Lexers for agile languages
- Lexers for assembly languages
- Lexers for compiled languages
- Lexers for .net languages
- Lexers for functional languages
- Lexers for math languages
- Lexers for other languages
- Lexers for parser generators
- Special lexers
- Lexers for various template engines' markup
- Lexers for non-source code file types
- Lexers for web-related languages and markup
- Iterating over all lexers
This page lists all available builtin lexers and the options they take.
Currently, all lexers support these options:
- stripnl
- Strip leading and trailing newlines from the input (default: True)
- stripall
- Strip all leading and trailing whitespace from the input (default: False).
- tabsize
- If given and greater than 0, expand tabs in the input (default: 0).
- encoding
New in Pygments 0.6.
If given, must be an encoding name (such as "utf-8"). This encoding will be used to convert the input string to Unicode (if it is not already a Unicode string). The default is "latin1".
If this option is set to "guess", a simple UTF-8 vs. Latin-1 detection is used, if it is set to "chardet", the chardet library is used to guess the encoding of the input.
The "Short Names" field lists the identifiers that can be used with the get_lexer_by_name() function.
These lexers are builtin and can be imported from pygments.lexers:
Lexers for agile languages
ClojureLexer
Lexer for Clojure source code.
New in Pygments 0.11.
Short names: clojure, clj Filename patterns: *.clj Mimetypes: text/x-clojure, application/x-clojure
IoLexer
For Io (a small, prototype-based programming language) source.
New in Pygments 0.10.
Short names: io Filename patterns: *.io Mimetypes: text/x-iosrc
LuaLexer
For Lua source code.
Additional options accepted:
- func_name_highlighting
- If given and True, highlight builtin function names (default: True).
- disabled_modules
If given, must be a list of module names whose function names should not be highlighted. By default all modules are highlighted.
To get a list of allowed modules have a look into the _luabuiltins module:
>>> from pygments.lexers._luabuiltins import MODULES >>> MODULES.keys() ['string', 'coroutine', 'modules', 'io', 'basic', ...]
Short names: lua Filename patterns: *.lua Mimetypes: text/x-lua, application/x-lua
MiniDLexer
For MiniD (a D-like scripting language) source.
Short names: minid Filename patterns: *.md Mimetypes: text/x-minidsrc
PerlLexer
For Perl source code.
Short names: perl, pl Filename patterns: *.pl, *.pm Mimetypes: text/x-perl, application/x-perl
Python3Lexer
For Python source code (version 3.0).
New in Pygments 0.10.
Short names: python3, py3 Filename patterns: None Mimetypes: text/x-python3, application/x-python3
Python3TracebackLexer
For Python 3.0 tracebacks, with support for chained exceptions.
New in Pygments 1.0.
Short names: py3tb Filename patterns: *.py3tb Mimetypes: text/x-python3-traceback
PythonConsoleLexer
For Python console output or doctests, such as:
>>> a = 'foo' >>> print a foo >>> 1 / 0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: integer division or modulo by zeroAdditional options:
- python3
- Use Python 3 lexer for code. Default is False. New in Pygments 1.0.
Short names: pycon Filename patterns: None Mimetypes: text/x-python-doctest
PythonLexer
For Python source code.
Short names: python, py Filename patterns: *.py, *.pyw, *.sc, SConstruct, SConscript Mimetypes: text/x-python, application/x-python
PythonTracebackLexer
For Python tracebacks.
New in Pygments 0.7.
Short names: pytb Filename patterns: *.pytb Mimetypes: text/x-python-traceback
RubyConsoleLexer
For Ruby interactive console (irb) output like:
irb(main):001:0> a = 1 => 1 irb(main):002:0> puts a 1 => nil
Short names: rbcon, irb Filename patterns: None Mimetypes: text/x-ruby-shellsession
RubyLexer
For Ruby source code.
Short names: rb, ruby Filename patterns: *.rb, *.rbw, Rakefile, *.rake, *.gemspec, *.rbx Mimetypes: text/x-ruby, application/x-ruby
TclLexer
For Tcl source code.
New in Pygments 0.10.
Short names: tcl Filename patterns: *.tcl Mimetypes: text/x-tcl, text/x-script.tcl, application/x-tcl
Lexers for assembly languages
CObjdumpLexer
For the output of 'objdump -Sr on compiled C files'
Short names: c-objdump Filename patterns: *.c-objdump Mimetypes: text/x-c-objdump
CppObjdumpLexer
For the output of 'objdump -Sr on compiled C++ files'
Short names: cpp-objdump, c++-objdumb, cxx-objdump Filename patterns: *.cpp-objdump, *.c++-objdump, *.cxx-objdump Mimetypes: text/x-cpp-objdump
DObjdumpLexer
For the output of 'objdump -Sr on compiled D files'
Short names: d-objdump Filename patterns: *.d-objdump Mimetypes: text/x-d-objdump
GasLexer
For Gas (AT&T) assembly code.
Short names: gas Filename patterns: *.s, *.S Mimetypes: text/x-gas
LlvmLexer
For LLVM assembly code.
Short names: llvm Filename patterns: *.ll Mimetypes: text/x-llvm
NasmLexer
For Nasm (Intel) assembly code.
Short names: nasm Filename patterns: *.asm, *.ASM Mimetypes: text/x-nasm
ObjdumpLexer
For the output of 'objdump -dr'
Short names: objdump Filename patterns: *.objdump Mimetypes: text/x-objdump
Lexers for compiled languages
CLexer
For C source code with preprocessor directives.
Short names: c Filename patterns: *.c, *.h Mimetypes: text/x-chdr, text/x-csrc
CppLexer
For C++ source code with preprocessor directives.
Short names: cpp, c++ Filename patterns: *.cpp, *.hpp, *.c++, *.h++, *.cc, *.hh, *.cxx, *.hxx Mimetypes: text/x-c++hdr, text/x-c++src
CythonLexer
For Pyrex and Cython source code.
New in Pygments 1.1.
Short names: cython, pyx Filename patterns: *.pyx, *.pxd, *.pxi Mimetypes: text/x-cython, application/x-cython
DLexer
For D source.
Short names: d Filename patterns: *.d, *.di Mimetypes: text/x-dsrc
DelphiLexer
For Delphi (Borland Object Pascal), Turbo Pascal and Free Pascal source code.
Additional options accepted:
- turbopascal
- Highlight Turbo Pascal specific keywords (default: True).
- delphi
- Highlight Borland Delphi specific keywords (default: True).
- freepascal
- Highlight Free Pascal specific keywords (default: True).
- units
- A list of units that should be considered builtin, supported are System, SysUtils, Classes and Math. Default is to consider all of them builtin.
Short names: delphi, pas, pascal, objectpascal Filename patterns: *.pas Mimetypes: text/x-pascal
DylanLexer
For the Dylan language.
New in Pygments 0.7.
Short names: dylan Filename patterns: *.dylan Mimetypes: text/x-dylan
FortranLexer
Lexer for FORTRAN 90 code.
New in Pygments 0.10.
Short names: fortran Filename patterns: *.f, *.f90 Mimetypes: text/x-fortran
GLShaderLexer
GLSL (OpenGL Shader) lexer.
New in Pygments 1.1.
Short names: glsl Filename patterns: *.vert, *.frag, *.geo Mimetypes: text/x-glslsrc
JavaLexer
For Java source code.
Short names: java Filename patterns: *.java Mimetypes: text/x-java
ObjectiveCLexer
For Objective-C source code with preprocessor directives.
Short names: objective-c, objectivec, obj-c, objc Filename patterns: *.m Mimetypes: text/x-objective-c
PrologLexer
Lexer for Prolog files.
Short names: prolog Filename patterns: *.prolog, *.pro, *.pl Mimetypes: text/x-prolog
ScalaLexer
For Scala source code.
Short names: scala Filename patterns: *.scala Mimetypes: text/x-scala
ValaLexer
For Vala source code with preprocessor directives.
New in Pygments 1.1.
Short names: vala, vapi Filename patterns: *.vala, *.vapi Mimetypes: text/x-vala
Lexers for .net languages
BooLexer
For Boo source code.
Short names: boo Filename patterns: *.boo Mimetypes: text/x-boo
CSharpAspxLexer
Lexer for highligting C# within ASP.NET pages.
Short names: aspx-cs Filename patterns: *.aspx, *.asax, *.ascx, *.ashx, *.asmx, *.axd Mimetypes: None
CSharpLexer
For C# source code.
Additional options accepted:
- unicodelevel
Determines which Unicode characters this lexer allows for identifiers. The possible values are:
- none -- only the ASCII letters and numbers are allowed. This is the fastest selection.
- basic -- all Unicode characters from the specification except category Lo are allowed.
- full -- all Unicode characters as specified in the C# specs are allowed. Note that this means a considerable slowdown since the Lo category has more than 40,000 characters in it!
The default value is basic.
New in Pygments 0.8.
Short names: csharp, c# Filename patterns: *.cs Mimetypes: text/x-csharp
VbNetAspxLexer
Lexer for highligting Visual Basic.net within ASP.NET pages.
Short names: aspx-vb Filename patterns: *.aspx, *.asax, *.ascx, *.ashx, *.asmx, *.axd Mimetypes: None
VbNetLexer
For Visual Basic.NET source code.
Short names: vb.net, vbnet Filename patterns: *.vb, *.bas Mimetypes: text/x-vbnet, text/x-vba
Lexers for functional languages
CommonLispLexer
A Common Lisp lexer.
New in Pygments 0.9.
Short names: common-lisp, cl Filename patterns: *.cl, *.lisp, *.el Mimetypes: text/x-common-lisp
ErlangLexer
For the Erlang functional programming language.
Blame Jeremy Thurgood (http://jerith.za.net/).
New in Pygments 0.9.
Short names: erlang Filename patterns: *.erl, *.hrl Mimetypes: text/x-erlang
ErlangShellLexer
Shell sessions in erl (for Erlang code).
New in Pygments 1.1.
Short names: erl Filename patterns: *.erl-sh Mimetypes: text/x-erl-shellsession
HaskellLexer
A Haskell lexer based on the lexemes defined in the Haskell 98 Report.
New in Pygments 0.8.
Short names: haskell, hs Filename patterns: *.hs Mimetypes: text/x-haskell
LiterateHaskellLexer
For Literate Haskell (Bird-style or LaTeX) source.
Additional options accepted:
- litstyle
- If given, must be "bird" or "latex". If not given, the style is autodetected: if the first non-whitespace character in the source is a backslash or percent character, LaTeX is assumed, else Bird.
New in Pygments 0.9.
Short names: lhs, literate-haskell Filename patterns: *.lhs Mimetypes: text/x-literate-haskell
OcamlLexer
For the OCaml language.
New in Pygments 0.7.
Short names: ocaml Filename patterns: *.ml, *.mli, *.mll, *.mly Mimetypes: text/x-ocaml
SchemeLexer
A Scheme lexer, parsing a stream and outputting the tokens needed to highlight scheme code. This lexer could be most probably easily subclassed to parse other LISP-Dialects like Common Lisp, Emacs Lisp or AutoLisp.
This parser is checked with pastes from the LISP pastebin at http://paste.lisp.org/ to cover as much syntax as possible.
It supports the full Scheme syntax as defined in R5RS.
New in Pygments 0.6.
Short names: scheme, scm Filename patterns: *.scm Mimetypes: text/x-scheme, application/x-scheme
Lexers for math languages
MatlabLexer
For Matlab (or GNU Octave) source code. Contributed by Ken Schutte <kschutte@csail.mit.edu>.
New in Pygments 0.10.
Short names: matlab, octave Filename patterns: *.m Mimetypes: text/matlab
MatlabSessionLexer
For Matlab (or GNU Octave) sessions. Modeled after PythonConsoleLexer. Contributed by Ken Schutte <kschutte@csail.mit.edu>.
New in Pygments 0.10.
Short names: matlabsession Filename patterns: None Mimetypes: None
MuPADLexer
A MuPAD lexer. Contributed by Christopher Creutzig <christopher@creutzig.de>.
New in Pygments 0.8.
Short names: mupad Filename patterns: *.mu Mimetypes: None
NumPyLexer
A Python lexer recognizing Numerical Python builtins.
New in Pygments 0.10.
Short names: numpy Filename patterns: None Mimetypes: None
SLexer
For S, S-plus, and R source code.
New in Pygments 0.10.
Short names: splus, s, r Filename patterns: *.S, *.R Mimetypes: text/S-plus, text/S, text/R
Lexers for other languages
ABAPLexer
Lexer for ABAP, SAP's integrated language.
New in Pygments 1.1.
Short names: abap Filename patterns: *.abap Mimetypes: text/x-abap
AppleScriptLexer
For AppleScript source code, including AppleScript Studio. Contributed by Andreas Amann <aamann@mac.com>.
Short names: applescript Filename patterns: *.applescript Mimetypes: None
BashLexer
Lexer for (ba)sh shell scripts.
New in Pygments 0.6.
Short names: bash, sh Filename patterns: *.sh, *.ebuild, *.eclass Mimetypes: application/x-sh, application/x-shellscript
BashSessionLexer
Lexer for simplistic shell sessions.
New in Pygments 1.1.
Short names: console Filename patterns: *.sh-session Mimetypes: application/x-shell-session
BatchLexer
Lexer for the DOS/Windows Batch file format.
New in Pygments 0.7.
Short names: bat Filename patterns: *.bat, *.cmd Mimetypes: application/x-dos-batch
BefungeLexer
Lexer for the esoteric Befunge language.
New in Pygments 0.7.
Short names: befunge Filename patterns: *.befunge Mimetypes: application/x-befunge
BrainfuckLexer
Lexer for the esoteric BrainFuck language.
Short names: brainfuck, bf Filename patterns: *.bf, *.b Mimetypes: application/x-brainfuck
GnuplotLexer
For Gnuplot plotting scripts.
New in Pygments 0.11.
Short names: gnuplot Filename patterns: *.plot, *.plt Mimetypes: text/x-gnuplot
LogtalkLexer
For Logtalk source code.
New in Pygments 0.10.
Short names: logtalk Filename patterns: *.lgt Mimetypes: text/x-logtalk
MOOCodeLexer
For MOOCode (the MOO scripting language).
New in Pygments 0.9.
Short names: moocode Filename patterns: *.moo Mimetypes: text/x-moocode
ModelicaLexer
For Modelica source code.
New in Pygments 1.1.
Short names: modelica Filename patterns: *.mo Mimetypes: text/x-modelica
MySqlLexer
Special lexer for MySQL.
Short names: mysql Filename patterns: None Mimetypes: text/x-mysql
NewspeakLexer
For Newspeak <http://newspeaklanguage.org/> syntax.
Short names: newspeak Filename patterns: *.ns2 Mimetypes: text/x-newspeak
PovrayLexer
For Persistence of Vision Raytracer files.
New in Pygments 0.11.
Short names: pov Filename patterns: *.pov, *.inc Mimetypes: text/x-povray
RebolLexer
A REBOL lexer.
New in Pygments 1.1.
Short names: rebol Filename patterns: *.r, *.r3 Mimetypes: text/x-rebol
RedcodeLexer
A simple Redcode lexer based on ICWS'94. Contributed by Adam Blinkinsop <blinks@acm.org>.
New in Pygments 0.8.
Short names: redcode Filename patterns: *.cw Mimetypes: None
SmalltalkLexer
For Smalltalk syntax. Contributed by Stefan Matthias Aust. Rewritten by Nils Winter.
New in Pygments 0.10.
Short names: smalltalk, squeak Filename patterns: *.st Mimetypes: text/x-smalltalk
SqlLexer
Lexer for Structured Query Language. Currently, this lexer does not recognize any special syntax except ANSI SQL.
Short names: sql Filename patterns: *.sql Mimetypes: text/x-sql
SqliteConsoleLexer
Lexer for example sessions using sqlite3.
New in Pygments 0.11.
Short names: sqlite3 Filename patterns: *.sqlite3-console Mimetypes: text/x-sqlite3-console
TcshLexer
Lexer for tcsh scripts.
New in Pygments 0.10.
Short names: tcsh, csh Filename patterns: *.tcsh, *.csh Mimetypes: application/x-csh
Lexers for parser generators
AntlrActionScriptLexer
ANTLR with ActionScript Target
New in Pygments 1.1.
Short names: antlr-as, antlr-actionscript Filename patterns: *.G, *.g Mimetypes: None
AntlrCSharpLexer
ANTLR with C# Target
New in Pygments 1.1.
Short names: antlr-csharp, antlr-c# Filename patterns: *.G, *.g Mimetypes: None
AntlrCppLexer
ANTLR with CPP Target
New in Pygments 1.1.
Short names: antlr-cpp Filename patterns: *.G, *.g Mimetypes: None
AntlrJavaLexer
ANTLR with Java Target
New in Pygments 1.1
Short names: antlr-java Filename patterns: *.G, *.g Mimetypes: None
AntlrLexer
Generic ANTLR Lexer. Should not be called directly, instead use DelegatingLexer for your target language.
New in Pygments 1.1.
Short names: antlr Filename patterns: None Mimetypes: None
AntlrObjectiveCLexer
ANTLR with Objective-C Target
New in Pygments 1.1.
Short names: antlr-objc Filename patterns: *.G, *.g Mimetypes: None
AntlrPerlLexer
ANTLR with Perl Target
New in Pygments 1.1.
Short names: antlr-perl Filename patterns: *.G, *.g Mimetypes: None
AntlrPythonLexer
ANTLR with Python Target
New in Pygments 1.1.
Short names: antlr-python Filename patterns: *.G, *.g Mimetypes: None
AntlrRubyLexer
ANTLR with Ruby Target
New in Pygments 1.1.
Short names: antlr-ruby, antlr-rb Filename patterns: *.G, *.g Mimetypes: None
RagelCLexer
A lexer for Ragel in a C host file.
New in Pygments 1.1.
Short names: ragel-c Filename patterns: *.rl Mimetypes: None
RagelCppLexer
A lexer for Ragel in a CPP host file.
New in Pygments 1.1.
Short names: ragel-cpp Filename patterns: *.rl Mimetypes: None
RagelDLexer
A lexer for Ragel in a D host file.
New in Pygments 1.1.
Short names: ragel-d Filename patterns: *.rl Mimetypes: None
RagelEmbeddedLexer
A lexer for Ragel embedded in a host language file.
This will only highlight Ragel statements. If you want host language highlighting then call the language-specific Ragel lexer.
New in Pygments 1.1.
Short names: ragel-em Filename patterns: *.rl Mimetypes: None
RagelJavaLexer
A lexer for Ragel in a Java host file.
New in Pygments 1.1.
Short names: ragel-java Filename patterns: *.rl Mimetypes: None
RagelLexer
A pure Ragel lexer. Use this for fragments of Ragel. For .rl files, use RagelEmbeddedLexer instead (or one of the language-specific subclasses).
New in Pygments 1.1.
Short names: ragel Filename patterns: None Mimetypes: None
RagelObjectiveCLexer
A lexer for Ragel in an Objective C host file.
New in Pygments 1.1.
Short names: ragel-objc Filename patterns: *.rl Mimetypes: None
RagelRubyLexer
A lexer for Ragel in a Ruby host file.
New in Pygments 1.1.
Short names: ragel-ruby, ragel-rb Filename patterns: *.rl Mimetypes: None
Special lexers
RawTokenLexer
Recreate a token stream formatted with the RawTokenFormatter. This lexer raises exceptions during parsing if the token stream in the file is malformed.
Additional options accepted:
- compress
- If set to "gz" or "bz2", decompress the token stream with the given compression algorithm before lexing (default: "").
Short names: raw Filename patterns: None Mimetypes: application/x-pygments-tokens
TextLexer
"Null" lexer, doesn't highlight anything.
Short names: text Filename patterns: *.txt Mimetypes: text/plain
Lexers for various template engines' markup
CheetahHtmlLexer
Subclass of the CheetahLexer that highlights unlexer data with the HtmlLexer.
Short names: html+cheetah, html+spitfire Filename patterns: None Mimetypes: text/html+cheetah, text/html+spitfire
CheetahJavascriptLexer
Subclass of the CheetahLexer that highlights unlexer data with the JavascriptLexer.
Short names: js+cheetah, javascript+cheetah, js+spitfire, javascript+spitfire Filename patterns: None Mimetypes: application/x-javascript+cheetah, text/x-javascript+cheetah, text/javascript+cheetah, application/x-javascript+spitfire, text/x-javascript+spitfire, text/javascript+spitfire
CheetahLexer
Generic cheetah templates lexer. Code that isn't Cheetah markup is yielded as Token.Other. This also works for spitfire templates which use the same syntax.
Short names: cheetah, spitfire Filename patterns: *.tmpl, *.spt Mimetypes: application/x-cheetah, application/x-spitfire
CheetahXmlLexer
Subclass of the CheetahLexer that highlights unlexer data with the XmlLexer.
Short names: xml+cheetah, xml+spitfire Filename patterns: None Mimetypes: application/xml+cheetah, application/xml+spitfire
CssDjangoLexer
Subclass of the DjangoLexer that highlights unlexed data with the CssLexer.
Short names: css+django, css+jinja Filename patterns: None Mimetypes: text/css+django, text/css+jinja
CssErbLexer
Subclass of ErbLexer which highlights unlexed data with the CssLexer.
Short names: css+erb, css+ruby Filename patterns: None Mimetypes: text/css+ruby
CssGenshiLexer
A lexer that highlights CSS definitions in genshi text templates.
Short names: css+genshitext, css+genshi Filename patterns: None Mimetypes: text/css+genshi
CssPhpLexer
Subclass of PhpLexer which highlights unmatched data with the CssLexer.
Short names: css+php Filename patterns: None Mimetypes: text/css+php
CssSmartyLexer
Subclass of the SmartyLexer that highlights unlexed data with the CssLexer.
Short names: css+smarty Filename patterns: None Mimetypes: text/css+smarty
DjangoLexer
Generic django and jinja template lexer.
It just highlights django/jinja code between the preprocessor directives, other data is left untouched by the lexer.
Short names: django, jinja Filename patterns: None Mimetypes: application/x-django-templating, application/x-jinja
ErbLexer
Generic ERB (Ruby Templating) lexer.
Just highlights ruby code between the preprocessor directives, other data is left untouched by the lexer.
All options are also forwarded to the RubyLexer.
Short names: erb Filename patterns: None Mimetypes: application/x-ruby-templating
EvoqueHtmlLexer
Subclass of the EvoqueLexer that highlights unlexed data with the HtmlLexer.
New in Pygments 1.1.
Short names: html+evoque Filename patterns: *.html Mimetypes: text/html+evoque
EvoqueLexer
For files using the Evoque templating system.
New in Pygments 1.1.
Short names: evoque Filename patterns: *.evoque Mimetypes: application/x-evoque
EvoqueXmlLexer
Subclass of the EvoqueLexer that highlights unlexed data with the XmlLexer.
New in Pygments 1.1.
Short names: xml+evoque Filename patterns: *.xml Mimetypes: application/xml+evoque
GenshiLexer
A lexer that highlights genshi and kid kid XML templates.
Short names: genshi, kid, xml+genshi, xml+kid Filename patterns: *.kid Mimetypes: application/x-genshi, application/x-kid
GenshiTextLexer
A lexer that highlights genshi text templates.
Short names: genshitext Filename patterns: None Mimetypes: application/x-genshi-text, text/x-genshi
HtmlDjangoLexer
Subclass of the DjangoLexer that highighlights unlexed data with the HtmlLexer.
Nested Javascript and CSS is highlighted too.
Short names: html+django, html+jinja Filename patterns: None Mimetypes: text/html+django, text/html+jinja
HtmlGenshiLexer
A lexer that highlights genshi and kid kid HTML templates.
Short names: html+genshi, html+kid Filename patterns: None Mimetypes: text/html+genshi
HtmlPhpLexer
Subclass of PhpLexer that highlights unhandled data with the HtmlLexer.
Nested Javascript and CSS is highlighted too.
Short names: html+php Filename patterns: *.phtml Mimetypes: application/x-php, application/x-httpd-php, application/x-httpd-php3, application/x-httpd-php4, application/x-httpd-php5
HtmlSmartyLexer
Subclass of the SmartyLexer that highighlights unlexed data with the HtmlLexer.
Nested Javascript and CSS is highlighted too.
Short names: html+smarty Filename patterns: None Mimetypes: text/html+smarty
JavascriptDjangoLexer
Subclass of the DjangoLexer that highlights unlexed data with the JavascriptLexer.
Short names: js+django, javascript+django, js+jinja, javascript+jinja Filename patterns: None Mimetypes: application/x-javascript+django, application/x-javascript+jinja, text/x-javascript+django, text/x-javascript+jinja, text/javascript+django, text/javascript+jinja
JavascriptErbLexer
Subclass of ErbLexer which highlights unlexed data with the JavascriptLexer.
Short names: js+erb, javascript+erb, js+ruby, javascript+ruby Filename patterns: None Mimetypes: application/x-javascript+ruby, text/x-javascript+ruby, text/javascript+ruby
JavascriptGenshiLexer
A lexer that highlights javascript code in genshi text templates.
Short names: js+genshitext, js+genshi, javascript+genshitext, javascript+genshi Filename patterns: None Mimetypes: application/x-javascript+genshi, text/x-javascript+genshi, text/javascript+genshi
JavascriptPhpLexer
Subclass of PhpLexer which highlights unmatched data with the JavascriptLexer.
Short names: js+php, javascript+php Filename patterns: None Mimetypes: application/x-javascript+php, text/x-javascript+php, text/javascript+php
JavascriptSmartyLexer
Subclass of the SmartyLexer that highlights unlexed data with the JavascriptLexer.
Short names: js+smarty, javascript+smarty Filename patterns: None Mimetypes: application/x-javascript+smarty, text/x-javascript+smarty, text/javascript+smarty
JspLexer
Lexer for Java Server Pages.
New in Pygments 0.7.
Short names: jsp Filename patterns: *.jsp Mimetypes: application/x-jsp
MakoCssLexer
Subclass of the MakoLexer that highlights unlexer data with the CssLexer.
New in Pygments 0.7.
Short names: css+mako Filename patterns: None Mimetypes: text/css+mako
MakoHtmlLexer
Subclass of the MakoLexer that highlights unlexed data with the HtmlLexer.
New in Pygments 0.7.
Short names: html+mako Filename patterns: None Mimetypes: text/html+mako
MakoJavascriptLexer
Subclass of the MakoLexer that highlights unlexer data with the JavascriptLexer.
New in Pygments 0.7.
Short names: js+mako, javascript+mako Filename patterns: None Mimetypes: application/x-javascript+mako, text/x-javascript+mako, text/javascript+mako
MakoLexer
Generic mako templates lexer. Code that isn't Mako markup is yielded as Token.Other.
New in Pygments 0.7.
Short names: mako Filename patterns: *.mao Mimetypes: application/x-mako
MakoXmlLexer
Subclass of the MakoLexer that highlights unlexer data with the XmlLexer.
New in Pygments 0.7.
Short names: xml+mako Filename patterns: None Mimetypes: application/xml+mako
MyghtyCssLexer
Subclass of the MyghtyLexer that highlights unlexer data with the CssLexer.
New in Pygments 0.6.
Short names: css+myghty Filename patterns: None Mimetypes: text/css+myghty
MyghtyHtmlLexer
Subclass of the MyghtyLexer that highlights unlexer data with the HtmlLexer.
New in Pygments 0.6.
Short names: html+myghty Filename patterns: None Mimetypes: text/html+myghty
MyghtyJavascriptLexer
Subclass of the MyghtyLexer that highlights unlexer data with the JavascriptLexer.
New in Pygments 0.6.
Short names: js+myghty, javascript+myghty Filename patterns: None Mimetypes: application/x-javascript+myghty, text/x-javascript+myghty, text/javascript+mygthy
MyghtyLexer
Generic myghty templates lexer. Code that isn't Myghty markup is yielded as Token.Other.
New in Pygments 0.6.
Short names: myghty Filename patterns: *.myt, autodelegate Mimetypes: application/x-myghty
MyghtyXmlLexer
Subclass of the MyghtyLexer that highlights unlexer data with the XmlLexer.
New in Pygments 0.6.
Short names: xml+myghty Filename patterns: None Mimetypes: application/xml+myghty
RhtmlLexer
Subclass of the ERB lexer that highlights the unlexed data with the html lexer.
Nested Javascript and CSS is highlighted too.
Short names: rhtml, html+erb, html+ruby Filename patterns: *.rhtml Mimetypes: text/html+ruby
SmartyLexer
Generic Smarty template lexer.
Just highlights smarty code between the preprocessor directives, other data is left untouched by the lexer.
Short names: smarty Filename patterns: *.tpl Mimetypes: application/x-smarty
XmlDjangoLexer
Subclass of the DjangoLexer that highlights unlexed data with the XmlLexer.
Short names: xml+django, xml+jinja Filename patterns: None Mimetypes: application/xml+django, application/xml+jinja
XmlErbLexer
Subclass of ErbLexer which highlights data outside preprocessor directives with the XmlLexer.
Short names: xml+erb, xml+ruby Filename patterns: None Mimetypes: application/xml+ruby
XmlPhpLexer
Subclass of PhpLexer that higlights unhandled data with the XmlLexer.
Short names: xml+php Filename patterns: None Mimetypes: application/xml+php
XmlSmartyLexer
Subclass of the SmartyLexer that highlights unlexed data with the XmlLexer.
Short names: xml+smarty Filename patterns: None Mimetypes: application/xml+smarty
Lexers for non-source code file types
ApacheConfLexer
Lexer for configuration files following the Apache config file format.
New in Pygments 0.6.
Short names: apacheconf, aconf, apache Filename patterns: .htaccess, apache.conf, apache2.conf Mimetypes: text/x-apacheconf
BBCodeLexer
A lexer that highlights BBCode(-like) syntax.
New in Pygments 0.6.
Short names: bbcode Filename patterns: None Mimetypes: text/x-bbcode
BaseMakefileLexer
Lexer for simple Makefiles (no preprocessing).
New in Pygments 0.10.
Short names: basemake Filename patterns: None Mimetypes: None
DarcsPatchLexer
DarcsPatchLexer is a lexer for the various versions of the darcs patch format. Examples of this format are derived by commands such as darcs annotate --patch and darcs send.
New in Pygments 0.10.
Short names: dpatch Filename patterns: *.dpatch, *.darcspatch Mimetypes: None
DebianControlLexer
Lexer for Debian control files and apt-cache show <pkg> outputs.
New in Pygments 0.9.
Short names: control Filename patterns: control Mimetypes: None
DiffLexer
Lexer for unified or context-style diffs or patches.
Short names: diff, udiff Filename patterns: *.diff, *.patch Mimetypes: text/x-diff, text/x-patch
GettextLexer
Lexer for Gettext catalog files.
New in Pygments 0.9.
Short names: pot, po Filename patterns: *.pot, *.po Mimetypes: application/x-gettext, text/x-gettext, text/gettext
GroffLexer
Lexer for the (g)roff typesetting language, supporting groff extensions. Mainly useful for highlighting manpage sources.
New in Pygments 0.6.
Short names: groff, nroff, man Filename patterns: *.[1234567], *.man Mimetypes: application/x-troff, text/troff
IniLexer
Lexer for configuration files in INI style.
Short names: ini, cfg Filename patterns: *.ini, *.cfg, *.properties Mimetypes: text/x-ini
IrcLogsLexer
Lexer for IRC logs in irssi, xchat or weechat style.
Short names: irc Filename patterns: *.weechatlog Mimetypes: text/x-irclog
LighttpdConfLexer
Lexer for Lighttpd configuration files.
New in Pygments 0.11.
Short names: lighty, lighttpd Filename patterns: None Mimetypes: text/x-lighttpd-conf
MakefileLexer
Lexer for BSD and GNU make extensions (lenient enough to handle both in the same file even).
Rewritten in Pygments 0.10.
Short names: make, makefile, mf, bsdmake Filename patterns: *.mak, Makefile, makefile, Makefile.*, GNUmakefile Mimetypes: text/x-makefile
MoinWikiLexer
For MoinMoin (and Trac) Wiki markup.
New in Pygments 0.7.
Short names: trac-wiki, moin Filename patterns: None Mimetypes: text/x-trac-wiki
NginxConfLexer
Lexer for Nginx configuration files.
New in Pygments 0.11.
Short names: nginx Filename patterns: None Mimetypes: text/x-nginx-conf
RstLexer
For reStructuredText markup.
New in Pygments 0.7.
Additional options accepted:
- handlecodeblocks
- Highlight the contents of .. sourcecode:: langauge and .. code:: language directives with a lexer for the given language (default: True). New in Pygments 0.8.
Short names: rst, rest, restructuredtext Filename patterns: *.rst, *.rest Mimetypes: text/x-rst, text/prs.fallenstein.rst
SourcesListLexer
Lexer that highlights debian sources.list files.
New in Pygments 0.7.
Short names: sourceslist, sources.list Filename patterns: sources.list Mimetypes: None
SquidConfLexer
Lexer for squid configuration files.
New in Pygments 0.9.
Short names: squidconf, squid.conf, squid Filename patterns: squid.conf Mimetypes: text/x-squidconf
TexLexer
Lexer for the TeX and LaTeX typesetting languages.
Short names: tex, latex Filename patterns: *.tex, *.aux, *.toc Mimetypes: text/x-tex, text/x-latex
VimLexer
Lexer for VimL script files.
New in Pygments 0.8.
Short names: vim Filename patterns: *.vim, .vimrc Mimetypes: text/x-vim
YamlLexer
Lexer for YAML, a human-friendly data serialization language.
New in Pygments 0.11.
Short names: yaml Filename patterns: *.yaml, *.yml Mimetypes: text/x-yaml
Iterating over all lexers
New in Pygments 0.6.
To get all lexers (both the builtin and the plugin ones), you can use the get_all_lexers() function from the pygments.lexers module:
>>> from pygments.lexers import get_all_lexers >>> i = get_all_lexers() >>> i.next() ('Diff', ('diff',), ('*.diff', '*.patch'), ('text/x-diff', 'text/x-patch')) >>> i.next() ('Delphi', ('delphi', 'objectpascal', 'pas', 'pascal'), ('*.pas',), ('text/x-pascal',)) >>> i.next() ('XML+Ruby', ('xml+erb', 'xml+ruby'), (), ())
As you can see, the return value is an iterator which yields tuples in the form (name, aliases, filetypes, mimetypes).