Original README
Solidity and Yul 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.
LaTeX Repo README
This repo builds on top of the source which is can be located at https://gitlab.com/veox/pygments-lexer-solidity.
To use the lexer for LaTeX highlighting simply extract the lexer-latex.zip
file and upload both the __init__.py
and lexer.py
in your document directory or use a service like overleaf.com
- Download zip archive of minimal template for overleaf.com -
https://github.com/sambacha/latex-solidity/releases/download/v202.06/overleaft-solidity-template.zip
A reference LaTeX document and generated PDF are included. This was rendered and generated using the overleaf web application. see latex/example.pdf
\begin{minted}{lexer.py:SolidityLexer -x}
... your code here ...
\end{minted}
\begin{minted}{lexer.py:YulLexer -x}
... your code here ...
\end{minted}
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 .
Depends on doc-building infrastructure.
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.
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 colorized HTML file:
pygmentize -v -O full,style=fruity -o example.sol.html example.sol
BSD 2-clause simplified. See LICENSE.txt
.