Skip to main content

pygments-lexer-solidity

Solidity lexer for Pygments, distributed as a PyPI package.

If you want pretty syntax highlighting in documentation for Solidity files, and you’re using Pygments, this might just be the thing for you.

Currently, Solidity keywords up to version 0.8.0 are included, to the best of my ability. MRs are welcome!

The Yul intermediate language is also supported, including for stand-alone code blocks.

Installation

Set up your virtual environment, no matter how you do it.

% virtualenv .virtualenv/`basename $(pwd)`
% source .virtualenv/`basename $(pwd)`/bin/activate

Then install via PyPI:

% pip install pygments-lexer-solidity

Or from a local git repo:

% pip install -r requirements.txt
% pip install -e .

Usage

Depends on doc-building infrastructure.

Sphinx

Have this in Sphinx’s conf.py:

from sphinx.highlighting import lexers
from pygments_lexer_solidity import SolidityLexer, YulLexer
lexers['solidity'] = SolidityLexer()
lexers['yul'] = YulLexer()

Then use .. code-block:: solidity for Solidity code blocks, or .. code-block:: yul for Yul.

Command-line

To test a local copy of the lexer on the CLI:

% pygmentize -x -l pygments_lexer_solidity/lexer.py:SolidityLexer example.sol

To generate a colorised HTML file:

% pygmentize -v -O full,style=fruity -o example.sol.html example.sol

License

BSD 2-clause simplified. See LICENSE.txt.

Metadata

Release files for pygments-lexer-solidity 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygments-lexer-solidity 0.7.0
File Size Uploaded
pygments-lexer-solidity-0.7.0.tar.gz 7.3 kB Details

Release files / pygments-lexer-solidity-0.7.0.tar.gz

Download URL pygments-lexer-solidity-0.7.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a347fd96981838331b6d98b0f891776908a49406d343ff2a40a6a1c8475a9350
BLAKE2b-256 checksum
How to use checksums
ced6294f7957572e9604fdf11fb4acf5273735d7eb8c695a983f29a74846ed88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.7.0 This release

1 release file

0.6

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page