Skip to main content

Solidity lexer for Pygments (includes Yul intermediate language)

Project description

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.6.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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygments-lexer-solidity-0.6.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file pygments-lexer-solidity-0.6.tar.gz.

File metadata

  • Download URL: pygments-lexer-solidity-0.6.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.2 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for pygments-lexer-solidity-0.6.tar.gz
Algorithm Hash digest
SHA256 736bb768effb573e3355e90bbeeacb4d9808a2fdb3eb350a3527b8030acab66b
MD5 63aa78da5fc89372c2f9e0c86715edf8
BLAKE2b-256 d86cebec9a9f5b985522518d2f15c32222dee3b6911f2b695ba789346e70897b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page