Pygments is a generic syntax highlighter written in Python
BSD-2-CLAUSE License
Bot releases are visible (Hide)
New lexers:
Android.bp
(#2659)Updated lexers:
openrc
alias (#2599, #2371)uninstantiation
keyword and recognizeNone
/True
/False
Token.Comment
for comments instead ofComment.Preproc
(#2598):
, ::
and ->
as Punctuation
Whitespace
, instead of Text
<?doc?>
and <?note?>
tags (#2597)kk-*
in variant_langs
(#2647)val
and var
(#2602)New styles:
Make background colors in the image formatter work with Pillow 10.0 (#2623)
Require Python 3.8. As a result, the importlib-metadata
package
is no longer needed for fast plugin discovery on Python 3.7.
The plugins
extra (used as, e.g., pip install pygments[plugins]
)
is kept for backwards compatibility but now has no effect. (#2601)
Require the url
attribute for lexers inside Pygments, add
it to many lexers (#2588)
Replace Pyflakes linter with Ruff (#2592)
Add macOS CI (#2594)
Built-in lexers now declare the version of Pygments in which they were
added in a required version_added
lexer attribute, instead of a
.. versionadded::
directive in the docstring (#2589, #2634)
The url
attribute is now required for built-in lexers and
has been added to all existing lexers (#2588)
The RTF formatter supports line number and line highlighting now (#1217, #2654)
Add \sa0
keyword in the RTF formatter (#1111, #2607)
Register pycon
as an alias for the Python console lexer (#2697)
Add MIME-Type for DesktopLexer
(#2613)
Fix native style to meet WCAG AA guidelines (#2600)
Fix typo in documentation (#2672)
Use format strings consistently (#2661)
Add __class_getitem__
to Formatter
to improve typing support (#2665)
Published by Anteru 11 months ago
Published by Anteru 11 months ago
Updated lexers:
Published by Anteru 11 months ago
New lexers:
Updated lexers:
elseif
keyword (#2528)lean3
, in preparation for a possible switch to lean
highlighting as Lean 4 (#2546)and
keyword, remove value
from keywords (#2521)starlark
and bazel
aliases (#2517, #2516)len
like size
(#2508)panic
keyword and ->
operator (#2510)[=[ bracketed arguments ]=]
(#2549)Fix ctags support and tests (#2487)
Include Lexer.add_filter
in the documentation (#2519)
Add a Lean3Lexer
alias (#2546)
The pygments.styles
module contains a new STYLES
variable with a dictionary of built-in styles. The old STYLE_MAP
variable, which uses a different format, is kept for backwards compatibility.
On Windows, add a new installation extra (windows-terminal
) which pulls in dependencies for colored console output. See :doc:cmdline
for more details. (#2505)
Support more file types in autopygmentize
script (#2513)
Change color of numbers in rrt
style (#2526)
Fix error when trying to look up plugin formatters by file extension of the output format (#2563)
Use Hatchling as a build backend instead of setuptools.
This change is transparent to most users. Distribution packagers who build without build isolation need to add hatchling as a build
dependency and remove setuptools. People downloading source distributions and wheels from PyPI directly should note that they now have pygments
in their file names instead of Pygments
. (#2573)
Improve the test framework to also check for lost tokens when processing the snippets and example files (#2582.)
Improve the Dracula style definition to make it easier to maintain (#2575)
Published by Anteru about 1 year ago
native
style missing from style list (#2484)Published by Anteru about 1 year ago
New lexers:
Updated lexers:
application/pem-certificate-chain
mimetype (#2471)analyse_text
implementation (#2460), and highlight URL encoded data (#2465, #1620)Add Generic.EmphStrong
token for bold italic markup (#2444)
Add Lightbulb style (#2474)
Improve contrast in Monokai style (#2448)
Add documentation how to create terminal code highlighting commands (#2131, #2425)
Add support for loading TrueType fonts to the ImageFormatter
(#1960)
Published by Anteru over 1 year ago
Updated lexers:
Fix Python console traceback lexing being too strict
and sometimes reordering output (#2407, #2410, #2412)
Published by Anteru over 1 year ago
Added lexers:
Updated lexers:
AMDGPU: Add support for scratch_
instructions, the attr*.*
argument,
as well as the off
modifier (#2327).
APDL: Miscellaneous improvements (#2314)
bash/tcsh:
break
to keywords (#2377)Chapel: Support attributes (#2376)
CMake: Implement bracket style comments (#2338, #2354)
CSS: Improve lexing of numbers inside function calls (#2382, #2383)
diff: Support normal diff syntax, as opposed to unified diff syntax (#2321)
GLSL, HLSL:
LilyPond: minor update of builtins
PHP: support attributes (#2055, #2347, #2360), fix anonymous classes without
parameters (#2359), improve lexing of variable variable syntax (#2358)
Python:
None
(#2406)Rebol/Red: Don't require script headers (#2348, #2349)
Spice: Update keywords (#2336)
SQL+Jinja (analyse_text
method): Fix catastrophic backtracking (#2355)
Terraform: Add hcl
alias (#2375)
Declare support for Python 3.11 and drop support for Python 3.6 (#2324).
Update native
style to improve contrast (#2325).
Update `github-dark`` style to match latest Primer style (#2401)
Revert a change that made guessing lexers based on file names slower
on Python 3.10 and older (#2328).
Fix some places where a locale-dependent encoding could unintentionally
be used instead of UTF-8 (#2326).
Fix Python traceback handling (#2226, #2329).
Groff formatter: sort color definitions for reproducibility (#2343)
Move project metadata to pyproject.toml
, remove setup.py
and setup.cfg
(#2342)
The top-level Makefile
has been removed. Instead, all shortcuts
for developing are now defined and run through tox. The doc
folder
still contains a Makefile
as an alternative to tox -e doc
.
Published by Anteru almost 2 years ago
Added lexers:
Updated lexers:
Abap: Update keywords (#2281)
Alloy: Update for Alloy 6 (#1963)
C family (C, C++ and many others):
C#: Fix number and operator recognition (#2256, #2257)
CSound: Updated builtins (#2268)
F#: Add .fsx
file extension (#2282)
gas (GNU assembler): recognize braces as punctuation (#2230)
HTTP: Add CONNECT
keyword (#2242)
Inform 6: Fix lexing of properties and doubles (#2214)
INI: Allow comments that are not their own line (#2217, #2161)
Java properties: Fix issue with whitespace-delimited keys, support comments starting with !
and escapes, no longer support undocumented ;
and //
comments (#2241)
LilyPond: Improve heuristics, add \maxima
duration (#2283)
LLVM: Add opaque pointer type (#2269)
Macaulay2: Update keywords (#2305)
Minecraft-related lexers (SNB and Minecraft function) moved to pygments.lexers.minecraft
(#2276)
Nim: General improvements (#1970)
Nix: Fix single quotes inside indented strings (#2289)
Objective J: Fix catastrophic backtracking (#2225)
NASM: Add support for SSE/AVX/AVX-512 registers as well as 'rel' and 'abs' address operators (#2212)
Powershell:
local:
keyword (#2254)Solidity: Add boolean operators (#2292)
Spice: Add enum
keyword and fix a bug regarding binary, hexadecimal and octal number tokens (#2227)
YAML: Accept colons in key names (#2277)
Fix make mapfiles
when Pygments is not installed in editable mode (#2223)
Support more filetypes and compression types in autopygmentize
(#2219)
Merge consecutive tokens in Autohotkey, Clay (#2248)
Add .nasm
as a recognized file type for NASM (#2280)
Add *Spec.hs
as a recognized file type for HSpec
(#2308)
Add *.pyi
(for typing stub files) as a recognized file type for Python (#2331)
The HTML lexer no longer emits empty spans for whitespace (#2304)
Fix IRCFormatter
inserting linenumbers incorrectly (#2270)
Published by Anteru about 2 years ago
Added lexers:
Updated lexers:
Error
tokens (#2207, #2208)Set
and qualified identifiers (#2158)value
modifier (#2142)Name.Builtin
instead of Keyword.Type
(#2136)\"$var\"
inside strings (#2105)\N
, \u
and \U
escape sequences in string literals, but not in bytes literals where they are not supported (#2204)${name}
variables (#2145)<<
heredoc delimiters (#2162)Added styles:
nord
and nord-darker
; #2189, #1799, #1678)Pygments now tries to use the importlib.metadata
module to discover plugins instead of the slower pkg_resources
(#2155). In particular, this largely speeds up the pygmentize
script when the lexer is not specified.
importlib.metadata
is only available in the Python standard library since Python 3.8. For older versions, there exists an importlib_metadata
backport on PyPI. For this reason, Pygments now defines a packaging extra plugins
, which adds a requirement on importlib_metadata
if the Python version is older than 3.8. Thus, in order to install Pygments with optimal plugin support even for old Python versions, you should do:
pip install pygments[plugins]
Pygments still falls back on pkg_resources
if neither importlib.metadata
nor importlib_metadata
is found, but it will be slower.
Silently ignore BrokenPipeError
in the command-line interface (#2193).
The HtmlFormatter
now uses the linespans
attribute for anchorlinenos
if the lineanchors
attribute is unset (#2026).
The highlight
, lex
and format
functions no longer wrongly report "argument must be a lexer/formatter instance, not a class" in some cases where this is not the actual problem (#2123).
Fix warnings in doc build (#2124).
The codetagify
filter now recognizes FIXME
tags by default (#2150).
The pygmentize
command now recognizes if the COLORTERM
environment variable is set to a value indicating that true-color support is available. In that case, it uses the TerminalTrueColorFormatter
by default (#2160)
Remove redundant caches for filename patterns (#2153)
Use new non-deprecated Pillow API for text bounding box in ImageFormatter
(#2198)
Remove default_style
(#930, #2183)
Stop treating DeprecationWarnings
as errors in the unit tests (#2196)
Published by Anteru over 2 years ago
Added lexers:
UnixConfigLexer
for "colon-separated" config files, like /etc/passwd
(#2112)Updated lexers:
Agda: Update keyword list (#2017)
C family: Fix identifiers after case
statements (#2084)
Clojure: Highlight ratios (#2042)
Csound: Update to 6.17 (#2064)
CSS: Update the list of properties (#2113)
Elpi:
->
(#2028)Futhark: Add missing tokens (#2118)
Gherkin: Add But
(#2046)
Inform6: Update to 6.36 (#2050)
JSON: Support C comments in JSON (#2049). Note: This doesn't mean the JSON parser now supports JSONC or JSON5 proper, just that it doesn't error out when seeing a /* */
or //
style comment. If you need proper comment handling, consider using the JavaScript
lexer.
LilyPond:
PHP: Update builtin function and keyword list (#2054, #2056)
Scheme: Various improvements (#2060)
Spice: Update the keyword list, add new types (#2063, #2067)
Terraform:
Add plugins
argument to get_all_lexers()
.
Bump minimal Python version to 3.6 (#2059)
Fix multiple lexers marking whitespace as Text
(#2025)
Remove various redundant uses of re.UNICODE
(#2058)
Associate .resource
with the Robot framework (#2047)
Associate .cljc
with Clojure (#2043)
Associate .tpp
with C++ (#2031)
Remove traces of Python 2 from the documentation (#2039)
The native
style was updated to meet the WCAG AAA contrast guidelines (#2038)
Fix various typos (#2030)
Fix Groff
formatter not inheriting token styles correctly (#2024)
Various improvements to the CI (#2036)
The Ada lexer has been moved to a separate file (#2117)
When linenos=table
is used, the <table>
itself is now wrapped with a <div class="highlight">
tag instead of placing it inside the <td class="code">
cell (#632.) With this change, the output matches the documented behavior.
⚠️ If you have subclassed HtmlFormatter.wrap
, you may have to adjust the logic.
Published by Anteru almost 3 years ago
Updated lexers:
record
keywords result in Error
tokens in some cases (#2018)Fix links to line numbers not working correctly (#2014)
Remove underline
from Whitespace
style in the Tango
theme (#2020)
Fix IRC
and Terminal256
formatters not backtracking correctly for custom token types, resulting in some unstyled tokens (#1986)
Published by Anteru almost 3 years ago
Updated lexers:
unsigned int
) (#2008):
to result in Error
tokens (#2010)Published by Anteru almost 3 years ago
Added lexers:
.SRCINFO
(#1951)Updated lexers:
comment
and commentary
(#1899, #1806)void
data type (#1948)yield
(#1941) and sealed classes/record (#1902)--no-show-raw-insn
dumps (#1981)\
inside quoted strings (#1479)~
in tracebacks (#2004)Added styles:
LilyPond
language.There is new infrastructure in place to improve style accessibility. The default style has been updated to conform to WCAG recommendations. All styles are now checked for sufficient contrast by default to prevent regressions. (#1919, #1937, #1938, #1940)
Clean up unused imports (#1887)
Fix multiple lexers producing repeated single-character tokens
Fix multiple lexers marking whitespace as Text
(#1237, #1905, #1908, #1914, #1911, #1923, #1939, #1957, #1978)
Remove duplicated assignments in the Paraiso style (#1934)
pygmentize
supports JSON output for the various list functions now, making it easier to consume them from scripts. (#1437, #1890)
Use the shell
lexer for kshrc
files (#1947)
Use the ruby
lexer for Vagrantfile
files (#1936)
Use the C lexer for .xbm
and .xpm
files (#1802)
Add a groff
formatter (#1873)
Update documentation (#1928)
Line anchors now link to themselves (#1973)
Add official support for Python 3.10 (#1917)
Fix several missing colors in dark styles: Gruvbox dark, Monokai, Rrt, Sas, Strata dark (#1955)
Associate more file types with man
pages
The HtmlFormatter
can now emit tooltips for each token to ease debugging of lexers (#1822)
Add f90
as an alias for fortran
(#2000)
Published by Anteru about 3 years ago
Added lexers:
Updated lexers:
C-family: Fix preprocessor token issues (#1830)
C# (#1573, #1869)
CSound (#1837)
Fennel (#1862)
JavaScript (#1741, #1814)
LLVM (#1824)
Rust
Scala: Add support for the \
operator (#1857)
Swift (#1767, #1842)
Tcl: Allow ,
and @
in strings (#1834, #1742)
Fix assert statements in TNT lexer.
Token types across all lexers have been unified (using the most common token
type name) (#1816, #1819)
Improve Jasmin min score analysis (#1619)
Add new alias for Go files (#1827)
Fix multi-line console highlighting (#1833)
Add a new trivial lexer which outputs everything as Text.Generic.Output
(#1835, #1836)
Use the .ini
lexer for systemd
files (#1849)
Fix a FutureWarning
related to words()
(#1854)
pwsh
is now recognized as an alias for PowerShell (#1876)
Published by Anteru over 3 years ago
Added lexers:
Updated lexers:
:
(#1682, #1758)Add Pango formatter (#1727)
Autopygmentize uses file
first instead of pygments -N
(#1786)
Fix links (#1716)
Fix issue with LaTeX formatter and minted
(#1734, #1735, #1736, #1737)
Improve alias order (#1780)
Improve line number colors (#1779, #1778)
Fix CTag related issue (#1724)
Recognize .leex
as Elixir templates
Updated filename
handling in HTML formatter if linenos='table'
(#1757)
<td>
holding the code, but outside the <pre>
. This would invariably break the a lignment with line numbers.filename
is specified, a separate <tr>
is emitted before the table content which contains a single <th>
with colspan=2
so it<span class="filename">...</span>
so any existing stylestable_cls_step_1_start_1_special_0_noanchor_filename.html
tests/html_linenos_expected_output/
directory.Added styles:
Published by Anteru over 3 years ago
minted
(#1734, #1735, #1736, #1737)Added lexers:
Updated lexers:
AutoIt: Support single quoted strings (#1667, #1663)
C/C++ & related: Fix mishandling '*/' (#1695)
Cocoa: Add builtin types (#1703)
Console (#1672)
Eiffel: Fix performance issues (#1658)
Fortran: Improve combined keyword detection (#1677, #1188)
J: Fix operator ?
lexing (#1700, #1149)
JavaScript/TypeScript: Fix escapes in backtick strings (#1679, #1686)
Kotlin: Improve string interpolation, modifier keyword handling, and various small issues (#1699)
LESS: Support single-line comments (#1046)
Matlab:
Python: Improve handling of raw f-strings (#1681, #1683)
Ruby: Better method name handling (#1531)
Stata: Updated keywords (#1470)
Added styles:
The pygmentize
script now uses argparse
, all options should work
as before
Add pygmentize -C
option to guess a lexer from content
With this release, Pygments moves to a new internal testing system (#1649.) See Contributing.md
for details. The main advantage of this new change is a much better test coverage of all existing example lexers. It also makes it much easier to add new test snippets.
Make guessing prefer Python 3 lexer
Do not guess MIME or SQL without reason
Changed setuptools to use a declarative config through setup.cfg
. Building Pygments now requires setuptools 39.2+.
Add markdown to MarkdownLexer aliases (#1687)
Change line number handling
<table>
based output, the td.linenos
element will have either a normal
or special
class attached. Previously, only special
line<pre>
, once via <span class="special">
. This also meanstd.linenos pre
is no longer styled, instead, use td.linenos .normal
and td.linenos .special
.background-color: transparent
and color: inherit
by default. This works much better with dark styles which don't have colors set for line numbers.Remove "raw" alias from RawTokenLexer, so that it cannot be selected by alias.
Fix RawTokenLexer to work in Python 3 and handle exceptions.
Add prompt colors to the Solarized theme (#1529)
Image formatter supports background colors now (#1374)
Add support for anchors in conjunction with inline line numbers (#1591)
Modernize the codebase using pyupgrade
(#1622)
Add support for line numbers to the terminal256
formatter (#1674, #1653)
Improve analyze_text
logic for ECL
(#1610)
Improve analyze_text
logic for CBM Basic V2
(#1607)
Improve LaTeX formatter (#1708, #1709)
Published by Anteru almost 4 years ago
Updated lexers:
Apache configurations: Improve handling of malformed tags (#1656)
CSS: Add support for variables (#1633, #1666)
Crystal (#1650, #1670)
Coq (#1648)
Fortran: Add missing keywords (#1635, #1665)
Ini (#1624)
JavaScript and variants (#1647 -- missing regex flags, #1651)
Markdown (#1623, #1617)
Shell
in
keyword (#1652)SQL - Fix keywords (#1668)
Typescript: Fix incorrect punctuation handling (#1510, #1511)
Fix infinite loop in SML lexer (#1625)
Fix backtracking string regexes in JavaScript/TypeScript, Modula2
and many other lexers (#1637)
Limit recursion with nesting Ruby heredocs (#1638)
Fix a few inefficient regexes for guessing lexers
Fix the raw token lexer handling of Unicode (#1616)
Revert a private API change in the HTML formatter (#1655) --
please note that private APIs remain subject to change!
Fix several exponential/cubic-complexity regexes found by
Ben Caller/Doyensec (#1675)
Fix incorrect MATLAB example (#1582)
Thanks to Google's OSS-Fuzz project for finding many of these bugs.
Published by Anteru almost 4 years ago
Updated lexers:
Deprecated JsonBareObjectLexer, which is now identical to JsonLexer (#1600)
The ImgFormatter
now calculates the exact character width, which fixes some issues with overlapping text (#1213, #1611)
Documentation fixes (#1609, #1599, #1598)
Fixed duplicated Juttle language alias (#1604, #1606)
Added support for Kotlin scripts (#1587)
Removed CSS rule which forced margin to 0